getReportRaw method

  1. @override
Future<Map<String, Object?>> getReportRaw()
override

Collects device trust signals as a raw map.

Platform implementations should return the six boolean signal keys and:

  • flags (non-negative int; optional for legacy implementations)
  • rootedOrJailbroken (bool)
  • emulator (bool)
  • devModeEnabled (bool)
  • adbEnabled (bool)
  • fridaSuspected (bool)
  • debuggerAttached (bool)
  • details (Map<String, dynamic>)

DeviceTrustReport prefers flags when available and derives it from the six legacy boolean keys otherwise.

Implementation

@override
Future<Map<String, Object?>> getReportRaw() async {
  final Object? result = await _channel.invokeMethod<Object?>(
    'getDeviceTrustReport',
  );

  if (result == null) {
    throw PlatformException(
      code: 'NULL_RESULT',
      message: 'device_trust returned null',
    );
  }

  // Keep accepting the original verbose map during upgrades where the Dart
  // package and native plugin may temporarily be on different versions.
  if (result is Map<Object?, Object?>) {
    return result.map((key, value) => MapEntry(key.toString(), value));
  }

  if (result is! List<Object?> || result.length != 3) {
    throw _invalidReportPayload();
  }

  final version = result[0];
  final flags = result[1];
  final details = result[2];

  if (version is! int ||
      version != _reportProtocolVersion ||
      flags is! int ||
      flags < 0 ||
      details is! Map<Object?, Object?> ||
      details.keys.any((key) => key is! String)) {
    throw _invalidReportPayload();
  }

  return {
    'flags': flags,
    'rootedOrJailbroken': DeviceTrustFlag.rootedOrJailbroken.isSetIn(flags),
    'emulator': DeviceTrustFlag.emulator.isSetIn(flags),
    'devModeEnabled': DeviceTrustFlag.devModeEnabled.isSetIn(flags),
    'adbEnabled': DeviceTrustFlag.adbEnabled.isSetIn(flags),
    'fridaSuspected': DeviceTrustFlag.fridaSuspected.isSetIn(flags),
    'debuggerAttached': DeviceTrustFlag.debuggerAttached.isSetIn(flags),
    'details': Map<String, Object?>.from(details),
  };
}