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

Commit 64554062 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Unify the default behaviour path for solid color ss

ActivityRecord#shouldUseSolidColorSplashScreen is used to force a
solid color splash screen when necessary, taking into account the style
set in the ActivityOptions and the preference set by the activity theme.
When there is no style set in the ActivityOptions and the app has not
specifed a preference, the method provides a default behavior.

Currently this default behaviour is different depending on whether
the ActivityOptions object is null. This shouldn't be the case - the
default behaviour should be the same when the object is null and when the
splash screen style in the ActivityOptions is UNDEFINED.

This CL unifies the default path for when the SplashScreen style is not
specified in the ActivityOptions and the activity doesn't have a
preference for showing an icon.

Bug: 296354973
Test: m
Change-Id: Ia27afaf91fc526b4b34efb40b5a43b0f3796c8c6
parent 1f81948b
Loading
Loading
Loading
Loading
+31 −28
Original line number Diff line number Diff line
@@ -7309,6 +7309,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        return false;
    }

    /**
     * @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.
     */
    private boolean shouldUseSolidColorSplashScreen(ActivityRecord sourceRecord,
            boolean startActivity, ActivityOptions options, int resolvedTheme) {
        if (sourceRecord == null && !startActivity) {
@@ -7322,39 +7328,36 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }

        // setSplashScreenStyle decide in priority of windowSplashScreenBehavior.
        if (options != null) {
            final int optionsStyle = options.getSplashScreenStyle();
        final int optionsStyle = options != null ? options.getSplashScreenStyle() :
                SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED;
        if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR) {
            return true;
        } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON
                    || isIconStylePreferred(resolvedTheme)) {
            return false;
        }
            // Choose the default behavior for Launcher and SystemUI when the SplashScreen style is
            // not specified in the ActivityOptions.
            if (mLaunchSourceType == LAUNCH_SOURCE_TYPE_HOME
                    || launchedFromUid == Process.SHELL_UID) {

        // 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 (isIconStylePreferred(resolvedTheme)) {
            return false;
        }
        } else {
            // Need to check sourceRecord in case this activity is launched from a service.
            if (sourceRecord == null) {
                sourceRecord = searchCandidateLaunchingActivity();
            }

        if (sourceRecord != null && !sourceRecord.isActivityTypeHome()) {
            if (sourceRecord != null) {
                return sourceRecord.mSplashScreenStyleSolidColor;
            }

        // If this activity was launched from Launcher or System for first start, never use a
        // solid color splash screen.
        // Need to check sourceRecord before in case this activity is launched from service.
        return !startActivity || !(mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEM
                || mLaunchSourceType == LAUNCH_SOURCE_TYPE_HOME
                || launchedFromUid == Process.SHELL_UID);
            // 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;
        }
    }

    private int getSplashscreenTheme(ActivityOptions options) {