android enable disable bluetooth via command line
출처 : https://stackoverflow.com/questions/37259260/android-enable-disable-bluetooth-via-command-line
Version:1.0 StartHTML:000000257 EndHTML:000008187 StartFragment:000007736 EndFragment:000008087 StartSelection:000007736 EndSelection:000008081 SourceURL:https://stackoverflow.com/questions/37259260/android-enable-disable-bluetooth-via-command-line
To enable:
To disable:
|
Find BT Mac address of android from adb.
BT Mac Address 확인하기
adb shell settings get secure bluetooth_address
or
adb shell service call bluetooth_manager 10 for Android 4.4.4
adb shell service call bluetooth_manager 12 for Android 5.0+
$ adb shell service call bluetooth_manager 12
Result: Parcel(
0x00000000: 00000000 00000011 00430030 0042003a '........0.C.:.B.'
0x00000010: 003a0038 00380041 0030003a 003a0030 '8.:.A.8.:.0.0.:.'
0x00000020: 00310034 0045003a 00000037 '4.1.:.E.7... ')
root@KM1000:/ # service
Usage: service [-h|-?]
service list
service check SERVICE
service call SERVICE CODE [i32 INT | s16 STR] ...
Options:
i32: Write the integer INT into the send parcel.
s16: Write the UTF-16 string STR into the send parcel.
/frameworks/native/cmds/service/service.cpp
에서
/frameworks/base/core/java/android/bluetooth/IBluetoothManager.aidl 여기 나온 순서대로
interface IBluetoothManager
31{
32 IBluetooth registerAdapter(in IBluetoothManagerCallback callback); ---------------1
33 void unregisterAdapter(in IBluetoothManagerCallback callback); ---------------2
34 void registerStateChangeCallback(in IBluetoothStateChangeCallback callback); ---------------3
35 void unregisterStateChangeCallback(in IBluetoothStateChangeCallback callback); ---------------4
36 boolean isEnabled(); ---------------5
37 boolean enable(String packageName); ---------------6
38 boolean enableNoAutoConnect(String packageName); ---------------7
39 boolean disable(String packageName, boolean persist); ---------------8
40 int getState(); ---------------9
41 IBluetoothGatt getBluetoothGatt();---------------10
42
43 boolean bindBluetoothProfileService(int profile, IBluetoothProfileServiceConnection proxy); ---------------11
44 void unbindBluetoothProfileService(int profile, IBluetoothProfileServiceConnection proxy); ---------------12
45
46 String getAddress(); ---------------13
47 String getName(); ---------------14
48
49 boolean isBleScanAlwaysAvailable(); ---------------15
50 int updateBleAppCount(IBinder b, boolean enable, String packageName); ---------------16
51 boolean isBleAppPresent(); ---------------17
52}
53