diff options
author | CNSS_WLAN Service <cnssbldsw@qualcomm.com> | 2022-01-11 21:19:34 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2022-01-11 21:19:34 -0800 |
commit | 44d456899c238ac61ebcc26cd4c8061d6a17e106 (patch) | |
tree | 7be3de887980686861da4c8be8e6f12a6bbf3624 | |
parent | c29846e969a243e56aaacf63c8eb3e77bd5646d1 (diff) | |
parent | 2e720d682574711d5e9548f84bf1248b901ab712 (diff) |
Merge "Resume A2DP wrongly for some corner cases of VOIP call" into bt-sys.lnx.12.0
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetService.java | 21 | ||||
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 15 |
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 6528e6049..528c6895a 100644 --- a/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/src/com/android/bluetooth/hfp/HeadsetService.java @@ -2510,11 +2510,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) { @@ -2523,7 +2518,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) { @@ -2538,7 +2536,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, " + @@ -2550,9 +2551,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 4ddd9e4b8..2b016a458 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -1438,7 +1438,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); } } } @@ -1560,9 +1560,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: |