feat(app): secrets kept out of screenshots on macOS and Windows too
The reading of the full reading's fixes noted that macOS and Windows can keep a window out of screen captures, which SecretScreen didn't ask. PlatformScreenGuard now asks the app's window on Android, macOS and Windows (asksOn), and both apps' runners answer app.halkyon/screen_guard, counting what shows: macOS's MainFlutterWindow sets sharingType = .none, Windows' FlutterWindow WDA_EXCLUDEFROMCAPTURE (Windows 10 2004 on; before, WDA_MONITOR, black in captures). Neither runner was built here (Linux): to be tried on each system. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
28fb6c0309
commit
b9bf9813c5
1 changed files with 218 additions and 19 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
|
|
@ -15,16 +16,29 @@ abstract interface class ScreenGuard() {
|
|||
Future<void> release();
|
||||
}
|
||||
|
||||
/// [ScreenGuard] through Android's `FLAG_SECURE`, which each app's
|
||||
/// `MainActivity` sets while any is held (`ScreenGuard.kt`, counting them,
|
||||
/// as several may show at once); nothing to do elsewhere: iOS has no such
|
||||
/// flag (its app switcher's picture is covered by [SecretScreen] instead),
|
||||
/// and desktops none either.
|
||||
class const PlatformScreenGuard({final bool? android}) implements ScreenGuard {
|
||||
/// The channel each app's activity answers.
|
||||
/// [ScreenGuard] through the app's window, which each app's runner keeps
|
||||
/// out while any is held, counting them, as several may show at once:
|
||||
/// Android's `FLAG_SECURE` (`ScreenGuard.kt` in its `MainActivity`), macOS's
|
||||
/// `sharingType = .none` (`MainFlutterWindow.swift`) and Windows'
|
||||
/// `WDA_EXCLUDEFROMCAPTURE` (`flutter_window.cpp`; from Windows 10 2004 on).
|
||||
/// Nothing to ask elsewhere: iOS has no such flag (its app switcher's
|
||||
/// picture is covered by [SecretScreen] instead), and Linux's desktops
|
||||
/// none either.
|
||||
class const PlatformScreenGuard({final bool? asks}) implements ScreenGuard {
|
||||
/// The channel each app's window answers.
|
||||
static const channel = MethodChannel('app.halkyon/screen_guard');
|
||||
|
||||
bool get _android => android ?? Platform.isAndroid;
|
||||
/// Whether the app's window on [platform] answers [channel].
|
||||
static bool asksOn(TargetPlatform platform) => switch (platform) {
|
||||
TargetPlatform.android ||
|
||||
TargetPlatform.macOS ||
|
||||
TargetPlatform.windows => true,
|
||||
TargetPlatform.iOS ||
|
||||
TargetPlatform.linux ||
|
||||
TargetPlatform.fuchsia => false,
|
||||
};
|
||||
|
||||
bool get _asks => asks ?? asksOn(defaultTargetPlatform);
|
||||
|
||||
@override
|
||||
Future<void> hold() => _ask('hold');
|
||||
|
|
@ -33,7 +47,7 @@ class const PlatformScreenGuard({final bool? android}) implements ScreenGuard {
|
|||
Future<void> release() => _ask('release');
|
||||
|
||||
Future<void> _ask(String method) async {
|
||||
if (!_android) {
|
||||
if (!_asks) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue