Loading services/core/java/com/android/server/wm/TaskFragment.java +3 −2 Original line number Diff line number Diff line Loading @@ -591,8 +591,9 @@ class TaskFragment extends WindowContainer<WindowContainer> { * @see #isAllowedToEmbedActivityInTrustedMode(ActivityRecord) */ boolean isAllowedToBeEmbeddedInTrustedMode() { final Predicate<ActivityRecord> callback = this::isAllowedToEmbedActivityInTrustedMode; return forAllActivities(callback); // Traverse all activities to see if any of them are not in the trusted mode. final Predicate<ActivityRecord> callback = r -> !isAllowedToEmbedActivityInTrustedMode(r); return !forAllActivities(callback); } /** Loading services/core/java/com/android/server/wm/WindowOrganizerController.java +3 −1 Original line number Diff line number Diff line Loading @@ -1438,7 +1438,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub } final WindowConfiguration requestedWindowConfig = requestedConfig.windowConfiguration; final WindowConfiguration parentWindowConfig = parentConfig.windowConfiguration; if (!parentWindowConfig.getBounds().contains(requestedWindowConfig.getBounds())) { if (!requestedWindowConfig.getBounds().isEmpty() && !parentWindowConfig.getBounds().contains(requestedWindowConfig.getBounds())) { String msg = "Permission Denial: " + func + " from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " trying to apply bounds outside of parent for non-trusted host," Loading @@ -1447,6 +1448,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub throw new SecurityException(msg); } if (requestedWindowConfig.getAppBounds() != null && !requestedWindowConfig.getAppBounds().isEmpty() && parentWindowConfig.getAppBounds() != null && !parentWindowConfig.getAppBounds().contains( requestedWindowConfig.getAppBounds())) { Loading services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -403,4 +403,29 @@ public class TaskFragmentTest extends WindowTestsBase { assertFalse(activity0.hasOverlayOverUntrustedModeEmbedded()); assertFalse(activity1.hasOverlayOverUntrustedModeEmbedded()); } @Test public void testIsAllowedToBeEmbeddedInTrustedMode() { final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm) .setCreateParentTask() .createActivityCount(2) .build(); final ActivityRecord activity0 = taskFragment.getBottomMostActivity(); final ActivityRecord activity1 = taskFragment.getTopMostActivity(); // Allowed if all children activities are allowed. doReturn(true).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity0); doReturn(true).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity1); assertTrue(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); // Disallowed if any child activity is not allowed. doReturn(false).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity0); assertFalse(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); doReturn(false).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity1); assertFalse(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); } } Loading
services/core/java/com/android/server/wm/TaskFragment.java +3 −2 Original line number Diff line number Diff line Loading @@ -591,8 +591,9 @@ class TaskFragment extends WindowContainer<WindowContainer> { * @see #isAllowedToEmbedActivityInTrustedMode(ActivityRecord) */ boolean isAllowedToBeEmbeddedInTrustedMode() { final Predicate<ActivityRecord> callback = this::isAllowedToEmbedActivityInTrustedMode; return forAllActivities(callback); // Traverse all activities to see if any of them are not in the trusted mode. final Predicate<ActivityRecord> callback = r -> !isAllowedToEmbedActivityInTrustedMode(r); return !forAllActivities(callback); } /** Loading
services/core/java/com/android/server/wm/WindowOrganizerController.java +3 −1 Original line number Diff line number Diff line Loading @@ -1438,7 +1438,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub } final WindowConfiguration requestedWindowConfig = requestedConfig.windowConfiguration; final WindowConfiguration parentWindowConfig = parentConfig.windowConfiguration; if (!parentWindowConfig.getBounds().contains(requestedWindowConfig.getBounds())) { if (!requestedWindowConfig.getBounds().isEmpty() && !parentWindowConfig.getBounds().contains(requestedWindowConfig.getBounds())) { String msg = "Permission Denial: " + func + " from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " trying to apply bounds outside of parent for non-trusted host," Loading @@ -1447,6 +1448,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub throw new SecurityException(msg); } if (requestedWindowConfig.getAppBounds() != null && !requestedWindowConfig.getAppBounds().isEmpty() && parentWindowConfig.getAppBounds() != null && !parentWindowConfig.getAppBounds().contains( requestedWindowConfig.getAppBounds())) { Loading
services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -403,4 +403,29 @@ public class TaskFragmentTest extends WindowTestsBase { assertFalse(activity0.hasOverlayOverUntrustedModeEmbedded()); assertFalse(activity1.hasOverlayOverUntrustedModeEmbedded()); } @Test public void testIsAllowedToBeEmbeddedInTrustedMode() { final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm) .setCreateParentTask() .createActivityCount(2) .build(); final ActivityRecord activity0 = taskFragment.getBottomMostActivity(); final ActivityRecord activity1 = taskFragment.getTopMostActivity(); // Allowed if all children activities are allowed. doReturn(true).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity0); doReturn(true).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity1); assertTrue(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); // Disallowed if any child activity is not allowed. doReturn(false).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity0); assertFalse(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); doReturn(false).when(taskFragment).isAllowedToEmbedActivityInTrustedMode(activity1); assertFalse(taskFragment.isAllowedToBeEmbeddedInTrustedMode()); } }