Merge "Also add starting window when activity is not alive" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-05-16 16:13:17 +00:00
committed by Android (Google) Code Review
3 changed files with 15 additions and 10 deletions

View File

@@ -2165,7 +2165,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
final boolean shown = mWindowContainerController.addStartingWindow(packageName, theme,
compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
allowTaskSnapshot());
allowTaskSnapshot(),
state.ordinal() >= RESUMED.ordinal() && state.ordinal() <= STOPPED.ordinal());
if (shown) {
mStartingWindowState = STARTING_WINDOW_SHOWN;
}

View File

@@ -447,7 +447,7 @@ public class AppWindowContainerController
public boolean addStartingWindow(String pkg, int theme, CompatibilityInfo compatInfo,
CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags,
IBinder transferFrom, boolean newTask, boolean taskSwitch, boolean processRunning,
boolean allowTaskSnapshot) {
boolean allowTaskSnapshot, boolean activityCreated) {
synchronized(mWindowMap) {
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "setAppStartingWindow: token=" + mToken
+ " pkg=" + pkg + " transferFrom=" + transferFrom);
@@ -475,7 +475,7 @@ public class AppWindowContainerController
}
final int type = getStartingWindowType(newTask, taskSwitch, processRunning,
allowTaskSnapshot);
allowTaskSnapshot, activityCreated);
if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
return createSnapshot();
@@ -546,8 +546,9 @@ public class AppWindowContainerController
}
private int getStartingWindowType(boolean newTask, boolean taskSwitch, boolean processRunning,
boolean allowTaskSnapshot) {
if (newTask || !processRunning) {
boolean allowTaskSnapshot, boolean activityCreated) {
if (newTask || !processRunning
|| (taskSwitch && !activityCreated)) {
return STARTING_WINDOW_TYPE_SPLASH_SCREEN;
} else if (taskSwitch && allowTaskSnapshot) {
return STARTING_WINDOW_TYPE_SNAPSHOT;

View File

@@ -97,7 +97,8 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
final WindowTestUtils.TestAppWindowContainerController controller =
createAppWindowController();
controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
false);
waitUntilHandlersIdle();
final AppWindowToken atoken = controller.getAppWindowToken(mDisplayContent);
assertHasStartingWindow(atoken);
@@ -113,11 +114,12 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
final WindowTestUtils.TestAppWindowContainerController controller2 =
createAppWindowController();
controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
false);
waitUntilHandlersIdle();
controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(),
true, true, false, true);
true, true, false, true, false);
waitUntilHandlersIdle();
assertNoStartingWindow(controller1.getAppWindowToken(mDisplayContent));
assertHasStartingWindow(controller2.getAppWindowToken(mDisplayContent));
@@ -134,10 +136,11 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
// Surprise, ...! Transfer window in the middle of the creation flow.
controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(),
true, true, false, true);
true, true, false, true, false);
});
controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
false);
waitUntilHandlersIdle();
assertNoStartingWindow(controller1.getAppWindowToken(mDisplayContent));
assertHasStartingWindow(controller2.getAppWindowToken(mDisplayContent));