Skip to content

Commit

Permalink
Updates captureToBitmap in ViewCapture to treat API 34 the same way t…
Browse files Browse the repository at this point in the history
…hat all previous API works.

Because API 34 wasn't getting the surface, it was including the action bar and messing up the screenshots. By removing it, it will use the surface instead and it works perfectly.

PiperOrigin-RevId: 588915479
  • Loading branch information
copybara-androidxtest committed Dec 19, 2023
1 parent dd3de37 commit 9a5eb38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

**Bug Fixes**

* ViewCapture.captureToBitmap API 34 now uses the surface directly to take the screenshot.

**New Features**

**Breaking Changes**
Expand Down
1 change: 0 additions & 1 deletion core/java/androidx/test/core/view/ViewCapture.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ private fun View.generateBitmap(bitmapFuture: ResolvableFuture<Bitmap>, rect: Re
val destBitmap = Bitmap.createBitmap(rectWidth, rectHeight, Bitmap.Config.ARGB_8888)
when {
Build.VERSION.SDK_INT < 26 -> generateBitmapFromDraw(destBitmap, bitmapFuture, rect)
Build.VERSION.SDK_INT >= 34 -> generateBitmapFromPixelCopy(destBitmap, bitmapFuture, rect)
this is SurfaceView -> generateBitmapFromSurfaceViewPixelCopy(destBitmap, bitmapFuture, rect)
else -> generateBitmapFromPixelCopy(this.getSurface(), destBitmap, bitmapFuture, rect)
}
Expand Down

0 comments on commit 9a5eb38

Please sign in to comment.