Loading core/java/android/content/pm/PackageParser.java +15 −1 Original line number Diff line number Diff line Loading @@ -8923,6 +8923,8 @@ public class PackageParser { private final @ParseFlags int mFlags; private AssetManager mCachedAssetManager; private ApkAssets mBaseApkAssets; DefaultSplitAssetLoader(PackageLite pkg, @ParseFlags int flags) { mBaseCodePath = pkg.baseCodePath; mSplitCodePaths = pkg.splitCodePaths; Loading Loading @@ -8953,9 +8955,11 @@ public class PackageParser { ApkAssets[] apkAssets = new ApkAssets[(mSplitCodePaths != null ? mSplitCodePaths.length : 0) + 1]; mBaseApkAssets = loadApkAssets(mBaseCodePath, mFlags); // Load the base. int splitIdx = 0; apkAssets[splitIdx++] = loadApkAssets(mBaseCodePath, mFlags); apkAssets[splitIdx++] = mBaseApkAssets; // Load any splits. if (!ArrayUtils.isEmpty(mSplitCodePaths)) { Loading @@ -8982,6 +8986,11 @@ public class PackageParser { public void close() throws Exception { IoUtils.closeQuietly(mCachedAssetManager); } @Override public ApkAssets getBaseApkAssets() { return mBaseApkAssets; } } /** Loading Loading @@ -9085,5 +9094,10 @@ public class PackageParser { IoUtils.closeQuietly(assets); } } @Override public ApkAssets getBaseApkAssets() { return mCachedSplitApks[0][0]; } } } core/java/android/content/pm/parsing/ParsingPackageUtils.java +15 −7 Original line number Diff line number Diff line Loading @@ -383,10 +383,9 @@ public class ParsingPackageUtils { } try { final AssetManager assets = assetLoader.getBaseAssetManager(); final File baseApk = new File(lite.getBaseApkPath()); final ParseResult<ParsingPackage> result = parseBaseApk(input, baseApk, lite.getPath(), assets, flags); lite.getPath(), assetLoader, flags); if (result.isError()) { return input.error(result); } Loading Loading @@ -442,7 +441,7 @@ public class ParsingPackageUtils { final ParseResult<ParsingPackage> result = parseBaseApk(input, apkFile, apkFile.getCanonicalPath(), assetLoader.getBaseAssetManager(), flags); assetLoader, flags); if (result.isError()) { return input.error(result); } Loading @@ -458,7 +457,8 @@ public class ParsingPackageUtils { } private ParseResult<ParsingPackage> parseBaseApk(ParseInput input, File apkFile, String codePath, AssetManager assets, int flags) { String codePath, SplitAssetLoader assetLoader, int flags) throws PackageParserException { final String apkPath = apkFile.getAbsolutePath(); String volumeUuid = null; Loading @@ -469,6 +469,7 @@ public class ParsingPackageUtils { if (DEBUG_JAR) Slog.d(TAG, "Scanning base APK: " + apkPath); final AssetManager assets = assetLoader.getBaseAssetManager(); final int cookie = assets.findCookieForPath(apkPath); if (cookie == 0) { return input.error(INSTALL_PARSE_FAILED_BAD_MANIFEST, Loading Loading @@ -500,12 +501,19 @@ public class ParsingPackageUtils { } } ApkAssets apkAssets = assets.getApkAssets()[0]; if (apkAssets.definesOverlayable()) { ApkAssets apkAssets = assetLoader.getBaseApkAssets(); boolean definesOverlayable = false; try { definesOverlayable = apkAssets.definesOverlayable(); } catch (IOException ignored) { // Will fail if there's no packages in the ApkAssets, which can be treated as false } if (definesOverlayable) { SparseArray<String> packageNames = assets.getAssignedPackageIdentifiers(); int size = packageNames.size(); for (int index = 0; index < size; index++) { String packageName = packageNames.get(index); String packageName = packageNames.valueAt(index); Map<String, String> overlayableToActor = assets.getOverlayableMap(packageName); if (overlayableToActor != null && !overlayableToActor.isEmpty()) { for (String overlayable : overlayableToActor.keySet()) { Loading core/java/android/content/pm/split/DefaultSplitAssetLoader.java +8 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { private final @ParseFlags int mFlags; private AssetManager mCachedAssetManager; private ApkAssets mBaseApkAssets; public DefaultSplitAssetLoader(PackageLite pkg, @ParseFlags int flags) { mBaseApkPath = pkg.getBaseApkPath(); mSplitApkPaths = pkg.getSplitApkPaths(); Loading Loading @@ -76,7 +78,7 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { // Load the base. int splitIdx = 0; apkAssets[splitIdx++] = loadApkAssets(mBaseApkPath, mFlags); apkAssets[splitIdx++] = mBaseApkAssets = loadApkAssets(mBaseApkPath, mFlags); // Load any splits. if (!ArrayUtils.isEmpty(mSplitApkPaths)) { Loading @@ -99,6 +101,11 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { return getBaseAssetManager(); } @Override public ApkAssets getBaseApkAssets() { return mBaseApkAssets; } @Override public void close() throws Exception { IoUtils.closeQuietly(mCachedAssetManager); Loading core/java/android/content/pm/split/SplitAssetDependencyLoader.java +5 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,11 @@ public class SplitAssetDependencyLoader extends SplitDependencyLoader<PackagePar return mCachedAssetManagers[idx + 1]; } @Override public ApkAssets getBaseApkAssets() { return mCachedSplitApks[0][0]; } @Override public void close() throws Exception { for (AssetManager assets : mCachedAssetManagers) { Loading core/java/android/content/pm/split/SplitAssetLoader.java +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.pm.split; import android.content.pm.PackageParser; import android.content.res.ApkAssets; import android.content.res.AssetManager; /** Loading @@ -27,4 +28,6 @@ import android.content.res.AssetManager; public interface SplitAssetLoader extends AutoCloseable { AssetManager getBaseAssetManager() throws PackageParser.PackageParserException; AssetManager getSplitAssetManager(int splitIdx) throws PackageParser.PackageParserException; ApkAssets getBaseApkAssets(); } Loading
core/java/android/content/pm/PackageParser.java +15 −1 Original line number Diff line number Diff line Loading @@ -8923,6 +8923,8 @@ public class PackageParser { private final @ParseFlags int mFlags; private AssetManager mCachedAssetManager; private ApkAssets mBaseApkAssets; DefaultSplitAssetLoader(PackageLite pkg, @ParseFlags int flags) { mBaseCodePath = pkg.baseCodePath; mSplitCodePaths = pkg.splitCodePaths; Loading Loading @@ -8953,9 +8955,11 @@ public class PackageParser { ApkAssets[] apkAssets = new ApkAssets[(mSplitCodePaths != null ? mSplitCodePaths.length : 0) + 1]; mBaseApkAssets = loadApkAssets(mBaseCodePath, mFlags); // Load the base. int splitIdx = 0; apkAssets[splitIdx++] = loadApkAssets(mBaseCodePath, mFlags); apkAssets[splitIdx++] = mBaseApkAssets; // Load any splits. if (!ArrayUtils.isEmpty(mSplitCodePaths)) { Loading @@ -8982,6 +8986,11 @@ public class PackageParser { public void close() throws Exception { IoUtils.closeQuietly(mCachedAssetManager); } @Override public ApkAssets getBaseApkAssets() { return mBaseApkAssets; } } /** Loading Loading @@ -9085,5 +9094,10 @@ public class PackageParser { IoUtils.closeQuietly(assets); } } @Override public ApkAssets getBaseApkAssets() { return mCachedSplitApks[0][0]; } } }
core/java/android/content/pm/parsing/ParsingPackageUtils.java +15 −7 Original line number Diff line number Diff line Loading @@ -383,10 +383,9 @@ public class ParsingPackageUtils { } try { final AssetManager assets = assetLoader.getBaseAssetManager(); final File baseApk = new File(lite.getBaseApkPath()); final ParseResult<ParsingPackage> result = parseBaseApk(input, baseApk, lite.getPath(), assets, flags); lite.getPath(), assetLoader, flags); if (result.isError()) { return input.error(result); } Loading Loading @@ -442,7 +441,7 @@ public class ParsingPackageUtils { final ParseResult<ParsingPackage> result = parseBaseApk(input, apkFile, apkFile.getCanonicalPath(), assetLoader.getBaseAssetManager(), flags); assetLoader, flags); if (result.isError()) { return input.error(result); } Loading @@ -458,7 +457,8 @@ public class ParsingPackageUtils { } private ParseResult<ParsingPackage> parseBaseApk(ParseInput input, File apkFile, String codePath, AssetManager assets, int flags) { String codePath, SplitAssetLoader assetLoader, int flags) throws PackageParserException { final String apkPath = apkFile.getAbsolutePath(); String volumeUuid = null; Loading @@ -469,6 +469,7 @@ public class ParsingPackageUtils { if (DEBUG_JAR) Slog.d(TAG, "Scanning base APK: " + apkPath); final AssetManager assets = assetLoader.getBaseAssetManager(); final int cookie = assets.findCookieForPath(apkPath); if (cookie == 0) { return input.error(INSTALL_PARSE_FAILED_BAD_MANIFEST, Loading Loading @@ -500,12 +501,19 @@ public class ParsingPackageUtils { } } ApkAssets apkAssets = assets.getApkAssets()[0]; if (apkAssets.definesOverlayable()) { ApkAssets apkAssets = assetLoader.getBaseApkAssets(); boolean definesOverlayable = false; try { definesOverlayable = apkAssets.definesOverlayable(); } catch (IOException ignored) { // Will fail if there's no packages in the ApkAssets, which can be treated as false } if (definesOverlayable) { SparseArray<String> packageNames = assets.getAssignedPackageIdentifiers(); int size = packageNames.size(); for (int index = 0; index < size; index++) { String packageName = packageNames.get(index); String packageName = packageNames.valueAt(index); Map<String, String> overlayableToActor = assets.getOverlayableMap(packageName); if (overlayableToActor != null && !overlayableToActor.isEmpty()) { for (String overlayable : overlayableToActor.keySet()) { Loading
core/java/android/content/pm/split/DefaultSplitAssetLoader.java +8 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { private final @ParseFlags int mFlags; private AssetManager mCachedAssetManager; private ApkAssets mBaseApkAssets; public DefaultSplitAssetLoader(PackageLite pkg, @ParseFlags int flags) { mBaseApkPath = pkg.getBaseApkPath(); mSplitApkPaths = pkg.getSplitApkPaths(); Loading Loading @@ -76,7 +78,7 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { // Load the base. int splitIdx = 0; apkAssets[splitIdx++] = loadApkAssets(mBaseApkPath, mFlags); apkAssets[splitIdx++] = mBaseApkAssets = loadApkAssets(mBaseApkPath, mFlags); // Load any splits. if (!ArrayUtils.isEmpty(mSplitApkPaths)) { Loading @@ -99,6 +101,11 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader { return getBaseAssetManager(); } @Override public ApkAssets getBaseApkAssets() { return mBaseApkAssets; } @Override public void close() throws Exception { IoUtils.closeQuietly(mCachedAssetManager); Loading
core/java/android/content/pm/split/SplitAssetDependencyLoader.java +5 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,11 @@ public class SplitAssetDependencyLoader extends SplitDependencyLoader<PackagePar return mCachedAssetManagers[idx + 1]; } @Override public ApkAssets getBaseApkAssets() { return mCachedSplitApks[0][0]; } @Override public void close() throws Exception { for (AssetManager assets : mCachedAssetManagers) { Loading
core/java/android/content/pm/split/SplitAssetLoader.java +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.pm.split; import android.content.pm.PackageParser; import android.content.res.ApkAssets; import android.content.res.AssetManager; /** Loading @@ -27,4 +28,6 @@ import android.content.res.AssetManager; public interface SplitAssetLoader extends AutoCloseable { AssetManager getBaseAssetManager() throws PackageParser.PackageParserException; AssetManager getSplitAssetManager(int splitIdx) throws PackageParser.PackageParserException; ApkAssets getBaseApkAssets(); }