Revert "fix persistent audio on, Donot connect_audio when enter CONNECTED state"
This reverts commit 3ce52a01d734e73a21074ab8397cf67b16d6595f
Hi Matt,
I reviewed your changes (2), and they look good. However, your changes in (1), seem to be causing a side-effect while testing the headset connection setup while call is active/outgoing/incoming. Since this change was merged, I am sending my comments thru email.
Here is the scenario
1. No headset connection
2. Place an outgoing call, and answer it at the remote side
3. Initiate connection from headset
4. SCO seems to be setup by Java side even before SLC setup completes
ISSUE#1: Once Java receives connection event, it automatically calls connect_audio, even though SLC has not been setup
ð Can you make a change to call connect_audio, only after SLC is complete? If this difficult to do, can this code just be removed, as the stack will do automatically after SLC setup when phone_state_change is called
ISSUE#2: If we redo this for an outgoing call (call answered prior to headset connection), then the Java side does not initiate SCO audio
ð To have a consistent behavior, if Java side is setting up SCO for active call, shouldn’t we be doing the same for outgoing call too?
Thanks
Ravi
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index ab98f0d..cdefde7 100755
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -260,9 +260,6 @@
mCurrentDevice = device;
transitionTo(mConnected);
}
- if (isInCall()) {
- deferMessage(obtainMessage(CONNECT_AUDIO, mCurrentDevice));
- }
break;
case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING:
Log.w(TAG, "Ignore HF DISCONNECTING event, device: " + device);
@@ -287,7 +284,6 @@
boolean retValue = HANDLED;
switch(message.what) {
case CONNECT:
- case CONNECT_AUDIO:
deferMessage(message);
break;
case CONNECT_TIMEOUT:
@@ -426,10 +422,6 @@
mIncomingDevice = null;
transitionTo(mConnected);
}
- // All the above conditions go from disconnect/connecting to connected
- if (isInCall()) {
- deferMessage(obtainMessage(CONNECT_AUDIO, mCurrentDevice));
- }
}
break;
case HeadsetHalConstants.CONNECTION_STATE_CONNECTING:
@@ -478,6 +470,9 @@
@Override
public void enter() {
log("Enter Connected: " + getCurrentMessage().what);
+ if (isInCall()) {
+ sendMessage(CONNECT_AUDIO);
+ }
}
@Override
@@ -676,7 +671,7 @@
@Override
public void enter() {
- log("Enter AudioOn: " + getCurrentMessage().what);
+ log("Enter Audio: " + getCurrentMessage().what);
mAudioManager.setParameters(HEADSET_NAME + "=" + getCurrentDeviceName() + ";" +
HEADSET_NREC + "=on");
}
@@ -693,19 +688,13 @@
boolean retValue = HANDLED;
switch(message.what) {
- case DISCONNECT:
- deferMessage(obtainMessage(DISCONNECT, message.obj));
- // fall through
case DISCONNECT_AUDIO:
- {
- BluetoothDevice device = (BluetoothDevice) message.obj;
- if (device != null && !mCurrentDevice.equals(device)) {
- break;
- }
- disconnectAudioNative(getByteAddress(mCurrentDevice));
- }
+ // TODO(BT) when failure broadcast a audio disconnecting to connected intent
+ // check if device matches mCurrentDevice
+ disconnectAudioNative(getByteAddress(mCurrentDevice));
break;
case VOICE_RECOGNITION_START:
+ // TODO(BT) should we check if device matches mCurrentDevice?
startVoiceRecognitionNative();
break;
case VOICE_RECOGNITION_STOP: