Merge "[DO NOT MERGE] Don't accidentally delete renamed packages" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e9db00e39f
@@ -2161,6 +2161,18 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
mFirstBoot = !mSettings.readLPw(sUserManager.getUsers(false));
|
||||
|
||||
// Clean up orphaned packages for which the code path doesn't exist
|
||||
// and they are an update to a system app - caused by bug/32321269
|
||||
final int packageSettingCount = mSettings.mPackages.size();
|
||||
for (int i = packageSettingCount - 1; i >= 0; i--) {
|
||||
PackageSetting ps = mSettings.mPackages.valueAt(i);
|
||||
if (!isExternal(ps) && (ps.codePath == null || !ps.codePath.exists())
|
||||
&& mSettings.getDisabledSystemPkgLPr(ps.name) != null) {
|
||||
mSettings.mPackages.removeAt(i);
|
||||
mSettings.enableSystemPackageLPw(ps.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (mFirstBoot) {
|
||||
requestCopyPreoptedFiles();
|
||||
}
|
||||
@@ -3115,8 +3127,12 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
flags = updateFlagsForPackage(flags, userId, packageName);
|
||||
enforceCrossUserPermission(Binder.getCallingUid(), userId,
|
||||
false /* requireFullPermission */, false /* checkShell */, "get package info");
|
||||
|
||||
// reader
|
||||
synchronized (mPackages) {
|
||||
// Normalize package name to hanlde renamed packages
|
||||
packageName = normalizePackageNameLPr(packageName);
|
||||
|
||||
final boolean matchFactoryOnly = (flags & MATCH_FACTORY_ONLY) != 0;
|
||||
PackageParser.Package p = null;
|
||||
if (matchFactoryOnly) {
|
||||
@@ -3317,8 +3333,12 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
flags = updateFlagsForApplication(flags, userId, packageName);
|
||||
enforceCrossUserPermission(Binder.getCallingUid(), userId,
|
||||
false /* requireFullPermission */, false /* checkShell */, "get application info");
|
||||
|
||||
// writer
|
||||
synchronized (mPackages) {
|
||||
// Normalize package name to hanlde renamed packages
|
||||
packageName = normalizePackageNameLPr(packageName);
|
||||
|
||||
PackageParser.Package p = mPackages.get(packageName);
|
||||
if (DEBUG_PACKAGE_INFO) Log.v(
|
||||
TAG, "getApplicationInfo " + packageName
|
||||
@@ -3340,6 +3360,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String normalizePackageNameLPr(String packageName) {
|
||||
String normalizedPackageName = mSettings.mRenamedPackages.get(packageName);
|
||||
return normalizedPackageName != null ? normalizedPackageName : packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeStorageAndNotify(final String volumeUuid, final long freeStorageSize,
|
||||
final IPackageDataObserver observer) {
|
||||
@@ -19691,6 +19716,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
||||
private void assertPackageKnown(String volumeUuid, String packageName)
|
||||
throws PackageManagerException {
|
||||
synchronized (mPackages) {
|
||||
// Normalize package name to handle renamed packages
|
||||
packageName = normalizePackageNameLPr(packageName);
|
||||
|
||||
final PackageSetting ps = mSettings.mPackages.get(packageName);
|
||||
if (ps == null) {
|
||||
throw new PackageManagerException("Package " + packageName + " is unknown");
|
||||
@@ -19705,6 +19733,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
||||
private void assertPackageKnownAndInstalled(String volumeUuid, String packageName, int userId)
|
||||
throws PackageManagerException {
|
||||
synchronized (mPackages) {
|
||||
// Normalize package name to handle renamed packages
|
||||
packageName = normalizePackageNameLPr(packageName);
|
||||
|
||||
final PackageSetting ps = mSettings.mPackages.get(packageName);
|
||||
if (ps == null) {
|
||||
throw new PackageManagerException("Package " + packageName + " is unknown");
|
||||
|
||||
Reference in New Issue
Block a user