类 ResourceMapping

java.lang.Object
io.github.amsonix.molt.internal.reschiper.bundle.ResourceMapping

public class ResourceMapping extends Object
The ResourceMapping class represents a mapping of resources, directories, and entry files used for obfuscating resource-related data within Android apps. It provides methods to manage and write these mapping rules to a file.
  • 构造器详细资料

    • ResourceMapping

      public ResourceMapping()
      Constructs an empty ResourceMapping object.
  • 方法详细资料

    • getResourceSimpleName

      @Contract(pure=true) public static String getResourceSimpleName(@NotNull @NotNull String resourceName)
      Extracts the simple name from a resource path.
      参数:
      resourceName - The resource name containing the path.
      返回:
      The simple name of the resource.
    • getDirMapping

      public Map<String,String> getDirMapping()
      Gets the directory mapping.
      返回:
      A map of raw directory paths to obfuscate directory paths.
    • getResourceMapping

      public Map<String,String> getResourceMapping()
      Gets the resource mapping.
      返回:
      A map of raw resource names to obfuscate resource names.
    • getEntryFilesMapping

      public Map<String,String> getEntryFilesMapping()
      Gets the entry files mapping.
      返回:
      A map of raw entry file paths to obfuscated entry file paths.
    • putDirMapping

      public void putDirMapping(String rawPath, String obfuscatePath)
      Adds a directory mapping to the resource mapping.
      参数:
      rawPath - The raw directory path.
      obfuscatePath - The obfuscated directory path.
    • putResourceMapping

      public void putResourceMapping(String rawResource, String obfuscateResource)
      Adds a resource mapping to the resource mapping.
      参数:
      rawResource - The raw resource name.
      obfuscateResource - The obfuscated resource name.
      抛出:
      IllegalArgumentException - if the obfuscateResource already exists in the mapping.
    • putApkResourceMapping

      public void putApkResourceMapping(String rawResource, String obfuscateResource)
      APK arsc 映射:key 为 type/name,混淆名在不同 type 下可重复(与 AAB 全限定名不同)。
    • putEntryFileMapping

      public void putEntryFileMapping(String rawPath, String obfuscatedPath)
      Adds an entry file mapping to the entry files mapping.
      参数:
      rawPath - The raw entry file path.
      obfuscatedPath - The obfuscated entry file path.
    • getPathMappingNameList

      public List<String> getPathMappingNameList()
      Gets a list of simple names from the directory mapping.
      返回:
      A list of simple names extracted from obfuscated directory paths.
    • addResourceNameAndId

      public void addResourceNameAndId(String name, String id)
      Adds a resource name and its corresponding ID to the mapping.
      参数:
      name - The resource name.
      id - The ID associated with the resource name.
    • addResourcePathAndId

      public void addResourcePathAndId(String path, String id)
      Adds a resource path and its corresponding ID to the mapping.
      参数:
      path - The resource path.
      id - The ID associated with the resource path.
    • writeMappingToFile

      public void writeMappingToFile(@NotNull @NotNull Path mappingPath) throws IOException
      Writes the mapping rules to a file at the specified path.
      参数:
      mappingPath - The path to the mapping file.
      抛出:
      IOException - If there is an issue with file I/O.