MCPcopy
hub / github.com/callstack/agent-device / resolveAndroidNetworkRecoveryContext

Function resolveAndroidNetworkRecoveryContext

src/daemon/app-log.ts:302–330  ·  view source on GitHub ↗
(params: {
  device: DeviceInfo;
  appBundleId?: string;
  appLogPath: string;
  appLogState?: AppLogState;
})

Source from the content-addressed store, hash-verified

300}
301
302async function resolveAndroidNetworkRecoveryContext(params: {
303 device: DeviceInfo;
304 appBundleId?: string;
305 appLogPath: string;
306 appLogState?: AppLogState;
307}): Promise<AndroidNetworkRecoveryContext | null> {
308 const { device, appBundleId, appLogPath, appLogState } = params;
309 if (device.platform !== 'android' || !appBundleId) {
310 return null;
311 }
312 if (appLogState !== undefined && appLogState !== 'active') {
313 return { reason: 'inactive' };
314 }
315 if (appLogState !== 'active') {
316 return null;
317 }
318
319 const trackedPid = readTrackedAndroidLogcatPid(
320 path.join(path.dirname(appLogPath), APP_LOG_PID_FILENAME),
321 );
322 if (!trackedPid) {
323 return null;
324 }
325 const currentPid = await resolveAndroidPid(device.id, appBundleId);
326 if (!currentPid || currentPid === trackedPid) {
327 return null;
328 }
329 return { reason: 'stale-active', trackedPid };
330}
331
332function buildAndroidRecoveryNote(
333 context: AndroidNetworkRecoveryContext,

Callers 1

Calls 2

resolveAndroidPidFunction · 0.90

Tested by

no test coverage detected