isLocked method
SpringBoard's lock state: true locked, false unlocked, null when unreadable.
Implementation
Future<bool?> isLocked(String udid) async {
try {
final res = await runBounded(
'xcrun',
[
'simctl',
'spawn',
udid,
'notifyutil',
'-g',
'com.apple.springboard.lockstate',
],
timeout: const Duration(seconds: 8),
phase: 'reading the lock state');
if (res.exitCode != 0) return null;
return switch ((res.stdout as String).trim().split(' ').last) {
'0' => false,
'' => null,
_ => true,
};
} on Object {
return null;
}
}