Set permissions for launching on private displays
- System UIDs must be allowed to launch anything and everywhere.
- Display owner must be allowed to launch activities on it.
- Apps that are already on target display must be allowed to launch
there.
- All other apps mustn't be allowed to launch on private displays.
Bug: 34230873
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testPermissionLaunchFromSystem
Test: #testPermissionLaunchFromAppOnSecondary
Test: #testPermissionLaunchFromOwner
Test: #testPermissionLaunchFromDifferentApp
Change-Id: Ic98005649a6368370c512e822cba4e9decc18ae9
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index a72a958..6f984a5c 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -741,8 +741,14 @@
return mStack;
}
- /** Must be used for setting parent stack because it performs configuration updates. */
+ /**
+ * Must be used for setting parent stack because it performs configuration updates.
+ * Must be called after adding task as a child to the stack.
+ */
void setStack(ActivityStack stack) {
+ if (stack != null && !stack.isInStackLocked(this)) {
+ throw new IllegalStateException("Task must be added as a Stack child first.");
+ }
mStack = stack;
onParentChanged();
}
@@ -769,6 +775,12 @@
return mStack;
}
+ @Override
+ void onParentChanged() {
+ super.onParentChanged();
+ mService.mStackSupervisor.updateUIDsPresentOnDisplay();
+ }
+
// Close up recents linked list.
void closeRecentsChain() {
if (mPrevAffiliate != null) {