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

Commit 3f103eb4 authored by Winson Chung's avatar Winson Chung
Browse files

Fix issue with non-focusable PiP activities being resumed.

- When the change to finish activities was made in ag/2067154, it exposed
  an issue in pinned stacks where we would resume the next top activity
  once the top activity finished pausing. Normally, the pinned stack is
  not focusable, but since it has an alwaysFocusable menu activity it
  becomes the focused stack and falls into this case.

  Instead of finding the next top activity, we need to find the next top
  focusable activity to resume, and fall through to focusing the top
  activity in the next focusable stack if there is none.

Bug: 37199067
Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testNoResumeAfterTaskOverlayFinishes
Change-Id: Ib79826ff38bb3beb38a40183ddc6819e5040bb27
parent 9aa64e6c
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -645,9 +645,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    }

    final ActivityRecord topRunningActivityLocked() {
        return topRunningActivityLocked(false /* focusableOnly */);
    }

    final ActivityRecord topRunningActivityLocked(boolean focusableOnly) {
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            ActivityRecord r = mTaskHistory.get(taskNdx).topRunningActivityLocked();
            if (r != null) {
            if (r != null && (!focusableOnly || r.isFocusable())) {
                return r;
            }
        }
@@ -1324,7 +1328,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                        + (timeout ? " (due to timeout)" : " (pause complete)"));
                mService.mWindowManager.deferSurfaceLayout();
                try {
                    completePauseLocked(true, null);
                    completePauseLocked(true /* resumeNext */, null /* resumingActivity */);
                } finally {
                    mService.mWindowManager.continueSurfaceLayout();
                }
@@ -2198,8 +2202,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            return false;
        }

        // Find the topmost activity in this stack that is not finishing.
        final ActivityRecord next = topRunningActivityLocked();
        // Find the next top-most activity to resume in this stack that is not finishing and is
        // focusable. If it is not focusable, we will fall into the case below to resume the
        // top activity in the next focusable task.
        final ActivityRecord next = topRunningActivityLocked(true /* focusableOnly */);

        final boolean hasRunningActivity = next != null;