From 3fb34bfe772907c9d21454248e1297db876ae7ae Mon Sep 17 00:00:00 2001 From: Vadim Caen Date: Wed, 6 Apr 2022 16:38:36 +0200 Subject: [PATCH] Fix splashscreen listener not being called Bug: 228313271 Test: AndroidX SplashscreenParametrizedTest Change-Id: Ia68016ddc73e4d1f5d18f076d4474e0e3086c138 --- core/java/android/window/SplashScreenView.java | 6 ++++-- core/java/android/window/StartingWindowInfo.java | 6 +++++- .../shell/startingsurface/SplashscreenContentDrawer.java | 7 +++++++ .../com/android/server/wm/StartingSurfaceController.java | 7 +++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java index a791cfab84e22..2d1deb2a57bb7 100644 --- a/core/java/android/window/SplashScreenView.java +++ b/core/java/android/window/SplashScreenView.java @@ -237,7 +237,6 @@ public final class SplashScreenView extends FrameLayout { /** * Set the Runnable that can receive the task which should be executed on UI thread. - * @param uiThreadInitTask */ public Builder setUiThreadInitConsumer(Consumer uiThreadInitTask) { mUiThreadInitTask = uiThreadInitTask; @@ -281,9 +280,11 @@ public final class SplashScreenView extends FrameLayout { view.mBrandingImageView = view.findViewById(R.id.splashscreen_branding_view); + boolean hasIcon = false; // center icon if (mIconDrawable instanceof SplashScreenView.IconAnimateListener || mSurfacePackage != null) { + hasIcon = true; if (mUiThreadInitTask != null) { mUiThreadInitTask.accept(() -> view.mIconView = createSurfaceView(view)); } else { @@ -306,9 +307,10 @@ public final class SplashScreenView extends FrameLayout { if (mIconBackground != null) { imageView.setBackground(mIconBackground); } + hasIcon = true; view.mIconView = imageView; } - if (mOverlayDrawable != null || (view.mIconView == null && !mAllowHandleSolidColor)) { + if (mOverlayDrawable != null || (!hasIcon && !mAllowHandleSolidColor)) { view.setNotCopyable(); } diff --git a/core/java/android/window/StartingWindowInfo.java b/core/java/android/window/StartingWindowInfo.java index 5aa4501045b1f..d161037679874 100644 --- a/core/java/android/window/StartingWindowInfo.java +++ b/core/java/android/window/StartingWindowInfo.java @@ -142,7 +142,11 @@ public final class StartingWindowInfo implements Parcelable { */ public static final int TYPE_PARAMETER_ACTIVITY_DRAWN = 0x00000040; /** - * Application is allowed to handle solid color splash screen. + * Application will receive the + * {@link + * android.window.SplashScreen.OnExitAnimationListener#onSplashScreenExit(SplashScreenView)} + * callback, even when the splash screen only shows a solid color. + * * @hide */ public static final int TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN = 0x00000080; 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 b6c8cffb9699a..75a999bcb292b 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 @@ -363,6 +363,7 @@ public class SplashscreenContentDrawer { private Drawable[] mFinalIconDrawables; private int mFinalIconSize = mIconSize; private Consumer mUiThreadInitTask; + /** @see #setAllowHandleSolidColor(boolean) **/ private boolean mAllowHandleSolidColor; StartingWindowViewBuilder(@NonNull Context context, @NonNull ActivityInfo aInfo) { @@ -390,6 +391,12 @@ public class SplashscreenContentDrawer { return this; } + /** + * If true, the application will receive a the + * {@link + * android.window.SplashScreen.OnExitAnimationListener#onSplashScreenExit(SplashScreenView)} + * callback, effectively copying the {@link SplashScreenView} into the client process. + */ StartingWindowViewBuilder setAllowHandleSolidColor(boolean allowHandleSolidColor) { mAllowHandleSolidColor = allowHandleSolidColor; return this; diff --git a/services/core/java/com/android/server/wm/StartingSurfaceController.java b/services/core/java/com/android/server/wm/StartingSurfaceController.java index 4ab9d2fd34765..813e06fecf486 100644 --- a/services/core/java/com/android/server/wm/StartingSurfaceController.java +++ b/services/core/java/com/android/server/wm/StartingSurfaceController.java @@ -39,6 +39,7 @@ import android.compat.annotation.EnabledSince; import android.content.pm.ApplicationInfo; import android.os.UserHandle; import android.util.Slog; +import android.window.SplashScreenView; import android.window.TaskSnapshot; import java.util.ArrayList; @@ -51,8 +52,10 @@ public class StartingSurfaceController { private static final String TAG = TAG_WITH_CLASS_NAME ? StartingSurfaceController.class.getSimpleName() : TAG_WM; /** - * Allow the solid color style splash screen view can be copy and transfer to another process if - * the app targeting to {@link android.os.Build.VERSION_CODES#TIRAMISU} or higher. + * Application is allowed to receive the + * {@link + * android.window.SplashScreen.OnExitAnimationListener#onSplashScreenExit(SplashScreenView)} + * callback, even when the splash screen only shows a solid color. */ @ChangeId @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.TIRAMISU)