Merge "Allow transfer starting window to windowDisableStarting activity." into sc-dev

This commit is contained in:
Wei Sheng Shih
2021-06-24 01:38:48 +00:00
committed by Android (Google) Code Review

View File

@@ -38,6 +38,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
@@ -1786,17 +1787,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
/**
* Evaluate the theme for a starting window.
* @param prev Previous activity which may have a starting window.
* @param originalTheme The original theme which read from activity or application.
* @param replaceTheme The replace theme which requested from starter.
* @return Resolved theme.
*/
private int evaluateStartingWindowTheme(String pkg, int originalTheme, int replaceTheme) {
private int evaluateStartingWindowTheme(ActivityRecord prev, String pkg, int originalTheme,
int replaceTheme) {
// Skip if the package doesn't want a starting window.
if (!validateStartingWindowTheme(pkg, originalTheme)) {
if (!validateStartingWindowTheme(prev, pkg, originalTheme)) {
return 0;
}
int selectedTheme = originalTheme;
if (replaceTheme != 0 && validateStartingWindowTheme(pkg, replaceTheme)) {
if (replaceTheme != 0 && validateStartingWindowTheme(prev, pkg, replaceTheme)) {
// allow to replace theme
selectedTheme = replaceTheme;
}
@@ -1833,7 +1836,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return LAUNCH_SOURCE_TYPE_APPLICATION;
}
private boolean validateStartingWindowTheme(String pkg, int theme) {
private boolean validateStartingWindowTheme(ActivityRecord prev, String pkg, int theme) {
// If this is a translucent window, then don't show a starting window -- the current
// effect (a full-screen opaque starting window that fades away to the real contents
// when it is ready) does not work for this.
@@ -1870,7 +1873,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return false;
}
if (windowDisableStarting && !launchedFromSystemSurface()) {
return false;
// Check if previous activity can transfer the starting window to this activity.
return prev != null && prev.getActivityType() == ACTIVITY_TYPE_STANDARD
&& prev.mTransferringSplashScreenState == TRANSFER_SPLASH_SCREEN_IDLE
&& (prev.mStartingData != null
|| (prev.mStartingWindow != null && prev.mStartingSurface != null));
}
return true;
}
@@ -6276,7 +6283,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
mSplashScreenStyleEmpty = shouldUseEmptySplashScreen(sourceRecord);
final int resolvedTheme = evaluateStartingWindowTheme(packageName, theme,
final int resolvedTheme = evaluateStartingWindowTheme(prev, packageName, theme,
splashScreenTheme);
final boolean shown = addStartingWindow(packageName, resolvedTheme,