Repository navigation
Sprint 1C: App-only capture & circular floating control - #4
Merged
Merged
Conversation
…ng control exists
…e, dead-code removal, honesty fixes
…only capture UI; overlay-independence fixes
…for single-app first frame
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.
Stacked on PR #3 (
sprint-1b-hero-recognition, unmerged). Do not merge before #3; nothing here merges automatically.Sprint 1C lets the user freeze/resume the MLBB capture without leaving the game: prefer Single app / app window → Mobile Legends (Android 14+ chooser; never forced), keep the last valid game frame when MLBB is hidden, and toggle LIVE/FROZEN with one small circular overlay button. No recommendation UI, panel, menu, toolbar, fullscreen overlay, accessibility service or game interaction.
What is in this PR
onCapturedContentVisibilityChanged(API 34+) wired into the CAPTURING guard; pureCaptureVisibilityPolicy(JVM-tested) gatesFramePipeline: hidden window ⇒ images acquired/closed, never converted/published; last valid game frame (and a pinned frame) preserved; visible again ⇒ live publication resumes unless pinned. Resume requested while hidden flips intent to LIVE, effective on visibility return. Freeze/resume never recreate the projection/VirtualDisplay and never create a second VirtualDisplay; resize keeps the gate state.TYPE_APPLICATION_OVERLAY+FLAG_NOT_FOCUSABLE; tap toggles via the sharedCaptureFreezepath; 400ms long-press drag; nearest-edge snap; normalized position in DataStore; re-anchored on rotation; attached only during capture; removed on every teardown path.SYSTEM_ALERT_WINDOWdeclared; requested only from the Enable toggle via Android's overlay-settings screen; denial ⇒ capture + in-app Freeze/Resume unaffected; screen explains how to grant it later.Verification (CI is the build of record; authoring host has no Android toolchain)
3c7b58c· CI run 43936524131: unit tests 926, 0 failures / 0 errors / 0 skipped; strict lint ✅;assembleAndroidTest✅;assembleDebug✅. Docs-only head9c6270fre-verified green as run 43937268586.app-debug.apk, 10,876,851 bytes — sha256ade9ec10c5d6b9d4e372b325e6b521f87170d0fa5273c9b30e9ea9063a763070(artifactdraftlens-debugon run 43936524131).SYSTEM_ALERT_WINDOWpresent in the merged manifest (utf-16-lestring scan);foregroundServiceType=0x20(mediaProjection) confirmed by the CI manifest check.docs/TESTING_PHYSICAL_DEVICE.md. Overlay-vs-capture isolation (single-app and full-display) is an on-device finding only; no exclusion claim is made and no capture region is masked.Known limitations
Follow-up (this push): notification Pause, permissions-only UI, overlay independence
Root cause of the overlay "freezing" during app-only capture: the overlay lifecycle was already decoupled from capture visibility (render, touch, window lifetime have no frame input;
onCapturedContentVisibilityChangedgates only theFramePipeline). Three real defects produced the observed behavior: (1) a silent no-op tap onNoFramein fresh app-only sessions; (2) the glyph and the notification derived only fromfrozenFrame, so a non-pin publication block (PAUSED) still showed LIVE/green; (3) no shared derivation of "is live publication happening?". Fixes: a singleCapturePublishStatederivation (pin wins over pause for presentation) now collected from a combined frozen-frame + session-state flow and shared by overlay and notification; toast feedback onNoFrame; overlay tap is the unified pause/freeze toggle. No OEM masking, no mode fallback — OEM/immersive-game overlay coverage remains a hardware finding (rows 44–53).Notification: Stop + exactly one state action — Pause while LIVE, Resume while PAUSED or FROZEN. Pause maps onto the existing
CaptureStatus.PAUSEDpipeline gate (projection and VirtualDisplay persist; latest valid frame preserved; nothing replaces it). Resume =resumeLive()+setPaused(false). No Freeze wording remains in the notification.UI slim-down: removed the capture-mode tutorial card, the floating-control tutorial card, all in-game help texts, and the stale Sprint-0 marker. Kept, in one compact Permissions card: notification permission (status + grant action) and floating-overlay permission (status + switch + Android settings action). Capture controls, live preview and sampling interval unchanged.
Tests: JVM-tested
CapturePublishStatematrix, holder pause-preservation tests, pause-visibility sequence case, instrumentedoverlaySurvivesPublicationStateFlips(compile-only; plus the existing attach/remove and orphan-attach regression tests). Instrumented tests compiled, not executed.Follow-up 2: single-app MLBB first-frame bug
Root cause (code-level): Sprint 1C registers
MediaProjection.CallbackbeforeFramePipeline.start(),createVirtualDisplay()andbeginCapture(). In single-app modethe initial
onCapturedContentVisibilityChanged(false)(MLBB hidden while the user is inDraftLens) and
onCapturedContentResize(W,H)(selected app's dimensions) both arrive inthat STARTING window. The old boolean gate either got overwritten by start()'s unconditional
trueor closed the gate before any frame existed; the early resize was ignored or treatedas fatal ("VirtualDisplay disappeared during resize"); frames published in STARTING were
dropped from the holder. Combined → zero published frames and "No frame captured yet".
Diagnostics added first (
CaptureDiagnostics, rate-limited first-4/every-20; no pixels):callback seq/value/pipelineInitialized/status, resize seq/readiness, per-acquisition image
dims/generation/isActive/generationCurrent/frozen/contentVisible, exact gate-reject reason,
sampling accept/reject, conversion result + bitmap dims, publication and holder delivery.
Run
adb logcat -v time -s CaptureSessionService FramePipelineper the A–E checklist — itanswers whether ImageReader received images that our code rejected or the platform sent none.
Fix: explicit UNKNOWN/VISIBLE/HIDDEN policy owned by the service (UNKNOWN deliberately
open; first published frame promotes to VISIBLE so later
falseis authoritative); callbacksbefore pipeline creation preserved, stale-session ones rejected, transitions idempotent;
pipeline no longer resets the gate;
PendingResizebuffers the latest valid selected-appdimensions and sizes both VirtualDisplay and ImageReader at startup, applies later values
idempotently, and no longer kills the session when the VD is not ready; holder records
frames published during STARTING. Visibility protection, Pause/Freeze, in-app controls and
overlay behavior otherwise unchanged.
Tests: JVM policy state machine, pending-resize retention, first-frame/visibility
sequences; instrumented suite compiled only. Instrumented and device tests not executed.
The A–E first-frame checklist (full-display baseline, single-app MLBB, transitions, overlay
disabled, resize incl. landscape) remains NOT RUN — this fix is NOT claimed to work on a
device from CI alone.