agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
1 lines • 1.75 kB
JavaScript
import{O as e,v as t}from"./sdk-contracts.js";import{n}from"./adb-failure.js";import{o as r}from"./adb.js";import{n as i,t as a}from"./settings-global-toggle.js";import{t as o}from"./inventory-parsers.js";const s=`android.hardware.bluetooth`,c={service:`bluetooth`,row:`bluetooth_on`,label:`Bluetooth`,stateKey:`bluetooth`,parseRow:e=>{if(e===`1`)return`enabled`;if(e===`0`||e===`2`)return`disabled`},notAppliedReason:`bluetooth-not-applied`,unreadableReason:`bluetooth-unreadable`,sampleIntervalMs:200,hint:"A device policy or user restriction can block Bluetooth changes. Run `adb shell settings get global bluetooth_on` to see what the device holds."};async function l(n,r,i){try{await u(n,i)}catch(n){throw n instanceof t?e(n,`no`):n}return await a(n,c,r,i)}async function u(e,a){let c=await r(e,[`pm`,`list`,`features`],{allowFailure:!0,signal:a});if(c.exitCode!==0)throw n(`Failed to read Android device features`,c,{deviceId:e.id});if(!o(c.stdout,s))throw new t(`UNSUPPORTED_OPERATION`,`This Android device has no Bluetooth adapter, so nothing was changed.`,{reason:`android_bluetooth_adapter_missing`,deviceId:e.id,hint:`Some emulator images ship without Bluetooth. Use a device or emulator image whose pm list features includes ${s}.`});let{sdkInt:l,result:u}=await i(e,a);if(l===null)throw n(`Failed to read the Android API level, so nothing was changed.`,u,{deviceId:e.id});if(l<27)throw new t(`UNSUPPORTED_OPERATION`,`This Android build has no shell command for Bluetooth, so nothing was changed.`,{reason:`android_bluetooth_command_unavailable`,deviceId:e.id,sdkInt:l,hint:`settings bluetooth needs svc bluetooth, which requires Android 8.1 (API 27) or newer. Use a newer device or emulator image.`})}export{l as setAndroidBluetooth};