Loading core/java/com/android/internal/util/ScreenshotRequest.java +22 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import android.view.Display; import android.view.WindowManager; import java.util.Objects; Loading @@ -53,11 +54,12 @@ public class ScreenshotRequest implements Parcelable { private final Bitmap mBitmap; private final Rect mBoundsInScreen; private final Insets mInsets; private final int mDisplayId; private ScreenshotRequest( @WindowManager.ScreenshotType int type, @WindowManager.ScreenshotSource int source, ComponentName topComponent, int taskId, int userId, Bitmap bitmap, Rect boundsInScreen, Insets insets) { Bitmap bitmap, Rect boundsInScreen, Insets insets, int displayId) { mType = type; mSource = source; mTopComponent = topComponent; Loading @@ -66,6 +68,7 @@ public class ScreenshotRequest implements Parcelable { mBitmap = bitmap; mBoundsInScreen = boundsInScreen; mInsets = insets; mDisplayId = displayId; } ScreenshotRequest(Parcel in) { Loading @@ -77,6 +80,7 @@ public class ScreenshotRequest implements Parcelable { mBitmap = HardwareBitmapBundler.bundleToHardwareBitmap(in.readTypedObject(Bundle.CREATOR)); mBoundsInScreen = in.readTypedObject(Rect.CREATOR); mInsets = in.readTypedObject(Insets.CREATOR); mDisplayId = in.readInt(); } @WindowManager.ScreenshotType Loading Loading @@ -113,6 +117,10 @@ public class ScreenshotRequest implements Parcelable { return mTopComponent; } public int getDisplayId() { return mDisplayId; } @Override public int describeContents() { return 0; Loading @@ -128,6 +136,7 @@ public class ScreenshotRequest implements Parcelable { dest.writeTypedObject(HardwareBitmapBundler.hardwareBitmapToBundle(mBitmap), 0); dest.writeTypedObject(mBoundsInScreen, 0); dest.writeTypedObject(mInsets, 0); dest.writeInt(mDisplayId); } @NonNull Loading Loading @@ -161,6 +170,7 @@ public class ScreenshotRequest implements Parcelable { private int mTaskId = INVALID_TASK_ID; private int mUserId = USER_NULL; private ComponentName mTopComponent; private int mDisplayId = Display.INVALID_DISPLAY; /** * Begin building a ScreenshotRequest. Loading Loading @@ -193,7 +203,7 @@ public class ScreenshotRequest implements Parcelable { } return new ScreenshotRequest(mType, mSource, mTopComponent, mTaskId, mUserId, mBitmap, mBoundsInScreen, mInsets); mBoundsInScreen, mInsets, mDisplayId); } /** Loading Loading @@ -255,6 +265,16 @@ public class ScreenshotRequest implements Parcelable { mInsets = insets; return this; } /** * Set the display ID for this request. * * @param displayId see {@link Display} */ public Builder setDisplayId(int displayId) { mDisplayId = displayId; return this; } } /** Loading core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotRequestTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Insets; import android.graphics.Rect; import android.hardware.HardwareBuffer; import android.os.Parcel; import android.view.Display; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -64,10 +65,12 @@ public final class ScreenshotRequestTest { assertNull("Bitmap was expected to be null", out.getBitmap()); assertNull("Bounds were expected to be null", out.getBoundsInScreen()); assertEquals(Insets.NONE, out.getInsets()); assertEquals(Display.INVALID_DISPLAY, out.getDisplayId()); } @Test public void testProvidedScreenshot() { int displayId = 5; Bitmap bitmap = makeHardwareBitmap(50, 50); ScreenshotRequest in = new ScreenshotRequest.Builder(TAKE_SCREENSHOT_PROVIDED_IMAGE, SCREENSHOT_OTHER) Loading @@ -77,6 +80,7 @@ public final class ScreenshotRequestTest { .setBitmap(bitmap) .setBoundsOnScreen(new Rect(10, 10, 60, 60)) .setInsets(Insets.of(2, 3, 4, 5)) .setDisplayId(displayId) .build(); Parcel parcel = Parcel.obtain(); Loading @@ -92,6 +96,7 @@ public final class ScreenshotRequestTest { assertTrue("Bitmaps should be equal", out.getBitmap().sameAs(bitmap)); assertEquals(new Rect(10, 10, 60, 60), out.getBoundsInScreen()); assertEquals(Insets.of(2, 3, 4, 5), out.getInsets()); assertEquals(displayId, out.getDisplayId()); } @Test Loading Loading
core/java/com/android/internal/util/ScreenshotRequest.java +22 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import android.view.Display; import android.view.WindowManager; import java.util.Objects; Loading @@ -53,11 +54,12 @@ public class ScreenshotRequest implements Parcelable { private final Bitmap mBitmap; private final Rect mBoundsInScreen; private final Insets mInsets; private final int mDisplayId; private ScreenshotRequest( @WindowManager.ScreenshotType int type, @WindowManager.ScreenshotSource int source, ComponentName topComponent, int taskId, int userId, Bitmap bitmap, Rect boundsInScreen, Insets insets) { Bitmap bitmap, Rect boundsInScreen, Insets insets, int displayId) { mType = type; mSource = source; mTopComponent = topComponent; Loading @@ -66,6 +68,7 @@ public class ScreenshotRequest implements Parcelable { mBitmap = bitmap; mBoundsInScreen = boundsInScreen; mInsets = insets; mDisplayId = displayId; } ScreenshotRequest(Parcel in) { Loading @@ -77,6 +80,7 @@ public class ScreenshotRequest implements Parcelable { mBitmap = HardwareBitmapBundler.bundleToHardwareBitmap(in.readTypedObject(Bundle.CREATOR)); mBoundsInScreen = in.readTypedObject(Rect.CREATOR); mInsets = in.readTypedObject(Insets.CREATOR); mDisplayId = in.readInt(); } @WindowManager.ScreenshotType Loading Loading @@ -113,6 +117,10 @@ public class ScreenshotRequest implements Parcelable { return mTopComponent; } public int getDisplayId() { return mDisplayId; } @Override public int describeContents() { return 0; Loading @@ -128,6 +136,7 @@ public class ScreenshotRequest implements Parcelable { dest.writeTypedObject(HardwareBitmapBundler.hardwareBitmapToBundle(mBitmap), 0); dest.writeTypedObject(mBoundsInScreen, 0); dest.writeTypedObject(mInsets, 0); dest.writeInt(mDisplayId); } @NonNull Loading Loading @@ -161,6 +170,7 @@ public class ScreenshotRequest implements Parcelable { private int mTaskId = INVALID_TASK_ID; private int mUserId = USER_NULL; private ComponentName mTopComponent; private int mDisplayId = Display.INVALID_DISPLAY; /** * Begin building a ScreenshotRequest. Loading Loading @@ -193,7 +203,7 @@ public class ScreenshotRequest implements Parcelable { } return new ScreenshotRequest(mType, mSource, mTopComponent, mTaskId, mUserId, mBitmap, mBoundsInScreen, mInsets); mBoundsInScreen, mInsets, mDisplayId); } /** Loading Loading @@ -255,6 +265,16 @@ public class ScreenshotRequest implements Parcelable { mInsets = insets; return this; } /** * Set the display ID for this request. * * @param displayId see {@link Display} */ public Builder setDisplayId(int displayId) { mDisplayId = displayId; return this; } } /** Loading
core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotRequestTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Insets; import android.graphics.Rect; import android.hardware.HardwareBuffer; import android.os.Parcel; import android.view.Display; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -64,10 +65,12 @@ public final class ScreenshotRequestTest { assertNull("Bitmap was expected to be null", out.getBitmap()); assertNull("Bounds were expected to be null", out.getBoundsInScreen()); assertEquals(Insets.NONE, out.getInsets()); assertEquals(Display.INVALID_DISPLAY, out.getDisplayId()); } @Test public void testProvidedScreenshot() { int displayId = 5; Bitmap bitmap = makeHardwareBitmap(50, 50); ScreenshotRequest in = new ScreenshotRequest.Builder(TAKE_SCREENSHOT_PROVIDED_IMAGE, SCREENSHOT_OTHER) Loading @@ -77,6 +80,7 @@ public final class ScreenshotRequestTest { .setBitmap(bitmap) .setBoundsOnScreen(new Rect(10, 10, 60, 60)) .setInsets(Insets.of(2, 3, 4, 5)) .setDisplayId(displayId) .build(); Parcel parcel = Parcel.obtain(); Loading @@ -92,6 +96,7 @@ public final class ScreenshotRequestTest { assertTrue("Bitmaps should be equal", out.getBitmap().sameAs(bitmap)); assertEquals(new Rect(10, 10, 60, 60), out.getBoundsInScreen()); assertEquals(Insets.of(2, 3, 4, 5), out.getInsets()); assertEquals(displayId, out.getDisplayId()); } @Test Loading