androidPackageForPid method
The Android package whose process is pid on serial, or null when adb cannot tell.
Implementation
Future<String?> androidPackageForPid(String serial, int pid) async {
try {
final res = await runBounded(adbPath, ['-s', serial, 'shell', 'cat', '/proc/$pid/cmdline'],
timeout: const Duration(seconds: 3), phase: 'adb cmdline');
final name = (res.stdout as String).replaceAll('\u0000', '').trim().split(':').first;
return RegExp(r'^[A-Za-z][\w]*(\.\w+)+$').hasMatch(name) ? name : null;
} on Object {
return null;
}
}