Handles null outInfo in deleteSystemPackageLI

This change adds null checks before accessing outInfo in
deleteSystemPackageLI.

Bug: 139907865
Test: manual; remove static dependency on eng build and reboot
Change-Id: If0fd48343e89cbb77ccd25826656194195d5b0cd
Merged-in: If0fd48343e89cbb77ccd25826656194195d5b0cd
This commit is contained in:
Patrick Baumann
2019-08-23 13:50:23 -07:00
parent 1d7a53da98
commit d54f430b56

View File

@@ -19032,10 +19032,11 @@ public class PackageManagerService extends IPackageManager.Stub
* Tries to delete system package. * Tries to delete system package.
*/ */
private void deleteSystemPackageLIF(DeletePackageAction action, PackageSetting deletedPs, private void deleteSystemPackageLIF(DeletePackageAction action, PackageSetting deletedPs,
int[] allUserHandles, int flags, PackageRemovedInfo outInfo, boolean writeSettings) int[] allUserHandles, int flags, @Nullable PackageRemovedInfo outInfo,
boolean writeSettings)
throws SystemDeleteException { throws SystemDeleteException {
final boolean applyUserRestrictions final boolean applyUserRestrictions =
= (allUserHandles != null) && (outInfo.origUsers != null); (allUserHandles != null) && outInfo != null && (outInfo.origUsers != null);
final PackageParser.Package deletedPkg = deletedPs.pkg; final PackageParser.Package deletedPkg = deletedPs.pkg;
// 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
@@ -19056,6 +19057,7 @@ public class PackageManagerService extends IPackageManager.Stub
} }
} }
if (outInfo != null) {
// Delete the updated package // Delete the updated package
outInfo.isRemovedPackageSystemUpdate = true; outInfo.isRemovedPackageSystemUpdate = true;
if (outInfo.removedChildPackages != null) { if (outInfo.removedChildPackages != null) {
@@ -19073,6 +19075,7 @@ public class PackageManagerService extends IPackageManager.Stub
} }
} }
} }
}
if (disabledPs.versionCode < deletedPs.versionCode) { if (disabledPs.versionCode < deletedPs.versionCode) {
// Delete data for downgrades // Delete data for downgrades
@@ -19101,7 +19104,8 @@ public class PackageManagerService extends IPackageManager.Stub
if (DEBUG_REMOVE) Slog.d(TAG, "Re-installing system package: " + disabledPs); if (DEBUG_REMOVE) Slog.d(TAG, "Re-installing system package: " + disabledPs);
try { try {
installPackageFromSystemLIF(disabledPs.codePathString, allUserHandles, installPackageFromSystemLIF(disabledPs.codePathString, allUserHandles,
outInfo.origUsers, deletedPs.getPermissionsState(), writeSettings); outInfo == null ? null : outInfo.origUsers, deletedPs.getPermissionsState(),
writeSettings);
} catch (PackageManagerException e) { } catch (PackageManagerException e) {
Slog.w(TAG, "Failed to restore system package:" + deletedPkg.packageName + ": " Slog.w(TAG, "Failed to restore system package:" + deletedPkg.packageName + ": "
+ e.getMessage()); + e.getMessage());