Bluetooth hands free client volume control

AndroidBluetoothAndroid 4.4-KitkatHfp

Android Problem Overview


I have an android device acting as a hands free client device using hfp.

Using the following code:

I am able to receive a call and the speakers and mic are working as expected.

My problem is that I can't seem to control the volume.

I tried using the following lines of code to find the correct stream, but none of them seem to work.

I tracked the volume command being sent from the phone to the client in the class HeadsetClientStateMachine , line #1822 in the following link: HeadsetClientStateMachine from lolipop

case EVENT_TYPE_VOLUME_CHANGED:
    if (event.valueInt == HeadsetClientHalConstants.VOLUME_TYPE_SPK) {
        mAudioManager.setStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO, event.valueInt2, AudioManager.FLAG_SHOW_UI);
        mVgsFromStack = true;
       Log.d(TAG, "EventVolumeChange STREAM_BLUETOOTH_SCO value: " + event.valueInt2);
    }

When I change the volume on the phone, I do see the log showing the updated value of the sound, which means that the setStreamVolume() method is being called, but the volume doesn't change.

Does anyone know what could be causing this issue?

EDIT:

I am still looking for an answer and am now looking toward the audio HAL implementation. I suspect that the link between the HAL and the audio driver is somehow incorrect... I don't know much about low level implementation and am not sure what I should be looking for.

Android Solutions


Solution 1 - Android

Could you please try below. I did not try myself but sounds similar problem if I understand correctly:

https://stackoverflow.com/questions/4472613/android-bluetooth-earpiece-volume

"Android is using int 6 for bluetooth volume and not documented. Just use 6 instead of AudioManager.STREAM_VOICE_CALL and try, It should work"

I assume for you will be to replace AudioManager.STREAM_BLUETOOTH_SCO with 6.

Good luck, I hope it will work.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDistwoView Question on Stackoverflow
Solution 1 - AndroidAdiView Answer on Stackoverflow