### Question:
ResourcesObfuscator { public AppBundle obfuscate() throws IOException { TimeClock timeClock = new TimeClock(); checkResMappingRules(); Map<BundleModuleName, BundleModule> obfuscatedModules = new HashMap<>(); Map<String, Set<String>> typeEntryMapping = generateObfuscatedEntryFilesFromMapping(); for (Map.Entry<BundleModuleName, BundleModule> entry : rawAppBundle.getModules().entrySet()) { BundleModule bundleModule = entry.getValue(); BundleModuleName bundleModuleName = entry.getKey(); generateResourceMappingRule(bundleModule, typeEntryMapping); Map<String, String> obfuscateModuleEntriesMap = obfuscateModuleEntries(bundleModule, typeEntryMapping); BundleModule obfuscatedModule = obfuscateBundleModule(bundleModule, obfuscateModuleEntriesMap); obfuscatedModules.put(bundleModuleName, obfuscatedModule); } AppBundle appBundle = rawAppBundle.toBuilder() .setModules(ImmutableMap.copyOf(obfuscatedModules)) .build(); System.out.println(String.format( "obfuscate resources done, coast %s", timeClock.getCoast() )); resourcesMapping.writeMappingToFile(outputMappingPath); return appBundle; } ResourcesObfuscator(Path bundlePath, AppBundle rawAppBundle, Set<String> whiteListRules, Path outputLogLocationDir, Path mappingPath); Path getOutputMappingPath(); AppBundle obfuscate(); static final String RESOURCE_ANDROID_PREFIX; static final String FILE_MAPPING_NAME; }### Answer:
@Test public void test() throws IOException { Set<String> whiteList = new HashSet<>( ImmutableSet.of( "com.bytedance.android.ugc.aweme.R.raw.*", "*.R.drawable.icon", "*.R.anim.ab*" ) ); Path bundlePath = loadResourceFile("demo/demo.aab").toPath(); Path outputDir = getTempDirPath(); AppBundleAnalyzer analyzer = new AppBundleAnalyzer(bundlePath); AppBundle appBundle = analyzer.analyze(); ResourcesObfuscator obfuscator = new ResourcesObfuscator(bundlePath, appBundle, whiteList, outputDir, loadResourceFile("demo/mapping.txt").toPath()); AppBundle obfuscateAppBundle = obfuscator.obfuscate(); assert obfuscateAppBundle != null; assert obfuscateAppBundle.getModules().size() == appBundle.getModules().size(); appBundle.getModules().forEach((bundleModuleName, bundleModule) -> { BundleModule obfuscatedModule = obfuscateAppBundle.getModule(bundleModuleName); assert obfuscatedModule.getEntries().size() == bundleModule.getEntries().size(); }); }