Skip to content

Commit 52a404f

Browse files
Winson ChungAndroid Build Coastguard Worker
authored andcommitted
Ensure that only SysUI can override pending intent launch flags
- Originally added in ag/5139951, this method ensured that activities launched from widgets are always started in a new task (if the activity is launched in the home task, the task is not brough forward with the recents transition). We can restrict this to only recents callers since this only applies to 1p launchers in gesture nav (both the gesture with 3p launchers and button nav in general will always start the home intent directly, which makes adding the NEW_TASK flag unnecessary). Bug: 243794108 Test: Ensure that the original bug b/112508020 still works (with the test app in the bug, swipe up still works after launching an activity from the widget, and fails without applying the override flags) Change-Id: Id53c6a2aa6da5933d488ca06a0bfc4ef89a4c343 (cherry picked from commit c4d3106) Merged-In: Id53c6a2aa6da5933d488ca06a0bfc4ef89a4c343
1 parent d8e918f commit 52a404f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

services/core/java/com/android/server/am/PendingIntentRecord.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,16 @@ public int sendInner(int code, Intent intent, String resolvedType, IBinder allow
379379
resolvedType = key.requestResolvedType;
380380
}
381381

382-
// Apply any launch flags from the ActivityOptions. This is to ensure that the caller
383-
// can specify a consistent launch mode even if the PendingIntent is immutable
382+
// Apply any launch flags from the ActivityOptions. This is used only by SystemUI
383+
// to ensure that we can launch the pending intent with a consistent launch mode even
384+
// if the provided PendingIntent is immutable (ie. to force an activity to launch into
385+
// a new task, or to launch multiple instances if supported by the app)
384386
final ActivityOptions opts = ActivityOptions.fromBundle(options);
385387
if (opts != null) {
386-
finalIntent.addFlags(opts.getPendingIntentLaunchFlags());
388+
// TODO(b/254490217): Move this check into SafeActivityOptions
389+
if (controller.mAtmInternal.isCallerRecents(Binder.getCallingUid())) {
390+
finalIntent.addFlags(opts.getPendingIntentLaunchFlags());
391+
}
387392
}
388393

389394
// Extract options before clearing calling identity

0 commit comments

Comments
 (0)