diff options
5 files changed, 58 insertions, 46 deletions
diff --git a/core/java/android/window/StartingWindowInfo.java b/core/java/android/window/StartingWindowInfo.java index 451acbe84a60..a88e394c0985 100644 --- a/core/java/android/window/StartingWindowInfo.java +++ b/core/java/android/window/StartingWindowInfo.java @@ -122,7 +122,7 @@ public final class StartingWindowInfo implements Parcelable { TYPE_PARAMETER_PROCESS_RUNNING, TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT, TYPE_PARAMETER_ACTIVITY_CREATED, - TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN, + TYPE_PARAMETER_ALLOW_ICON, TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN, TYPE_PARAMETER_WINDOWLESS, TYPE_PARAMETER_LEGACY_SPLASH_SCREEN @@ -143,7 +143,7 @@ public final class StartingWindowInfo implements Parcelable { /** @hide */ public static final int TYPE_PARAMETER_ACTIVITY_CREATED = 0x00000010; /** @hide */ - public static final int TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN = 0x00000020; + public static final int TYPE_PARAMETER_ALLOW_ICON = 0x00000020; /** * The parameter which indicates if the activity has finished drawing. * @hide diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/phone/PhoneStartingWindowTypeAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/phone/PhoneStartingWindowTypeAlgorithm.java index 72fc8686f648..6ea6516a96f5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/phone/PhoneStartingWindowTypeAlgorithm.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/phone/PhoneStartingWindowTypeAlgorithm.java @@ -30,7 +30,7 @@ import static android.window.StartingWindowInfo.TYPE_PARAMETER_LEGACY_SPLASH_SCR import static android.window.StartingWindowInfo.TYPE_PARAMETER_NEW_TASK; import static android.window.StartingWindowInfo.TYPE_PARAMETER_PROCESS_RUNNING; import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH; -import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN; +import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_ICON; import static android.window.StartingWindowInfo.TYPE_PARAMETER_WINDOWLESS; import android.window.StartingWindowInfo; @@ -52,8 +52,7 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor final boolean processRunning = (parameter & TYPE_PARAMETER_PROCESS_RUNNING) != 0; final boolean allowTaskSnapshot = (parameter & TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT) != 0; final boolean activityCreated = (parameter & TYPE_PARAMETER_ACTIVITY_CREATED) != 0; - final boolean isSolidColorSplashScreen = - (parameter & TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN) != 0; + final boolean allowIcon = (parameter & TYPE_PARAMETER_ALLOW_ICON) != 0; final boolean legacySplashScreen = ((parameter & TYPE_PARAMETER_LEGACY_SPLASH_SCREEN) != 0); final boolean activityDrawn = (parameter & TYPE_PARAMETER_ACTIVITY_DRAWN) != 0; @@ -67,13 +66,13 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor + "processRunning=%b, " + "allowTaskSnapshot=%b, " + "activityCreated=%b, " - + "isSolidColorSplashScreen=%b, " + + "allowIcon=%b, " + "legacySplashScreen=%b, " + "activityDrawn=%b, " + "windowless=%b, " + "topIsHome=%b", newTask, taskSwitch, processRunning, allowTaskSnapshot, activityCreated, - isSolidColorSplashScreen, legacySplashScreen, activityDrawn, windowlessSurface, + allowIcon, legacySplashScreen, activityDrawn, windowlessSurface, topIsHome); if (windowlessSurface) { @@ -81,7 +80,7 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor } if (!topIsHome) { if (!processRunning || newTask || (taskSwitch && !activityCreated)) { - return getSplashscreenType(isSolidColorSplashScreen, legacySplashScreen); + return getSplashscreenType(allowIcon, legacySplashScreen); } } @@ -95,18 +94,18 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor } } if (!activityDrawn && !topIsHome) { - return getSplashscreenType(isSolidColorSplashScreen, legacySplashScreen); + return getSplashscreenType(allowIcon, legacySplashScreen); } } return STARTING_WINDOW_TYPE_NONE; } - private static int getSplashscreenType(boolean solidColorSplashScreen, - boolean legacySplashScreen) { - return solidColorSplashScreen - ? STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN - : legacySplashScreen - ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN + private static int getSplashscreenType(boolean allowIcon, boolean legacySplashScreen) { + if (allowIcon) { + return legacySplashScreen ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN : STARTING_WINDOW_TYPE_SPLASH_SCREEN; + } else { + return STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN; + } } } diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 52dafc276711..5fec50e29a9c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -580,7 +580,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A IBinder mRequestedLaunchingTaskFragmentToken; // Tracking splash screen status from previous activity - boolean mSplashScreenStyleSolidColor = false; + boolean mAllowIconSplashScreen = true; boolean mPauseSchedulePendingForPip = false; @@ -2408,8 +2408,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @VisibleForTesting boolean addStartingWindow(String pkg, int resolvedTheme, ActivityRecord from, boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, - boolean activityCreated, boolean isSimple, - boolean activityAllDrawn) { + boolean activityCreated, boolean allowIcon, boolean activityAllDrawn) { // If the display is frozen, we won't do anything until the actual window is // displayed so there is no reason to put in the starting window. if (!okToDisplay()) { @@ -2444,8 +2443,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final int typeParameter = StartingSurfaceController .makeStartingWindowTypeParameter(newTask, taskSwitch, processRunning, - allowTaskSnapshot, activityCreated, isSimple, useLegacy, activityAllDrawn, - type, packageName, mUserId); + allowTaskSnapshot, activityCreated, allowIcon, useLegacy, + activityAllDrawn, type, packageName, mUserId); if (type == STARTING_WINDOW_TYPE_SNAPSHOT) { if (isActivityTypeHome()) { @@ -6747,7 +6746,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void onFirstWindowDrawn(WindowState win) { firstWindowDrawn = true; // stop tracking - mSplashScreenStyleSolidColor = true; + mAllowIconSplashScreen = false; if (mStartingWindow != null) { ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Finish starting %s" @@ -6796,7 +6795,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void onStartingWindowDrawn() { boolean wasTaskVisible = false; if (task != null) { - mSplashScreenStyleSolidColor = true; + mAllowIconSplashScreen = false; wasTaskVisible = !setTaskHasBeenVisible(); } @@ -7321,19 +7320,32 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } /** - * @return true if a solid color splash screen must be used - * false when an icon splash screen can be used, but the final decision for whether to - * use an icon or solid color splash screen will be made by WmShell. + * Checks whether an icon splash screen can be used in the starting window based on the + * preference in the {@code options} and this activity's theme, giving higher priority to the + * {@code options}'s preference. + * + * When no preference is specified, a default behaviour is defined: + * - if the activity is started from the home or shell app, an icon can be used + * - if the activity is started from SystemUI, an icon should not be used + * - if there is a launching activity, use its preference + * - if none of the above is met, only use an icon when the activity is started for the first + * time from a System app + * + * The returned value is sent to WmShell, which will make the final decision on what splash + * screen type will be used. + * + * @return true if an icon can be used in the splash screen + * false when an icon should not be used in the splash screen */ - private boolean shouldUseSolidColorSplashScreen(ActivityRecord sourceRecord, + private boolean canUseIconSplashScreen(ActivityRecord sourceRecord, boolean startActivity, ActivityOptions options, int resolvedTheme) { if (sourceRecord == null && !startActivity) { - // Use simple style if this activity is not top activity. This could happen when adding - // a splash screen window to the warm start activity which is re-create because top is - // finishing. + // Shouldn't use an icon if this activity is not top activity. This could happen when + // adding a splash screen window to the warm start activity which is re-create because + // top is finishing. final ActivityRecord above = task.getActivityAbove(this); if (above != null) { - return true; + return false; } } @@ -7341,32 +7353,33 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final int optionsStyle = options != null ? options.getSplashScreenStyle() : SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED; if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR) { - return true; + return false; } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON || isIconStylePreferred(resolvedTheme)) { - return false; + return true; } // Choose the default behavior when neither the ActivityRecord nor the activity theme have // specified a splash screen style. if (mLaunchSourceType == LAUNCH_SOURCE_TYPE_HOME || launchedFromUid == Process.SHELL_UID) { - return false; - } else if (mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEMUI) { return true; + } else if (mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEMUI) { + return false; } else { - // Need to check sourceRecord in case this activity is launched from a service. + // Need to check sourceRecord in case this activity is launched from a service or a + // trampoline activity. if (sourceRecord == null) { sourceRecord = searchCandidateLaunchingActivity(); } if (sourceRecord != null) { - return sourceRecord.mSplashScreenStyleSolidColor; + return sourceRecord.mAllowIconSplashScreen; } // Use an icon if the activity was launched from System for the first start. - // Otherwise, must use solid color splash screen. - return mLaunchSourceType != LAUNCH_SOURCE_TYPE_SYSTEM || !startActivity; + // Otherwise, can't use an icon splash screen. + return mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEM && startActivity; } } @@ -7430,7 +7443,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final int resolvedTheme = evaluateStartingWindowTheme(prev, packageName, theme, splashScreenTheme); - mSplashScreenStyleSolidColor = shouldUseSolidColorSplashScreen(sourceRecord, startActivity, + mAllowIconSplashScreen = canUseIconSplashScreen(sourceRecord, startActivity, startOptions, resolvedTheme); final boolean activityCreated = @@ -7442,7 +7455,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean scheduled = addStartingWindow(packageName, resolvedTheme, prev, newTask || newSingleActivity, taskSwitch, processRunning, - allowTaskSnapshot(), activityCreated, mSplashScreenStyleSolidColor, allDrawn); + allowTaskSnapshot(), activityCreated, mAllowIconSplashScreen, allDrawn); if (DEBUG_STARTING_WINDOW_VERBOSE && scheduled) { Slog.d(TAG, "Scheduled starting window for " + this); } diff --git a/services/core/java/com/android/server/wm/StartingSurfaceController.java b/services/core/java/com/android/server/wm/StartingSurfaceController.java index a55c232990cf..a0517bebca6d 100644 --- a/services/core/java/com/android/server/wm/StartingSurfaceController.java +++ b/services/core/java/com/android/server/wm/StartingSurfaceController.java @@ -19,12 +19,12 @@ package com.android.server.wm; import static android.window.StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_CREATED; import static android.window.StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_DRAWN; import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN; +import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_ICON; import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT; import static android.window.StartingWindowInfo.TYPE_PARAMETER_LEGACY_SPLASH_SCREEN; import static android.window.StartingWindowInfo.TYPE_PARAMETER_NEW_TASK; import static android.window.StartingWindowInfo.TYPE_PARAMETER_PROCESS_RUNNING; import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH; -import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN; import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SNAPSHOT; import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SPLASH_SCREEN; @@ -102,7 +102,7 @@ public class StartingSurfaceController { static int makeStartingWindowTypeParameter(boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated, - boolean isSolidColor, boolean useLegacy, boolean activityDrawn, int startingWindowType, + boolean allowIcon, boolean useLegacy, boolean activityDrawn, int startingWindowType, String packageName, int userId) { int parameter = 0; if (newTask) { @@ -120,8 +120,8 @@ public class StartingSurfaceController { if (activityCreated || startingWindowType == STARTING_WINDOW_TYPE_SNAPSHOT) { parameter |= TYPE_PARAMETER_ACTIVITY_CREATED; } - if (isSolidColor) { - parameter |= TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN; + if (allowIcon) { + parameter |= TYPE_PARAMETER_ALLOW_ICON; } if (useLegacy) { parameter |= TYPE_PARAMETER_LEGACY_SPLASH_SCREEN; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index ae587003c1c2..8ec3ac6ca3fd 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -2871,14 +2871,14 @@ public class ActivityRecordTests extends WindowTestsBase { .setTask(sourceRecord.getTask()).build(); secondRecord.showStartingWindow(null /* prev */, true /* newTask */, false, true /* startActivity */, sourceRecord); - assertFalse(secondRecord.mSplashScreenStyleSolidColor); + assertTrue(secondRecord.mAllowIconSplashScreen); secondRecord.onStartingWindowDrawn(); final ActivityRecord finalRecord = new ActivityBuilder(mAtm) .setTask(sourceRecord.getTask()).build(); finalRecord.showStartingWindow(null /* prev */, true /* newTask */, false, true /* startActivity */, secondRecord); - assertTrue(finalRecord.mSplashScreenStyleSolidColor); + assertFalse(finalRecord.mAllowIconSplashScreen); } @Test |