adb:设置手机屏幕亮度
在自动化测试过程中,有时可能会需要调节Android设备屏幕亮度的场景时,可借助adb命令来实现
-
获取亮度是否为自动调节
adb shell settings get system screen_brightness_mode # 输出:0(未开启<自动调整亮度>), 1(已开启<自动调整亮度>)
-
修改设备亮度为自动调节/ 取消自动调节
# 关闭<自动调整亮度> adb shell settings put system screen_brightness_mode 0 # 开启<自动调整亮度> adb shell settings put system screen_brightness_mode 1
-
获取当前手机屏幕亮度值
adb shell settings get system screen_brightness # 输出:'90\n' # <class 'str'>
-
设置当前手机屏幕亮度
adb shell settings put system screen_brightness xxxx # 如设置为1000 adb shell settings put system screen_brightness 1000