Merge changes I8ae4e331,Id4e37c3e,If0fd4834 into oc-dev

* changes:
  Fixes NPE when preparing app data during init
  Use KNOWN_PACKAGES when shared lib consumers
  Handles null outInfo in deleteSystemPackageLI
This commit is contained in:
Bryan Ferris
2020-01-08 22:46:45 +00:00
committed by Android (Google) Code Review

View File

@@ -18951,7 +18951,7 @@ public class PackageManagerService extends IPackageManager.Stub
continue; continue;
} }
List<VersionedPackage> libClientPackages = getPackagesUsingSharedLibraryLPr( List<VersionedPackage> libClientPackages = getPackagesUsingSharedLibraryLPr(
libEntry.info, 0, currUserId); libEntry.info, MATCH_KNOWN_PACKAGES, currUserId);
if (!ArrayUtils.isEmpty(libClientPackages)) { if (!ArrayUtils.isEmpty(libClientPackages)) {
Slog.w(TAG, "Not removing package " + pkg.manifestPackageName Slog.w(TAG, "Not removing package " + pkg.manifestPackageName
+ " hosting lib " + libEntry.info.getName() + " version " + " hosting lib " + libEntry.info.getName() + " version "
@@ -19283,7 +19283,8 @@ public class PackageManagerService extends IPackageManager.Stub
* Tries to delete system package. * Tries to delete system package.
*/ */
private boolean deleteSystemPackageLIF(PackageParser.Package deletedPkg, private boolean deleteSystemPackageLIF(PackageParser.Package deletedPkg,
PackageSetting deletedPs, int[] allUserHandles, int flags, PackageRemovedInfo outInfo, PackageSetting deletedPs, int[] allUserHandles, int flags,
@Nullable PackageRemovedInfo outInfo,
boolean writeSettings) { boolean writeSettings) {
if (deletedPs.parentPackageName != null) { if (deletedPs.parentPackageName != null) {
Slog.w(TAG, "Attempt to delete child system package " + deletedPkg.packageName); Slog.w(TAG, "Attempt to delete child system package " + deletedPkg.packageName);
@@ -19291,7 +19292,7 @@ public class PackageManagerService extends IPackageManager.Stub
} }
final boolean applyUserRestrictions final boolean applyUserRestrictions
= (allUserHandles != null) && (outInfo.origUsers != null); = (allUserHandles != null) && outInfo != null && (outInfo.origUsers != null);
final PackageSetting disabledPs; final PackageSetting disabledPs;
// Confirm if the system package has been updated // Confirm if the system package has been updated
// An updated system app can be deleted. This will also have to restore // An updated system app can be deleted. This will also have to restore
@@ -19321,19 +19322,21 @@ public class PackageManagerService extends IPackageManager.Stub
} }
} }
// Delete the updated package if (outInfo != null) {
outInfo.isRemovedPackageSystemUpdate = true; // Delete the updated package
if (outInfo.removedChildPackages != null) { outInfo.isRemovedPackageSystemUpdate = true;
final int childCount = (deletedPs.childPackageNames != null) if (outInfo.removedChildPackages != null) {
? deletedPs.childPackageNames.size() : 0; final int childCount = (deletedPs.childPackageNames != null)
for (int i = 0; i < childCount; i++) { ? deletedPs.childPackageNames.size() : 0;
String childPackageName = deletedPs.childPackageNames.get(i); for (int i = 0; i < childCount; i++) {
if (disabledPs.childPackageNames != null && disabledPs.childPackageNames String childPackageName = deletedPs.childPackageNames.get(i);
.contains(childPackageName)) { if (disabledPs.childPackageNames != null && disabledPs.childPackageNames
PackageRemovedInfo childInfo = outInfo.removedChildPackages.get( .contains(childPackageName)) {
childPackageName); PackageRemovedInfo childInfo = outInfo.removedChildPackages.get(
if (childInfo != null) { childPackageName);
childInfo.isRemovedPackageSystemUpdate = true; if (childInfo != null) {
childInfo.isRemovedPackageSystemUpdate = true;
}
} }
} }
} }
@@ -23433,9 +23436,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
mSettings.writeKernelMappingLPr(ps); mSettings.writeKernelMappingLPr(ps);
} }
final UserManager um = mContext.getSystemService(UserManager.class); final UserManagerService um = sUserManager;
UserManagerInternal umInternal = getUserManagerInternal(); UserManagerInternal umInternal = getUserManagerInternal();
for (UserInfo user : um.getUsers()) { for (UserInfo user : um.getUsers(false /* excludeDying */)) {
final int flags; final int flags;
if (umInternal.isUserUnlockingOrUnlocked(user.id)) { if (umInternal.isUserUnlockingOrUnlocked(user.id)) {
flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE; flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
@@ -24062,8 +24065,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
continue; continue;
} }
final String packageName = ps.pkg.packageName; final String packageName = ps.pkg.packageName;
// Skip over if system app // Skip over if system app or static shared library
if ((ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) { if ((ps.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0
|| !TextUtils.isEmpty(ps.pkg.staticSharedLibName)) {
continue; continue;
} }
if (DEBUG_CLEAN_APKS) { if (DEBUG_CLEAN_APKS) {