Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66a7a866 authored by Galia Peycheva's avatar Galia Peycheva Committed by Android (Google) Code Review
Browse files

Merge "Add config to disable using the appIcon for splash screens" into main

parents b0e4b1fd 27ed4b69
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -164,6 +164,13 @@ public final class StartingWindowInfo implements Parcelable {
     */
    public static final int TYPE_PARAMETER_WINDOWLESS = 0x00000100;

    /**
     * Application has set Window_windowSplashScreenBehavior to
     * SPLASH_SCREEN_BEHAVIOR_ICON_PREFERRED.
     * @hide
     */
    public static final int TYPE_PARAMETER_APP_PREFERS_ICON = 0x00000200;

    /**
     * Application is allowed to use the legacy splash screen
     * @hide
+5 −0
Original line number Diff line number Diff line
@@ -57,4 +57,9 @@
          - 0 for radial vanish + slide up
          - 1 for fade out -->
    <integer name="starting_window_exit_animation_type">1</integer>

    <!-- Whether this device allows to use the appIcon as a fallback icon for the splash screen
        window. If false, the splash screen will be a solid color splash screen whenever the
        app has not provided a windowSplashScreenAnimatedIcon. -->
    <bool name="config_canUseAppIconForSplashScreen">false</bool>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -136,4 +136,9 @@

    <!-- Whether DragAndDrop capability is enabled -->
    <bool name="config_enableShellDragDrop">true</bool>

    <!-- Whether this device allows to use the appIcon as a fallback icon for the splash screen
        window. If false, the splash screen will be a solid color splash screen whenever the
        app has not provided a windowSplashScreenAnimatedIcon. -->
    <bool name="config_canUseAppIconForSplashScreen">true</bool>
</resources>
+14 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
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 android.window.StartingWindowInfo.TYPE_PARAMETER_APP_PREFERS_ICON;

import android.annotation.ColorInt;
import android.annotation.IntDef;
@@ -125,6 +126,7 @@ public class SplashscreenContentDrawer {
    private final TransactionPool mTransactionPool;
    private final SplashScreenWindowAttrs mTmpAttrs = new SplashScreenWindowAttrs();
    private final Handler mSplashscreenWorkerHandler;
    private final boolean mCanUseAppIconForSplashScreen;
    @VisibleForTesting
    final ColorCache mColorCache;

@@ -141,6 +143,8 @@ public class SplashscreenContentDrawer {
        shellSplashscreenWorkerThread.start();
        mSplashscreenWorkerHandler = shellSplashscreenWorkerThread.getThreadHandler();
        mColorCache = new ColorCache(mContext, mSplashscreenWorkerHandler);
        mCanUseAppIconForSplashScreen = context.getResources().getBoolean(
                com.android.wm.shell.R.bool.config_canUseAppIconForSplashScreen);
    }

    /**
@@ -427,7 +431,10 @@ public class SplashscreenContentDrawer {
        getWindowAttrs(context, mTmpAttrs);
        mLastPackageContextConfigHash = context.getResources().getConfiguration().hashCode();

        final Drawable legacyDrawable = suggestType == STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
        final @StartingWindowType int splashType =
                suggestType == STARTING_WINDOW_TYPE_SPLASH_SCREEN && !canUseIcon(info)
                ? STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN : suggestType;
        final Drawable legacyDrawable = splashType == STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
                ? peekLegacySplashscreenContent(context, mTmpAttrs) : null;
        final ActivityInfo ai = info.targetActivityInfo != null
                ? info.targetActivityInfo
@@ -439,12 +446,17 @@ public class SplashscreenContentDrawer {
        return new SplashViewBuilder(context, ai)
                .setWindowBGColor(themeBGColor)
                .overlayDrawable(legacyDrawable)
                .chooseStyle(suggestType)
                .chooseStyle(splashType)
                .setUiThreadInitConsumer(uiThreadInitConsumer)
                .setAllowHandleSolidColor(info.allowHandleSolidColorSplashScreen())
                .build();
    }

    private boolean canUseIcon(StartingWindowInfo info) {
        return mCanUseAppIconForSplashScreen || mTmpAttrs.mSplashScreenIcon != null
             || (info.startingWindowTypeParameter & TYPE_PARAMETER_APP_PREFERS_ICON) != 0;
    }

    private int getBGColorFromCache(ActivityInfo ai, IntSupplier windowBgColorSupplier) {
        return mColorCache.getWindowColor(ai.packageName, mLastPackageContextConfigHash,
                mTmpAttrs.mWindowBgColor, mTmpAttrs.mWindowBgResId, windowBgColorSupplier).mBgColor;
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class StartingWindowControllerTests extends ShellTestCase {
        MockitoAnnotations.initMocks(this);
        doReturn(mock(Display.class)).when(mDisplayManager).getDisplay(anyInt());
        doReturn(mDisplayManager).when(mContext).getSystemService(eq(DisplayManager.class));
        doReturn(super.mContext.getResources()).when(mContext).getResources();
        mShellInit = spy(new ShellInit(mMainExecutor));
        mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler,
                mMainExecutor));
Loading