Is there any Adb command to set the volume to a particular value? I know that we can do
adb shell input keyevent
for volume up and down but i want to set it to a particular value. If I change it it DB then I have to reboot the device for the changes to be reflected so i do not want to go that path. Isn't there any API where I can change the value without having to restart it and having to be dependent on Volume up and Down?
I have used the service call audio test to set the volume on an android 2.3 device. In order to be more generic you need to research IBinder and the transaction number.
To find out what you want:
Adb shell service list packages
Search for the service class and 'transaction' online ("com.Bluetooth.Ibluetooth transaction")
Find the source files and find the Ibinder transaction details. This will be followed by the details of the input parameters.
I.e the first transaction on Bluetooth is .is enabled(). There are no input parameters
To use it send:
Adb shell service call Bluetooth 1
It should return a parcel containing the answer.
Remember: - I think it is only for rooted devices - the transaction number you find has an offset of 1 (transaction 0 is called with service call 'service' 1) - There are two types of input: i32 for integer or s16 for string
To set the audio there are three input integers for set volume (transaction 6)
To use it send:
Adb shell service call 7 i32 3 i32 15 i32 0 This will set the media volume to 15 (default number of levels for media audio is 15)
On a rooted phone you can call
setMasterVolume()
withservice call audio <code> i32 <volume>
. The codes are version specific. Let's say you want to set volume to 50% on a KitKat device. The command will be:media
shell command can also be used:The first example is probably the one you were looking for (but it probably didn't exist at the time of asking)