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

Commit 171d4adb authored by Rachit Jain's avatar Rachit Jain
Browse files

Reland^2 "Revert "Defer resume of activity while applying wct""

- When the hierarchy is changing, defer resuming the activity until it is ready to let it finish processing the wct.
- If the activity does not wait, there will be extra lifecycle states even if they are applied in the same wct. Update test to not defer resume at the start.
- Only send wct if the activity is in the resumed state since the activity could have been removed already.

Change-Id: I1e2a8d9a26eecee1286967157923b5b3b4fb2ecb
Flag: EXEMPT (bug fix)
Bug: 369186876
Test: atest CtsWindowManagerDeviceActivity com.android.server.wm.ActivityTaskManagerServiceTests
parent ab8211ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1452,7 +1452,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    boolean scheduleTopResumedActivityChanged(boolean onTop) {
        if (!attachedToProcess()) {
        if (!attachedToProcess() || isState(DESTROYING, DESTROYED)) {
            ProtoLog.w(WM_DEBUG_STATES,
                    "Can't report activity position update - client not running, "
                            + "activityRecord=%s", this);
+4 −1
Original line number Diff line number Diff line
@@ -2280,6 +2280,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
     * sent to the new top resumed activity.
     */
    ActivityRecord updateTopResumedActivityIfNeeded(String reason) {
        if (!readyToResume()) {
            return mTopResumedActivity;
        }
        final ActivityRecord prevTopActivity = mTopResumedActivity;
        final Task topRootTask = mRootWindowContainer.getTopDisplayFocusedRootTask();
        if (topRootTask == null || topRootTask.getTopResumedActivity() == prevTopActivity) {
@@ -2340,8 +2343,8 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                && mTopResumedActivity.scheduleTopResumedActivityChanged(false /* onTop */)) {
            scheduleTopResumedStateLossTimeout(mTopResumedActivity);
            mTopResumedActivityWaitingForPrev = true;
            mTopResumedActivity = null;
        }
        mTopResumedActivity = null;
    }

    /** Schedule top resumed state change if previous top activity already reported back. */
+0 −2
Original line number Diff line number Diff line
@@ -382,13 +382,11 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {

    @Test
    public void testResumeNextActivityOnCrashedAppDied() {
        mSupervisor.beginDeferResume();
        final ActivityRecord homeActivity = new ActivityBuilder(mAtm)
                .setTask(mRootWindowContainer.getDefaultTaskDisplayArea().getOrCreateRootHomeTask())
                .build();
        final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
        activity.setState(RESUMED, "test");
        mSupervisor.endDeferResume();

        assertEquals(activity.app, mAtm.mInternal.getTopApp());