Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03e17d9a authored by lijilou's avatar lijilou Committed by Jilou li
Browse files

InstallPackageHelper: fiX the NPE problem.

 Install the renamed apk,use the new name to getPackageLPr may be null,so we should make a null judgment.

Test: monkey test
Flag: EXEMPT bugfix
Bug: 386727719
Change-Id: Ia41a401bceaa13889ea66f5e3e337b99e3e4b799
parent b4838c7c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1387,7 +1387,7 @@ final class InstallPackageHelper {
        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);
@@ -1398,14 +1398,15 @@ final class InstallPackageHelper {
                    // name.  We must continue using the original name, so
                    // rename the new package here.
                    parsedPackage.setPackageName(oldName);
                    pkgName = parsedPackage.getPackageName();
                    replace = true;
                    pkgName = oldName;
                    ps = mPm.mSettings.getPackageLPr(oldName);
                    if (DEBUG_INSTALL) {
                        Slog.d(TAG, "Replacing existing renamed package: oldName="
                                + oldName + " pkgName=" + pkgName);
                    }
                } else if (ps != null) {
                    // This package, under its official name, already exists
                }
                if (ps != null) {
                    // This package, under its official name or its old name, already exists
                    // on the device; we should replace it.
                    replace = true;
                    if (DEBUG_INSTALL) Slog.d(TAG, "Replace existing package: " + pkgName);