diff options
| author | 2023-11-29 07:12:01 +0000 | |
|---|---|---|
| committer | 2023-11-29 07:34:51 +0000 | |
| commit | aeb30c14c97edea3ccaf318476720e013e59b8b8 (patch) | |
| tree | fe2b0d5cd27c81f1e771e3c6642d6f2bb845bf19 | |
| parent | ac4089a9e3376cb718fa0ca6d8381c6e108cf06c (diff) | |
Excluding pip Task while trying to move Activity on Top
In ActivityEmbedding, touching on the embedded and non-current-focused
Activity will make the Activity focused if the parent Task is not moving
to top. However, it doesn't work when there's a pip Task. That's because
the pip Task is always-on-top and also focusable. The touched Task is
therefore not the top focusable Task and was requested to move to top
(though it is a no-op since it cannot be moved above pip).
Bug: 311984433
Test: ActivityRecordTests
Change-Id: Ib3f92d81b5a2daf9bb6dc4b7dbdfa53f9d45c7bd
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityRecord.java | 3 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 081759d563a5..3e35f963d15e 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -3386,7 +3386,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (currentFocusedApp != null && currentFocusedApp.task == task && topFocusedDisplayId == mDisplayContent.getDisplayId()) { final Task topFocusableTask = mDisplayContent.getTask( - (t) -> t.isLeafTask() && t.isFocusable(), true /* traverseTopToBottom */); + (t) -> t.isLeafTask() && t.isFocusable() && !t.inPinnedWindowingMode(), + true /* traverseTopToBottom */); if (task == topFocusableTask) { if (currentFocusedApp == this) { ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: already on top " diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 786432a5dc88..ecb537eeab6e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -3717,6 +3717,24 @@ public class ActivityRecordTests extends WindowTestsBase { verify(task).moveTaskToBack(any()); } + /** + * Verifies the {@link ActivityRecord#moveFocusableActivityToTop} returns {@code false} if + * there's a PIP task on top. + */ + @Test + public void testMoveFocusableActivityToTop() { + // Create a Task + final Task task = createTask(mDisplayContent); + final ActivityRecord ar = createActivityRecord(task); + + // Create a PIP Task on top + final Task pipTask = createTask(mDisplayContent); + doReturn(true).when(pipTask).inPinnedWindowingMode(); + + // Verifies that the Task is not moving-to-top. + assertFalse(ar.moveFocusableActivityToTop("test")); + } + private ICompatCameraControlCallback getCompatCameraControlCallback() { return new ICompatCameraControlCallback.Stub() { @Override |