Start BLUETOOTH_SETTINGS Action Returns SecurityException (Requires BLUETOOTH_ADMIN Permission)

2

I'm trying to get to the Bluetooth Settings page on Android with this ADB command.

adb shell am start -a android.settings.BLUETOOTH_SETTINGS

However, I get a SecurityException for the response saying I need the android.permission.BLUETOOTH_ADMIN permission

Starting: Intent { act=android.settings.BLUETOOTH_SETTINGS }
Security exception: Permission Denial: starting Intent { act=android.settings.BLUETOOTH_SETTINGS flg=0x10000000 cmp=com.android.settings/.Settings$BluetoothSettingsActivity } from null (pid=19661, uid=2000) requires android.permission.BLUETOOTH_ADMIN

java.lang.SecurityException: Permission Denial: starting Intent { act=android.settings.BLUETOOTH_SETTINGS flg=0x10000000 cmp=com.android.settings/.Settings$BluetoothSettingsActivity } from null (pid=19661, uid=2000) requires android.permission.BLUETOOTH_ADMIN
at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1922)
at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:631)
at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:411)
at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1281)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:6014)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:424)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:142)
at android.os.ShellCommand.exec(ShellCommand.java:96)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:18782)
at android.os.Binder.shellCommand(Binder.java:581)
at android.os.Binder.onTransact(Binder.java:481)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4775)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3844)
at android.os.Binder.execTransact(Binder.java:682)

Any clue on how to work around this or a different method via ADB to open the Bluetooth Settings page?

android
security
bluetooth
permissions
admin

1 Answer

0

If you are looking to pair a device then you can use adb shell am start -a android.bluetooth.devicepicker.action.LAUNCH. Or you could use adb shell am start -a android.settings.SETTINGS and navigate to the Bluetooth Settings.

Otherwise, you can probably make a simple app that has the BLUETOOTH_ADMIN permission and follow the answer here

answered on Stack Overflow Dec 6, 2019 by JacquesBauer

User contributions licensed under CC BY-SA 3.0