MCPcopy Index your code
hub / github.com/callstack/agent-device / resolveAndroidTarget

Function resolveAndroidTarget

src/platforms/android/devices.ts:189–222  ·  view source on GitHub ↗
(serial: string)

Source from the content-addressed store, hash-verified

187}
188
189async function resolveAndroidTarget(serial: string): Promise<'mobile' | 'tv'> {
190 const characteristicsResult = await runCmd(
191 'adb',
192 adbArgs(serial, ['shell', 'getprop', 'ro.build.characteristics']),
193 {
194 allowFailure: true,
195 timeoutMs: ANDROID_BOOT_PROP_TIMEOUT_MS,
196 },
197 );
198 const characteristicsTarget = parseAndroidTargetFromCharacteristics(
199 commandOutput(characteristicsResult),
200 );
201 if (characteristicsTarget === 'tv') {
202 return 'tv';
203 }
204
205 if (await hasAnyAndroidTvFeature(serial)) {
206 return 'tv';
207 }
208
209 const featureListResult = await runCmd(
210 'adb',
211 adbArgs(serial, ['shell', 'pm', 'list', 'features']),
212 {
213 allowFailure: true,
214 timeoutMs: ANDROID_BOOT_PROP_TIMEOUT_MS,
215 },
216 );
217 if (parseAndroidFeatureListForTv(commandOutput(featureListResult))) {
218 return 'tv';
219 }
220
221 return 'mobile';
222}
223
224export async function listAndroidDevices(
225 options: AndroidDeviceDiscoveryOptions = {},

Callers 1

listAndroidDevicesFunction · 0.85

Calls 6

runCmdFunction · 0.90
adbArgsFunction · 0.85
commandOutputFunction · 0.85
hasAnyAndroidTvFeatureFunction · 0.85

Tested by

no test coverage detected