#22238: Android: security hardening to prevent screenshots of manual gateway settings
app: android
size: XS
Cluster:
Android Ed25519 Enhancements
## Summary
- Set `FLAG_SECURE` on the bottom sheet window while the Advanced manual gateway section is expanded
- Prevents screenshots and screen recording of sensitive connection credentials (host, port, gateway token, TLS config)
- Flag is scoped to the `AnimatedVisibility` composable — automatically clears when the section collapses or the sheet is dismissed
## Test plan
- [x] Open Settings → expand Advanced manual gateway section → verify screenshots are blocked
- [x] Collapse the section or dismiss the sheet → verify screenshots work again
- [x] Verify no regressions in other settings sections
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds screenshot prevention to the Advanced manual gateway settings section by setting `FLAG_SECURE` on the bottom sheet window. The flag is scoped to the `AnimatedVisibility` block containing sensitive connection details (host, port, gateway token, TLS config) and automatically clears when the section collapses.
**Key changes:**
- Adds `DisposableEffect` inside `AnimatedVisibility` to manage `FLAG_SECURE` lifecycle
- Uses `LocalView.current.parent as? DialogWindowProvider` to access the `ModalBottomSheet` window
- Safe null handling ensures graceful fallback if window reference is unavailable
**Implementation notes:**
- The window reference retrieval uses safe casting and null-safe calls, so if the `DialogWindowProvider` cast fails, the feature silently degrades without crashes
- `DisposableEffect(Unit)` correctly triggers when content enters/exits composition as `AnimatedVisibility` adds/removes content based on visibility state
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with low risk - it adds a security hardening feature with proper error handling
- The implementation follows Android best practices for screenshot prevention using `FLAG_SECURE`, includes proper lifecycle management via `DisposableEffect`, and uses defensive null-safe programming. The approach gracefully degrades if the window reference is unavailable. The only minor concern is that the window reference retrieval pattern (`LocalView.current.parent as? DialogWindowProvider`) may not work in all Compose contexts, but the safe casting ensures this won't cause crashes - it will simply fail silently without blocking screenshots
- No files require special attention
<sub>Last reviewed commit: 1b72ff0</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#22697: Android: mask gateway token as password field with visibility toggle
by SimonSchubert · 2026-02-21
74.0%
#19548: fix(android): show scaffold instead of raw JSON on canvas auth errors
by gregmousseau · 2026-02-17
69.7%
#5867: Android: Add BouncyCastle Ed25519 fallback and gateway token UI
by brandonpollack23 · 2026-02-01
69.0%
#13321: android/gateway: harden manual connect identity and A2UI UX
by m888m · 2026-02-10
69.0%
#23364: Gateway: add risk-ack interlock for dangerous Control UI flags
by bmendonca3 · 2026-02-22
68.8%
#21964: Security: harden gateway and plugin trust boundaries
by Elormyevu · 2026-02-20
66.9%
#15951: fix: Android production build permits cleartext traffic globally
by coygeek · 2026-02-14
66.6%
#11205: Android: fix gateway connection and canvas URL for Tailscale serve
by emonty · 2026-02-07
66.5%
#21326: Security/UI: harden Control UI gatewayUrl URL overrides
by bmendonca3 · 2026-02-19
66.4%
#18685: fix(ui): prevent tabnabbing in chat images
by Mariana-Codebase · 2026-02-16
66.4%