androidbluetoothadbandroid-sourceandroid-13

Is there any way to turn on bluetooth using cmd line (adb shell preferably)


I tried turning on bluetooth using cmd bluetooth_manager enable:
But i see its failing a check in BluetoothManagerService.java::checkIfCallerIsForegroundUser Since the caller is shell (UID 2000). So Framework is not allowing to turn on Bluetooth

====================================
Also tried using service call bluetooth_manager 3 (call for enable api)
This is failing on Null pointer reference call from BluetoothManager

====================================
Tried with adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
This is asking for allow or deny permission, it can be automated but i am looking for any other options if there are


Solution

  • cmd bluetooth_manager enable and disable works fine in non sudo mode. (adb should not be in root mode)