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

Commit 70aa4d18 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Also add starting window when activity is not alive

The fact whether the process is running or not is not necessarily
a reason to not show a starting window. Sometimes the process with
an activity gets killed, but later gets restarted because of some
broadcast or service without recreating the activity. In this
case, we still need a splash screen to hide the recreation delay,
which is usually as expensive as if the process is not running.

Test: Open Calendar, kill `pid calendar`, reopen it, make sure
starting window is shown.
Test: As above but with a couple of other apps - with and widhout
trampoline activities.
Test: Boot freshly and open a couple of apps from recents

Change-Id: I8c4f928fca77b5446cab55c89bc69adbaaaa8da3
Fixes: 37951698
parent 5afccc62
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2165,7 +2165,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
        final boolean shown = mWindowContainerController.addStartingWindow(packageName, theme,
                compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
                prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
                allowTaskSnapshot());
                allowTaskSnapshot(),
                state.ordinal() >= RESUMED.ordinal() && state.ordinal() <= STOPPED.ordinal());
        if (shown) {
            mStartingWindowState = STARTING_WINDOW_SHOWN;
        }
+5 −4
Original line number Diff line number Diff line
@@ -447,7 +447,7 @@ public class AppWindowContainerController
    public boolean addStartingWindow(String pkg, int theme, CompatibilityInfo compatInfo,
            CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags,
            IBinder transferFrom, boolean newTask, boolean taskSwitch, boolean processRunning,
            boolean allowTaskSnapshot) {
            boolean allowTaskSnapshot, boolean activityCreated) {
        synchronized(mWindowMap) {
            if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "setAppStartingWindow: token=" + mToken
                    + " pkg=" + pkg + " transferFrom=" + transferFrom);
@@ -475,7 +475,7 @@ public class AppWindowContainerController
            }

            final int type = getStartingWindowType(newTask, taskSwitch, processRunning,
                    allowTaskSnapshot);
                    allowTaskSnapshot, activityCreated);

            if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
                return createSnapshot();
@@ -546,8 +546,9 @@ public class AppWindowContainerController
    }

    private int getStartingWindowType(boolean newTask, boolean taskSwitch, boolean processRunning,
            boolean allowTaskSnapshot) {
        if (newTask || !processRunning) {
            boolean allowTaskSnapshot, boolean activityCreated) {
        if (newTask || !processRunning
                || (taskSwitch && !activityCreated)) {
            return STARTING_WINDOW_TYPE_SPLASH_SCREEN;
        } else if (taskSwitch && allowTaskSnapshot) {
            return STARTING_WINDOW_TYPE_SNAPSHOT;
+8 −5
Original line number Diff line number Diff line
@@ -97,7 +97,8 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
        final WindowTestUtils.TestAppWindowContainerController controller =
                createAppWindowController();
        controller.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
                false);
        waitUntilHandlersIdle();
        final AppWindowToken atoken = controller.getAppWindowToken(mDisplayContent);
        assertHasStartingWindow(atoken);
@@ -113,11 +114,12 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
        final WindowTestUtils.TestAppWindowContainerController controller2 =
                createAppWindowController();
        controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
                false);
        waitUntilHandlersIdle();
        controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(),
                true, true, false, true);
                true, true, false, true, false);
        waitUntilHandlersIdle();
        assertNoStartingWindow(controller1.getAppWindowToken(mDisplayContent));
        assertHasStartingWindow(controller2.getAppWindowToken(mDisplayContent));
@@ -134,10 +136,11 @@ public class AppWindowContainerControllerTests extends WindowTestsBase {
            // Surprise, ...! Transfer window in the middle of the creation flow.
            controller2.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
                    android.R.style.Theme, null, "Test", 0, 0, 0, 0, controller1.mToken.asBinder(),
                    true, true, false, true);
                    true, true, false, true, false);
        });
        controller1.addStartingWindow(InstrumentationRegistry.getContext().getPackageName(),
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true);
                android.R.style.Theme, null, "Test", 0, 0, 0, 0, null, true, true, false, true,
                false);
        waitUntilHandlersIdle();
        assertNoStartingWindow(controller1.getAppWindowToken(mDisplayContent));
        assertHasStartingWindow(controller2.getAppWindowToken(mDisplayContent));