Clean up renamed packages during app removal
It doesn't clean up a renamed package when a package is removed
by OTA or uninstalls, which could lead to failing installs for
renamed packages. This CL cleans up renamed packages when an app
is removed and during initialization just in case.
Bug: 178191975
Test: Manulal (removed by OTA)
Add Package A
Verify package A exists
Remove A, add package B w/ original-package A
Verify package A exists, but codepath is to package B
Remove B
Verify the renamed package for B is cleaned up
Test: Manulal (removed by uninstalls)
Add Package A
Verify package A exists
Remove A, add package B w/ original-package A
Verify package A exists, but codepath is to package B
Upgrade B on /data and Remove B on /system
Verify B is installed as non-system app
Uninstall B
Verify the renamed package for B is cleaned up
Change-Id: Ief8f7c5b66339f4dea009361fbaca949f1f16367
This commit is contained in:
committed by
Patrick Baumann
parent
ebef117686
commit
71378bde10
@@ -7577,6 +7577,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
mExpectingBetter.clear();
|
||||
|
||||
mSettings.pruneRenamedPackagesLPw();
|
||||
|
||||
// Resolve the storage manager.
|
||||
mStorageManagerPackage = getStorageManagerPackageName();
|
||||
|
||||
@@ -21867,6 +21869,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
clearPackagePreferredActivitiesLPw(
|
||||
deletedPs.name, changedUsers, UserHandle.USER_ALL);
|
||||
|
||||
mSettings.removeRenamedPackageLPw(deletedPs.realName);
|
||||
}
|
||||
if (changedUsers.size() > 0) {
|
||||
updateDefaultHomeNotLocked(changedUsers);
|
||||
|
||||
@@ -747,6 +747,15 @@ public final class Settings implements Watchable, Snappable {
|
||||
mRenamedPackages.remove(pkgName);
|
||||
}
|
||||
|
||||
void pruneRenamedPackagesLPw() {
|
||||
for (int i = mRenamedPackages.size() - 1; i >= 0; i--) {
|
||||
PackageSetting ps = mPackages.get(mRenamedPackages.valueAt(i));
|
||||
if (ps == null) {
|
||||
mRenamedPackages.removeAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets and optionally creates a new shared user id. */
|
||||
SharedUserSetting getSharedUserLPw(String name, int pkgFlags, int pkgPrivateFlags,
|
||||
boolean create) throws PackageManagerException {
|
||||
|
||||
Reference in New Issue
Block a user