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

Commit b1daa5e2 authored by Louis Chang's avatar Louis Chang
Browse files

Updates visibility before trying to notify task stack changes

The previous activity would be immediately paused while starting
a resume-while-pausing activity, but we did not notify the
task stack changes to the listeners because the activity visibilities
weren't updated yet.

Bug: 154447447
Test: atest TaskStackChangedListenerTest

Change-Id: Id5da1c8f0fdf755341381bf49d8f48f396eebb55
parent 950aca57
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1334,6 +1334,8 @@ class ActivityStack extends Task {
            prev.cpuTimeAtResume = 0; // reset it
        }

        mRootWindowContainer.ensureActivitiesVisible(resuming, 0, !PRESERVE_WINDOWS);

        // Notify when the task stack has changed, but only if visibilities changed (not just
        // focus). Also if there is an active pinned stack - we always want to notify it about
        // task stack changes, because its positioning may depend on it.
@@ -1342,8 +1344,6 @@ class ActivityStack extends Task {
            mAtmService.getTaskChangeNotificationController().notifyTaskStackChanged();
            mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = false;
        }

        mRootWindowContainer.ensureActivitiesVisible(resuming, 0, !PRESERVE_WINDOWS);
    }

    boolean isTopStackInDisplayArea() {
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@
                  android:screenOrientation="sensorLandscape"
                  android:showWhenLocked="true"
                  android:turnScreenOn="true" />
        <activity android:name="com.android.server.wm.TaskStackChangedListenerTest$ResumeWhilePausingActivity"
                  android:resumeWhilePausing="true"/>
        <activity android:name="com.android.server.wm.ScreenDecorWindowTests$TestActivity"
                  android:showWhenLocked="true" android:allowEmbedded="true"/>
    </application>
+25 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public class TaskStackChangedListenerTest {
    @Before
    public void setUp() throws Exception {
        mService = ActivityManager.getService();
        sTaskStackChangedCalled = false;
    }

    @After
@@ -112,6 +113,28 @@ public class TaskStackChangedListenerTest {
        assertTrue(sActivityBResumed);
    }

    @Test
    @Presubmit
    public void testTaskStackChanged_resumeWhilePausing() throws Exception {
        registerTaskStackChangedListener(new TaskStackListener() {
            @Override
            public void onTaskStackChanged() throws RemoteException {
                synchronized (sLock) {
                    sTaskStackChangedCalled = true;
                }
            }
        });

        final Context context = getInstrumentation().getContext();
        context.startActivity(new Intent(context, ResumeWhilePausingActivity.class).addFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK));
        UiDevice.getInstance(getInstrumentation()).waitForIdle();

        synchronized (sLock) {
            assertTrue(sTaskStackChangedCalled);
        }
    }

    @Test
    @Presubmit
    public void testTaskDescriptionChanged() throws Exception {
@@ -617,5 +640,7 @@ public class TaskStackChangedListenerTest {
    // Activity that has {@link android.R.attr#resizeableActivity} attribute set to {@code true}
    public static class ActivityInActivityView extends TestActivity {}

    public static class ResumeWhilePausingActivity extends TestActivity {}

    public static class LandscapeActivity extends TestActivity {}
}