ASM - Allow sources to launch into own task with NEW_TASK

This was previously blocked to try and provide consistency with launching
into a different task. Relaxing for compatibility.

Usecase: An app launches its main_activity, which trampolines
with NEW_TASK and matching affinity to main_activity. If the user
goes home before the trampoline, it would be blocked before this change.

Bug: 270680647
Test: atest ActivitySecurityModelTest
Change-Id: Ib9412d6cd9c7183da19fee8afd4bc47524d5736c
This commit is contained in:
Hani Kazmi
2023-02-27 13:47:22 +00:00
parent af730e95f9
commit 5cc88e94fd
2 changed files with 7 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ class ActivitySecurityModelFeatureFlags {
static final String DOC_LINK = "go/android-asm";
/** Used to determine which version of the ASM logic was used in logs while we iterate */
static final int ASM_VERSION = 5;
static final int ASM_VERSION = 6;
private static final String NAMESPACE = NAMESPACE_WINDOW_MANAGER;
private static final String KEY_ASM_PREFIX = "ActivitySecurity__";

View File

@@ -1948,9 +1948,13 @@ class ActivityStarter {
boolean passesAsmChecks = true;
Task sourceTask = mSourceRecord.getTask();
// Don't allow launches into a new task if the current task is not foreground.
// Allow launching into a new task (or a task matching the launched activity's
// affinity) only if the current task is foreground or mutating its own task.
// The latter can happen eg. if caller uses NEW_TASK flag and the activity being
// launched matches affinity of source task.
if (taskToFront) {
passesAsmChecks = sourceTask != null && sourceTask.isVisible();
passesAsmChecks = sourceTask != null
&& (sourceTask.isVisible() || sourceTask == targetTask);
}
if (passesAsmChecks) {