Complete booting when frontmost activity is idle
The boot process is intended to complete when the frontmost activity becomes idle. This change fixes a corner case where the system was booting and the Home activity became idle when it was not at the front causing the system to never complete booting. Before ag/603303 a secondary stack was created for the TaskPersister at the beginning of activity manager systemReady(). Following that change the secondary stack was created for the first time when a task was restored from system ui recents when getTaskThumbnail() was called. At the time it was created it was also moved to the front of the stack order. If that stack creation happens to occur after the Home activity is started but before the Home activity becomes idle then the new stack will obscure the Home activity and the boot process does not complete. 1. This change adds a test for an idle activity coming to the front when a stack is moving to the front and we haven't completed booting yet. If this situation is detected the boot sequence is then completed. 2. This change fixes the stack ordering so that creating a new task when restoring recents does not automatically move the stack to the front. Fixes bug 18949470. Change-Id: I243f0bb4396b518a0a8835c0c7bdccb2581a3520
This commit is contained in:
@@ -414,6 +414,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
if (DEBUG_STACK) Slog.d(TAG, "moveHomeTask: topStack old=" + topStack + " new="
|
||||
+ mFocusedStack);
|
||||
}
|
||||
if (mService.mBooting || !mService.mBooted) {
|
||||
final ActivityRecord r = topRunningActivityLocked();
|
||||
if (r != null && r.idle) {
|
||||
checkFinishBootingLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void moveHomeStackTaskToTop(int homeStackTaskType) {
|
||||
@@ -2235,6 +2241,24 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the frontmost task is idle.
|
||||
* @return the state of mService.mBooting before this was called.
|
||||
*/
|
||||
private boolean checkFinishBootingLocked() {
|
||||
final boolean booting = mService.mBooting;
|
||||
boolean enableScreen = false;
|
||||
mService.mBooting = false;
|
||||
if (!mService.mBooted) {
|
||||
mService.mBooted = true;
|
||||
enableScreen = true;
|
||||
}
|
||||
if (booting || enableScreen) {
|
||||
mService.postFinishBooting(booting, enableScreen);
|
||||
}
|
||||
return booting;
|
||||
}
|
||||
|
||||
// Checked.
|
||||
final ActivityRecord activityIdleInternalLocked(final IBinder token, boolean fromTimeout,
|
||||
Configuration config) {
|
||||
@@ -2246,7 +2270,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
int NS = 0;
|
||||
int NF = 0;
|
||||
boolean booting = false;
|
||||
boolean enableScreen = false;
|
||||
boolean activityRemoved = false;
|
||||
|
||||
ActivityRecord r = ActivityRecord.forToken(token);
|
||||
@@ -2274,12 +2297,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
//Slog.i(TAG, "IDLE: mBooted=" + mBooted + ", fromTimeout=" + fromTimeout);
|
||||
if (isFrontStack(r.task.stack) || fromTimeout) {
|
||||
booting = mService.mBooting;
|
||||
mService.mBooting = false;
|
||||
if (!mService.mBooted) {
|
||||
mService.mBooted = true;
|
||||
enableScreen = true;
|
||||
}
|
||||
booting = checkFinishBootingLocked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2352,10 +2370,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
//dump();
|
||||
//mWindowManager.dump();
|
||||
|
||||
if (booting || enableScreen) {
|
||||
mService.postFinishBooting(booting, enableScreen);
|
||||
}
|
||||
|
||||
if (activityRemoved) {
|
||||
resumeTopActivitiesLocked();
|
||||
}
|
||||
@@ -2624,6 +2638,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
// before an application stack is created...Go ahead and create one on the default
|
||||
// display.
|
||||
stack = getStack(createStackOnDisplay(getNextStackId(), Display.DEFAULT_DISPLAY));
|
||||
// Restore home stack to top.
|
||||
moveHomeStack(true);
|
||||
if (DEBUG_RECENTS)
|
||||
Slog.v(TAG, "Created stack=" + stack + " for recents restoration.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user