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

Commit b409e6c6 authored by Charles Chen's avatar Charles Chen
Browse files

Fix NPE in RootActivityContainer

We cannot guarantee that ActivityDisplay can be always gotten.
Add a null check to prevent NPE when display is null.

Bug: 124025708
Test: WmTests
Change-Id: I180bdea83e8a40dee27199759177f2bdb70aacd2
parent 29bdd5d1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ class RootActivityContainer extends ConfigurationContainer
     * corresponding record in display manager.
     */
    // TODO: Look into consolidating with getActivityDisplay()
    ActivityDisplay getActivityDisplayOrCreate(int displayId) {
    @Nullable ActivityDisplay getActivityDisplayOrCreate(int displayId) {
        ActivityDisplay activityDisplay = getActivityDisplay(displayId);
        if (activityDisplay != null) {
            return activityDisplay;
@@ -1317,6 +1317,9 @@ class RootActivityContainer extends ConfigurationContainer
        if (DEBUG_STACK) Slog.v(TAG, "Display added displayId=" + displayId);
        synchronized (mService.mGlobalLock) {
            final ActivityDisplay display = getActivityDisplayOrCreate(displayId);
            if (display == null) {
                return;
            }
            // Do not start home before booting, or it may accidentally finish booting before it
            // starts. Instead, we expect home activities to be launched when the system is ready
            // (ActivityManagerService#systemReady).