You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过命令行(优先adb shell)开启蓝牙?已尝试多方法均失败

无弹窗通过ADB开启蓝牙的方案探索

已尝试方法的问题总结

  • bluetooth_manager enable:在BluetoothManagerService.java::checkIfCallerIsForegroundUser校验失败,shell用户(UID 2000)被系统框架禁止执行该操作。
  • service call bluetooth_manager 3:因BluetoothManager空指针引用调用失败。
  • adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE:会触发权限确认弹窗,虽可自动化,但需无弹窗方案。

替代方案

1. Root环境下修改系统设置

设备root后可直接修改全局设置并重启蓝牙服务:

# 设置蓝牙为开启状态
adb shell settings put global bluetooth_on 1
# 重启蓝牙服务(先关后开确保生效)
adb shell service call bluetooth_manager 4
adb shell service call bluetooth_manager 3

2. Android 10+ 使用cmd bluetooth命令(需权限)

Android 10及以上支持cmd bluetooth工具,先为shell授予权限再执行:

# 授予shell蓝牙权限
adb shell pm grant com.android.shell android.permission.BLUETOOTH_ADMIN
adb shell pm grant com.android.shell android.permission.BLUETOOTH
# 开启蓝牙
adb shell cmd bluetooth enable

部分定制ROM可能仍限制该操作,需视设备情况而定。

3. 定制轻量应用(无root)

开发仅含蓝牙开启逻辑的应用,提前通过ADB授予权限后启动:

  • 应用核心逻辑(Java):
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null && !adapter.isEnabled()) {
    adapter.enable();
}
  • ADB操作命令:
# 提前授予应用权限
adb shell pm grant com.your.app.package android.permission.BLUETOOTH_ADMIN
adb shell pm grant com.your.app.package android.permission.BLUETOOTH
# 启动应用执行开启操作
adb shell am start -n com.your.app.package/.EnableBluetoothActivity

内容的提问来源于stack exchange,提问作者Nandish R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 18:47:07