diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 75e919990f01f..87971cb41f96d 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -318,15 +318,20 @@
android:exported="false">
+
+
+
+ android:process=":screenshot"
+ android:exported="false" />
+ android:process=":screenshot"
+ android:exported="false" />
{
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
- // Create a share action for the notification
- PendingIntent chooseAction = PendingIntent.getBroadcast(context, 0,
- new Intent(context, GlobalScreenshot.TargetChosenReceiver.class),
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
- Intent chooserIntent = Intent.createChooser(sharingIntent, null,
- chooseAction.getIntentSender())
- .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent shareAction = PendingIntent.getActivity(context, 0, chooserIntent,
+ // Create a share action for the notification. Note, we proxy the call to ShareReceiver
+ // because RemoteViews currently forces an activity options on the PendingIntent being
+ // launched, and since we don't want to trigger the share sheet in this case, we will
+ // start the chooser activitiy directly in ShareReceiver.
+ PendingIntent shareAction = PendingIntent.getBroadcast(context, 0,
+ new Intent(context, GlobalScreenshot.ShareReceiver.class)
+ .putExtra(SHARING_INTENT, sharingIntent),
PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Action.Builder shareActionBuilder = new Notification.Action.Builder(
R.drawable.ic_screenshot_share,
@@ -292,7 +297,7 @@ class SaveImageInBackgroundTask extends AsyncTask {
mNotificationBuilder.addAction(shareActionBuilder.build());
// Create a delete action for the notification
- PendingIntent deleteAction = PendingIntent.getBroadcast(context, 0,
+ PendingIntent deleteAction = PendingIntent.getBroadcast(context, 0,
new Intent(context, GlobalScreenshot.DeleteScreenshotReceiver.class)
.putExtra(GlobalScreenshot.SCREENSHOT_URI_ID, uri.toString()),
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
@@ -403,6 +408,7 @@ class DeleteImageInBackgroundTask extends AsyncTask {
class GlobalScreenshot {
static final String SCREENSHOT_URI_ID = "android:screenshot_uri_id";
+ static final String SHARING_INTENT = "android:screenshot_sharing_intent";
private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130;
private static final int SCREENSHOT_DROP_IN_DURATION = 430;
@@ -896,6 +902,30 @@ class GlobalScreenshot {
nManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, n);
}
+ /**
+ * Receiver to proxy the share intent.
+ */
+ public static class ShareReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ try {
+ ActivityManager.getService().closeSystemDialogs(SYSTEM_DIALOG_REASON_SCREENSHOT);
+ } catch (RemoteException e) {
+ }
+
+ Intent sharingIntent = intent.getParcelableExtra(SHARING_INTENT);
+ PendingIntent chooseAction = PendingIntent.getBroadcast(context, 0,
+ new Intent(context, GlobalScreenshot.TargetChosenReceiver.class),
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
+ Intent chooserIntent = Intent.createChooser(sharingIntent, null,
+ chooseAction.getIntentSender())
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
+ ActivityOptions opts = ActivityOptions.makeBasic();
+ opts.setDisallowEnterPictureInPictureWhileLaunching(true);
+ context.startActivityAsUser(chooserIntent, opts.toBundle(), UserHandle.CURRENT);
+ }
+ }
+
/**
* Removes the notification for a screenshot after a share target is chosen.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 0575e21d66232..7a10985fc60c6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -300,6 +300,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// Should match the values in PhoneWindowManager
public static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
+ static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot";
private static final String BANNER_ACTION_CANCEL =
"com.android.systemui.statusbar.banner_action_cancel";
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index d62d9357e43f0..791b2c066821f 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -3007,13 +3007,6 @@ class ActivityStack extends ConfigurationContai
// Ensure the task/activity being brought forward is not the assistant
return false;
}
- final boolean isFullscreen = toFrontTask != null
- ? toFrontTask.containsOnlyFullscreenActivities()
- : toFrontActivity.fullscreen;
- if (!isFullscreen) {
- // Ensure the task/activity being brought forward is fullscreen
- return false;
- }
return true;
}
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 1bbb06871cc2a..eadc8a6eadba2 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -1112,19 +1112,6 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta
return intent != null ? intent : affinityIntent;
}
- /**
- * @return Whether there are only fullscreen activities in this task.
- */
- boolean containsOnlyFullscreenActivities() {
- for (int i = 0; i < mActivities.size(); i++) {
- final ActivityRecord r = mActivities.get(i);
- if (!r.finishing && !r.fullscreen) {
- return false;
- }
- }
- return true;
- }
-
/** Returns the first non-finishing activity from the root. */
ActivityRecord getRootActivity() {
for (int i = 0; i < mActivities.size(); i++) {
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 0610b77c08f96..bc531c3dee1bf 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -335,6 +335,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist";
+ static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot";
/**
* These are the system UI flags that, when changing, can cause the layout