diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 3313378e1670..fa392d7c28bc 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -1263,7 +1263,7 @@ private void preparePackageLI(InstallRequest request) throws PrepareFailure { boolean systemApp = false; boolean replace = false; synchronized (mPm.mLock) { - final PackageSetting ps = mPm.mSettings.getPackageLPr(pkgName); + PackageSetting ps = mPm.mSettings.getPackageLPr(pkgName); // Check if installing already existing package if ((installFlags & PackageManager.INSTALL_REPLACE_EXISTING) != 0) { String oldName = mPm.mSettings.getRenamedPackageLPr(pkgName); @@ -1276,6 +1276,7 @@ private void preparePackageLI(InstallRequest request) throws PrepareFailure { parsedPackage.setPackageName(oldName); pkgName = parsedPackage.getPackageName(); replace = true; + ps = mPm.mSettings.getPackageLPr(pkgName); if (DEBUG_INSTALL) { Slog.d(TAG, "Replacing existing renamed package: oldName=" + oldName + " pkgName=" + pkgName);