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

Commit 270799ad authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Prevent potential NPE when forcing stop package during boot

Some test cases may send package removal command before boot
complete, e.g. around SecondaryZygotePreload stage. Then
ActivityManagerService#setWindowManager is not called yet so
mRootWindowContainer in ATMS is null.

Bug: 219066637
Bug: 186665301
Test: Restart device by "adb shell am restart".
      And keep sending "adb uninstall $validPackageName".
      The device should still boot successfully without crash.
      And the target package is also removed successfully.
Change-Id: I2711fabb0755b53a9817ce81ab553e5ce2a8c389
parent cdd2a77e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6091,7 +6091,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        public boolean onForceStopPackage(String packageName, boolean doit, boolean evenPersistent,
                int userId) {
            synchronized (mGlobalLock) {

                // In case if setWindowManager hasn't been called yet when booting.
                if (mRootWindowContainer == null) return false;
                return mRootWindowContainer.finishDisabledPackageActivities(packageName,
                        null /* filterByClasses */, doit, evenPersistent, userId,
                        // Only remove the activities without process because the activities with