I’m currently developing an Android app using Kotlin/Jetpack Compose and have run into a persistent issue when trying to detect overlay on Samsung devices using the Popup View option. I’m trying to detect overlays using the FLAG_WINDOW_IS_PARTIALLY_OBSCURED and FLAG_WINDOW_IS_OBSCURED flags in a pointerInteropFilter as shown below:
Button(
onClick = { /* Button Click Action */ },
modifier = Modifier
.padding(16.dp)
.pointerInteropFilter { event ->
val flags = event.flags
val isPartiallyObscured = (flags and FLAG_WINDOW_IS_PARTIALLY_OBSCURED) != 0
val isFullyObscured = (flags and FLAG_WINDOW_IS_OBSCURED) != 0
val theBadTouch = isPartiallyObscured || isFullyObscured
if (event.action == ACTION_DOWN && theBadTouch) {
statusText = "Tapjack detected! (flags: $flags)"
true // Don't consume the event
} else {
false // Consume the event normally
}
}
) {
Text("Button 2")
}
This approach works perfectly on Huawei and other devices with floating windows, where tapjacking is detected successfully. However, when I run the same code on Samsung devices that are using the Popup View feature, the overlay detection doesn’t seem to work at all—nothing happens.
I have also tried using:
setHideOverlayWindows(true)
This is available starting in API level 31 and is supposed to prevent non-system overlay windows from being drawn on top of the current window, but this does not work on Samsung devices either.
Has anyone faced a similar issue or have a workaround for overlay detection on Samsung devices? Any insight into how Samsung’s Popup View differs from standard floating windows would also be appreciated!
Thanks in advance!