mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 13:40:48 +00:00
devlib/target: change get_rotation (Android)
Command 'settings get system user_rotation' does not report current screen orientation value when auto-rotate is enabled or device does not support it (returning null). Replaced command used by get_rotation to 'dumpsys input'. It should now return current screen orientation value (0-3).
This commit is contained in:
parent
bdaea26f6f
commit
c4c76ebcf8
@ -45,6 +45,7 @@ FSTAB_ENTRY_REGEX = re.compile(r'(\S+) on (.+) type (\S+) \((\S+)\)')
|
|||||||
ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|Display Power: state)=([0-9]+|true|false|ON|OFF)',
|
ANDROID_SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|Display Power: state)=([0-9]+|true|false|ON|OFF)',
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'cur=(?P<width>\d+)x(?P<height>\d+)')
|
ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'cur=(?P<width>\d+)x(?P<height>\d+)')
|
||||||
|
ANDROID_SCREEN_ROTATION_REGEX = re.compile(r'orientation=(?P<rotation>[0-3])')
|
||||||
DEFAULT_SHELL_PROMPT = re.compile(r'^.*(shell|root|juno)@?.*:[/~]\S* *[#$] ',
|
DEFAULT_SHELL_PROMPT = re.compile(r'^.*(shell|root|juno)@?.*:[/~]\S* *[#$] ',
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
KVERSION_REGEX = re.compile(
|
KVERSION_REGEX = re.compile(
|
||||||
@ -1495,11 +1496,11 @@ class AndroidTarget(Target):
|
|||||||
self.set_rotation(3)
|
self.set_rotation(3)
|
||||||
|
|
||||||
def get_rotation(self):
|
def get_rotation(self):
|
||||||
cmd = 'settings get system user_rotation'
|
output = self.execute('dumpsys input')
|
||||||
res = self.execute(cmd).strip()
|
match = ANDROID_SCREEN_ROTATION_REGEX.search(output)
|
||||||
try:
|
if match:
|
||||||
return int(res)
|
return int(match.group('rotation'))
|
||||||
except ValueError:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_rotation(self, rotation):
|
def set_rotation(self, rotation):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user