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

Commit ed9c44a2 authored by wilsonshih's avatar wilsonshih
Browse files

Create splash screen if activity launched with FLAG_ACTIVITY_CLEAR_TASK

When an activity launched with NEW_TASK and CLEAR_TASK, there will
finish the original activities and reuse the same task to create a new
activity, so there will need to wait for the new window drawn to
trigger wm transition, which slow down the launch response. And because
this condition should be a kind of warm launch, there should create a
splash screen for it.

Bug: 187808226
Test: atest ActivityRecordTests SplashscreenTests
Test: manual verify by winscope
Change-Id: I263edcd75fcd21999b9ceb9fac8bfcf8419539a3
parent 5c86c0c1
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -6254,12 +6254,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final int resolvedTheme = evaluateStartingWindowTheme(packageName, theme,
                splashScreenTheme);

        final boolean activityCreated =
                mState.ordinal() >= STARTED.ordinal() && mState.ordinal() <= STOPPED.ordinal();
        // If this activity is just created and all activities below are finish, treat this
        // scenario as warm launch.
        final boolean newSingleActivity = !newTask && !activityCreated
                && task.getActivity((r) -> !r.finishing && r != this) == null;

        final boolean shown = addStartingWindow(packageName, resolvedTheme,
                compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
                prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
                allowTaskSnapshot(),
                mState.ordinal() >= STARTED.ordinal() && mState.ordinal() <= STOPPED.ordinal(),
                mSplashScreenStyleEmpty);
                prev != null ? prev.appToken : null,
                newTask || newSingleActivity, taskSwitch, isProcessRunning(),
                allowTaskSnapshot(), activityCreated, mSplashScreenStyleEmpty);
        if (shown) {
            mStartingWindowState = STARTING_WINDOW_SHOWN;
        }