Merge "Start home activities on displays that are empty"
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 608e450..de8024f 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2016,10 +2016,7 @@
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) {
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index 4339e51..c43fd24 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -179,6 +179,7 @@
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 @@
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 @@
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 @@
}
}
} 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;
}
}
}
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java
index c5b42f9..84a32fc 100644
--- a/services/core/java/com/android/server/wm/RootActivityContainer.java
+++ b/services/core/java/com/android/server/wm/RootActivityContainer.java
@@ -336,6 +336,15 @@
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.