fix: screenshot and MediaProjection failures on Android 14+ - #2
Open
debugtalk wants to merge 1 commit into
Open
Conversation
- Add canTakeScreenshot to accessibility_service_config.xml to enable AccessibilityService.takeScreenshot() fallback on API 30+ - Create MediaProjection inside ScreenshotConsentActivity (Android 15+ requires getMediaProjection() called while Activity is visible) - Upgrade foreground service type to MEDIA_PROJECTION after user consent instead of at startup (avoids SecurityException on OEM ROMs like ColorOS) - Add AtomicBoolean guard to prevent double FGS type upgrade and reset it on MediaProjection session loss for re-authorization - Add onMediaProjectionGranted callback for FGS upgrade notification Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
9 tasks
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
Fix screenshot and MediaProjection failures on Android 14+ by restructuring the consent flow and adding the missing accessibility capability.
Type of Change
Changes
android:canTakeScreenshot="true"to accessibility service config, enablingAccessibilityService.takeScreenshot()fallback on API 30+ (capabilities bitmask was 41 instead of 169 due to missingCAPABILITY_CAN_TAKE_SCREENSHOT)getMediaProjection()call intoScreenshotConsentActivityinstead of deferring to Service, satisfying Android 15+ requirement that it must be called while a visible Activity existsMEDIA_PROJECTIONtype upgrade to after user consent, avoidingSecurityExceptionon OEM ROMs (e.g. ColorOS) that add extra permission requirementsAtomicBooleanguard to prevent double FGS type upgrade (Activity-side and Service-side callback), with proper reset on MediaProjection session loss and service destroyTesting
Protobuf Changes
No
.protofiles modified.Checklist