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

Commit 07c97efe authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "[pm] set installed=false after DELETE_KEEP_DATA on single user" into main

parents 99b3e9fe 13dae678
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -464,10 +464,7 @@ final class DeletePackageHelper {
                        if (DEBUG_REMOVE) Slog.d(TAG, "Still installed by other users");
                        clearPackageStateAndReturn = true;
                    } else {
                        // We need to set it back to 'installed' so the uninstall
                        // broadcasts will be sent correctly.
                        if (DEBUG_REMOVE) Slog.d(TAG, "Not installed by other users, full delete");
                        ps.setInstalled(true, userId);
                        mPm.mSettings.writeKernelMappingLPr(ps);
                        clearPackageStateAndReturn = false;
                    }
+15 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.os.incremental.IncrementalManager.isIncrementalPath;
import static android.os.storage.StorageManager.FLAG_STORAGE_CE;
import static android.os.storage.StorageManager.FLAG_STORAGE_DE;
import static android.os.storage.StorageManager.FLAG_STORAGE_EXTERNAL;

import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
import static com.android.server.pm.PackageManagerService.DEBUG_INSTALL;
import static com.android.server.pm.PackageManagerService.DEBUG_REMOVE;
@@ -400,6 +399,21 @@ final class RemovePackageHelper {
                        changedUsers);
                mPm.postPreferredActivityChangedBroadcast(UserHandle.USER_ALL);
            }
        } else if (!deletedPs.isSystem() && outInfo != null && !outInfo.mIsUpdate
                && outInfo.mRemovedUsers != null) {
            // For non-system uninstalls with DELETE_KEEP_DATA, set the installed state to false
            // for affected users. This does not apply to app updates where the old apk is replaced
            // but the old data remains.
            if (DEBUG_REMOVE) {
                Slog.d(TAG, "Updating installed state to false because of DELETE_KEEP_DATA");
            }
            for (int userId : outInfo.mRemovedUsers) {
                if (DEBUG_REMOVE) {
                    final boolean wasInstalled = deletedPs.getInstalled(userId);
                    Slog.d(TAG, "    user " + userId + ": " + wasInstalled + " => " + false);
                }
                deletedPs.setInstalled(/* installed= */ false, userId);
            }
        }
        // make sure to preserve per-user installed state if this removal was just
        // a downgrade of a system app to the factory package