support media projection feature for android 14 #1552
Merged
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.
After AOS 14, changeCaptureFormat() should resize the VirtualDisplay instead of recreating it due to the limitation on reusing MediaProjectionPermissionResultData. And it is necessary to obtain capture permission first and request foreground service; otherwise, the app crashes due to the media projection permission policy.
Use Helper.requestCapturePermission() to obtain capture permission on Android 14 specially targetSdkVersion 34 or above.
Tested on Android 13, 14 and targetSdkVersion 33, 34 combinations.