Support Android 16 (Baklava) - #1
Merged
Merged
Conversation
Refactors the screen capture hooking logic to support major API changes introduced in Android 16. The previous implementation failed on newer platforms due to class, method, and field refactoring in the AOSP framework.
This commit introduces version-aware logic to handle three distinct generations of the screen capture API:
- **Android 13 and below:** Continues to use the original hook for `android.view.SurfaceControl` and its boolean `mCaptureSecureLayers` field.
- **Android 14 (Upside Down Cake):** Targets the new `android.window.ScreenCapture` class and its `CaptureArgs`, which still uses the `mCaptureSecureLayers` field.
- **Android Baklava (API 36+):** Adapts to the latest API, which includes:
- Targeting the new `android.window.ScreenCaptureInternal` class.
- Hooking the renamed methods `captureDisplay` and `captureLayers` (dropping the "native" prefix).
- Modifying the new integer-based policy fields `mSecureContentPolicy` and `mProtectedContentPolicy` by setting them to `1` to enable capture.
1 task
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.
Refactors the screen capture hooking logic to support major API changes introduced in Android 16. The previous implementation failed on newer platforms due to class, method, and field refactoring in the AOSP framework.
This commit introduces version-aware logic to handle three distinct generations of the screen capture API:
Android 13 and below: Continues to use the original hook for
android.view.SurfaceControland its booleanmCaptureSecureLayersfield.Android 14 (Upside Down Cake): Targets the new
android.window.ScreenCaptureclass and itsCaptureArgs, which still uses themCaptureSecureLayersfield.Android Baklava (API 36+): Adapts to the latest API, which includes:
android.window.ScreenCaptureInternalclass.captureDisplayandcaptureLayers(dropping the "native" prefix).mSecureContentPolicyandmProtectedContentPolicyby setting them to1to enable capture.