//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:
//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:
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) {
// 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) {
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:
//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;
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