diff options
| author | Winson Chung <winsonc@google.com> | 2018-09-27 13:55:58 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2018-09-28 11:22:29 -0700 |
| commit | d070775c940df1869c211f4a184a0f82dd58dc78 (patch) | |
| tree | 1226c93e451ecdcef5a9e98939aab8892d957b52 /core/java/android/widget/RemoteViews.java | |
| parent | 1780672b198a24839bf26882f8b2eb3128fd6542 (diff) | |
Add activity options flag to force launching an activity in a new task
- This is to work around issues where the caller (ie. RemoteViews) is
launching a provided pending intent that is immutable and still needs
to ensure that it is launched in a separate task.
Bug: 112508020
Test: Launch an immutable pending intent from a widget and ensure it
launches in a new task as expected
Change-Id: I70c318674da15a78418548ee719cb1257f899ac6
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 35ff6cc23499..001a09dd8c21 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -368,10 +368,12 @@ public class RemoteViews implements Parcelable, Filter { // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT? Context context = view.getContext(); ActivityOptions opts = getActivityOptions(context); + // The NEW_TASK flags are applied through the activity options and not as a part of + // the call to startIntentSender() to ensure that they are consistently applied to + // both mutable and immutable PendingIntents. context.startIntentSender( pendingIntent.getIntentSender(), fillInIntent, - Intent.FLAG_ACTIVITY_NEW_TASK, - Intent.FLAG_ACTIVITY_NEW_TASK, 0, opts.toBundle()); + 0, 0, 0, opts.toBundle()); } catch (IntentSender.SendIntentException e) { android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e); return false; @@ -399,10 +401,15 @@ public class RemoteViews implements Parcelable, Filter { windowAnimationStyle.recycle(); if (enterAnimationId != 0) { - return ActivityOptions.makeCustomAnimation(context, enterAnimationId, 0); + final ActivityOptions opts = ActivityOptions.makeCustomAnimation(context, + enterAnimationId, 0); + opts.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + return opts; } } - return ActivityOptions.makeBasic(); + final ActivityOptions opts = ActivityOptions.makeBasic(); + opts.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + return opts; } } |
