( deviceId: string, appBundleId: string, )
| 47 | } |
| 48 | |
| 49 | export async function readRecentAndroidLogcatForPackage( |
| 50 | deviceId: string, |
| 51 | appBundleId: string, |
| 52 | ): Promise<{ pid: string | null; text: string; recoveredPids: string[] } | null> { |
| 53 | assertAndroidPackageArgSafe(appBundleId); |
| 54 | const pid = await resolveAndroidPid(deviceId, appBundleId); |
| 55 | const adb = resolveAndroidAdbExecutor(androidDeviceForSerial(deviceId)); |
| 56 | const text = await captureAndroidLogcatWithAdb(adb, { lines: 4000, timeoutMs: 3_000 }).catch( |
| 57 | () => '', |
| 58 | ); |
| 59 | if (text.trim().length === 0) { |
| 60 | return null; |
| 61 | } |
| 62 | const recoveredPids = collectAndroidPackagePids(text, appBundleId, pid); |
| 63 | if (recoveredPids.length === 0) { |
| 64 | return null; |
| 65 | } |
| 66 | const filteredText = filterAndroidLogcatToPids(text, appBundleId, recoveredPids); |
| 67 | if (filteredText.trim().length === 0) { |
| 68 | return null; |
| 69 | } |
| 70 | return { pid, text: filteredText, recoveredPids }; |
| 71 | } |
| 72 | |
| 73 | export async function startAndroidAppLog( |
| 74 | deviceId: string, |
no test coverage detected