Merge "[pm] fail install-existing for apps deleted with KEEP_DATA" into udc-dev am: 5d8b0d27bf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22936883

Change-Id: I089e57a1104ec95778daa6549fcf07064efdc025
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Song Chun Fan
2023-05-04 15:54:34 +00:00
committed by Automerger Merge Worker
2 changed files with 2 additions and 1 deletions

View File

@@ -453,6 +453,7 @@ final class DeletePackageHelper {
// We need to set it back to 'installed' so the uninstall // We need to set it back to 'installed' so the uninstall
// broadcasts will be sent correctly. // broadcasts will be sent correctly.
if (DEBUG_REMOVE) Slog.d(TAG, "Not installed by other users, full delete"); if (DEBUG_REMOVE) Slog.d(TAG, "Not installed by other users, full delete");
ps.setPkg(null);
ps.setInstalled(true, userId); ps.setInstalled(true, userId);
mPm.mSettings.writeKernelMappingLPr(ps); mPm.mSettings.writeKernelMappingLPr(ps);
clearPackageStateAndReturn = false; clearPackageStateAndReturn = false;

View File

@@ -654,7 +654,7 @@ final class InstallPackageHelper {
synchronized (mPm.mLock) { synchronized (mPm.mLock) {
final Computer snapshot = mPm.snapshotComputer(); final Computer snapshot = mPm.snapshotComputer();
pkgSetting = mPm.mSettings.getPackageLPr(packageName); pkgSetting = mPm.mSettings.getPackageLPr(packageName);
if (pkgSetting == null) { if (pkgSetting == null || pkgSetting.getPkg() == null) {
return PackageManager.INSTALL_FAILED_INVALID_URI; return PackageManager.INSTALL_FAILED_INVALID_URI;
} }
if (!snapshot.canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) { if (!snapshot.canViewInstantApps(callingUid, UserHandle.getUserId(callingUid))) {