Add mobile app switcher privacy setting#3063
Conversation
Adds a mobile-only app switcher privacy mode with Off, App lock, and Always options, defaulting to Always. The setting hides app content from recents/app switcher views without blocking normal foreground screenshots. On Android 13+, uses the platform recents screenshot API. On Android 12L and older, applies FLAG_SECURE only while the app is leaving the foreground and clears it again on resume. On iOS and other mobile lifecycle snapshots, shows a full-screen privacy cover while inactive, hidden, or paused. Also adds Security settings UI and tests for the privacy mode logic, lifecycle cover behavior, and native channel calls.
| } | ||
|
|
||
| override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
| // do nothing, because the engine was been configured in provideEngine |
There was a problem hiding this comment.
There are packages on pub.dev which can do this so I don't have to maintain it
There was a problem hiding this comment.
Not really. The closest ones either keep FLAG_SECURE enabled while protection is active, which blocks foreground screenshots, or still require MainActivity lifecycle integration for app switcher only behavior.
The Android 13+ part of this PR uses setRecentsScreenshotEnabled(false), which none of the packages expose. That API is the reason screenshots remain allowed while Recents is hidden on Android 13+, and is the idiomatic way to do so.
I could if you prefer,
- switch to a package even if that means foreground screenshots are blocked while enabled, or
- first propose/add setRecentsScreenshotEnabled support upstream to a package such as screen_protector?
There was a problem hiding this comment.
@krille-chan Let me know because if you prefer the 2nd option then it'll take time to upstream those changes in the flutter package as well
Adds a mobile-only app switcher privacy mode with Off, App lock, and Always options, defaulting to Always. The setting hides app content from recents/app switcher views without blocking normal foreground screenshots.
On Android 13+, uses the platform recents screenshot API. On Android 12L and older, applies FLAG_SECURE only while the app is leaving the foreground and clears it again on resume. On iOS and other mobile lifecycle snapshots, shows a full-screen privacy cover while inactive, hidden, or paused.
Closes #2453
Pull Request has been tested on: