summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpenghua <quic_penghua@quicinc.com>2021-12-28 12:13:11 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2022-01-11 02:35:18 -0800
commit2e720d682574711d5e9548f84bf1248b901ab712 (patch)
treed2e35b1dd17f622b1fbfa6b2f72094fdd5f2f4ce
parentfd7dee6840c7b620029ff37018eb510fa30ab85b (diff)
Resume A2DP wrongly for some corner cases of VOIP call
1.Headset state machine is blocked when it call MM audio API to resume A2DP because the call state is not IDEL in stack layer The reason is headset state machine can't receive call state update from headset service. We need post message to Headset state machine to resume A2DP, but not call MM audio API directlly. 2.Ensure VOIP call state is correct if stopScoUsingVirtualVoiceCall and startScoUsingVirtualVoiceCall are executed almost at the same time. 3. If the call started/ended by the time A2DP suspend ack is received, send the call indicators before resuming A2DP CRs-Fixed: 3100571 Change-Id: I124be0c1f855e24c1ec7306068d1a38983de74d1
-rw-r--r--src/com/android/bluetooth/hfp/HeadsetService.java21
-rw-r--r--src/com/android/bluetooth/hfp/HeadsetStateMachine.java15
2 files changed, 22 insertions, 14 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java
index e1438f7a4..a648c773d 100644
--- a/src/com/android/bluetooth/hfp/HeadsetService.java
+++ b/src/com/android/bluetooth/hfp/HeadsetService.java
@@ -2493,11 +2493,6 @@ public class HeadsetService extends ProfileService {
}
}
}
- mStateMachinesThread.getThreadHandler().post(() -> {
- mSystemInterface.getHeadsetPhoneState().setNumActiveCall(numActive);
- mSystemInterface.getHeadsetPhoneState().setNumHeldCall(numHeld);
- mSystemInterface.getHeadsetPhoneState().setCallState(callState);
- });
List<BluetoothDevice> availableDevices =
getDevicesMatchingConnectionStates(CONNECTING_CONNECTED_STATES);
if(availableDevices.size() > 0) {
@@ -2506,7 +2501,10 @@ public class HeadsetService extends ProfileService {
doForEachConnectedConnectingStateMachine(
stateMachine -> stateMachine.sendMessage(HeadsetStateMachine.CALL_STATE_CHANGED,
new HeadsetCallState(numActive, numHeld, callState, number, type, name)));
- mStateMachinesThread.getThreadHandler().post(() -> {
+ mStateMachinesThread.getThreadHandler().post(() -> {
+ mSystemInterface.getHeadsetPhoneState().setNumActiveCall(numActive);
+ mSystemInterface.getHeadsetPhoneState().setNumHeldCall(numHeld);
+ mSystemInterface.getHeadsetPhoneState().setCallState(callState);
if (!(mSystemInterface.isInCall() || mSystemInterface.isRinging())) {
Log.i(TAG, "no call, sending resume A2DP message to state machines");
for (BluetoothDevice device : availableDevices) {
@@ -2521,7 +2519,10 @@ public class HeadsetService extends ProfileService {
}
});
} else {
- mStateMachinesThread.getThreadHandler().post(() -> {
+ mStateMachinesThread.getThreadHandler().post(() -> {
+ mSystemInterface.getHeadsetPhoneState().setNumActiveCall(numActive);
+ mSystemInterface.getHeadsetPhoneState().setNumHeldCall(numHeld);
+ mSystemInterface.getHeadsetPhoneState().setCallState(callState);
if (!(mSystemInterface.isInCall() || mSystemInterface.isRinging())) {
//If no device is connected, resume A2DP if there is no call
Log.i(TAG, "No device is connected and no call, " +
@@ -2533,9 +2534,9 @@ public class HeadsetService extends ProfileService {
"set A2DPsuspended to true");
mHfpA2dpSyncInterface.suspendA2DP(HeadsetA2dpSync.
A2DP_SUSPENDED_BY_CS_CALL, null);
- }
- });
- }
+ }
+ });
+ }
}
}
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 3676d6b32..56067e70c 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -1430,7 +1430,7 @@ public class HeadsetStateMachine extends StateMachine {
if (!(mSystemInterface.isInCall() || mSystemInterface.isRinging())) {
// SCO disconnected, resume A2DP if there is no call
stateLogD("SCO disconnected, set A2DPsuspended to false");
- mHeadsetService.getHfpA2DPSyncInterface().releaseA2DP(mDevice);
+ sendMessage(RESUME_A2DP);
}
}
}
@@ -1552,9 +1552,16 @@ public class HeadsetStateMachine extends StateMachine {
break;
case HeadsetHalConstants.AUDIO_STATE_DISCONNECTED:
if (!(mSystemInterface.isInCall() || mSystemInterface.isRinging())) {
- // SCO disconnected, resume A2DP if there is no call
- stateLogD("SCO disconnected, set A2DPsuspended to false");
- mHeadsetService.getHfpA2DPSyncInterface().releaseA2DP(mDevice);
+ /* If the call started/ended by the time A2DP suspend ack
+ * is received, send the call indicators before resuming
+ * A2DP.
+ */
+ if (mPendingCallStates.size() == 0) {
+ stateLogD("processAudioEvent, resuming A2DP after SCO disconnected");
+ mHeadsetService.getHfpA2DPSyncInterface().releaseA2DP(mDevice);
+ } else {
+ stateLogW("processAudioEvent,not resuming due to pending call states");
+ }
}
break;
case HeadsetHalConstants.AUDIO_STATE_DISCONNECTING: