Merge "Remove embedded & document launch always restrictions from a bubble"

This commit is contained in:
Mady Mellor
2019-10-10 23:10:36 +00:00
committed by Android (Google) Code Review
5 changed files with 12 additions and 29 deletions

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}