Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1849,6 +1849,7 @@ public class HeadsetService extends ProfileService { if (mActiveDevice != null && callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED && !mSystemInterface.isCallIdle() && isCallIdleBefore) { mSystemInterface.getAudioManager().setA2dpSuspended(true); mSystemInterface.getAudioManager().setLeAudioSuspended(true); } }); doForEachConnectedStateMachine( Loading @@ -1859,6 +1860,7 @@ public class HeadsetService extends ProfileService { && mSystemInterface.isCallIdle() && !isAudioOn()) { // Resume A2DP when call ended and SCO is not connected mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); } }); if (callState == HeadsetHalConstants.CALL_STATE_IDLE) { Loading Loading @@ -2094,6 +2096,7 @@ public class HeadsetService extends ProfileService { // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); } } } Loading android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +2 −0 Original line number Diff line number Diff line Loading @@ -1113,8 +1113,10 @@ public class HeadsetStateMachine extends StateMachine { case CONNECT_AUDIO: stateLogD("CONNECT_AUDIO, device=" + mDevice); mSystemInterface.getAudioManager().setA2dpSuspended(true); mSystemInterface.getAudioManager().setLeAudioSuspended(true); if (!mNativeInterface.connectAudio(mDevice)) { mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); stateLogE("Failed to connect SCO audio for " + mDevice); // No state change involved, fire broadcast immediately broadcastAudioState(mDevice, BluetoothHeadset.STATE_AUDIO_DISCONNECTED, Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -943,6 +943,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -998,6 +999,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1079,6 +1081,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertEquals(deviceA, mHeadsetService.getActiveDevice()); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(deviceA); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, deviceA, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading Loading @@ -1127,6 +1130,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(device); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading @@ -1144,6 +1148,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(device); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(device); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java +7 −3 Original line number Diff line number Diff line Loading @@ -719,6 +719,7 @@ public class HeadsetServiceTest { TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); verify(mAudioManager, never()).setA2dpSuspended(true); verify(mAudioManager, never()).setLeAudioSuspended(true); HeadsetTestUtils.verifyPhoneStateChangeSetters(mPhoneState, headsetCallState, ASYNC_CALL_TIMEOUT_MILLIS); } Loading Loading @@ -776,8 +777,9 @@ public class HeadsetServiceTest { TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); // Should not ask Audio HAL to suspend A2DP without active device // Should not ask Audio HAL to suspend A2DP or LE Audio without active device verify(mAudioManager, never()).setA2dpSuspended(true); verify(mAudioManager, never()).setLeAudioSuspended(true); // Make sure we notify device about this change verify(mStateMachines.get(mCurrentDevice)).sendMessage( HeadsetStateMachine.CALL_STATE_CHANGED, headsetCallState); Loading @@ -794,8 +796,9 @@ public class HeadsetServiceTest { headsetCallState.mType, headsetCallState.mName, false); TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); // Ask Audio HAL to suspend A2DP // Ask Audio HAL to suspend A2DP and LE Audio verify(mAudioManager).setA2dpSuspended(true); verify(mAudioManager).setLeAudioSuspended(true); // Make sure state is updated verify(mStateMachines.get(mCurrentDevice)).sendMessage( HeadsetStateMachine.CALL_STATE_CHANGED, headsetCallState); Loading Loading @@ -858,8 +861,9 @@ public class HeadsetServiceTest { mHeadsetService.phoneStateChanged(headsetCallState.mNumActive, headsetCallState.mNumHeld, headsetCallState.mCallState, headsetCallState.mNumber, headsetCallState.mType, headsetCallState.mName, false); // Ask Audio HAL to suspend A2DP // Ask Audio HAL to suspend A2DP and LE Audio verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); // Make sure we notify devices about this change for (BluetoothDevice device : connectedDevices) { verify(mStateMachines.get(device)).sendMessage(HeadsetStateMachine.CALL_STATE_CHANGED, Loading system/audio_bluetooth_hw/audio_bluetooth_hw.cc +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,8 @@ static int adev_set_parameters(struct audio_hw_device* dev, LOG(VERBOSE) << __func__ << ": ParamsMap=[" << GetAudioParamString(params) << "]"; if (params.find("A2dpSuspended") == params.end()) { if (params.find("A2dpSuspended") == params.end() && params.find("LeAudioSuspended") == params.end()) { return -ENOSYS; } Loading Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1849,6 +1849,7 @@ public class HeadsetService extends ProfileService { if (mActiveDevice != null && callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED && !mSystemInterface.isCallIdle() && isCallIdleBefore) { mSystemInterface.getAudioManager().setA2dpSuspended(true); mSystemInterface.getAudioManager().setLeAudioSuspended(true); } }); doForEachConnectedStateMachine( Loading @@ -1859,6 +1860,7 @@ public class HeadsetService extends ProfileService { && mSystemInterface.isCallIdle() && !isAudioOn()) { // Resume A2DP when call ended and SCO is not connected mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); } }); if (callState == HeadsetHalConstants.CALL_STATE_IDLE) { Loading Loading @@ -2094,6 +2096,7 @@ public class HeadsetService extends ProfileService { // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); } } } Loading
android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +2 −0 Original line number Diff line number Diff line Loading @@ -1113,8 +1113,10 @@ public class HeadsetStateMachine extends StateMachine { case CONNECT_AUDIO: stateLogD("CONNECT_AUDIO, device=" + mDevice); mSystemInterface.getAudioManager().setA2dpSuspended(true); mSystemInterface.getAudioManager().setLeAudioSuspended(true); if (!mNativeInterface.connectAudio(mDevice)) { mSystemInterface.getAudioManager().setA2dpSuspended(false); mSystemInterface.getAudioManager().setLeAudioSuspended(false); stateLogE("Failed to connect SCO audio for " + mDevice); // No state change involved, fire broadcast immediately broadcastAudioState(mDevice, BluetoothHeadset.STATE_AUDIO_DISCONNECTED, Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -943,6 +943,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -998,6 +999,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1079,6 +1081,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertEquals(deviceA, mHeadsetService.getActiveDevice()); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(deviceA); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, deviceA, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading Loading @@ -1127,6 +1130,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(device); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading @@ -1144,6 +1148,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(device); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(device); waitAndVerifyAudioStateIntent(ASYNC_CALL_TIMEOUT_MILLIS, device, BluetoothHeadset.STATE_AUDIO_CONNECTING, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceTest.java +7 −3 Original line number Diff line number Diff line Loading @@ -719,6 +719,7 @@ public class HeadsetServiceTest { TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); verify(mAudioManager, never()).setA2dpSuspended(true); verify(mAudioManager, never()).setLeAudioSuspended(true); HeadsetTestUtils.verifyPhoneStateChangeSetters(mPhoneState, headsetCallState, ASYNC_CALL_TIMEOUT_MILLIS); } Loading Loading @@ -776,8 +777,9 @@ public class HeadsetServiceTest { TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); // Should not ask Audio HAL to suspend A2DP without active device // Should not ask Audio HAL to suspend A2DP or LE Audio without active device verify(mAudioManager, never()).setA2dpSuspended(true); verify(mAudioManager, never()).setLeAudioSuspended(true); // Make sure we notify device about this change verify(mStateMachines.get(mCurrentDevice)).sendMessage( HeadsetStateMachine.CALL_STATE_CHANGED, headsetCallState); Loading @@ -794,8 +796,9 @@ public class HeadsetServiceTest { headsetCallState.mType, headsetCallState.mName, false); TestUtils.waitForLooperToFinishScheduledTask( mHeadsetService.getStateMachinesThreadLooper()); // Ask Audio HAL to suspend A2DP // Ask Audio HAL to suspend A2DP and LE Audio verify(mAudioManager).setA2dpSuspended(true); verify(mAudioManager).setLeAudioSuspended(true); // Make sure state is updated verify(mStateMachines.get(mCurrentDevice)).sendMessage( HeadsetStateMachine.CALL_STATE_CHANGED, headsetCallState); Loading Loading @@ -858,8 +861,9 @@ public class HeadsetServiceTest { mHeadsetService.phoneStateChanged(headsetCallState.mNumActive, headsetCallState.mNumHeld, headsetCallState.mCallState, headsetCallState.mNumber, headsetCallState.mType, headsetCallState.mName, false); // Ask Audio HAL to suspend A2DP // Ask Audio HAL to suspend A2DP and LE Audio verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setLeAudioSuspended(true); // Make sure we notify devices about this change for (BluetoothDevice device : connectedDevices) { verify(mStateMachines.get(device)).sendMessage(HeadsetStateMachine.CALL_STATE_CHANGED, Loading
system/audio_bluetooth_hw/audio_bluetooth_hw.cc +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,8 @@ static int adev_set_parameters(struct audio_hw_device* dev, LOG(VERBOSE) << __func__ << ": ParamsMap=[" << GetAudioParamString(params) << "]"; if (params.find("A2dpSuspended") == params.end()) { if (params.find("A2dpSuspended") == params.end() && params.find("LeAudioSuspended") == params.end()) { return -ENOSYS; } Loading