CodeName OneShai Almog3 min readintermediate
Tapjacking Protection: Rejecting Android Touches Behind an Overlay
Summary
Codename One adds tapjacking protection to its Android runtime. It detects fully or partially obscured MotionEvents, offers four policies (OFF, REPORT, BLOCK, STRICT), can block the entire gesture, and on Android 12+ can request the system hide overlay windows. The API is exposed via `DeviceIntegrity.setTapjackingProtection` and a listener for state changes. iOS has no overlay threat, so the feat…
- Android marks touches as fully or partially obscured; Codename One surfaces this via `isScreenObscured()`.
- Four tapjacking policies let you log, block, or strictly drop gestures depending on confidence level.
- `BLOCK` is the recommended default for sensitive screens; `STRICT` also drops partially obscured touches but may reject legitimate system UI interactions.
- On Android 12+, you can request the OS to hide overlay windows with `HIDE_OVERLAY_WINDOWS` permission, combined with `setSecureScreen(true)` for screen‑capture protection.
Tapjacking can trick users into confirming financial or permission actions by overlaying UI elements. By detecting and optionally blocking obscured touches, apps can prevent unauthorized actions without relying on user vigilance, raising the security baseline for mobile payments and sensitive flows.
6/10