[Android] Modal: FLAG_SECURE
not respected in modal dialog
#48317
+14
−0
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:
Fixes #38537
Setting
WindowManager.LayoutParams.FLAG_SECURE
in the window flags is not respected in the Android Modal component, causing security issues with screenshots or screen recordings as the content in the modal is visible. The flag works correctly in the rest of the components, see the videos in the linked issue.This PR addresses that by checking whether this flag is set in the current activity and then setting it in the dialog when creating a new one in the
ReactModalHostView
.Changelog:
[ANDROID][FIXED] -
FLAG_SECURE
not respected in Modal dialogTest Plan:
To test this, you need a physical device as with the emulator the flags don't seem to be respected either.
The easiest way to test this in code is by setting the flags in the main activity. You can do so by adding this code snippet:
onCreate in RNTesterApplication.kt
Then, you can render a simple modal component:
RNTesterPlayground.js
You can then try to record the screen or take screenshots. You will notice that before opening the modal, you won't be able to see anything in the recording, but when opening the modal, the content is visible.
I've tried my best to record the before and after the fix, but as the screen recordings will mostly show a black screen, you have to forward a bit in both videos to see the difference.
Before the fix (notice the blank screen and then content visible)
Before.mp4
After the fix (notice all the screen recording is a black screen)
WhatsApp.Video.2024-12-17.at.22.36.45.mp4