Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth hands free client volume control

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.

like image 908
Distwo Avatar asked Sep 01 '15 00:09

Distwo


People also ask

Can you control volume on Bluetooth headphones?

Look for your Bluetooth headset listed under the Devices category, right click on it and select "Control". This brings up the "Bluetooth Device Control" screen. On it is a button labeled "Connect". Click the Connect button and you will then be able to see that the volume control is now connected to your headphones.

What is Bluetooth absolute volume?

Bluetooth absolute volume is a feature that synchronizes the system volume on your Android phone with the volume of your connected Bluetooth audio device, such as headphones, earbuds, or speakers. The feature is baked into most versions of Android; you should find it in any device running Android 6 or later.

How does Bluetooth volume control work?

With the Android absolute Bluetooth volume turned on, you turn up the volume on your phone. However, if you want it to go even louder, you can separately increase the volume on both devices. This will maximize the volume on both devices to give you the loudest possible sound.


1 Answers

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

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.

like image 56
Adi Avatar answered Oct 13 '22 04:10

Adi