diff options
| author | 2024-06-18 08:40:06 +0000 | |
|---|---|---|
| committer | 2024-06-18 08:40:06 +0000 | |
| commit | 58ab8744f5f91148e9504532f7334507860a79fc (patch) | |
| tree | 36e1cd90b89d5b86625459216c38e06b95e352c2 | |
| parent | e45635f1bf3b79f78f9dec52756431a09ca08fb0 (diff) | |
| parent | 7b82b3266003d62beba4d240b76de5555767e147 (diff) | |
Merge "Fix untrusted activity not shown when pinned" into main
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityRecord.java | 11 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java | 46 |
2 files changed, 50 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 13d6e51a0585..10243a798b85 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -6245,12 +6245,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } - // Check if there are any activities with different UID over the activity that is embedded - // in untrusted mode. Traverse bottom to top with boundary so that it will only check - // activities above this activity. + // Check if there are any activities with different UID occluding partially the activity + // that is embedded in untrusted mode. Traverse bottom to top with boundary so that it will + // only check activities above this activity. final ActivityRecord differentUidOverlayActivity = getTask().getActivity( - a -> !a.finishing && a.getUid() != getUid(), this /* boundary */, - false /* includeBoundary */, false /* traverseTopToBottom */); + a -> !a.finishing && a.getUid() != getUid() && Rect.intersects(a.getBounds(), + getBounds()), this /* boundary */, false /* includeBoundary */, + false /* traverseTopToBottom */); return differentUidOverlayActivity != null; } diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java index f94e5e3c38ed..35b6b70cb611 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java @@ -499,8 +499,8 @@ public class TaskFragmentTest extends WindowTestsBase { .build(); final ActivityRecord activity0 = organizedTf.getBottomMostActivity(); final ActivityRecord activity1 = organizedTf.getTopMostActivity(); - // Bottom activity is untrusted embedding. Top activity is trusted embedded. - // Activity0 has overlay over untrusted mode embedded. + // Bottom activity is untrusted embedding. Top activity is trusted embedded and occludes + // the bottom activity. Activity0 has overlay over untrusted mode embedded. activity0.info.applicationInfo.uid = DEFAULT_TASK_FRAGMENT_ORGANIZER_UID + 1; activity1.info.applicationInfo.uid = DEFAULT_TASK_FRAGMENT_ORGANIZER_UID; doReturn(true).when(organizedTf).isAllowedToEmbedActivityInUntrustedMode(activity0); @@ -537,6 +537,48 @@ public class TaskFragmentTest extends WindowTestsBase { } @Test + public void testActivityHasOverlayOverUntrustedModeEmbeddedWithAdjacentTaskFragments() { + final Task rootTask = createTask(mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, + ACTIVITY_TYPE_STANDARD); + final Rect taskBounds = rootTask.getBounds(); + final TaskFragment organizedTf0 = new TaskFragmentBuilder(mAtm) + .createActivityCount(1) + .setParentTask(rootTask) + .setFragmentToken(new Binder()) + .setOrganizer(mOrganizer) + .setBounds(new Rect(taskBounds.left, taskBounds.top, + taskBounds.left + taskBounds.width() / 2, taskBounds.bottom)) + .build(); + final TaskFragment organizedTf1 = new TaskFragmentBuilder(mAtm) + .createActivityCount(1) + .setParentTask(rootTask) + .setFragmentToken(new Binder()) + .setOrganizer(mOrganizer) + .setBounds(new Rect(taskBounds.left + taskBounds.width() / 2, taskBounds.top, + taskBounds.right, taskBounds.bottom)) + .build(); + final ActivityRecord activity0 = organizedTf0.getTopMostActivity(); + final ActivityRecord activity1 = organizedTf1.getTopMostActivity(); + + activity0.info.applicationInfo.uid = DEFAULT_TASK_FRAGMENT_ORGANIZER_UID + 1; + activity1.info.applicationInfo.uid = DEFAULT_TASK_FRAGMENT_ORGANIZER_UID; + doReturn(true).when(organizedTf0).isAllowedToEmbedActivityInUntrustedMode(activity0); + + assertFalse("Activity0 doesn't have overlay because it's not occluded by activity1", + activity0.hasOverlayOverUntrustedModeEmbedded()); + assertFalse(activity1.hasOverlayOverUntrustedModeEmbedded()); + + // Expand organizedTf1 bounds slightly. + final Rect tfBounds1 = organizedTf1.getBounds(); + organizedTf1.setBounds(tfBounds1.left - 5, tfBounds1.top, taskBounds.right + 5, + tfBounds1.bottom); + + assertTrue("Activity0 has overlay because it's occluded partially by activity1", + activity0.hasOverlayOverUntrustedModeEmbedded()); + assertFalse(activity1.hasOverlayOverUntrustedModeEmbedded()); + } + + @Test public void testIsAllowedToBeEmbeddedInTrustedMode() { final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm) .setCreateParentTask() |