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

Commit 819ab25c authored by Felka Chang's avatar Felka Chang
Browse files

Fix NPE on calling Resources.getConfiguration()

Root cause: To update the code paths without triggering onChanged().
Explanation:
  1. The mInstallArgs.mInstallFlags contains
     PackageManager.DONT_KILL_APP.
  2. The existing package settings is not null.
     a.k.a. ps1.getOldCodePaths() != null
  3. The call flow doesn't trigger ps1.setOldCodePaths(...)
  4. The settings memory has been updated. However, snapshot doesn't
     update to the clients of PackageManagerServices.

Reference: b/210884444#comment12
Reference: b/209805326#comment10

Test: presubmit

Bug: 210884444
Bug: 209805326
Change-Id: I8a52a65bdfaed0ab385ee21b0512efae54f92c30
parent cd88027c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1969,14 +1969,15 @@ final class InstallPackageHelper {
                            reconciledPkg.mPrepareResult.mExistingPackage.getPackageName());
                    if ((reconciledPkg.mInstallArgs.mInstallFlags & PackageManager.DONT_KILL_APP)
                            == 0) {
                        if (ps1.getOldCodePaths() == null) {
                            ps1.setOldCodePaths(new ArraySet<>());
                        Set<String> oldCodePaths = ps1.getOldCodePaths();
                        if (oldCodePaths == null) {
                            oldCodePaths = new ArraySet<>();
                        }
                        Collections.addAll(ps1.getOldCodePaths(), oldPackage.getBaseApkPath());
                        Collections.addAll(oldCodePaths, oldPackage.getBaseApkPath());
                        if (oldPackage.getSplitCodePaths() != null) {
                            Collections.addAll(ps1.getOldCodePaths(),
                                    oldPackage.getSplitCodePaths());
                            Collections.addAll(oldCodePaths, oldPackage.getSplitCodePaths());
                        }
                        ps1.setOldCodePaths(oldCodePaths);
                    } else {
                        ps1.setOldCodePaths(null);
                    }