adb设置音量

Android 11之前

Android 10 方案

  • 设置媒体音量为0可以设置为:

    adb shell media volume --set 0
    
  • 各项的详细设置

adb shell 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

Android 11方案

  • 设置媒体音量为0可以设置为:

adb shell service call audio 10 i32 3 i32 0 i32 1Result: Parcel(00000000    '....')
  • 参数用法详细解释看这里

  • streamType参数,详情看这里

# coding:UTF-8
import os
import time

devices = ['dasodahd', , 'du1eoqhdhd']

while True:
    for device in devices:
        cmd = f'adb -s {device} shell service call audio 10 i32 3 i32 0 i32 1'
        cmd2 = f'adb -s {device} shell  service call audio 10 i32 4 i32 0 i32 1'
        cmd3 = f'adb -s {device} shell svc wifi disable'
        os.popen(cmd)
        os.popen(cmd2)
        os.popen(cmd3)
    time.sleep(30)

参考文章:https://blog.csdn.net/xcjean/article/details/103091155

你可能感兴趣的:(adb设置音量)