Add support for capturing screenshots of multiple windows with hardware bitmap support #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add support for capturing screenshots of multiple windows with hardware bitmap support
Issue:
with error:
Software rendering doesn't support hardware bitmaps.Utils.capture()is not capable of capturingscreenshots of multiple window surfaces (dialogs, bottom sheets,
Compose overlays).
Cause:
bitmaps, but modern Android apps use hardware-accelerated bitmaps
for performance improvement, causing screenshot capture to fail.
Utils.capture()which internally usesPixelCopy API that supports hardware bitmaps but could only capture
the screenshot of the main activity window and not any additional
windows layered on top (dialogs, bottom sheets, etc.).
Android's rendering system, requiring separate capture operations.
Fix:
MultiWindowScreenshotCapture.javautility class tohandle hardware-accelerated bitmap capture of multiple windows using PixelCopy API.
Shaky.java:traditional Views without hardware bitmaps).
hardware bitmaps).
Utils.capture()for main activity window only (last resort).getRootViews()to detect all active windows usingreflection into WindowManager internals.
captureMultipleAsync()method with dual capture strategy:mSurface)for per-window isolation.
ViewRootDataclass to encapsulate window hierarchy information:CollectDataTask.javato handle multiple bitmaps:Testing done
Tested locally in integrating app and verified that the changes work as expected: