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

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

Merge "Force notify overlay paths on package replaced due to system update uninstall"

parents ecac954e 61fe40c6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -6108,6 +6108,14 @@ public class Intent implements Parcelable, Cloneable {
     */
    public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";

    /**
     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
     * intents to indicate that this is a system update uninstall.
     * @hide
     */
    public static final String EXTRA_SYSTEM_UPDATE_UNINSTALL =
            "android.intent.extra.SYSTEM_UPDATE_UNINSTALL";

    /**
     * Used as an int extra field in {@link android.app.AlarmManager} pending intents
     * to tell the application being invoked how many pending alarms are being
+9 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public final class OverlayInfo implements CriticalOverlayInfo, Parcelable {
            STATE_ENABLED_IMMUTABLE,
            // @Deprecated STATE_TARGET_IS_BEING_REPLACED,
            STATE_OVERLAY_IS_BEING_REPLACED,
            STATE_SYSTEM_UPDATE_UNINSTALL,
    })
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
@@ -127,6 +128,14 @@ public final class OverlayInfo implements CriticalOverlayInfo, Parcelable {
    @Deprecated
    public static final int STATE_ENABLED_IMMUTABLE = 6;

    /**
     * The target package needs to be refreshed as a result of a system update uninstall, which
     * must recalculate the state of overlays against the newly enabled system package, which may
     * differ in resources/policy from the /data variant that was uninstalled.
     * @hide
     */
    public static final int STATE_SYSTEM_UPDATE_UNINSTALL = 7;

    /**
     * Overlay category: theme.
     * <p>
+6 −4
Original line number Diff line number Diff line
@@ -379,6 +379,8 @@ public final class OverlayManagerService extends SystemService {
            final String packageName = data.getSchemeSpecificPart();

            final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
            final boolean systemUpdateUninstall =
                    intent.getBooleanExtra(Intent.EXTRA_SYSTEM_UPDATE_UNINSTALL, false);

            final int[] userIds;
            final int extraUid = intent.getIntExtra(Intent.EXTRA_UID, UserHandle.USER_NULL);
@@ -405,7 +407,7 @@ public final class OverlayManagerService extends SystemService {
                    break;
                case ACTION_PACKAGE_REMOVED:
                    if (replacing) {
                        onPackageReplacing(packageName, userIds);
                        onPackageReplacing(packageName, systemUpdateUninstall, userIds);
                    } else {
                        onPackageRemoved(packageName, userIds);
                    }
@@ -463,7 +465,7 @@ public final class OverlayManagerService extends SystemService {
        }

        private void onPackageReplacing(@NonNull final String packageName,
                @NonNull final int[] userIds) {
                boolean systemUpdateUninstall, @NonNull final int[] userIds) {
            try {
                traceBegin(TRACE_TAG_RRO, "OMS#onPackageReplacing " + packageName);
                for (int userId : userIds) {
@@ -472,8 +474,8 @@ public final class OverlayManagerService extends SystemService {
                                packageName, userId);
                        if (pkg != null && !mPackageManager.isInstantApp(packageName, userId)) {
                            try {
                                updateTargetPackagesLocked(
                                        mImpl.onPackageReplacing(packageName, userId));
                                updateTargetPackagesLocked(mImpl.onPackageReplacing(packageName,
                                        systemUpdateUninstall, userId));
                            } catch (OperationFailedException e) {
                                Slog.e(TAG, "onPackageReplacing internal error", e);
                            }
+13 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.content.om.OverlayInfo.STATE_ENABLED;
import static android.content.om.OverlayInfo.STATE_MISSING_TARGET;
import static android.content.om.OverlayInfo.STATE_NO_IDMAP;
import static android.content.om.OverlayInfo.STATE_OVERLAY_IS_BEING_REPLACED;
import static android.content.om.OverlayInfo.STATE_SYSTEM_UPDATE_UNINSTALL;
import static android.content.om.OverlayInfo.STATE_TARGET_IS_BEING_REPLACED;
import static android.os.UserHandle.USER_SYSTEM;

@@ -78,6 +79,7 @@ final class OverlayManagerServiceImpl {

    // Flags to use in conjunction with updateState.
    private static final int FLAG_OVERLAY_IS_BEING_REPLACED = 1 << 1;
    private static final int FLAG_SYSTEM_UPDATE_UNINSTALL = 1 << 2;

    private final PackageManagerHelper mPackageManager;
    private final IdmapManager mIdmapManager;
@@ -275,9 +277,13 @@ final class OverlayManagerServiceImpl {
    }

    @NonNull
    Set<UserPackage> onPackageReplacing(@NonNull final String pkgName, final int userId)
            throws OperationFailedException {
        return reconcileSettingsForPackage(pkgName, userId, FLAG_OVERLAY_IS_BEING_REPLACED);
    Set<UserPackage> onPackageReplacing(@NonNull final String pkgName,
            boolean systemUpdateUninstall, final int userId) throws OperationFailedException {
        int flags = FLAG_OVERLAY_IS_BEING_REPLACED;
        if (systemUpdateUninstall) {
            flags |= FLAG_SYSTEM_UPDATE_UNINSTALL;
        }
        return reconcileSettingsForPackage(pkgName, userId, flags);
    }

    @NonNull
@@ -840,6 +846,10 @@ final class OverlayManagerServiceImpl {
            return STATE_OVERLAY_IS_BEING_REPLACED;
        }

        if ((flags & FLAG_SYSTEM_UPDATE_UNINSTALL) != 0) {
            return STATE_SYSTEM_UPDATE_UNINSTALL;
        }

        if (targetPackage == null) {
            return STATE_MISSING_TARGET;
        }
+1 −0
Original line number Diff line number Diff line
@@ -7317,6 +7317,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            }

            consumer.accept(mPackageStateMutator);
            mPackageStateMutator.onFinished();
            onChanged();
        }

Loading