23
23
from autopilot.display import Display as DisplayBase
24
from subprocess import check_output
27
DEVICE = check_output(
28
["/usr/bin/getprop", "ro.product.device"]).decode().strip()
33
"generic": (480, 800),
35
"maguro": (720, 1280),
36
"manta": (2560, 1600),
37
"grouper": (800, 1280),
40
if DEVICE not in RESOLUTIONS:
41
raise NotImplementedError(
42
'Device "{}" is not supported by Autopilot.'.format(DEVICE))
44
X, Y = RESOLUTIONS[DEVICE]
24
from autopilot.platform import image_codename
28
def query_resolution():
30
return _get_fbset_resolution()
32
return _get_hardcoded_resolution()
35
def _get_fbset_resolution():
36
"""Return the resolution, as determined by fbset, or None."""
37
fbset_output = _get_fbset_output()
38
for line in fbset_output.split('\n'):
40
if line.startswith('Mode'):
41
quoted_resolution = line.split()[1]
42
resolution_string = quoted_resolution.strip('"')
43
return tuple(int(piece) for piece in resolution_string.split('x'))
44
raise RuntimeError("No modes found from fbset output")
47
def _get_fbset_output():
48
return subprocess.check_output(["fbset", "-s", "-x"]).decode().strip()
51
def _get_hardcoded_resolution():
52
name = image_codename()
55
"generic": (480, 800),
57
"maguro": (720, 1280),
58
"manta": (2560, 1600),
59
"grouper": (800, 1280),
62
if name not in resolutions:
63
raise NotImplementedError(
64
'Device "{}" is not supported by Autopilot.'.format(name))
66
return resolutions[name]
46
69
logger = logging.getLogger(__name__)
49
72
class Display(DisplayBase):
50
73
"""The base class/inteface for the display devices"""
76
super(Display, self).__init__()
77
self._X, self._Y = query_resolution()
52
79
def get_num_screens(self):
53
80
"""Get the number of screens attached to the PC."""
60
87
def get_screen_width(self):
63
90
def get_screen_height(self):
66
93
def get_screen_geometry(self, screen_number):
67
94
"""Get the geometry for a particular screen.
69
96
:return: Tuple containing (x, y, width, height).
99
return (0, 0, self._X, self._Y)