appInfoForDevice method
(CFBundleIdentifier, display name) of the user app running on iOS udid,
found by its Containers/Bundle/Application/…app process — device-global,
NOT correlated to our VM. Fallback only, for when the project dir is
unknown; prefer appInfoForProject.
Returns null when MORE THAN ONE distinct app is running on the sim: the scan can't tell which one owns the caller's VM, and a wrong bundleId would make kill_app terminate the wrong app. Callers fall back to the VM's authoritative package name instead of a guessed identity.
Implementation
Future<(String?, String?)?> appInfoForDevice(String udid) async {
final ProcessResult ps;
try {
ps = await runBounded('ps', ['-Axww', '-o', 'command='], timeout: const Duration(seconds: 5), phase: 'ps');
} on Object {
return null;
}
if (ps.exitCode != 0) return null;
final appPaths = flutterBundlesFirst(appBundlePathsForDevice(ps.stdout as String, udid),
isFlutter: (p) => Directory('$p/Frameworks/Flutter.framework').existsSync());
if (appPaths.length != 1) return null; // none, or ambiguous
return await _readBundleInfo(appPaths.first);
}