Restrict background activity start by task
We now also allow apps to start activity in its own background task, while
that task won't move to front.
Background activity is not allowed to be started in new task or app
is not in that task stack.
Also, task moving / reparent task is not allowed.
Bug: 128772406
Test: atest android.server.wm.BackgroundActivityLaunchTest
Change-Id: I20f501e755f30f9ef581f7f8c39a2875f959e5b8
diff --git a/services/core/java/com/android/server/wm/TaskRecord.java b/services/core/java/com/android/server/wm/TaskRecord.java
index 15060e1..c26e3fd 100644
--- a/services/core/java/com/android/server/wm/TaskRecord.java
+++ b/services/core/java/com/android/server/wm/TaskRecord.java
@@ -1161,6 +1161,19 @@
return false;
}
+ /**
+ * Return true if any activities in this task belongs to input uid.
+ */
+ boolean containsAppUid(int uid) {
+ for (int i = mActivities.size() - 1; i >= 0; --i) {
+ final ActivityRecord r = mActivities.get(i);
+ if (r.getUid() == uid) {
+ return true;
+ }
+ }
+ return false;
+ }
+
void getAllRunningVisibleActivitiesLocked(ArrayList<ActivityRecord> outActivities) {
if (mStack != null) {
for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {