Merge "Fix splashscreen listener not being called" into tm-dev

This commit is contained in:
Vadim Caen
2022-04-11 09:58:15 +00:00
committed by Android (Google) Code Review
4 changed files with 21 additions and 5 deletions

View File

@@ -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<Runnable> 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();
}

View File

@@ -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;

View File

@@ -363,6 +363,7 @@ public class SplashscreenContentDrawer {
private Drawable[] mFinalIconDrawables;
private int mFinalIconSize = mIconSize;
private Consumer<Runnable> 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;

View File

@@ -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)