From db6ba3ba588ea691152a6f46e8a0ed157e34d7b2 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Mon, 21 Feb 2022 13:52:43 +0800 Subject: [PATCH] Rename 'EMPTY' to 'SOLID_COLOR' for splash screen style. Preventing from misleading developers. Bug: 217953215 Test: atest SplashscreenTests StartingSurfaceDrawerTests ActivityRecordTests Change-Id: I8669effb2e843ebe61e807850359b07b36b39fb3 --- core/api/current.txt | 2 +- core/java/android/app/ActivityOptions.java | 4 +-- core/java/android/window/SplashScreen.java | 4 +-- .../java/android/window/SplashScreenView.java | 8 ++--- .../android/window/StartingWindowInfo.java | 22 +++++++------- .../SplashscreenContentDrawer.java | 14 ++++----- .../StartingWindowController.java | 4 +-- .../PhoneStartingWindowTypeAlgorithm.java | 25 ++++++++-------- .../tv/TvStartingWindowTypeAlgorithm.java | 4 +-- .../com/android/server/wm/ActivityRecord.java | 30 +++++++++---------- .../server/wm/StartingSurfaceController.java | 18 +++++------ .../server/wm/ActivityRecordTests.java | 4 +-- 12 files changed, 70 insertions(+), 69 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index d8ea767a64005..32633f07458ce 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -57912,8 +57912,8 @@ package android.window { method public void clearOnExitAnimationListener(); method public void setOnExitAnimationListener(@NonNull android.window.SplashScreen.OnExitAnimationListener); method public void setSplashScreenTheme(@StyleRes int); - field public static final int SPLASH_SCREEN_STYLE_EMPTY = 0; // 0x0 field public static final int SPLASH_SCREEN_STYLE_ICON = 1; // 0x1 + field public static final int SPLASH_SCREEN_STYLE_SOLID_COLOR = 0; // 0x0 } public static interface SplashScreen.OnExitAnimationListener { diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 1d14307e6294f..87ac6cb1fe4c9 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -1472,12 +1472,12 @@ public class ActivityOptions extends ComponentOptions { * Sets the preferred splash screen style of the opening activities. This only applies if the * Activity or Process is not yet created. * @param style Can be either {@link SplashScreen#SPLASH_SCREEN_STYLE_ICON} or - * {@link SplashScreen#SPLASH_SCREEN_STYLE_EMPTY} + * {@link SplashScreen#SPLASH_SCREEN_STYLE_SOLID_COLOR} */ @NonNull public ActivityOptions setSplashScreenStyle(@SplashScreen.SplashScreenStyle int style) { if (style == SplashScreen.SPLASH_SCREEN_STYLE_ICON - || style == SplashScreen.SPLASH_SCREEN_STYLE_EMPTY) { + || style == SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR) { mSplashScreenStyle = style; } return this; diff --git a/core/java/android/window/SplashScreen.java b/core/java/android/window/SplashScreen.java index 3f65f475fbd56..fab180dae0bf6 100644 --- a/core/java/android/window/SplashScreen.java +++ b/core/java/android/window/SplashScreen.java @@ -52,7 +52,7 @@ public interface SplashScreen { * Flag to be used with {@link ActivityOptions#setSplashScreenStyle}, to avoid showing the * splash screen icon of the launched activity */ - int SPLASH_SCREEN_STYLE_EMPTY = 0; + int SPLASH_SCREEN_STYLE_SOLID_COLOR = 0; /** * Flag to be used with {@link ActivityOptions#setSplashScreenStyle}, to show the splash screen * icon of the launched activity. @@ -62,7 +62,7 @@ public interface SplashScreen { /** @hide */ @IntDef(prefix = { "SPLASH_SCREEN_STYLE_" }, value = { SPLASH_SCREEN_STYLE_UNDEFINED, - SPLASH_SCREEN_STYLE_EMPTY, + SPLASH_SCREEN_STYLE_SOLID_COLOR, SPLASH_SCREEN_STYLE_ICON }) @interface SplashScreenStyle {} diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java index 232248b6fab34..10d7ecab4ffa9 100644 --- a/core/java/android/window/SplashScreenView.java +++ b/core/java/android/window/SplashScreenView.java @@ -152,7 +152,7 @@ public final class SplashScreenView extends FrameLayout { private Instant mIconAnimationStart; private Duration mIconAnimationDuration; private Consumer mUiThreadInitTask; - private boolean mAllowHandleEmpty = true; + private boolean mAllowHandleSolidColor = true; public Builder(@NonNull Context context) { mContext = context; @@ -263,8 +263,8 @@ public final class SplashScreenView extends FrameLayout { * Sets whether this view can be copied and transferred to the client if the view is * empty style splash screen. */ - public Builder setAllowHandleEmpty(boolean allowHandleEmpty) { - mAllowHandleEmpty = allowHandleEmpty; + public Builder setAllowHandleSolidColor(boolean allowHandleSolidColor) { + mAllowHandleSolidColor = allowHandleSolidColor; return this; } @@ -314,7 +314,7 @@ public final class SplashScreenView extends FrameLayout { } view.mIconView = imageView; } - if (mOverlayDrawable != null || (view.mIconView == null && !mAllowHandleEmpty)) { + if (mOverlayDrawable != null || (view.mIconView == null && !mAllowHandleSolidColor)) { view.setNotCopyable(); } diff --git a/core/java/android/window/StartingWindowInfo.java b/core/java/android/window/StartingWindowInfo.java index 24899a4bcb9df..5aa4501045b1f 100644 --- a/core/java/android/window/StartingWindowInfo.java +++ b/core/java/android/window/StartingWindowInfo.java @@ -50,10 +50,10 @@ public final class StartingWindowInfo implements Parcelable { */ public static final int STARTING_WINDOW_TYPE_SNAPSHOT = 2; /** - * Prefer empty splash screen starting window. + * Prefer solid color splash screen starting window. * @hide */ - public static final int STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN = 3; + public static final int STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN = 3; /** @hide **/ public static final int STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN = 4; @@ -65,7 +65,7 @@ public final class StartingWindowInfo implements Parcelable { STARTING_WINDOW_TYPE_NONE, STARTING_WINDOW_TYPE_SPLASH_SCREEN, STARTING_WINDOW_TYPE_SNAPSHOT, - STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN, + STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN, STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN }) public @interface StartingWindowType {} @@ -115,8 +115,8 @@ public final class StartingWindowInfo implements Parcelable { TYPE_PARAMETER_PROCESS_RUNNING, TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT, TYPE_PARAMETER_ACTIVITY_CREATED, - TYPE_PARAMETER_USE_EMPTY_SPLASH_SCREEN, - TYPE_PARAMETER_ALLOW_HANDLE_EMPTY_SCREEN, + TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN, + TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN, TYPE_PARAMETER_LEGACY_SPLASH_SCREEN }) public @interface StartingTypeParams {} @@ -135,17 +135,17 @@ public final class StartingWindowInfo implements Parcelable { /** @hide */ public static final int TYPE_PARAMETER_ACTIVITY_CREATED = 0x00000010; /** @hide */ - public static final int TYPE_PARAMETER_USE_EMPTY_SPLASH_SCREEN = 0x00000020; + public static final int TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN = 0x00000020; /** * The parameter which indicates if the activity has finished drawing. * @hide */ public static final int TYPE_PARAMETER_ACTIVITY_DRAWN = 0x00000040; /** - * Application is allowed to handle empty splash screen. + * Application is allowed to handle solid color splash screen. * @hide */ - public static final int TYPE_PARAMETER_ALLOW_HANDLE_EMPTY_SCREEN = 0x00000080; + public static final int TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN = 0x00000080; /** * Application is allowed to use the legacy splash screen * @hide @@ -192,10 +192,10 @@ public final class StartingWindowInfo implements Parcelable { } /** - * Return whether the application allow to handle the empty style splash screen. + * Return whether the application allow to handle the solid color style splash screen. */ - public boolean allowHandleEmptySplashScreen() { - return (startingWindowTypeParameter & TYPE_PARAMETER_ALLOW_HANDLE_EMPTY_SCREEN) != 0; + public boolean allowHandleSolidColorSplashScreen() { + return (startingWindowTypeParameter & TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN) != 0; } @Override diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java index 33aa018923a60..f0fb69f434997 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java @@ -18,8 +18,8 @@ package com.android.wm.shell.startingsurface; import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; -import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN; +import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN; import static com.android.wm.shell.startingsurface.StartingSurfaceDrawer.MAX_ANIMATION_DURATION; @@ -270,7 +270,7 @@ public class SplashscreenContentDrawer { .overlayDrawable(legacyDrawable) .chooseStyle(suggestType) .setUiThreadInitConsumer(uiThreadInitConsumer) - .setAllowHandleEmpty(info.allowHandleEmptySplashScreen()) + .setAllowHandleSolidColor(info.allowHandleSolidColorSplashScreen()) .build(); } @@ -367,7 +367,7 @@ public class SplashscreenContentDrawer { private Drawable[] mFinalIconDrawables; private int mFinalIconSize = mIconSize; private Consumer mUiThreadInitTask; - private boolean mAllowHandleEmpty; + private boolean mAllowHandleSolidColor; StartingWindowViewBuilder(@NonNull Context context, @NonNull ActivityInfo aInfo) { mContext = context; @@ -394,15 +394,15 @@ public class SplashscreenContentDrawer { return this; } - StartingWindowViewBuilder setAllowHandleEmpty(boolean allowHandleEmpty) { - mAllowHandleEmpty = allowHandleEmpty; + StartingWindowViewBuilder setAllowHandleSolidColor(boolean allowHandleSolidColor) { + mAllowHandleSolidColor = allowHandleSolidColor; return this; } SplashScreenView build() { Drawable iconDrawable; final long animationDuration; - if (mSuggestType == STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN + if (mSuggestType == STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN || mSuggestType == STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN) { // empty or legacy splash screen case animationDuration = 0; @@ -538,7 +538,7 @@ public class SplashscreenContentDrawer { .setCenterViewDrawable(foreground) .setAnimationDurationMillis(animationDuration) .setUiThreadInitConsumer(uiThreadInitTask) - .setAllowHandleEmpty(mAllowHandleEmpty); + .setAllowHandleSolidColor(mAllowHandleSolidColor); if (mSuggestType == STARTING_WINDOW_TYPE_SPLASH_SCREEN && mTmpAttrs.mBrandingImage != null) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java index 487eb7055e40a..fbc992378e504 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java @@ -16,10 +16,10 @@ package com.android.wm.shell.startingsurface; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; -import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_EMPTY_SPLASH_SCREEN; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_NONE; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SNAPSHOT; +import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN; import static android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN; import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission; @@ -155,7 +155,7 @@ public class StartingWindowController implements RemoteCallable