10

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!

luk3yx
  • 392
  • 4
  • 10
Omar
  • 557
  • 2
  • 6
  • 23
  • make sure you have `root`. also double check the proper `setMasterVolume` for your android version http://ktnr74.blogspot.com/2014/09/calling-android-services-from-adb-shell.html – Alex P. Dec 10 '14 at 00:28

2 Answers2

12

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.

Omar
  • 557
  • 2
  • 6
  • 23
  • 2
    Remaining options for streamtype: ''' AUDIO_STREAM_VOICE_CALL = 0, AUDIO_STREAM_SYSTEM = 1, AUDIO_STREAM_RING = 2, AUDIO_STREAM_MUSIC = 3, AUDIO_STREAM_ALARM = 4, AUDIO_STREAM_NOTIFICATION = 5, AUDIO_STREAM_BLUETOOTH_SCO = 6, AUDIO_STREAM_ENFORCED_AUDIBLE = 7, AUDIO_STREAM_DTMF = 8, AUDIO_STREAM_TTS = 9, AUDIO_STREAM_ACCESSIBILITY = 10, – psykid Feb 15 '19 at 13:17
6

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

adb shell service call audio 3 i32 3 i32 0 i32 
Nicofisi
  • 1,083
  • 1
  • 15
  • 27
user1627657
  • 59
  • 1
  • 2