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

Commit f6f7a58d authored by Chun-Wei Wang's avatar Chun-Wei Wang Committed by Android (Google) Code Review
Browse files

Merge "Migrate from ApexPackageInfo"

parents 9d93f384 52d99f93
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
@@ -314,6 +314,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
@@ -3129,7 +3129,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;
        }

@@ -3303,6 +3303,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
    }
@@ -3681,6 +3690,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);
@@ -4139,7 +4139,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