蓝牙状态:
adb shell settings get global bluetooth_on
或
adb shell settings list global |grep ^bluetooth_on
启用蓝牙
adb shell settings put global bluetooth_on 1
禁用蓝牙
adb shell settings put global bluetooth_on 0
Via am - 使用 enable 而不是请求
adb shell am broadcast -a android.intent.action.BLUETOOTH_ENABLE --ez state true
通过按键事件
adb shell am start -a android.settings.BLUETOOTH_SETTINGS
adb shell input keyevent 19
adb shell input keyevent 23
编辑 2019-06-22:
终于找到了一种在没有 root 的情况下在 Android 8.0 和更新版本上打开/关闭蓝牙的方法,“bluetooth_on”似乎不再适用于最新的 android 版本:
启用蓝牙 - 无需 root
adb shell settings put global bluetooth_disabled_profiles 1
禁用蓝牙 - 无需 root
adb shell settings put global bluetooth_disabled_profiles 0
既然上述工作正常,那么内容当然也工作正常:
启用蓝牙 - 无需 root
adb shell content insert --uri content://settings/global --bind name:s:bluetooth_disabled_profiles --bind value:s:1 --user 0
禁用蓝牙 - 无需 root:
adb shell content insert --uri content://settings/global --bind name:s:bluetooth_disabled_profiles --bind value:s:0 --user 0