diff options
author | Matthew Xie <mattx@google.com> | 2011-07-15 13:03:58 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2011-07-25 10:53:06 -0700 |
commit | 7f9ecca8f2dc288f785b37d2478e89b80fc3cefc (patch) | |
tree | 222a5fc71f2d5728075d15f0c99c6fa72e2226bf /core/java/android/server/BluetoothEventLoop.java | |
parent | 4a8df318b06a85a90309149ebcbff3b25077de15 (diff) | |
download | frameworks_base-7f9ecca8f2dc288f785b37d2478e89b80fc3cefc.zip frameworks_base-7f9ecca8f2dc288f785b37d2478e89b80fc3cefc.tar.gz frameworks_base-7f9ecca8f2dc288f785b37d2478e89b80fc3cefc.tar.bz2 |
Keep Bluetooth module hot to quickly swith it on/off
Add BluetoothAdapterStateMachine to maintain a inter state machine other than
the public BluetoothAdapter states. This is a improvement to BluetoothService
code. 2 internal state are added, LoadingFirmware and FirmwareLoaded to place
the Bluetooth module in a ready-to-switch-on state so that it can be quickly
switched on to have a better user experience
bug 5021787
Change-Id: Ia352e88cba509d9e98c900f85e7479f8cee1de5e
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index f345a6a..107a2a9 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -52,6 +52,7 @@ class BluetoothEventLoop { private final HashMap<String, Integer> mAuthorizationAgentRequestData; private final BluetoothService mBluetoothService; private final BluetoothAdapter mAdapter; + private final BluetoothAdapterStateMachine mBluetoothState; private BluetoothA2dp mA2dp; private BluetoothInputDevice mInputDevice; private final Context mContext; @@ -107,9 +108,11 @@ class BluetoothEventLoop { private static native void classInitNative(); /* package */ BluetoothEventLoop(Context context, BluetoothAdapter adapter, - BluetoothService bluetoothService) { + BluetoothService bluetoothService, + BluetoothAdapterStateMachine bluetoothState) { mBluetoothService = bluetoothService; mContext = context; + mBluetoothState = bluetoothState; mPasskeyAgentRequestData = new HashMap<String, Integer>(); mAuthorizationAgentRequestData = new HashMap<String, Integer>(); mAdapter = adapter; @@ -299,8 +302,8 @@ class BluetoothEventLoop { /** * Called by native code on a PropertyChanged signal from - * org.bluez.Adapter. This method is also called from Java at - * {@link BluetoothService.EnableThread#run()} to set the "Pairable" + * org.bluez.Adapter. This method is also called from + * {@link BluetoothAdapterStateMachine} to set the "Pairable" * property when Bluetooth is enabled. * * @param propValues a string array containing the key and one or more @@ -334,6 +337,15 @@ class BluetoothEventLoop { return; adapterProperties.setProperty(name, propValues[1]); + + if (name.equals("Pairable")) { + if (pairable.equals("true")) { + mBluetoothState.sendMessage(BluetoothAdapterStateMachine.BECOME_PAIRABLE); + } else { + mBluetoothState.sendMessage(BluetoothAdapterStateMachine.BECOME_NON_PAIRABLE); + } + } + int mode = BluetoothService.bluezStringToScanMode( pairable.equals("true"), discoverable.equals("true")); |