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

Commit dcdde95e authored by Louis Chang's avatar Louis Chang
Browse files

Start home activities on displays that are empty

During system boot, there could have several home activities
being sequentially launched (e.g. FallbackHome -> default home).
If a home activity doesn't support running on secondary displays,
we weren't sequentially start the next home activity even it
does support running on secondary displays.

Start home activities on displays that are empty (no activity)
whenever home changed.

Bug: 119844270
Test: atest ActivityManagerMultiDisplayTests
Change-Id: I78a4edd44212c47e20852f5de26f2c3a244f99de
parent 298c49e4
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -1993,10 +1993,7 @@ final class ActivityRecord extends ConfigurationContainer {
        stopped = false;

        if (isActivityTypeHome()) {
            WindowProcessController app = task.mActivities.get(0).app;
            if (hasProcess() && app != mAtmService.mHomeProcess) {
                mAtmService.mHomeProcess = app;
            }
            mStackSupervisor.updateHomeProcess(task.mActivities.get(0).app);
        }

        if (nowVisible) {
+19 −1
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
    static final int LAUNCH_TASK_BEHIND_COMPLETE = FIRST_SUPERVISOR_STACK_MSG + 12;
    static final int REPORT_MULTI_WINDOW_MODE_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 14;
    static final int REPORT_PIP_MODE_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 15;
    static final int REPORT_HOME_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 16;

    // Used to indicate that windows of activities should be preserved during the resize.
    static final boolean PRESERVE_WINDOWS = true;
@@ -795,7 +796,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                        System.identityHashCode(r), task.taskId, r.shortComponentName);
                if (r.isActivityTypeHome()) {
                    // Home process is the root process of the task.
                    mService.mHomeProcess = task.mActivities.get(0).app;
                    updateHomeProcess(task.mActivities.get(0).app);
                }
                mService.getPackageManagerInternalLocked().notifyPackageUse(
                        r.intent.getComponent().getPackageName(), NOTIFY_PACKAGE_USE_ACTIVITY);
@@ -917,6 +918,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        return true;
    }

    void updateHomeProcess(WindowProcessController app) {
        if (app != null && mService.mHomeProcess != app) {
            if (!mHandler.hasMessages(REPORT_HOME_CHANGED_MSG)) {
                mHandler.sendEmptyMessage(REPORT_HOME_CHANGED_MSG);
            }
            mService.mHomeProcess = app;
        }
    }

    private void logIfTransactionTooLarge(Intent intent, Bundle icicle) {
        int extrasSize = 0;
        if (intent != null) {
@@ -2545,7 +2555,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                        }
                    }
                } break;
                case REPORT_HOME_CHANGED_MSG: {
                    synchronized (mService.mGlobalLock) {
                        mHandler.removeMessages(REPORT_HOME_CHANGED_MSG);

                        // Start home activities on displays with no activities.
                        mRootActivityContainer.startHomeOnEmptyDisplays("homeChanged");
                    }
                }
                break;
            }
        }
    }
+9 −0
Original line number Diff line number Diff line
@@ -336,6 +336,15 @@ class RootActivityContainer extends ConfigurationContainer
        return homeStarted;
    }

    void startHomeOnEmptyDisplays(String reason) {
        for (int i = mActivityDisplays.size() - 1; i >= 0; i--) {
            final ActivityDisplay display = mActivityDisplays.get(i);
            if (display.topRunningActivity() == null) {
                startHomeOnDisplay(mCurrentUser, reason, display.mDisplayId);
            }
        }
    }

    /**
     * This starts home activity on displays that can have system decorations and only if the
     * home activity can have multiple instances.