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

Commit 52d99f93 authored by JW Wang's avatar JW Wang
Browse files

Migrate from ApexPackageInfo

We will store APEX package info in PMS. All queries should be done
via PM interfaces.

Bug: 225756739
Test: atest GtsStagedInstallHostTestCases \
            CtsStagedInstallHostTestCases \
	    StagedInstallInternalTest
Change-Id: Ifd7840bdb5384827ecc63ae21dd52483f3dd238e
parent d9180ce8
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -374,10 +374,8 @@ public abstract class ApexManager {
     * Dumps various state information to the provided {@link PrintWriter} object.
     *
     * @param pw the {@link PrintWriter} object to send information to.
     * @param packageName a {@link String} containing a package name, or {@code null}. If set, only
     *                    information about that specific package will be dumped.
     */
    abstract void dump(PrintWriter pw, @Nullable String packageName);
    abstract void dump(PrintWriter pw);

    @IntDef(
            flag = true,
@@ -946,7 +944,7 @@ public abstract class ApexManager {
        }

        @Override
        void dump(PrintWriter pw, @Nullable String packageName) {
        void dump(PrintWriter pw) {
            final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ", 120);
            try {
                ipw.println();
@@ -1174,7 +1172,7 @@ public abstract class ApexManager {
        }

        @Override
        void dump(PrintWriter pw, String packageName) {
        void dump(PrintWriter pw) {
            // No-op
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -311,6 +311,8 @@ public interface Computer extends PackageDataSnapshot {

    boolean isPackageAvailable(String packageName, @UserIdInt int userId);

    boolean isApexPackage(String packageName);

    @NonNull
    String[] currentToCanonicalPackageNames(@NonNull String[] names);

+15 −1
Original line number Diff line number Diff line
@@ -3127,7 +3127,7 @@ public class ComputerEngine implements Computer {
        final boolean checkin = dumpState.isCheckIn();

        // Return if the package doesn't exist.
        if (packageName != null && setting == null) {
        if (packageName != null && setting == null && !isApexPackage(packageName)) {
            return;
        }

@@ -3301,6 +3301,15 @@ public class ComputerEngine implements Computer {
                    }
                }
                ipw.decreaseIndent();
                break;
            }

            case DumpState.DUMP_APEX: {
                if (packageName == null || isApexPackage(packageName)) {
                    mApexManager.dump(pw);
                    mApexPackageInfo.dump(pw, packageName);
                }
                break;
            }
        } // switch
    }
@@ -3679,6 +3688,11 @@ public class ComputerEngine implements Computer {
        return false;
    }

    @Override
    public boolean isApexPackage(String packageName) {
        return mApexPackageInfo.isApexPackage(packageName);
    }

    @Override
    public String[] currentToCanonicalPackageNames(String[] names) {
        final int callingUid = Binder.getCallingUid();
+4 −12
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ import java.io.PrintWriter;
 */
final class DumpHelper {
    private final PermissionManagerServiceInternal mPermissionManager;
    private final ApexManager mApexManager;
    private final ApexPackageInfo mApexPackageInfo;
    private final StorageEventHelper mStorageEventHelper;
    private final DomainVerificationManagerInternal mDomainVerificationManager;
    private final PackageInstallerService mInstallerService;
@@ -64,8 +62,7 @@ final class DumpHelper {
    private final PerUidReadTimeouts[] mPerUidReadTimeouts;

    DumpHelper(
            PermissionManagerServiceInternal permissionManager, ApexManager apexManager,
            ApexPackageInfo apexPackageInfo,
            PermissionManagerServiceInternal permissionManager,
            StorageEventHelper storageEventHelper,
            DomainVerificationManagerInternal domainVerificationManager,
            PackageInstallerService installerService, String requiredVerifierPackage,
@@ -75,8 +72,6 @@ final class DumpHelper {
            ArraySet<String> protectedBroadcasts,
            PerUidReadTimeouts[] perUidReadTimeouts) {
        mPermissionManager = permissionManager;
        mApexManager = apexManager;
        mApexPackageInfo = apexPackageInfo;
        mStorageEventHelper = storageEventHelper;
        mDomainVerificationManager = domainVerificationManager;
        mInstallerService = installerService;
@@ -274,7 +269,7 @@ final class DumpHelper {
        // Return if the package doesn't exist.
        if (packageName != null
                && snapshot.getPackageStateInternal(packageName) == null
                && !mApexPackageInfo.isApexPackage(packageName)) {
                && !snapshot.isApexPackage(packageName)) {
            pw.println("Unable to find package: " + packageName);
            return;
        }
@@ -556,11 +551,8 @@ final class DumpHelper {
            mInstallerService.dump(new IndentingPrintWriter(pw, "  ", 120));
        }

        if (!checkin
                && dumpState.isDumping(DumpState.DUMP_APEX)
                && (packageName == null || mApexPackageInfo.isApexPackage(packageName))) {
            mApexManager.dump(pw, packageName);
            mApexPackageInfo.dump(pw, packageName);
        if (!checkin && dumpState.isDumping(DumpState.DUMP_APEX)) {
            snapshot.dump(DumpState.DUMP_APEX, fd, pw, dumpState);
        }

        if (!checkin
+3 −3
Original line number Diff line number Diff line
@@ -2469,8 +2469,8 @@ final class InstallPackageHelper {
            long requiredInstalledVersionCode, int installFlags) {
        String packageName = pkgLite.packageName;

        final PackageInfo activePackage = mPm.mApexPackageInfo.getPackageInfo(packageName,
                ApexManager.MATCH_ACTIVE_PACKAGE);
        final PackageInfo activePackage = mPm.snapshotComputer().getPackageInfo(
                packageName, PackageManager.MATCH_APEX, UserHandle.USER_SYSTEM);
        if (activePackage == null) {
            String errorMsg = "Attempting to install new APEX package " + packageName;
            Slog.w(TAG, errorMsg);
@@ -4145,7 +4145,7 @@ final class InstallPackageHelper {
        // conflicting names between APK and APEX.
        final boolean installApex = (scanFlags & SCAN_AS_APEX) != 0;
        if ((isUserInstall || isFirstBootOrUpgrade)
                && mPm.mApexPackageInfo.isApexPackage(pkg.getPackageName())
                && mPm.snapshotComputer().isApexPackage(pkg.getPackageName())
                && !installApex) {
            throw new PackageManagerException(INSTALL_FAILED_DUPLICATE_PACKAGE,
                    pkg.getPackageName()
Loading