diff --git a/libs/utils/android/system.py b/libs/utils/android/system.py index c26b0dd0830691c15e74b3892634f117662a7adc..7f37cde884ccf7773636b52e3abb0a948c2e2bc0 100644 --- a/libs/utils/android/system.py +++ b/libs/utils/android/system.py @@ -274,6 +274,26 @@ class System(object): """ target.execute('input keyevent KEYCODE_SLEEP') + @staticmethod + def volume(target, times=1, direction='down'): + """ + Increase or decrease volume + + :param target: instance of devlib Android target + :type target: devlib.target.AndroidTarget + + :param times: number of times to perform operation + :type times: int + + :param direction: which direction to increase (up/down) + :type direction: str + """ + for i in range(times): + if direction == 'up': + target.execute('input keyevent KEYCODE_VOLUME_UP') + elif direction == 'down': + target.execute('input keyevent KEYCODE_VOLUME_DOWN') + @staticmethod def gfxinfo_reset(target, apk_name): """