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

Commit 450a2547 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Fix crash for cross-process embedding" into tm-dev

parents a61b748e 6fcbfc39
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -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,"
@@ -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())) {
+25 −0
Original line number Diff line number Diff line
@@ -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());
    }
}