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
Enabling Bluetooth via adb shell without user interaction or root access is restricted by Android's security policies. Here's why your attempts fail and alternatives:
Why Attempts Fail Below Reasons
bluetooth_manager enable
: Fails due to BluetoothManagerService
enforcing checkIfCallerIsForegroundUser
, blocking non-foreground users like adb shell
.adb shell am start:
Shows a permission dialog that requires user action.Alternatives
adb root
adb shell service call bluetooth_manager 6
Without root, automation or creating a privileged app is your best option.