Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 062dde5e authored by Winson Chiu's avatar Winson Chiu Committed by Android (Google) Code Review
Browse files

Merge "Fix overlay reference app visibility" into sc-dev

parents a1ef6789 186c182c
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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)) {
@@ -8982,6 +8986,11 @@ public class PackageParser {
        public void close() throws Exception {
            IoUtils.closeQuietly(mCachedAssetManager);
        }

        @Override
        public ApkAssets getBaseApkAssets() {
            return mBaseApkAssets;
        }
    }

    /**
@@ -9085,5 +9094,10 @@ public class PackageParser {
                IoUtils.closeQuietly(assets);
            }
        }

        @Override
        public ApkAssets getBaseApkAssets() {
            return mCachedSplitApks[0][0];
        }
    }
}
+15 −7
Original line number Diff line number Diff line
@@ -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);
            }
@@ -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);
            }
@@ -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;
@@ -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,
@@ -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()) {
+8 −1
Original line number Diff line number Diff line
@@ -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();
@@ -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)) {
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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) {
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.content.pm.split;

import android.content.pm.PackageParser;
import android.content.res.ApkAssets;
import android.content.res.AssetManager;

/**
@@ -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