testing library

Test support: fake the platform side of device_safety_info in widget and unit tests.

class FakeRoot extends Fake implements RootHostApi {
  @override
  Future<CheckReportMsg> rootCheck() async => CheckReportMsg(
    signals: [SignalMsg(id: 'root.su_executable', level: SignalLevelMsg.high)],
    supported: true,
  );
}

DeviceSafety.forTesting(
  platform: DeviceSafetyPlatform(root: FakeRoot(), ffi: const FakeNativeChecks()),
);

Classes

AccessibilityServiceMsg
AppInfoHostApi
AppInfoMsg
AppSwitcherHostApi
BatchHostApi
Runs many checks in one round trip, in parallel on the platform side.
BatchRequestMsg
BatchResultMsg
BiometricHostApi
Biometric-bound keys: signing requires a fresh strong-biometric match, and enrolling a new fingerprint or face invalidates the key. Errors use the codes UNSUPPORTED, NOT_ENROLLED, CANCELLED, LOCKED_OUT, ENROLLMENT_CHANGED, KEY_MISSING and FAILED.
CallEventMsg
CallHostApi
CheckReportMsg
ClipboardHostApi
DeviceKeyHostApi
Hardware-bound signing keys (EC P-256, ECDSA with SHA-256). Errors use the codes UNSUPPORTED, KEY_MISSING and FAILED.
DeviceKeyInfoMsg
DeviceSafetyPlatform
Every platform entry point the package uses: the Pigeon host APIs, the live event streams and the native FFI checks. The default constructor uses the real ones; tests pass fakes (implement the generated API classes, or PlatformEvents / NativeChecksSource).
EnvironmentHostApi
Fraud-environment checks (Android; iOS reports unsupported).
FakeNativeChecks
A NativeChecksSource that reports the given bits (DSI_* flags), or nothing.
HookingHostApi
IntegrityHostApi
MalwareHostApi
NativeChecks
What the native C checks found. supported is false when the native library couldn't be used (not built for this platform, ABI mismatch); the signal lists are then empty.
NativeChecksSource
Source of native check results. An interface so tests can substitute a fake.
NotificationListenerMsg
OverlayAttackHostApi
OverlayConfigMsg
PlatformEvents
The live platform event streams. Each getter returns a new single-subscription stream backed by a platform event channel.
PostureHostApi
RootHostApi
ScreenProtectionHostApi
SignalMsg
One indicator. id is <check>.<signal> optionally followed by :<detail>, e.g. root.su_executable:/system/xbin/su.
SigningInfoMsg
How the app was signed, for the tampering check. Compared in Dart against DeviceSafetyConfig.expectedSigningCertificates / expectedIosTeamId.
VpnHostApi

Functions

callActivity({String instanceName = ''}) → Stream<CallEventMsg>
Returns a broadcast Stream of events from the callActivity event channel.
clipboardChanged({String instanceName = ''}) → Stream<int>
Epoch milliseconds of each clipboard change.
overlayAttack({String instanceName = ''}) → Stream<int>
Epoch milliseconds of each obscured touch (Android).
screenCaptureChanged({String instanceName = ''}) → Stream<bool>
Capture/mirroring state; the current state is sent first.
screenRecordingChanged({String instanceName = ''}) → Stream<bool>
Recording state (Android 15+, iOS); the current state is sent first.
screenshotTaken({String instanceName = ''}) → Stream<int>
Epoch milliseconds of each screenshot.
vpnChanged({String instanceName = ''}) → Stream<bool>
Whether a VPN is active, sent on every connectivity change.