Allow second consecutive activity start.

If we start two activities in onCreate the second one was being
blocked - because the current activity is no longer top but the new
activity is not yet visible. So we treat an INITIALIZING activity
as being visible for this purpose.

Bug: 130645908
Test: atest BackgroundActivityLaunchTest RootWindowContainerTests \
WmTests:ActivityStarterTests \
CtsWindowManagerDeviceTestCases:ActivityStarterTests
Change-Id: I96749f8b4d385527c91725827880bd12371d2411
This commit is contained in:
Alan Stokes
2019-04-18 13:41:58 +01:00
parent 27f23459d2
commit ac9a12924a

View File

@@ -23,6 +23,7 @@ import static android.view.Display.INVALID_DISPLAY;
import static com.android.server.am.ActivityManagerService.MY_PID;
import static com.android.server.wm.ActivityStack.ActivityState.DESTROYED;
import static com.android.server.wm.ActivityStack.ActivityState.DESTROYING;
import static com.android.server.wm.ActivityStack.ActivityState.INITIALIZING;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSING;
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
@@ -507,7 +508,14 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
continue;
}
ActivityRecord topActivity = task.getTopActivity();
if (topActivity != null && topActivity.visible) {
if (topActivity == null) {
continue;
}
// If an activity has just been started it will not yet be visible, but
// is expected to be soon. We treat this as if it were already visible.
// This ensures a subsequent activity can be started even before this one
// becomes visible.
if (topActivity.visible || topActivity.isState(INITIALIZING)) {
return true;
}
}