Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I have a rooted Galaxy S 2 (I9100) and was wondering if I can restart the Bluetooth on my phone via the terminal client on my phone.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

The following terminal command should enable Bluetooth via adb shell or Terminal Emulator app:

su
am start -a android.bluetooth.adapter.action.REQUEST_ENABLE

On most versions of Android, this command will present a pop-up window to the user asking to confirm request to enable BT. I believe this was done for security purposes whenever an app that is not system is toggling BT.

I haven't found a way to disable BT via a shell command unfortunately.

With WiFi it's a lot easier, and does not prompt user for permission:

su
svc wifi enable

will turn it on, and

su
svc wifi disable

will turn it off.

share|improve this answer
    
Thanks for the answer. I'll try the same. Could you also list the same for WiFi? –  Clyde Lobo Apr 5 '12 at 9:43
    
Edited my answer with the WiFi info. I haven't found a way to disable BT via a terminal command though :( –  Chahk Apr 5 '12 at 12:42
add comment

in android.bluetooth.IBluetoothManager, there some parameters

TRANSACTION_registerAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); TRANSACTION_unregisterAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); TRANSACTION_registerStateChangeCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2); TRANSACTION_unregisterStateChangeCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3); TRANSACTION_isEnabled = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4); TRANSACTION_enable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5); TRANSACTION_enableNoAutoConnect = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6); TRANSACTION_disable = (android.os.IBinder.FIRST_CALL_TRANSACTION + 7);
TRANSACTION_getAddress = (android.os.IBinder.FIRST_CALL_TRANSACTION + 8); TRANSACTION_getName = (android.os.IBinder.FIRST_CALL_TRANSACTION + 9);

android.os.IBinder.FIRST_CALL_TRANSACTION=1

SO, with rooted device, if you want to turn off bluetooth in adb shell super user mode (su)

service call bluetooth_manager 8

if you want to turn on bluetooth again

service call bluetooth_manager 6
share|improve this answer
    
device I use is HTC One with android 4.4.2 –  Jamy 2 days ago
add comment

Enable bluetooth:
service call bluetooth 3

Disable bluetooth:
service call bluetooth 4

share|improve this answer
    
Negative voter: could you help identifying the issue with this answer (after edit)? These worked in my rooted phone after su - so technically nothing wrong AFAIK. –  Narayanan Aug 2 '13 at 11:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.