diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 3de3578a09f1e..077e735d9d605 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -1520,7 +1520,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A hasBeenLaunched = false; mStackSupervisor = supervisor; - taskAffinity = aInfo.taskAffinity; + // b/35954083: Limit task affinity to uid to avoid various issues associated with sharing + // affinity across uids. + final String uid = Integer.toString(info.applicationInfo.uid); + if (info.taskAffinity != null && !info.taskAffinity.startsWith(uid)) { + info.taskAffinity = uid + ":" + info.taskAffinity; + } + taskAffinity = info.taskAffinity; stateNotNeeded = (aInfo.flags & FLAG_STATE_NOT_NEEDED) != 0; nonLocalizedLabel = aInfo.nonLocalizedLabel; labelRes = aInfo.labelRes;