I am trying to enable disable bluetooth on android device using command line.
I can enable it using
adb shell am start -a android.bluetooth.adapter.ac
For bluetooth status:
adb shell settings get global bluetooth_on
or
adb shell settings list global |grep ^bluetooth_on
Enable Bluetooth
adb shell settings put global bluetooth_on 1
Disable Bluetooth
adb shell settings put global bluetooth_on 0
Via am - Instead of request, use enable
adb shell am broadcast -a android.intent.action.BLUETOOTH_ENABLE --ez state true
Via Keyevents
adb shell am start -a android.settings.BLUETOOTH_SETTINGS
adb shell input keyevent 19
adb shell input keyevent 23
Finally figured out a way to toggle bluetooth on/off on Android 8.0 and newer versions without root, "bluetooth_on" doesn't seems to work on latest android versions anymore:
Enable Bluetooth - No root required
adb shell settings put global bluetooth_disabled_profiles 1
Disable Bluetooth - No root required
adb shell settings put global bluetooth_disabled_profiles 0
And since above works fine then of course content works fine aswell:
Enable Bluetooth - No root required
adb shell content insert --uri content://settings/global --bind name:s:bluetooth_disabled_profiles --bind value:s:1 --user 0
Disable Bluetooth - No root required:
adb shell content insert --uri content://settings/global --bind name:s:bluetooth_disabled_profiles --bind value:s:0 --user 0