OSDN Git Service

Bluetooth: Ignore second connect request
authorAnubhavGupta <anubhavg@codeaurora.org>
Fri, 15 Apr 2016 09:52:01 +0000 (15:22 +0530)
committerLinux Build Service Account <lnxbuild@localhost>
Wed, 24 Aug 2016 14:13:05 +0000 (08:13 -0600)
If due to UI sluggishness or because of some faulty
third-party app triggering multiple connect requests,
frameworks receives two back to back connect requests
for the same device, ignore the second connect request
in frameworks itself.

Change-Id: I77de0c2bde91891260e6198b2236ca27d253b839

packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java
packages/SettingsLib/src/com/android/settingslib/bluetooth/HeadsetProfile.java

index 9608daa..b9fb5aa 100755 (executable)
@@ -116,7 +116,11 @@ public final class A2dpProfile implements LocalBluetoothProfile {
         List<BluetoothDevice> sinks = getConnectedDevices();
         if (sinks != null) {
             for (BluetoothDevice sink : sinks) {
-                mService.disconnect(sink);
+                if (sink.equals(device)) {
+                    // Connect to same device, Ignore it
+                    Log.d(TAG,"Not disconnecting device = " + sink);
+                    return true;
+                }
             }
         }
         return mService.connect(device);
index 5529866..6e1d4f0 100755 (executable)
@@ -115,7 +115,11 @@ public final class HeadsetProfile implements LocalBluetoothProfile {
         List<BluetoothDevice> sinks = mService.getConnectedDevices();
         if (sinks != null) {
             for (BluetoothDevice sink : sinks) {
-                Log.d(TAG,"Not disconnecting device = " + sink);
+                if (sink.equals(device)) {
+                    // Connect to same device, Ignore it
+                    Log.d(TAG,"Not disconnecting device = " + sink);
+                    return true;
+                }
             }
         }
         return mService.connect(device);