OSDN Git Service

Fix for When Hf is rejected the device should initiate A2dp if a2dp is enabled
authorSwaminatha Balaji <swbalaji@broadcom.com>
Mon, 25 Jun 2012 11:04:09 +0000 (04:04 -0700)
committerMatthew Xie <mattx@google.com>
Fri, 27 Jul 2012 04:59:16 +0000 (21:59 -0700)
Change-Id: I15d3d6c8456e94553f479009c600dca1cd2361ac

src/com/android/bluetooth/a2dp/A2dpStateMachine.java
src/com/android/bluetooth/hfp/HeadsetStateMachine.java

index 7513763..4f43d43 100644 (file)
@@ -224,6 +224,8 @@ final class A2dpStateMachine extends StateMachine {
                     //reject the connection and stay in Disconnected state itself
                     Log.i(TAG,"Incoming A2DP rejected");
                     disconnectA2dpNative(getByteAddress(device));
+                    // the other profile connection should be initiated
+                    broadcastConnectOtherProfilesIntent(device);
                 }
                 break;
             case CONNECTION_STATE_CONNECTED:
@@ -241,6 +243,8 @@ final class A2dpStateMachine extends StateMachine {
                     //reject the connection and stay in Disconnected state itself
                     Log.i(TAG,"Incoming A2DP rejected");
                     disconnectA2dpNative(getByteAddress(device));
+                    // the other profile connection should be initiated
+                    broadcastConnectOtherProfilesIntent(device);
                 }
                 break;
             case CONNECTION_STATE_DISCONNECTING:
@@ -633,6 +637,15 @@ final class A2dpStateMachine extends StateMachine {
         return deviceList;
     }
 
+    private void broadcastConnectOtherProfilesIntent(BluetoothDevice device) {
+        // send other profile connect intent
+        if (DBG) log("Other Profile Connect intent sent " + device);
+
+        Intent intent = new Intent(BluetoothProfile.ACTION_CONNECT_OTHER_PROFILES);
+        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+        mContext.sendBroadcast(intent, A2dpService.BLUETOOTH_PERM);
+    }
+
     // This method does not check for error conditon (newState == prevState)
     private void broadcastConnectionState(BluetoothDevice device, int newState, int prevState) {
 
index 15712dc..a60b9ea 100755 (executable)
@@ -311,8 +311,6 @@ final class HeadsetStateMachine extends StateMachine {
                 // CONNECTION_STATE_CONNECTING and CONNECTION_STATE_CONNECTED.
                 if (BluetoothProfile.PRIORITY_OFF < mService.getPriority(device)) {
                     Log.i(TAG,"Incoming Hf accepted");
-                    // TODO(BT) Assume it's incoming connection
-                    //     Do we need to check priority and accept/reject accordingly?
                     broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING,
                                              BluetoothProfile.STATE_DISCONNECTED);
                     synchronized (HeadsetStateMachine.this) {
@@ -323,6 +321,8 @@ final class HeadsetStateMachine extends StateMachine {
                     Log.i(TAG,"Incoming Hf rejected");
                     //reject the connection and stay in Disconnected state itself
                     disconnectHfpNative(getByteAddress(device));
+                    // the other profile connection should be initiated
+                    broadcastConnectOtherProfilesIntent(device);
                 }
                 break;
             case HeadsetHalConstants.CONNECTION_STATE_CONNECTED:
@@ -340,6 +340,8 @@ final class HeadsetStateMachine extends StateMachine {
                     //reject the connection and stay in Disconnected state itself
                     Log.d(TAG,"Incoming Hf rejected");
                     disconnectHfpNative(getByteAddress(device));
+                    // the other profile connection should be initiated
+                    broadcastConnectOtherProfilesIntent(device);
                 }
 
                 break;
@@ -1223,6 +1225,15 @@ final class HeadsetStateMachine extends StateMachine {
         mService.sendBroadcast(intent, HeadsetService.BLUETOOTH_PERM);
     }
 
+    private void broadcastConnectOtherProfilesIntent(BluetoothDevice device) {
+        // send other profile connect intent
+        if (DBG) log("Other Profile Connect intent sent " + device);
+
+        Intent intent = new Intent(BluetoothProfile.ACTION_CONNECT_OTHER_PROFILES);
+        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+        mService.sendBroadcast(intent, HeadsetService.BLUETOOTH_PERM);
+    }
+
     private void broadcastAudioState(BluetoothDevice device, int newState, int prevState) {
         if(prevState == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
             // When SCO gets disconnected during call transfer, Virtual call