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

Commit 661f6b9c authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Revert "Rename shouldUseSolidColor to allowIcon"" into main

parents b8653e30 1752cd5e
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_ALLOW_ICON,
            TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN,
            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_ALLOW_ICON = 0x00000020;
    public static final int TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN = 0x00000020;
    /**
     * The parameter which indicates if the activity has finished drawing.
     * @hide
+13 −12
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_ALLOW_ICON;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;
import static android.window.StartingWindowInfo.TYPE_PARAMETER_WINDOWLESS;

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

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

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

    private static int getSplashscreenType(boolean allowIcon, boolean legacySplashScreen) {
        if (allowIcon) {
            return legacySplashScreen ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
    private static int getSplashscreenType(boolean solidColorSplashScreen,
            boolean legacySplashScreen) {
        return solidColorSplashScreen
                ? STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN
                : legacySplashScreen
                        ? STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
                        : STARTING_WINDOW_TYPE_SPLASH_SCREEN;
        } else {
            return STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN;
        }
    }
}
+25 −38
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 mAllowIconSplashScreen = true;
    boolean mSplashScreenStyleSolidColor = false;

    boolean mPauseSchedulePendingForPip = false;

@@ -2408,7 +2408,8 @@ 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 allowIcon, boolean activityAllDrawn) {
            boolean activityCreated, boolean isSimple,
            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()) {
@@ -2443,8 +2444,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

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

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

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

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

    /**
     * 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
     * @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 canUseIconSplashScreen(ActivityRecord sourceRecord,
    private boolean shouldUseSolidColorSplashScreen(ActivityRecord sourceRecord,
            boolean startActivity, ActivityOptions options, int resolvedTheme) {
        if (sourceRecord == null && !startActivity) {
            // 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.
            // 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.
            final ActivityRecord above = task.getActivityAbove(this);
            if (above != null) {
                return false;
                return true;
            }
        }

@@ -7353,33 +7341,32 @@ 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 false;
            return true;
        } else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON
                    || isIconStylePreferred(resolvedTheme)) {
            return true;
            return false;
        }

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

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

            // Use an icon if the activity was launched from System for the first start.
            // Otherwise, can't use an icon splash screen.
            return mLaunchSourceType == LAUNCH_SOURCE_TYPE_SYSTEM && startActivity;
            // Otherwise, must use solid color splash screen.
            return mLaunchSourceType != LAUNCH_SOURCE_TYPE_SYSTEM || !startActivity;
        }
    }

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

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

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

        final boolean scheduled = addStartingWindow(packageName, resolvedTheme,
                prev, newTask || newSingleActivity, taskSwitch, processRunning,
                allowTaskSnapshot(), activityCreated, mAllowIconSplashScreen, allDrawn);
                allowTaskSnapshot(), activityCreated, mSplashScreenStyleSolidColor, 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 allowIcon, boolean useLegacy, boolean activityDrawn, int startingWindowType,
            boolean isSolidColor, 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 (allowIcon) {
            parameter |= TYPE_PARAMETER_ALLOW_ICON;
        if (isSolidColor) {
            parameter |= TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN;
        }
        if (useLegacy) {
            parameter |= TYPE_PARAMETER_LEGACY_SPLASH_SCREEN;
+2 −2
Original line number Diff line number Diff line
@@ -2855,14 +2855,14 @@ public class ActivityRecordTests extends WindowTestsBase {
                .setTask(sourceRecord.getTask()).build();
        secondRecord.showStartingWindow(null /* prev */, true /* newTask */, false,
                true /* startActivity */, sourceRecord);
        assertTrue(secondRecord.mAllowIconSplashScreen);
        assertFalse(secondRecord.mSplashScreenStyleSolidColor);
        secondRecord.onStartingWindowDrawn();

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

    @Test