diff options
author | Nitin Arora <niarora@codeaurora.org> | 2015-09-04 16:19:21 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:25:58 -0600 |
commit | 9a6a57621d81e7c83fb5ba72aea93110e788b646 (patch) | |
tree | 7b9c75c18f7f83a4d923ad75d429e7b927e3954b /src/com/android/bluetooth/btservice | |
parent | 7bd835700185d7a52de11a527715ef3f13d688f5 (diff) | |
download | android_packages_apps_Bluetooth-9a6a57621d81e7c83fb5ba72aea93110e788b646.tar.gz android_packages_apps_Bluetooth-9a6a57621d81e7c83fb5ba72aea93110e788b646.tar.bz2 android_packages_apps_Bluetooth-9a6a57621d81e7c83fb5ba72aea93110e788b646.zip |
Bluetooth: Tracking the devices added using BLE On Apps
This change keeps a hashset of the devices connected using BLE Always
On Apps, so that when ACL disconnection callbacks are received in
STATE_BLE_ON or BLE_TURNING_OFF, the BLE_ACL_DISCONNECTED broadcast
is sent to only those ACL connections wheras the other devices
disconnecting due to reasons such as BT turn Off or SSR can still
receive ACL_DISCONNECTED intents.
Change-Id: I19b0f257d53f9d0e5590316b06088852ccd32804
Diffstat (limited to 'src/com/android/bluetooth/btservice')
-rw-r--r-- | src/com/android/bluetooth/btservice/RemoteDevices.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/bluetooth/btservice/RemoteDevices.java b/src/com/android/bluetooth/btservice/RemoteDevices.java index 729188ad3..48bc4c0da 100644 --- a/src/com/android/bluetooth/btservice/RemoteDevices.java +++ b/src/com/android/bluetooth/btservice/RemoteDevices.java @@ -30,10 +30,12 @@ import com.android.bluetooth.Utils; import java.util.concurrent.atomic.AtomicInteger; import java.util.ArrayList; import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; final class RemoteDevices { - private static final boolean DBG = false; + private static final boolean DBG = true; private static final String TAG = "BluetoothRemoteDevices"; @@ -47,11 +49,14 @@ final class RemoteDevices { private HashMap<BluetoothDevice, DeviceProperties> mDevices; + private Set<BluetoothDevice> mBleOnDevices; + RemoteDevices(AdapterService service) { mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapterService = service; mSdpTracker = new ArrayList<BluetoothDevice>(); mDevices = new HashMap<BluetoothDevice, DeviceProperties>(); + mBleOnDevices = new HashSet<BluetoothDevice>(); } @@ -61,6 +66,9 @@ final class RemoteDevices { if (mDevices != null) mDevices.clear(); + + if (mBleOnDevices != null) + mBleOnDevices.clear(); } @Override @@ -344,6 +352,9 @@ final class RemoteDevices { intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED); } else if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON) { intent = new Intent(BluetoothAdapter.ACTION_BLE_ACL_CONNECTED); + /* also save the device into LE always on device list */ + debugLog("aclStateChangeCallback: added device to Ble ON list"); + mBleOnDevices.add(device); } debugLog("aclStateChangeCallback: State:Connected to Device:" + device); } else { @@ -353,10 +364,14 @@ final class RemoteDevices { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM); } - if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_TURNING_OFF) { - intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED); - } else if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_OFF) { + if ((state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_OFF) && + (mBleOnDevices.contains(device))) { intent = new Intent(BluetoothAdapter.ACTION_BLE_ACL_DISCONNECTED); + debugLog("aclStateChangeCallback: removing device from Ble Always On List"); + mBleOnDevices.remove(device); + } else { + intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED); + debugLog("aclStateChangeCallback: sending ACL disconnected intent"); } debugLog("aclStateChangeCallback: State:DisConnected to Device:" + device); } |