Merge "Fix crash for cross-process embedding" into tm-dev am: 450a25477f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17951966 Change-Id: Icd14e64c74258f1eea62a5621e7cb32ccbed1866 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -591,8 +591,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
* @see #isAllowedToEmbedActivityInTrustedMode(ActivityRecord)
|
* @see #isAllowedToEmbedActivityInTrustedMode(ActivityRecord)
|
||||||
*/
|
*/
|
||||||
boolean isAllowedToBeEmbeddedInTrustedMode() {
|
boolean isAllowedToBeEmbeddedInTrustedMode() {
|
||||||
final Predicate<ActivityRecord> callback = this::isAllowedToEmbedActivityInTrustedMode;
|
// Traverse all activities to see if any of them are not in the trusted mode.
|
||||||
return forAllActivities(callback);
|
final Predicate<ActivityRecord> callback = r -> !isAllowedToEmbedActivityInTrustedMode(r);
|
||||||
|
return !forAllActivities(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1438,7 +1438,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
}
|
}
|
||||||
final WindowConfiguration requestedWindowConfig = requestedConfig.windowConfiguration;
|
final WindowConfiguration requestedWindowConfig = requestedConfig.windowConfiguration;
|
||||||
final WindowConfiguration parentWindowConfig = parentConfig.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="
|
String msg = "Permission Denial: " + func + " from pid="
|
||||||
+ Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()
|
+ Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()
|
||||||
+ " trying to apply bounds outside of parent for non-trusted host,"
|
+ " trying to apply bounds outside of parent for non-trusted host,"
|
||||||
@@ -1447,6 +1448,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
|||||||
throw new SecurityException(msg);
|
throw new SecurityException(msg);
|
||||||
}
|
}
|
||||||
if (requestedWindowConfig.getAppBounds() != null
|
if (requestedWindowConfig.getAppBounds() != null
|
||||||
|
&& !requestedWindowConfig.getAppBounds().isEmpty()
|
||||||
&& parentWindowConfig.getAppBounds() != null
|
&& parentWindowConfig.getAppBounds() != null
|
||||||
&& !parentWindowConfig.getAppBounds().contains(
|
&& !parentWindowConfig.getAppBounds().contains(
|
||||||
requestedWindowConfig.getAppBounds())) {
|
requestedWindowConfig.getAppBounds())) {
|
||||||
|
|||||||
@@ -403,4 +403,29 @@ public class TaskFragmentTest extends WindowTestsBase {
|
|||||||
assertFalse(activity0.hasOverlayOverUntrustedModeEmbedded());
|
assertFalse(activity0.hasOverlayOverUntrustedModeEmbedded());
|
||||||
assertFalse(activity1.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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user