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

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

Rename shouldUseSolidColor to allowIcon

This CL changes the name shouldUseSolidColor to allowIcon. This inverts
the meaning of the method/variable/type in ActivityRecord and WmShell,
which makes it easier to read and understand what this method does and
what the variable/type means.

Previously, the message of the shouldUseSolidColor was a "recommendation"
from WmCore to WmShell to use a solid color splash screen. This CL
transforms it into a policy for when an icon should not be used based
on the preferences provided via the public APIs.

There are no behavioural changes, only a name change.

Bug: 296354973
Test: flash && check a few splash screen interactions
Change-Id: I7a0abd040d4a551c5e4580b76a724935ee63ef1f
parent 64554062
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public final class StartingWindowInfo implements Parcelable {
            TYPE_PARAMETER_PROCESS_RUNNING,
            TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT,
            TYPE_PARAMETER_ACTIVITY_CREATED,
            TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN,
            TYPE_PARAMETER_ALLOW_ICON,
            TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN,
            TYPE_PARAMETER_WINDOWLESS,
            TYPE_PARAMETER_LEGACY_SPLASH_SCREEN
@@ -143,7 +143,7 @@ public final class StartingWindowInfo implements Parcelable {
    /** @hide */
    public static final int TYPE_PARAMETER_ACTIVITY_CREATED = 0x00000010;
    /** @hide */
    public static final int TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN = 0x00000020;
    public static final int TYPE_PARAMETER_ALLOW_ICON = 0x00000020;
    /**
     * The parameter which indicates if the activity has finished drawing.
     * @hide
+12 −13
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import static android.window.StartingWindowInfo.TYPE_PARAMETER_LEGACY_SPLASH_SCR
import static android.window.StartingWindowInfo.TYPE_PARAMETER_NEW_TASK;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_PROCESS_RUNNING;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_ICON;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_WINDOWLESS;

import android.window.StartingWindowInfo;
@@ -52,8 +52,7 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor
        final boolean processRunning = (parameter & TYPE_PARAMETER_PROCESS_RUNNING) != 0;
        final boolean allowTaskSnapshot = (parameter & TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT) != 0;
        final boolean activityCreated = (parameter & TYPE_PARAMETER_ACTIVITY_CREATED) != 0;
        final boolean isSolidColorSplashScreen =
                (parameter & TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN) != 0;
        final boolean allowIcon = (parameter & TYPE_PARAMETER_ALLOW_ICON) != 0;
        final boolean legacySplashScreen =
                ((parameter & TYPE_PARAMETER_LEGACY_SPLASH_SCREEN) != 0);
        final boolean activityDrawn = (parameter & TYPE_PARAMETER_ACTIVITY_DRAWN) != 0;
@@ -67,13 +66,13 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor
                        + "processRunning=%b, "
                        + "allowTaskSnapshot=%b, "
                        + "activityCreated=%b, "
                        + "isSolidColorSplashScreen=%b, "
                        + "allowIcon=%b, "
                        + "legacySplashScreen=%b, "
                        + "activityDrawn=%b, "
                        + "windowless=%b, "
                        + "topIsHome=%b",
                newTask, taskSwitch, processRunning, allowTaskSnapshot, activityCreated,
                isSolidColorSplashScreen, legacySplashScreen, activityDrawn, windowlessSurface,
                allowIcon, legacySplashScreen, activityDrawn, windowlessSurface,
                topIsHome);

        if (windowlessSurface) {
@@ -81,7 +80,7 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor
        }
        if (!topIsHome) {
            if (!processRunning || newTask || (taskSwitch && !activityCreated)) {
                return getSplashscreenType(isSolidColorSplashScreen, legacySplashScreen);
                return getSplashscreenType(allowIcon, legacySplashScreen);
            }
        }

@@ -95,18 +94,18 @@ public class PhoneStartingWindowTypeAlgorithm implements StartingWindowTypeAlgor
                }
            }
            if (!activityDrawn && !topIsHome) {
                return getSplashscreenType(isSolidColorSplashScreen, legacySplashScreen);
                return getSplashscreenType(allowIcon, legacySplashScreen);
            }
        }
        return STARTING_WINDOW_TYPE_NONE;
    }

    private static int getSplashscreenType(boolean solidColorSplashScreen,
            boolean legacySplashScreen) {
        return solidColorSplashScreen
                ? STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN
                : legacySplashScreen
                        ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
    private static int getSplashscreenType(boolean allowIcon, boolean legacySplashScreen) {
        if (allowIcon) {
            return legacySplashScreen ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
                        : STARTING_WINDOW_TYPE_SPLASH_SCREEN;
        } else {
            return STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN;
        }
    }
}
+38 −25
Original line number Diff line number Diff line
@@ -580,7 +580,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    IBinder mRequestedLaunchingTaskFragmentToken;

    // Tracking splash screen status from previous activity
    boolean mSplashScreenStyleSolidColor = false;
    boolean mAllowIconSplashScreen = true;

    boolean mPauseSchedulePendingForPip = false;

@@ -2398,8 +2398,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    @VisibleForTesting
    boolean addStartingWindow(String pkg, int resolvedTheme, ActivityRecord from, boolean newTask,
            boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot,
            boolean activityCreated, boolean isSimple,
            boolean activityAllDrawn) {
            boolean activityCreated, boolean allowIcon, boolean activityAllDrawn) {
        // If the display is frozen, we won't do anything until the actual window is
        // displayed so there is no reason to put in the starting window.
        if (!okToDisplay()) {
@@ -2434,8 +2433,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        final int typeParameter = StartingSurfaceController
                .makeStartingWindowTypeParameter(newTask, taskSwitch, processRunning,
                        allowTaskSnapshot, activityCreated, isSimple, useLegacy, activityAllDrawn,
                        type, packageName, mUserId);
                        allowTaskSnapshot, activityCreated, allowIcon, useLegacy,
                        activityAllDrawn, type, packageName, mUserId);

        if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
            if (isActivityTypeHome()) {
@@ -6737,7 +6736,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    void onFirstWindowDrawn(WindowState win) {
        firstWindowDrawn = true;
        // stop tracking
        mSplashScreenStyleSolidColor = true;
        mAllowIconSplashScreen = false;

        if (mStartingWindow != null) {
            ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Finish starting %s"
@@ -6786,7 +6785,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    void onStartingWindowDrawn() {
        boolean wasTaskVisible = false;
        if (task != null) {
            mSplashScreenStyleSolidColor = true;
            mAllowIconSplashScreen = false;
            wasTaskVisible = !setTaskHasBeenVisible();
        }

@@ -7311,19 +7310,32 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    /**
     * @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.
     * Checks whether an icon splash screen can be used in the starting window based on the
     * preference in the {@code options} and this activity's theme, giving higher priority to the
     * {@code options}'s preference.
     *
     * When no preference is specified, a default behaviour is defined:
     *  - if the activity is started from the home or shell app, an icon can be used
     *  - if the activity is started from SystemUI, an icon should not be used
     *  - if there is a launching activity, use its preference
     *  - if none of the above is met, only use an icon when the activity is started for the first
     *    time from a System app
     *
     * The returned value is sent to WmShell, which will make the final decision on what splash
     * screen type will be used.
     *
     * @return true if an icon can be used in the splash screen
     *         false when an icon should not be used in the splash screen
     */
    private boolean shouldUseSolidColorSplashScreen(ActivityRecord sourceRecord,
    private boolean canUseIconSplashScreen(ActivityRecord sourceRecord,
            boolean startActivity, ActivityOptions options, int resolvedTheme) {
        if (sourceRecord == null && !startActivity) {
            // Use simple style if this activity is not top activity. This could happen when adding
            // a splash screen window to the warm start activity which is re-create because top is
            // finishing.
            // Shouldn't use an icon if this activity is not top activity. This could happen when
            // adding a splash screen window to the warm start activity which is re-create because
            // top is finishing.
            final ActivityRecord above = task.getActivityAbove(this);
            if (above != null) {
                return true;
                return false;
            }
        }

@@ -7331,32 +7343,33 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final int optionsStyle = options != null ? options.getSplashScreenStyle() :
                SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED;
        if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR) {
            return true;
            return false;
        } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON
                    || isIconStylePreferred(resolvedTheme)) {
            return false;
            return true;
        }

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

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

            // 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;
            // Otherwise, can't use an icon splash screen.
            return mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEM && startActivity;
        }
    }

@@ -7420,7 +7433,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final int resolvedTheme = evaluateStartingWindowTheme(prev, packageName, theme,
                splashScreenTheme);

        mSplashScreenStyleSolidColor = shouldUseSolidColorSplashScreen(sourceRecord, startActivity,
        mAllowIconSplashScreen = canUseIconSplashScreen(sourceRecord, startActivity,
                startOptions, resolvedTheme);

        final boolean activityCreated =
@@ -7432,7 +7445,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        final boolean scheduled = addStartingWindow(packageName, resolvedTheme,
                prev, newTask || newSingleActivity, taskSwitch, processRunning,
                allowTaskSnapshot(), activityCreated, mSplashScreenStyleSolidColor, allDrawn);
                allowTaskSnapshot(), activityCreated, mAllowIconSplashScreen, allDrawn);
        if (DEBUG_STARTING_WINDOW_VERBOSE && scheduled) {
            Slog.d(TAG, "Scheduled starting window for " + this);
        }
+4 −4
Original line number Diff line number Diff line
@@ -19,12 +19,12 @@ package com.android.server.wm;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_CREATED;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ACTIVITY_DRAWN;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_ICON;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_ALLOW_TASK_SNAPSHOT;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_LEGACY_SPLASH_SCREEN;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_NEW_TASK;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_PROCESS_RUNNING;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_TASK_SWITCH;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;

import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SNAPSHOT;
import static com.android.server.wm.ActivityRecord.STARTING_WINDOW_TYPE_SPLASH_SCREEN;
@@ -102,7 +102,7 @@ public class StartingSurfaceController {

    static int makeStartingWindowTypeParameter(boolean newTask, boolean taskSwitch,
            boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated,
            boolean isSolidColor, boolean useLegacy, boolean activityDrawn, int startingWindowType,
            boolean allowIcon, boolean useLegacy, boolean activityDrawn, int startingWindowType,
            String packageName, int userId) {
        int parameter = 0;
        if (newTask) {
@@ -120,8 +120,8 @@ public class StartingSurfaceController {
        if (activityCreated || startingWindowType == STARTING_WINDOW_TYPE_SNAPSHOT) {
            parameter |= TYPE_PARAMETER_ACTIVITY_CREATED;
        }
        if (isSolidColor) {
            parameter |= TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;
        if (allowIcon) {
            parameter |= TYPE_PARAMETER_ALLOW_ICON;
        }
        if (useLegacy) {
            parameter |= TYPE_PARAMETER_LEGACY_SPLASH_SCREEN;
+2 −2
Original line number Diff line number Diff line
@@ -2871,14 +2871,14 @@ public class ActivityRecordTests extends WindowTestsBase {
                .setTask(sourceRecord.getTask()).build();
        secondRecord.showStartingWindow(null /* prev */, true /* newTask */, false,
                true /* startActivity */, sourceRecord);
        assertFalse(secondRecord.mSplashScreenStyleSolidColor);
        assertTrue(secondRecord.mAllowIconSplashScreen);
        secondRecord.onStartingWindowDrawn();

        final ActivityRecord finalRecord = new ActivityBuilder(mAtm)
                .setTask(sourceRecord.getTask()).build();
        finalRecord.showStartingWindow(null /* prev */, true /* newTask */, false,
                true /* startActivity */, secondRecord);
        assertTrue(finalRecord.mSplashScreenStyleSolidColor);
        assertFalse(finalRecord.mAllowIconSplashScreen);
    }

    @Test