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

Commit 9112adc4 authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] fail install-existing for apps deleted with KEEP_DATA

BUG: 269687045
Test: manual with the following steps:

$ adb install --user 10 ~/Downloads/WhatsApp.apk
$ adb shell cmd package uninstall -k --user 10 com.whatsapp
$ adb shell pm install-existing --user 0 com.whatsapp
android.content.pm.PackageManager$NameNotFoundException: Package com.whatsapp doesn't exist

Test: atest com.android.server.pm.PackageManagerTests
Change-Id: I88e03093fbb76550d9ca12c4a8bfd2ef54a418f7
parent 0a2721fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -453,6 +453,7 @@ final class DeletePackageHelper {
                        // 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.setPkg(null);
                        ps.setInstalled(true, userId);
                        mPm.mSettings.writeKernelMappingLPr(ps);
                        clearPackageStateAndReturn = false;
+1 −1
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ final class InstallPackageHelper {
            synchronized (mPm.mLock) {
                final Computer snapshot = mPm.snapshotComputer();
                pkgSetting = mPm.mSettings.getPackageLPr(packageName);
                if (pkgSetting == null) {
                if (pkgSetting == null || pkgSetting.getPkg() == null) {
                    return PackageManager.INSTALL_FAILED_INVALID_URI;
                }
                if (!snapshot.canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) {