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

Commit e9509a32 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Start home activities on displays that are empty"

parents 8823fa23 dcdde95e
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -2016,10 +2016,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;
@@ -793,7 +794,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);
@@ -915,6 +916,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) {
@@ -2540,7 +2550,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.