ADB command to mount volume?

Is there any Adb command to set the volume to a specific value? I know what we can do

adb shell input keyevent 

      

to increase and decrease the volume, but I want to set it to a specific value. If I change it to DB, then I need to reboot the device for the changes to be reflected, so I don't want to go that route. Isn't there some API where I can change the value without having to restart it and depending on volume up and down?

+1


source to share


2 answers


On the rooted phone, you can call setMasterVolume()

with service call audio <code> i32 <volume>

. The codes are version specific. Let's say you want to set the volume to 50% on a KitKat device. The command will:



service call audio 9 i32 50

      

+3


source


I used a sound test to call a service to set the volume on an Android 2.3 device. To be more general, you need to examine the IBinder and the transaction number.

To find out what you want:

Adb Shell Service List Packages

  • this will tell you the batch file you need to look for the service (Ie Bluetooth - com.Bluetooth.IBluetooth).

Search for service class and transactions online ("COM.Bluetooth.Ibluetooth transaction")

Find the source files and find information about the Ibinder transaction. This will be followed by details of the input parameters.

I. First Bluetooth transaction enabled. (included). No input parameters



To use it, submit:

Adb Bluetooth Shell Call Service 1

It should return a packet containing the response.

Remember: - I think this is for rooted devices only - the transaction number you find has an offset of 1 (transaction 0 is called with service 1) - There are two types of input: i32 for integer or s16 for string

There are three integers for sound setting for a given volume (transaction 6)

To use it, submit:

call Adb shell service 7 i32 3 i32 15 i32 0 This will set the media volume to 15 (default number of levels for media audio is 15)

+2


source







All Articles