diff --git a/api/test-current.txt b/api/test-current.txt index 478540599fbdf..700be90a206ea 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -131,7 +131,7 @@ package android.app { method public void startActivity(@NonNull android.content.Intent); method public void startActivity(@NonNull android.content.Intent, android.os.UserHandle); method public void startActivity(@NonNull android.app.PendingIntent); - method public void startActivity(@NonNull android.app.PendingIntent, @NonNull android.app.ActivityOptions); + method public void startActivity(@NonNull android.app.PendingIntent, @Nullable android.content.Intent, @NonNull android.app.ActivityOptions); } public abstract static class ActivityView.StateCallback { diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index b56c00e44d3f2..fbf1f59141a82 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -22,6 +22,7 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLI import static android.view.Display.INVALID_DISPLAY; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.TestApi; import android.app.ActivityManager.StackInfo; import android.content.ComponentName; @@ -324,16 +325,17 @@ public class ActivityView extends ViewGroup { * this method can be called. * * @param pendingIntent Intent used to launch an activity. + * @param fillInIntent Additional Intent data, see {@link Intent#fillIn Intent.fillIn()}. * @param options options for the activity * * @see StateCallback * @see #startActivity(Intent) */ - public void startActivity(@NonNull PendingIntent pendingIntent, + public void startActivity(@NonNull PendingIntent pendingIntent, @Nullable Intent fillInIntent, @NonNull ActivityOptions options) { options.setLaunchDisplayId(mVirtualDisplay.getDisplay().getDisplayId()); try { - pendingIntent.send(null /* context */, 0 /* code */, null /* intent */, + pendingIntent.send(getContext(), 0 /* code */, fillInIntent, null /* onFinished */, null /* handler */, null /* requiredPermission */, options.toBundle()); } catch (PendingIntent.CanceledException e) { diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index cc548d0c7f8ef..9568a18e5ca31 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -18,7 +18,6 @@ package com.android.systemui.bubbles; import static android.app.Notification.FLAG_AUTOGROUP_SUMMARY; import static android.app.Notification.FLAG_BUBBLE; -import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS; import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL; import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL; import static android.service.notification.NotificationListenerService.REASON_CANCEL; @@ -965,16 +964,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi + intent); return false; } - if (info.documentLaunchMode != DOCUMENT_LAUNCH_ALWAYS) { - Log.w(TAG, "Unable to send as bubble -- activity is not documentLaunchMode=always " - + "for intent: " + intent); - return false; - } - if ((info.flags & ActivityInfo.FLAG_ALLOW_EMBEDDED) == 0) { - Log.w(TAG, "Unable to send as bubble -- activity is not embeddable for intent: " - + intent); - return false; - } return true; } diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 521ebde7d2f0a..6f953d5845894 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -16,6 +16,8 @@ package com.android.systemui.bubbles; +import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; +import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT; import static android.view.Display.INVALID_DISPLAY; import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW; @@ -128,8 +130,12 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList Log.d(TAG, "onActivityViewReady: calling startActivity, " + "bubble=" + getBubbleKey()); } + Intent fillInIntent = new Intent(); + // Apply flags to make behaviour match documentLaunchMode=always. + fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT); + fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK); try { - mActivityView.startActivity(mBubbleIntent, options); + mActivityView.startActivity(mBubbleIntent, fillInIntent, options); } catch (RuntimeException e) { // If there's a runtime exception here then there's something // wrong with the intent, we can't really recover / try to populate diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 4293ccadd1fbc..4457e9c312d81 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -49,7 +49,6 @@ import static android.content.Context.BIND_ALLOW_WHITELIST_MANAGEMENT; import static android.content.Context.BIND_AUTO_CREATE; import static android.content.Context.BIND_FOREGROUND_SERVICE; import static android.content.Context.BIND_NOT_PERCEPTIBLE; -import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS; import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_TELEVISION; import static android.content.pm.PackageManager.MATCH_ALL; @@ -88,7 +87,6 @@ import static android.service.notification.NotificationListenerService.TRIM_FULL import static android.service.notification.NotificationListenerService.TRIM_LIGHT; import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__ACTIVITY_INFO_MISSING; import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__ACTIVITY_INFO_NOT_RESIZABLE; -import static android.util.StatsLogInternal.BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__DOCUMENT_LAUNCH_NOT_ALWAYS; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; @@ -5251,18 +5249,6 @@ public class NotificationManagerService extends SystemService { + intent); return false; } - if (info.documentLaunchMode != DOCUMENT_LAUNCH_ALWAYS) { - StatsLog.write(StatsLog.BUBBLE_DEVELOPER_ERROR_REPORTED, packageName, - BUBBLE_DEVELOPER_ERROR_REPORTED__ERROR__DOCUMENT_LAUNCH_NOT_ALWAYS); - Log.w(TAG, "Unable to send as bubble -- activity is not documentLaunchMode=always " - + "for intent: " + intent); - return false; - } - if ((info.flags & ActivityInfo.FLAG_ALLOW_EMBEDDED) == 0) { - Log.w(TAG, "Unable to send as bubble -- activity is not embeddable for intent: " - + intent); - return false; - } return true; }