Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the volume using adb shell service call audio [duplicate]

Tags:

android

adb

I am trying to change the volume on my android device using

service call audio 9 i32 50

to set the volume to 50%. Additionally, when I do:

service call audio 16

I was able to see that the hex value is 32. However, I don't see any changes on the device. The volume has not been changed.

On the other side, when I change the volume on the device by pushing the volume-up button, I don't read any changes when I do service call audio 16.

I want to change the volume by setting a direct value without using input keyevent KEY_VOLUME_UP (or DOWN).

Any help?

Thanks!

like image 677
Omar Avatar asked Dec 10 '14 00:12

Omar


2 Answers

Thank you for the quick response, but I found the solution, which is by using

"adb shell service call audio 7 i32 3 i32 0 i32 1"

Where 7 is the seventh function in "interface IAudioService" list: setStreamVolume(int streamType, int index, int flags, String callingPackage), 3 is speaker, 0 is the volume level and 1 is a flag. The second number (3) represents the following options: 1: phone 3: speaker 4: alarm 6: Bluetooth

Note: I was running as root when I tried the solution posted in my question but it didn't work.

like image 177
Omar Avatar answered Sep 22 '22 07:09

Omar


For speaker - to change media volume, to set it to 0

adb shell service call audio 3 i32 3 i32 0 i32 
like image 39
user1627657 Avatar answered Sep 24 '22 07:09

user1627657