For Android 10
adb shell media volume --show --stream 1 --set 1
example :
/ $ media volume --show --stream 4 --set 1
[v] will control stream=4 (STREAM_ALARM)
[v] will set volume to index=1
[v] Connecting to AudioService
Specific usage
usage: media [subcommand] [options]
media dispatch KEY
media list-sessions
media monitor <tag>
media volume [options]
media dispatch: dispatch a media key to the system.
KEY may be: play, pause, play-pause, mute, headsethook,
stop, next, previous, rewind, record, fast-forword.
media list-sessions: print a list of the current sessions.
media monitor: monitor updates to the specified session.
Use the tag from list-sessions.
media volume: the options are as follows:
--stream STREAM selects the stream to control, see AudioManager.STREAM_*
controls AudioManager.STREAM_MUSIC if no stream is specified
--set INDEX sets the volume index value
--adj DIRECTION adjusts the volume, use raise|same|lower for the direction
--get outputs the current volume
--show shows the UI during the volume change
examples:
adb shell media volume --show --stream 3 --set 11
adb shell media volume --stream 0 --adj lower
adb shell media volume --stream 3 --get
adb shell service call audio 7 i32 3 i32 0 i32 1
Source: SO post