Skip to content

Commit ddf9463

Browse files
committed
fix(android): bound the description probe at 2s and pin both props in fixtures
1 parent 240f49b commit ddf9463

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎packages/platform-android/src/inventory.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const scope: PlatformRequestScope = {
1717
const RUNNING_EMULATOR_PROBES: ReadonlyArray<readonly [string, string]> = [
1818
['ro.boot.qemu.avd_name', 'Pixel_9_Pro_XL\n'],
1919
['sys.boot_completed', '1\n'],
20-
['ro.product.model', 'sdk_gphone16k_arm64\n17\n'],
20+
['getprop ro.product.model; getprop ro.build.version.release', 'sdk_gphone16k_arm64\n17\n'],
2121
['ro.build.characteristics', 'phone\n'],
2222
['has-feature', 'false\n'],
2323
['pm\0list\0features', ''],
@@ -64,7 +64,15 @@ test.each([
6464
: []),
6565
],
6666
);
67-
assert.ok(calls.every((call) => call.timeoutMs === 10_000));
67+
const isDescriptionProbe = (call: HostCommandRequest) =>
68+
call.args.some((arg) => arg.includes('ro.product.model'));
69+
assert.deepEqual(
70+
calls.filter(isDescriptionProbe).map((call) => call.timeoutMs),
71+
[2_000],
72+
);
73+
assert.ok(
74+
calls.filter((call) => !isDescriptionProbe(call)).every((call) => call.timeoutMs === 10_000),
75+
);
6876
assert.ok(calls.every((call) => call.allowFailure === true));
6977
},
7078
);
@@ -74,7 +82,7 @@ test.each([
7482
[
7583
'times out',
7684
async () => {
77-
throw new AppError('COMMAND_FAILED', 'adb timed out after 10000ms', { timeoutMs: 10_000 });
85+
throw new AppError('COMMAND_FAILED', 'adb timed out after 2000ms', { timeoutMs: 2_000 });
7886
},
7987
],
8088
] as const)(

‎packages/platform-android/src/inventory.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from './inventory-parsers.ts';
2626

2727
const PROBE_TIMEOUT_MS = 10_000;
28+
const DEVICE_DESCRIPTION_TIMEOUT_MS = 2_000;
2829
const DEVICE_DESCRIPTION_PROBE = shellFragment(
2930
'getprop ro.product.model; getprop ro.build.version.release',
3031
);
@@ -146,7 +147,12 @@ async function readDeviceDescription(
146147
serial: string,
147148
): Promise<Pick<DeviceInfo, 'model' | 'osVersion'>> {
148149
try {
149-
const result = await runAdbShell(context, serial, [DEVICE_DESCRIPTION_PROBE]);
150+
const result = await runAdbShell(
151+
context,
152+
serial,
153+
[DEVICE_DESCRIPTION_PROBE],
154+
DEVICE_DESCRIPTION_TIMEOUT_MS,
155+
);
150156
return result.exitCode === 0 ? parseAndroidDeviceDescription(result.stdout) : {};
151157
} catch (error) {
152158
if (context.scope.signal.aborted) throw error;
@@ -264,22 +270,24 @@ async function runAdbShell(
264270
context: AndroidInventoryContext,
265271
serial: string,
266272
words: readonly ShellWord[],
273+
timeoutMs = PROBE_TIMEOUT_MS,
267274
): Promise<HostCommandResult> {
268-
return await run(context, context.adb, adbShellArgv(serial, words));
275+
return await run(context, context.adb, adbShellArgv(serial, words), timeoutMs);
269276
}
270277

271278
async function run(
272279
context: AndroidInventoryContext,
273280
executable: string,
274281
args: readonly string[],
282+
timeoutMs = PROBE_TIMEOUT_MS,
275283
): Promise<HostCommandResult> {
276284
try {
277285
return await context.host.commands.run(
278286
{
279287
executable,
280288
args,
281289
allowFailure: true,
282-
timeoutMs: PROBE_TIMEOUT_MS,
290+
timeoutMs,
283291
},
284292
context.scope.signal,
285293
);

‎src/managed-device-reachability.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ test.skipIf(process.platform === 'win32')(
102102
String.raw` ? "1\n"`,
103103
' : args.includes("ro.build.characteristics")',
104104
String.raw` ? "phone\n"`,
105-
' : args.some((arg) => arg.includes("ro.product.model"))',
105+
' : args.some((arg) => arg.includes("ro.product.model") && arg.includes("ro.build.version.release"))',
106106
String.raw` ? "sdk_gphone64_arm64\n16\n"`,
107107
' : args.includes("has-feature") || args.includes("pm")',
108108
String.raw` ? "false\n"`,

0 commit comments

Comments
 (0)