From c86448bb8671fe86bf93126990f1458afec2d082 Mon Sep 17 00:00:00 2001 From: Joel Fernandes Date: Tue, 16 May 2017 22:37:31 -0700 Subject: [PATCH] android: Add support to set volume Signed-off-by: Joel Fernandes --- libs/utils/android/system.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libs/utils/android/system.py b/libs/utils/android/system.py index c26b0dd08..7f37cde88 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): """ -- GitLab