Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +3 −3 Original line number Diff line number Diff line Loading @@ -1645,7 +1645,7 @@ public class HeadsetService extends ProfileService { // Suspend A2DP when call about is about to become active if (mActiveDevice != null && callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED && !mSystemInterface.isCallIdle() && isCallIdleBefore) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=true"); mSystemInterface.getAudioManager().setA2dpSuspended(true); } }); doForEachConnectedStateMachine( Loading @@ -1655,7 +1655,7 @@ public class HeadsetService extends ProfileService { if (callState == HeadsetHalConstants.CALL_STATE_IDLE && mSystemInterface.isCallIdle() && !isAudioOn()) { // Resume A2DP when call ended and SCO is not connected mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); } }); Loading Loading @@ -1813,7 +1813,7 @@ public class HeadsetService extends ProfileService { } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); } } } Loading android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +22 −33 Original line number Diff line number Diff line Loading @@ -80,12 +80,6 @@ public class HeadsetStateMachine extends StateMachine { private static final String TAG = "HeadsetStateMachine"; private static final boolean DBG = false; private static final String HEADSET_NAME = "bt_headset_name"; private static final String HEADSET_NREC = "bt_headset_nrec"; private static final String HEADSET_WBS = "bt_wbs"; private static final String HEADSET_AUDIO_FEATURE_ON = "on"; private static final String HEADSET_AUDIO_FEATURE_OFF = "off"; static final int CONNECT = 1; static final int DISCONNECT = 2; static final int CONNECT_AUDIO = 3; Loading Loading @@ -147,8 +141,9 @@ public class HeadsetStateMachine extends StateMachine { private HeadsetAgIndicatorEnableState mAgIndicatorEnableState; // The timestamp when the device entered connecting/connected state private long mConnectingTimestampMs = Long.MIN_VALUE; // Audio Parameters like NREC private final HashMap<String, String> mAudioParams = new HashMap<>(); // Audio Parameters private boolean mHasNrecEnabled = false; private boolean mHasWbsEnabled = false; // AT Phone book keeps a group of states used by AT+CPBR commands private final AtPhonebook mPhonebook; // HSP specific Loading Loading @@ -227,7 +222,8 @@ public class HeadsetStateMachine extends StateMachine { if (mPhonebook != null) { mPhonebook.cleanup(); } mAudioParams.clear(); mHasWbsEnabled = false; mHasNrecEnabled = false; } public void dump(StringBuilder sb) { Loading Loading @@ -322,8 +318,7 @@ public class HeadsetStateMachine extends StateMachine { BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_SCO_CONNECTION_STATE_CHANGED, mAdapterService.obfuscateAddress(device), getConnectionStateFromAudioState(toState), TextUtils.equals(mAudioParams.get(HEADSET_WBS), HEADSET_AUDIO_FEATURE_ON) ? BluetoothHfpProtoEnums.SCO_CODEC_MSBC mHasWbsEnabled ? BluetoothHfpProtoEnums.SCO_CODEC_MSBC : BluetoothHfpProtoEnums.SCO_CODEC_CVSD, mAdapterService.getMetricId(device)); mHeadsetService.onAudioStateChangedFromStateMachine(device, fromState, toState); Loading Loading @@ -456,7 +451,8 @@ public class HeadsetStateMachine extends StateMachine { mPhonebook.resetAtState(); updateAgIndicatorEnableState(null); mNeedDialingOutReply = false; mAudioParams.clear(); mHasWbsEnabled = false; mHasNrecEnabled = false; broadcastStateTransitions(); // Remove the state machine for unbonded devices if (mPrevState != null Loading Loading @@ -1083,9 +1079,9 @@ public class HeadsetStateMachine extends StateMachine { break; case CONNECT_AUDIO: stateLogD("CONNECT_AUDIO, device=" + mDevice); mSystemInterface.getAudioManager().setParameters("A2dpSuspended=true"); mSystemInterface.getAudioManager().setA2dpSuspended(true); if (!mNativeInterface.connectAudio(mDevice)) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); stateLogE("Failed to connect SCO audio for " + mDevice); // No state change involved, fire broadcast immediately broadcastAudioState(mDevice, BluetoothHeadset.STATE_AUDIO_DISCONNECTED, Loading Loading @@ -1530,15 +1526,12 @@ public class HeadsetStateMachine extends StateMachine { } private void setAudioParameters() { String keyValuePairs = String.join(";", new String[]{ HEADSET_NAME + "=" + getCurrentDeviceName(), HEADSET_NREC + "=" + mAudioParams.getOrDefault(HEADSET_NREC, HEADSET_AUDIO_FEATURE_OFF), HEADSET_WBS + "=" + mAudioParams.getOrDefault(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF) }); Log.i(TAG, "setAudioParameters for " + mDevice + ": " + keyValuePairs); mSystemInterface.getAudioManager().setParameters(keyValuePairs); AudioManager am = mSystemInterface.getAudioManager(); Log.i(TAG, "setAudioParameters for " + mDevice + ":" + " Name=" + getCurrentDeviceName() + " hasNrecEnabled=" + mHasNrecEnabled + " hasWbsEnabled=" + mHasWbsEnabled); am.setBluetoothHeadsetProperties(getCurrentDeviceName(), mHasNrecEnabled, mHasWbsEnabled); } private String parseUnknownAt(String atString) { Loading Loading @@ -1667,32 +1660,28 @@ public class HeadsetStateMachine extends StateMachine { } private void processNoiseReductionEvent(boolean enable) { String prevNrec = mAudioParams.getOrDefault(HEADSET_NREC, HEADSET_AUDIO_FEATURE_OFF); String newNrec = enable ? HEADSET_AUDIO_FEATURE_ON : HEADSET_AUDIO_FEATURE_OFF; mAudioParams.put(HEADSET_NREC, newNrec); log("processNoiseReductionEvent: " + HEADSET_NREC + " change " + prevNrec + " -> " + newNrec); log("processNoiseReductionEvent: " + mHasNrecEnabled + " -> " + enable); mHasNrecEnabled = enable; if (getAudioState() == BluetoothHeadset.STATE_AUDIO_CONNECTED) { setAudioParameters(); } } private void processWBSEvent(int wbsConfig) { String prevWbs = mAudioParams.getOrDefault(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF); boolean prevWbs = mHasWbsEnabled; switch (wbsConfig) { case HeadsetHalConstants.BTHF_WBS_YES: mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_ON); mHasWbsEnabled = true; break; case HeadsetHalConstants.BTHF_WBS_NO: case HeadsetHalConstants.BTHF_WBS_NONE: mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF); mHasWbsEnabled = false; break; default: Log.e(TAG, "processWBSEvent: unknown wbsConfig " + wbsConfig); return; } log("processWBSEvent: " + HEADSET_NREC + " change " + prevWbs + " -> " + mAudioParams.get( HEADSET_WBS)); log("processWBSEvent: " + prevWbs + " -> " + mHasWbsEnabled); } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) Loading android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +2 −2 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ public class HeadsetClientService extends ProfileService { Log.e(TAG, "AudioManager service doesn't exist?"); } else { // start AudioManager in a known state mAudioManager.setParameters("hfp_enable=false"); mAudioManager.setHfpEnabled(false); } mSmFactory = new HeadsetClientStateMachineFactory(); Loading Loading @@ -200,7 +200,7 @@ public class HeadsetClientService extends ProfileService { "Setting volume to audio manager: " + streamValue + " hands free: " + hfVol); } mAudioManager.setParameters("hfp_volume=" + hfVol); mAudioManager.setHfpVolume(hfVol); synchronized (mStateMachineMap) { for (HeadsetClientStateMachine sm : mStateMachineMap.values()) { if (sm != null) { Loading android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +6 −6 Original line number Diff line number Diff line Loading @@ -815,9 +815,9 @@ public class HeadsetClientStateMachine extends StateMachine { } logD("hfp_enable=" + enable); if (enable && !sAudioIsRouted) { mAudioManager.setParameters("hfp_enable=true"); mAudioManager.setHfpEnabled(true); } else if (!enable) { mAudioManager.setParameters("hfp_enable=false"); mAudioManager.setHfpEnabled(false); } sAudioIsRouted = enable; } Loading Loading @@ -1592,7 +1592,7 @@ public class HeadsetClientStateMachine extends StateMachine { // routing is handled by the bluetooth stack itself. The only reason to do so is // because Bluetooth SCO connection from the HF role is not entirely supported // for routing and volume purposes. // NOTE: All calls here are routed via the setParameters which changes the // NOTE: All calls here are routed via AudioManager methods which changes the // routing at the Audio HAL level. if (mService.isScoRouted()) { Loading @@ -1614,15 +1614,15 @@ public class HeadsetClientStateMachine extends StateMachine { logD("hfp_enable=true mAudioWbs is " + mAudioWbs); if (mAudioWbs) { logD("Setting sampling rate as 16000"); mAudioManager.setParameters("hfp_set_sampling_rate=16000"); mAudioManager.setHfpSamplingRate(16000); } else { logD("Setting sampling rate as 8000"); mAudioManager.setParameters("hfp_set_sampling_rate=8000"); mAudioManager.setHfpSamplingRate(8000); } logD("hf_volume " + hfVol); routeHfpAudio(true); mAudioFocusRequest = requestAudioFocus(); mAudioManager.setParameters("hfp_volume=" + hfVol); mAudioManager.setHfpVolume(hfVol); transitionTo(mAudioOn); break; Loading android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +5 −10 Original line number Diff line number Diff line Loading @@ -954,8 +954,7 @@ public class HeadsetServiceAndStateMachineTest { mHeadsetService.startVoiceRecognition(deviceA); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1008,8 +1007,7 @@ public class HeadsetServiceAndStateMachineTest { // We still continue on the initiating HF verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1084,8 +1082,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface).setActiveDevice(deviceA); Assert.assertEquals(deviceA, mHeadsetService.getActiveDevice()); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(deviceA); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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 @@ -1133,8 +1130,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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 @@ -1151,8 +1147,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertNotNull(device); Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(device); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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 Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +3 −3 Original line number Diff line number Diff line Loading @@ -1645,7 +1645,7 @@ public class HeadsetService extends ProfileService { // Suspend A2DP when call about is about to become active if (mActiveDevice != null && callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED && !mSystemInterface.isCallIdle() && isCallIdleBefore) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=true"); mSystemInterface.getAudioManager().setA2dpSuspended(true); } }); doForEachConnectedStateMachine( Loading @@ -1655,7 +1655,7 @@ public class HeadsetService extends ProfileService { if (callState == HeadsetHalConstants.CALL_STATE_IDLE && mSystemInterface.isCallIdle() && !isAudioOn()) { // Resume A2DP when call ended and SCO is not connected mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); } }); Loading Loading @@ -1813,7 +1813,7 @@ public class HeadsetService extends ProfileService { } // Unsuspend A2DP when SCO connection is gone and call state is idle if (mSystemInterface.isCallIdle()) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); } } } Loading
android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +22 −33 Original line number Diff line number Diff line Loading @@ -80,12 +80,6 @@ public class HeadsetStateMachine extends StateMachine { private static final String TAG = "HeadsetStateMachine"; private static final boolean DBG = false; private static final String HEADSET_NAME = "bt_headset_name"; private static final String HEADSET_NREC = "bt_headset_nrec"; private static final String HEADSET_WBS = "bt_wbs"; private static final String HEADSET_AUDIO_FEATURE_ON = "on"; private static final String HEADSET_AUDIO_FEATURE_OFF = "off"; static final int CONNECT = 1; static final int DISCONNECT = 2; static final int CONNECT_AUDIO = 3; Loading Loading @@ -147,8 +141,9 @@ public class HeadsetStateMachine extends StateMachine { private HeadsetAgIndicatorEnableState mAgIndicatorEnableState; // The timestamp when the device entered connecting/connected state private long mConnectingTimestampMs = Long.MIN_VALUE; // Audio Parameters like NREC private final HashMap<String, String> mAudioParams = new HashMap<>(); // Audio Parameters private boolean mHasNrecEnabled = false; private boolean mHasWbsEnabled = false; // AT Phone book keeps a group of states used by AT+CPBR commands private final AtPhonebook mPhonebook; // HSP specific Loading Loading @@ -227,7 +222,8 @@ public class HeadsetStateMachine extends StateMachine { if (mPhonebook != null) { mPhonebook.cleanup(); } mAudioParams.clear(); mHasWbsEnabled = false; mHasNrecEnabled = false; } public void dump(StringBuilder sb) { Loading Loading @@ -322,8 +318,7 @@ public class HeadsetStateMachine extends StateMachine { BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_SCO_CONNECTION_STATE_CHANGED, mAdapterService.obfuscateAddress(device), getConnectionStateFromAudioState(toState), TextUtils.equals(mAudioParams.get(HEADSET_WBS), HEADSET_AUDIO_FEATURE_ON) ? BluetoothHfpProtoEnums.SCO_CODEC_MSBC mHasWbsEnabled ? BluetoothHfpProtoEnums.SCO_CODEC_MSBC : BluetoothHfpProtoEnums.SCO_CODEC_CVSD, mAdapterService.getMetricId(device)); mHeadsetService.onAudioStateChangedFromStateMachine(device, fromState, toState); Loading Loading @@ -456,7 +451,8 @@ public class HeadsetStateMachine extends StateMachine { mPhonebook.resetAtState(); updateAgIndicatorEnableState(null); mNeedDialingOutReply = false; mAudioParams.clear(); mHasWbsEnabled = false; mHasNrecEnabled = false; broadcastStateTransitions(); // Remove the state machine for unbonded devices if (mPrevState != null Loading Loading @@ -1083,9 +1079,9 @@ public class HeadsetStateMachine extends StateMachine { break; case CONNECT_AUDIO: stateLogD("CONNECT_AUDIO, device=" + mDevice); mSystemInterface.getAudioManager().setParameters("A2dpSuspended=true"); mSystemInterface.getAudioManager().setA2dpSuspended(true); if (!mNativeInterface.connectAudio(mDevice)) { mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false"); mSystemInterface.getAudioManager().setA2dpSuspended(false); stateLogE("Failed to connect SCO audio for " + mDevice); // No state change involved, fire broadcast immediately broadcastAudioState(mDevice, BluetoothHeadset.STATE_AUDIO_DISCONNECTED, Loading Loading @@ -1530,15 +1526,12 @@ public class HeadsetStateMachine extends StateMachine { } private void setAudioParameters() { String keyValuePairs = String.join(";", new String[]{ HEADSET_NAME + "=" + getCurrentDeviceName(), HEADSET_NREC + "=" + mAudioParams.getOrDefault(HEADSET_NREC, HEADSET_AUDIO_FEATURE_OFF), HEADSET_WBS + "=" + mAudioParams.getOrDefault(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF) }); Log.i(TAG, "setAudioParameters for " + mDevice + ": " + keyValuePairs); mSystemInterface.getAudioManager().setParameters(keyValuePairs); AudioManager am = mSystemInterface.getAudioManager(); Log.i(TAG, "setAudioParameters for " + mDevice + ":" + " Name=" + getCurrentDeviceName() + " hasNrecEnabled=" + mHasNrecEnabled + " hasWbsEnabled=" + mHasWbsEnabled); am.setBluetoothHeadsetProperties(getCurrentDeviceName(), mHasNrecEnabled, mHasWbsEnabled); } private String parseUnknownAt(String atString) { Loading Loading @@ -1667,32 +1660,28 @@ public class HeadsetStateMachine extends StateMachine { } private void processNoiseReductionEvent(boolean enable) { String prevNrec = mAudioParams.getOrDefault(HEADSET_NREC, HEADSET_AUDIO_FEATURE_OFF); String newNrec = enable ? HEADSET_AUDIO_FEATURE_ON : HEADSET_AUDIO_FEATURE_OFF; mAudioParams.put(HEADSET_NREC, newNrec); log("processNoiseReductionEvent: " + HEADSET_NREC + " change " + prevNrec + " -> " + newNrec); log("processNoiseReductionEvent: " + mHasNrecEnabled + " -> " + enable); mHasNrecEnabled = enable; if (getAudioState() == BluetoothHeadset.STATE_AUDIO_CONNECTED) { setAudioParameters(); } } private void processWBSEvent(int wbsConfig) { String prevWbs = mAudioParams.getOrDefault(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF); boolean prevWbs = mHasWbsEnabled; switch (wbsConfig) { case HeadsetHalConstants.BTHF_WBS_YES: mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_ON); mHasWbsEnabled = true; break; case HeadsetHalConstants.BTHF_WBS_NO: case HeadsetHalConstants.BTHF_WBS_NONE: mAudioParams.put(HEADSET_WBS, HEADSET_AUDIO_FEATURE_OFF); mHasWbsEnabled = false; break; default: Log.e(TAG, "processWBSEvent: unknown wbsConfig " + wbsConfig); return; } log("processWBSEvent: " + HEADSET_NREC + " change " + prevWbs + " -> " + mAudioParams.get( HEADSET_WBS)); log("processWBSEvent: " + prevWbs + " -> " + mHasWbsEnabled); } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) Loading
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientService.java +2 −2 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ public class HeadsetClientService extends ProfileService { Log.e(TAG, "AudioManager service doesn't exist?"); } else { // start AudioManager in a known state mAudioManager.setParameters("hfp_enable=false"); mAudioManager.setHfpEnabled(false); } mSmFactory = new HeadsetClientStateMachineFactory(); Loading Loading @@ -200,7 +200,7 @@ public class HeadsetClientService extends ProfileService { "Setting volume to audio manager: " + streamValue + " hands free: " + hfVol); } mAudioManager.setParameters("hfp_volume=" + hfVol); mAudioManager.setHfpVolume(hfVol); synchronized (mStateMachineMap) { for (HeadsetClientStateMachine sm : mStateMachineMap.values()) { if (sm != null) { Loading
android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +6 −6 Original line number Diff line number Diff line Loading @@ -815,9 +815,9 @@ public class HeadsetClientStateMachine extends StateMachine { } logD("hfp_enable=" + enable); if (enable && !sAudioIsRouted) { mAudioManager.setParameters("hfp_enable=true"); mAudioManager.setHfpEnabled(true); } else if (!enable) { mAudioManager.setParameters("hfp_enable=false"); mAudioManager.setHfpEnabled(false); } sAudioIsRouted = enable; } Loading Loading @@ -1592,7 +1592,7 @@ public class HeadsetClientStateMachine extends StateMachine { // routing is handled by the bluetooth stack itself. The only reason to do so is // because Bluetooth SCO connection from the HF role is not entirely supported // for routing and volume purposes. // NOTE: All calls here are routed via the setParameters which changes the // NOTE: All calls here are routed via AudioManager methods which changes the // routing at the Audio HAL level. if (mService.isScoRouted()) { Loading @@ -1614,15 +1614,15 @@ public class HeadsetClientStateMachine extends StateMachine { logD("hfp_enable=true mAudioWbs is " + mAudioWbs); if (mAudioWbs) { logD("Setting sampling rate as 16000"); mAudioManager.setParameters("hfp_set_sampling_rate=16000"); mAudioManager.setHfpSamplingRate(16000); } else { logD("Setting sampling rate as 8000"); mAudioManager.setParameters("hfp_set_sampling_rate=8000"); mAudioManager.setHfpSamplingRate(8000); } logD("hf_volume " + hfVol); routeHfpAudio(true); mAudioFocusRequest = requestAudioFocus(); mAudioManager.setParameters("hfp_volume=" + hfVol); mAudioManager.setHfpVolume(hfVol); transitionTo(mAudioOn); break; Loading
android/app/tests/unit/src/com/android/bluetooth/hfp/HeadsetServiceAndStateMachineTest.java +5 −10 Original line number Diff line number Diff line Loading @@ -954,8 +954,7 @@ public class HeadsetServiceAndStateMachineTest { mHeadsetService.startVoiceRecognition(deviceA); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1008,8 +1007,7 @@ public class HeadsetServiceAndStateMachineTest { // We still continue on the initiating HF verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(deviceA, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(true); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).connectAudio(deviceA); verifyNoMoreInteractions(mNativeInterface); } Loading Loading @@ -1084,8 +1082,7 @@ public class HeadsetServiceAndStateMachineTest { verify(mNativeInterface).setActiveDevice(deviceA); Assert.assertEquals(deviceA, mHeadsetService.getActiveDevice()); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(deviceA); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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 @@ -1133,8 +1130,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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 @@ -1151,8 +1147,7 @@ public class HeadsetServiceAndStateMachineTest { Assert.assertNotNull(device); Assert.assertTrue(mHeadsetService.startVoiceRecognition(device)); verify(mNativeInterface, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).startVoiceRecognition(device); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)) .setParameters("A2dpSuspended=true"); verify(mAudioManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS)).setA2dpSuspended(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