feat(android): add screenshotStrategy option to force yadb screenshots - #2939
Merged
Conversation
Deploying midscene with
|
| Latest commit: |
4eb50c9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://90117bdd.midscene.pages.dev |
| Branch Preview URL: | https://feat-android-screenshot-stra.midscene.pages.dev |
Add a new 'screenshotStrategy' Android device option ('auto' | 'always-yadb')
that lets users default to yadb-based screenshots, e.g. to capture FLAG_SECURE
pages that screencap renders as black.
- core/android: implement screenshotBase64ViaYadb() and strategy check in
screenshotBase64(), plus MIDSCENE_ANDROID_SCREENSHOT_STRATEGY env var
- cli: document --android.screenshot-strategy in help text
- visualizer: wire screenshotStrategy through store, config selector UI
and playground execution (mirroring imeStrategy)
- site: document screenshotStrategy in en/zh android and reference docs
Tests: core, android, cli, visualizer unit suites pass; biome lint clean.
quanru
force-pushed
the
feat/android-screenshot-strategy
branch
2 times, most recently
from
August 7, 2026 08:13
936661e to
4eb50c9
Compare
Address review feedback on the Android screenshotStrategy docs: - Clarify that `auto` does not analyze screenshot content: a command that succeeds but returns a black frame will not trigger a yadb fallback; the next method is only tried when the previous one fails to execute. - Note that scrcpy is only tried when `scrcpyConfig.enabled` is on, and that yadb is used only as a fallback when `screencap` fails. - Reword `always-yadb` as bypassing the default auto flow (adb.takeScreenshot, screencap, and scrcpy when enabled) instead of the vague "skips earlier paths". - Make the Android-version / root + Magisk hook / FLAG_SECURE notes conditional: actual behavior depends on Android version, ROM, root/hook environment, and device configuration; advise verifying on the device.
quanru
force-pushed
the
feat/android-screenshot-strategy
branch
from
August 7, 2026 08:16
4eb50c9 to
027248b
Compare
EAGzzyCSL
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR adds a new
screenshotStrategyAndroid device option ('auto' | 'always-yadb') that lets users default to yadb-based screenshots. This is useful for capturingFLAG_SECUREpages (e.g. password entry screens in banking/payment apps) thatscreencaprenders as black frames.Why
When
screencapcaptures aFLAG_SECUREpage, the secure region appears black. The yadb tool creates a virtual display via thesecureparameter ofSurfaceControl.createDisplay, which can capture secure content directly on Android 11 and below (and on Android 12+ with root + Magisk hook). Users needed a way to force yadb screenshots instead of relying on the default fallback chain.What
screenshotBase64ViaYadb()and strategy check inscreenshotBase64(); addMIDSCENE_ANDROID_SCREENSHOT_STRATEGYenv var--android.screenshot-strategyin help textscreenshotStrategythrough store (with localStorage persistence), config selector UI, and playground execution — mirroring the existingimeStrategyintegrationscreenshotStrategyin en/zh Android and reference docsUsage
YAML:
Env var:
export MIDSCENE_ANDROID_SCREENSHOT_STRATEGY=always-yadbThe default is
auto, which tries scrcpy →adb.takeScreenshot→screencap→ yadb in order.always-yadbskips the earlier paths. Note yadb can only capture the default display (displayId=0).Validation
pnpm run lint(biome clean)npx nx test @midscene/core— 1385 passed, 8 skippednpx nx test @midscene/android— 352 passednpx nx test @midscene/cli— 203 passednpx nx test @midscene/visualizer— 109 passednpx nx build @midscene/visualizer— success