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

Commit da5a3ac0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Resuming the restarting activities only if they were on stack top"

parents 09ff08d0 cfe46219
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2918,7 +2918,7 @@ final class ActivityRecord extends ConfigurationContainer {
        return false;
    }

    boolean handleAlreadyVisible() {
    void handleAlreadyVisible() {
        stopFreezingScreenLocked(false);
        try {
            if (returningOptions != null) {
@@ -2926,7 +2926,6 @@ final class ActivityRecord extends ConfigurationContainer {
            }
        } catch(RemoteException e) {
        }
        return mState == RESUMED;
    }

    static void activityResumedLocked(IBinder token) {
+4 −14
Original line number Diff line number Diff line
@@ -2088,7 +2088,7 @@ class ActivityStack extends ConfigurationContainer {
            boolean aboveTop = top != null;
            final boolean stackShouldBeVisible = shouldBeVisible(starting);
            boolean behindFullscreenActivity = !stackShouldBeVisible;
            boolean resumeNextActivity = isFocusable() && isInStackLocked(starting) == null;
            final boolean resumeTopActivity = isFocusable() && isInStackLocked(starting) == null;
            for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
                final TaskRecord task = mTaskHistory.get(taskNdx);
                final ArrayList<ActivityRecord> activities = task.mActivities;
@@ -2122,15 +2122,8 @@ class ActivityStack extends ConfigurationContainer {
                        }

                        if (!r.attachedToProcess()) {
                            if (makeVisibleAndRestartIfNeeded(starting, configChanges, isTop,
                                    resumeNextActivity, r)) {
                                if (activityNdx >= activities.size()) {
                                    // Record may be removed if its process needs to restart.
                                    activityNdx = activities.size() - 1;
                                } else {
                                    resumeNextActivity = false;
                                }
                            }
                            makeVisibleAndRestartIfNeeded(starting, configChanges, isTop,
                                    resumeTopActivity && isTop, r);
                        } else if (r.visible) {
                            // If this activity is already visible, then there is nothing to do here.
                            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY,
@@ -2140,10 +2133,7 @@ class ActivityStack extends ConfigurationContainer {
                                r.makeClientVisible();
                            }

                            if (r.handleAlreadyVisible()) {
                                resumeNextActivity = false;
                            }

                            r.handleAlreadyVisible();
                            if (notifyClients) {
                                r.makeActiveIfNeeded(starting);
                            }
+17 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMAR
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
@@ -1122,6 +1123,22 @@ public class ActivityStackTests extends ActivityTestsBase {
        assertThat(result).isEqualTo(taskTop);
    }

    @Test
    public void testNonTopVisibleActivityNotResume() {
        final ActivityRecord nonTopVisibleActivity =
                new ActivityBuilder(mService).setTask(mTask).build();
        new ActivityBuilder(mService).setTask(mTask).build();
        doReturn(false).when(nonTopVisibleActivity).attachedToProcess();
        doReturn(true).when(nonTopVisibleActivity).shouldBeVisibleIgnoringKeyguard(anyBoolean());
        doNothing().when(mSupervisor).startSpecificActivityLocked(any(), anyBoolean(),
                anyBoolean());

        mStack.ensureActivitiesVisibleLocked(null /* starting */, 0 /* configChanges */,
                false /* preserveWindows */);
        verify(mSupervisor).startSpecificActivityLocked(any(), eq(false) /* andResume */,
                anyBoolean());
    }

    private void verifyShouldSleepActivities(boolean focusedStack,
            boolean keyguardGoingAway, boolean displaySleeping, boolean expected) {
        final ActivityDisplay display = mock(ActivityDisplay.class);