isDebugSigned static method

bool? isDebugSigned(
  1. File artifact
)

True when artifact is signed with the debug key, false when it is signed with another key, and null when no signature could be read.

Looks at the APK Signature Scheme v2+ block (APKs) and the JAR signature files in META-INF/ (AABs and older APKs).

Implementation

static bool? isDebugSigned(File artifact) {
  RandomAccessFile? file;
  try {
    file = artifact.openSync();
    final length = file.lengthSync();
    final central = _findCentralDirectory(file, length);
    if (central == null) return null;

    final apkBlock = _apkSigningBlock(file, central.offset);
    final signatures = <List<int>>[
      if (apkBlock != null) apkBlock,
      ..._jarSignatureBlocks(file, central),
    ];
    if (signatures.isEmpty) return null;
    return signatures.any((s) => _contains(s, _debugName));
  } catch (_) {
    return null;
  } finally {
    file?.closeSync();
  }
}