diff options
Diffstat (limited to 'packages/Shell/src')
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 13 | ||||
-rw-r--r-- | packages/Shell/src/com/android/shell/Screenshooter.java | 82 |
2 files changed, 17 insertions, 78 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index a8b184c3f204..600f0dc37775 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -616,7 +616,7 @@ public class BugreportProgressService extends Service { final IWindowManager wm = IWindowManager.Stub .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); try { - wm.dismissKeyguard(null); + wm.dismissKeyguard(null, null); } catch (Exception e) { // ignore it } @@ -1909,7 +1909,7 @@ public class BugreportProgressService extends Service { } final IDumpstate dumpstate = IDumpstate.Stub.asInterface(service); try { - token = dumpstate.setListener("Shell", this); + token = dumpstate.setListener("Shell", this, /* perSectionDetails= */ false); if (token != null) { token.asBinder().linkToDeath(this, 0); } @@ -1978,6 +1978,15 @@ public class BugreportProgressService extends Service { info.realMax = maxProgress; } + @Override + public void onSectionComplete(String title, int status, int size, int durationMs) + throws RemoteException { + if (DEBUG) { + Log.v(TAG, "Title: " + title + " Status: " + status + " Size: " + size + + " Duration: " + durationMs + "ms"); + } + } + public void dump(String prefix, PrintWriter pw) { pw.print(prefix); pw.print("token: "); pw.println(token); } diff --git a/packages/Shell/src/com/android/shell/Screenshooter.java b/packages/Shell/src/com/android/shell/Screenshooter.java index 8e27edf93d9c..8e0161961a49 100644 --- a/packages/Shell/src/com/android/shell/Screenshooter.java +++ b/packages/Shell/src/com/android/shell/Screenshooter.java @@ -17,12 +17,11 @@ package com.android.shell; import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.Point; +import android.graphics.Rect; import android.hardware.display.DisplayManagerGlobal; import android.util.Log; import android.view.Display; -import android.view.Surface; import android.view.SurfaceControl; /** @@ -35,18 +34,6 @@ final class Screenshooter { private static final String TAG = "Screenshooter"; - /** Rotation constant: Freeze rotation to 0 degrees (natural orientation) */ - public static final int ROTATION_FREEZE_0 = Surface.ROTATION_0; - - /** Rotation constant: Freeze rotation to 90 degrees . */ - public static final int ROTATION_FREEZE_90 = Surface.ROTATION_90; - - /** Rotation constant: Freeze rotation to 180 degrees . */ - public static final int ROTATION_FREEZE_180 = Surface.ROTATION_180; - - /** Rotation constant: Freeze rotation to 270 degrees . */ - public static final int ROTATION_FREEZE_270 = Surface.ROTATION_270; - /** * Takes a screenshot. * @@ -60,78 +47,21 @@ final class Screenshooter { final int displayWidth = displaySize.x; final int displayHeight = displaySize.y; - final float screenshotWidth; - final float screenshotHeight; - - final int rotation = display.getRotation(); - switch (rotation) { - case ROTATION_FREEZE_0: { - screenshotWidth = displayWidth; - screenshotHeight = displayHeight; - } break; - case ROTATION_FREEZE_90: { - screenshotWidth = displayHeight; - screenshotHeight = displayWidth; - } break; - case ROTATION_FREEZE_180: { - screenshotWidth = displayWidth; - screenshotHeight = displayHeight; - } break; - case ROTATION_FREEZE_270: { - screenshotWidth = displayHeight; - screenshotHeight = displayWidth; - } break; - default: { - throw new IllegalArgumentException("Invalid rotation: " - + rotation); - } - } - + int rotation = display.getRotation(); + Rect crop = new Rect(0, 0, displayWidth, displayHeight); Log.d(TAG, "Taking screenshot of dimensions " + displayWidth + " x " + displayHeight); // Take the screenshot Bitmap screenShot = - SurfaceControl.screenshot((int) screenshotWidth, (int) screenshotHeight); + SurfaceControl.screenshot(crop, displayWidth, displayHeight, rotation); if (screenShot == null) { - Log.e(TAG, "Failed to take screenshot of dimensions " + screenshotWidth + " x " - + screenshotHeight); + Log.e(TAG, "Failed to take screenshot of dimensions " + displayWidth + " x " + + displayHeight); return null; } - // Rotate the screenshot to the current orientation - if (rotation != ROTATION_FREEZE_0) { - Bitmap unrotatedScreenShot = Bitmap.createBitmap(displayWidth, displayHeight, - Bitmap.Config.ARGB_8888, screenShot.hasAlpha(), screenShot.getColorSpace()); - Canvas canvas = new Canvas(unrotatedScreenShot); - canvas.translate(unrotatedScreenShot.getWidth() / 2, - unrotatedScreenShot.getHeight() / 2); - canvas.rotate(getDegreesForRotation(rotation)); - canvas.translate(- screenshotWidth / 2, - screenshotHeight / 2); - canvas.drawBitmap(screenShot, 0, 0, null); - canvas.setBitmap(null); - screenShot.recycle(); - screenShot = unrotatedScreenShot; - } - // Optimization screenShot.setHasAlpha(false); return screenShot; } - - private static float getDegreesForRotation(int value) { - switch (value) { - case Surface.ROTATION_90: { - return 360f - 90f; - } - case Surface.ROTATION_180: { - return 360f - 180f; - } - case Surface.ROTATION_270: { - return 360f - 270f; - } default: { - return 0; - } - } - } - } |