summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2021-10-07 23:50:15 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-10-07 23:50:15 +0000
commitc03b0fa033117c03430e361d561aa910e95a0478 (patch)
tree9c6aaee5a3023a6c237394b44e06a3fdb46f6747 /packages/Shell/src
parent8cc0f40cf250d9c66dc15d0e8bc3a41db9a7cfa1 (diff)
parent531b8f4f2605c44cf73e8421f674a1c7a9c277ff (diff)
Merge "Merge Android 12"
Diffstat (limited to 'packages/Shell/src')
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java6
-rw-r--r--packages/Shell/src/com/android/shell/BugreportWarningActivity.java5
-rw-r--r--packages/Shell/src/com/android/shell/HeapDumpReceiver.java2
-rw-r--r--packages/Shell/src/com/android/shell/Screenshooter.java28
4 files changed, 20 insertions, 21 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 88112e3f5cc8..8c7011253c8a 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -750,18 +750,20 @@ public class BugreportProgressService extends Service {
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
infoIntent.putExtra(EXTRA_ID, info.id);
+ // Simple notification action button clicks are immutable
final PendingIntent infoPendingIntent =
PendingIntent.getService(mContext, info.id, infoIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
final Action infoAction = new Action.Builder(null,
mContext.getString(R.string.bugreport_info_action),
infoPendingIntent).build();
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
screenshotIntent.putExtra(EXTRA_ID, info.id);
+ // Simple notification action button clicks are immutable
PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent
.getService(mContext, info.id, screenshotIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
final Action screenshotAction = new Action.Builder(null,
mContext.getString(R.string.bugreport_screenshot_action),
screenshotPendingIntent).build();
diff --git a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
index 2191d939e591..ecd1369817b4 100644
--- a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
+++ b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
@@ -29,6 +29,7 @@ import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.WindowManager;
import android.widget.CheckBox;
import com.android.internal.app.AlertActivity;
@@ -47,6 +48,10 @@ public class BugreportWarningActivity extends AlertActivity
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ // Don't allow overlay windows.
+ getWindow().addSystemFlags(
+ WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
mSendIntent = getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
// We need to touch the extras to unpack them so they get migrated to
diff --git a/packages/Shell/src/com/android/shell/HeapDumpReceiver.java b/packages/Shell/src/com/android/shell/HeapDumpReceiver.java
index 858c521eaed5..7433c3ee37b6 100644
--- a/packages/Shell/src/com/android/shell/HeapDumpReceiver.java
+++ b/packages/Shell/src/com/android/shell/HeapDumpReceiver.java
@@ -180,7 +180,7 @@ public class HeapDumpReceiver extends BroadcastReceiver {
.setContentText(context.getText(
com.android.internal.R.string.dump_heap_notification_detail))
.setContentIntent(PendingIntent.getActivity(context, 2, shareIntent,
- PendingIntent.FLAG_UPDATE_CURRENT));
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
Log.v(TAG, "Creating share heap dump notification");
NotificationManager.from(context).notify(NOTIFICATION_ID, builder.build());
diff --git a/packages/Shell/src/com/android/shell/Screenshooter.java b/packages/Shell/src/com/android/shell/Screenshooter.java
index 8e0161961a49..85f25528f07e 100644
--- a/packages/Shell/src/com/android/shell/Screenshooter.java
+++ b/packages/Shell/src/com/android/shell/Screenshooter.java
@@ -17,11 +17,8 @@
package com.android.shell;
import android.graphics.Bitmap;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.hardware.display.DisplayManagerGlobal;
+import android.os.IBinder;
import android.util.Log;
-import android.view.Display;
import android.view.SurfaceControl;
/**
@@ -40,22 +37,17 @@ final class Screenshooter {
* @return The screenshot bitmap on success, null otherwise.
*/
static Bitmap takeScreenshot() {
- Display display = DisplayManagerGlobal.getInstance()
- .getRealDisplay(Display.DEFAULT_DISPLAY);
- Point displaySize = new Point();
- display.getRealSize(displaySize);
- final int displayWidth = displaySize.x;
- final int displayHeight = displaySize.y;
-
- int rotation = display.getRotation();
- Rect crop = new Rect(0, 0, displayWidth, displayHeight);
- Log.d(TAG, "Taking screenshot of dimensions " + displayWidth + " x " + displayHeight);
+ Log.d(TAG, "Taking fullscreen screenshot");
// Take the screenshot
- Bitmap screenShot =
- SurfaceControl.screenshot(crop, displayWidth, displayHeight, rotation);
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ final SurfaceControl.DisplayCaptureArgs captureArgs =
+ new SurfaceControl.DisplayCaptureArgs.Builder(displayToken)
+ .build();
+ final SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer =
+ SurfaceControl.captureDisplay(captureArgs);
+ final Bitmap screenShot = screenshotBuffer == null ? null : screenshotBuffer.asBitmap();
if (screenShot == null) {
- Log.e(TAG, "Failed to take screenshot of dimensions " + displayWidth + " x "
- + displayHeight);
+ Log.e(TAG, "Failed to take fullscreen screenshot");
return null;
}