Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Modal: FLAG_SECURE not respected in modal dialog #48317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ public class ReactModalHostView(context: ThemedReactContext) :

private fun getCurrentActivity(): Activity? = (context as ThemedReactContext).currentActivity

private fun isFlagSecureSet(activity: Activity?): Boolean {
if (activity == null) return false

val flags = activity.window.attributes.flags
return (flags and WindowManager.LayoutParams.FLAG_SECURE) != 0
}

/**
* showOrUpdate will display the Dialog. It is called by the manager once all properties are set
* because we need to know all of them before creating the Dialog. It is also smart during updates
Expand Down Expand Up @@ -293,6 +300,13 @@ public class ReactModalHostView(context: ThemedReactContext) :
if (hardwareAccelerated) {
newDialog.window?.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
}
val flagSecureSet = isFlagSecureSet(currentActivity)
if (flagSecureSet) {
newDialog.window?.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
}
if (currentActivity?.isFinishing == false) {
newDialog.show()
updateSystemAppearance()
Expand Down
Loading