Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control bluetooth operations using adb shell?

I am working on automating bluetooth actions on android like enable/disable, pairing/unpairing devices etc.

I want to know how to interact with unrooted android device for above mentioned bluetooth operations using adb shell commands or android intents.

For example, i want to know which devices are bluetooth paired with my android phone using adb shell commands.

is it possible?

like image 966
vasanthfriend Avatar asked Sep 04 '14 06:09

vasanthfriend


People also ask

How to control Android device with ADB shell commands?

As soon as you execute an ‘adb shell’ command on the command terminal, it sends a signal to your Android device and triggers the remote shell command console. Thus ADB shell commands let you control your Android device.

How to enable/disable Bluetooth on Android devices using adb?

To enable & disable Bluetooth using below adb commands needs your device to be rooted or if you are working on android development, your android should be userdebug build with root access.,

What is ADB command in Linux?

ADB Shell commands provide access to a Unix Shell that runs a command directly on your Android device. As soon as you execute an ‘adb shell’ command on the command terminal, it sends a signal to your Android device and triggers the remote shell command console. Thus ADB shell commands let you control your Android device.

How do I use ADB on Android emulator?

The Android Debug Bridge (adb) provides a Unix shell that you can use to run a variety of commands on an emulator or connected device. The command binaries are stored in the file system of the emulator or device, at /system/bin/... You can use the shell command to issue commands, with or without entering the adb remote shell on the emulator/device.


1 Answers

dumpsys is your friend:

  • Find your bluetooth service (must be running): adb shell dumpsys -l
  • Mine is bluetooth_manager, so I run: adb shell dumpsys bluetooth_manager
  • In output you can find section "Bonded devices"
like image 171
lojza Avatar answered Oct 26 '22 17:10

lojza