MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / getWindows

Method getWindows

src/com/dtmilano/android/adb/adbclient.py:1335–1436  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1333 return WifiManager(self)
1334
1335 def getWindows(self):
1336 self.__checkTransport()
1337 windows = {}
1338 dww = self.shell('dumpsys window windows')
1339 if DEBUG_WINDOWS: print(dww, file=sys.stderr)
1340 lines = dww.splitlines()
1341 widRE = re.compile(r'^ *Window #%s Window\{%s (u\d+ )?%s?.*\}:' %
1342 (_nd('num'), _nh('winId'), _ns('activity', greedy=True)))
1343 currentFocusRE = re.compile(r'^ mCurrentFocus=Window\{%s .*' % _nh('winId'))
1344 viewVisibilityRE = re.compile(' mViewVisibility=0x%s ' % _nh('visibility'))
1345 # This is for 4.0.4 API-15
1346 containingFrameRE = re.compile(r'^ *mContainingFrame=\[%s,%s\]\[%s,%s\] mParentFrame=\[%s,%s\]\[%s,%s\]' %
1347 (_nd('cx'), _nd('cy'), _nd('cw'), _nd('ch'), _nd('px'), _nd('py'), _nd('pw'),
1348 _nd('ph')))
1349 contentFrameRE = re.compile(r'^ *mContentFrame=\[%s,%s\]\[%s,%s\] mVisibleFrame=\[%s,%s\]\[%s,%s\]' %
1350 (_nd('x'), _nd('y'), _nd('w'), _nd('h'), _nd('vx'), _nd('vy'), _nd('vx1'),
1351 _nd('vy1')))
1352 # This is for 4.1 API-16
1353 framesRE = re.compile(r'^ *Frames: containing=\[%s,%s\]\[%s,%s\] parent=\[%s,%s\]\[%s,%s\]' %
1354 (_nd('cx'), _nd('cy'), _nd('cw'), _nd('ch'), _nd('px'), _nd('py'), _nd('pw'), _nd('ph')))
1355 contentRE = re.compile(r'^ *content=\[%s,%s\]\[%s,%s\] visible=\[%s,%s\]\[%s,%s\]' %
1356 (_nd('x'), _nd('y'), _nd('w'), _nd('h'), _nd('vx'), _nd('vy'), _nd('vx1'), _nd('vy1')))
1357 policyVisibilityRE = re.compile('mPolicyVisibility=%s ' % _ns('policyVisibility', greedy=True))
1358
1359 currentFocus = None
1360
1361 for l in range(len(lines)):
1362 m = widRE.search(lines[l])
1363 if m:
1364 num = int(m.group('num'))
1365 winId = m.group('winId')
1366 activity = m.group('activity')
1367 wvx = 0
1368 wvy = 0
1369 wvw = 0
1370 wvh = 0
1371 px = 0
1372 py = 0
1373 visibility = -1
1374 policyVisibility = 0x0
1375
1376 for l2 in range(l + 1, len(lines)):
1377 m = widRE.search(lines[l2])
1378 if m:
1379 l += (l2 - 1)
1380 break
1381 m = viewVisibilityRE.search(lines[l2])
1382 if m:
1383 visibility = int(m.group('visibility'))
1384 if DEBUG_COORDS: print("getWindows: visibility=", visibility, file=sys.stderr)
1385 if self.build[VERSION_SDK_PROPERTY] >= 17:
1386 wvx, wvy = (0, 0)
1387 wvw, wvh = (0, 0)
1388 if self.build[VERSION_SDK_PROPERTY] >= 16:
1389 m = framesRE.search(lines[l2])
1390 if m:
1391 px, py = obtainPxPy(m)
1392 m = contentRE.search(lines[l2 + 1])

Callers 3

getFocusedWindowMethod · 0.95
get_windowsMethod · 0.80
testGetWindowsMethod · 0.80

Calls 10

__checkTransportMethod · 0.95
shellMethod · 0.95
_ndFunction · 0.90
_nhFunction · 0.90
_nsFunction · 0.90
obtainPxPyFunction · 0.90
obtainVxVyFunction · 0.90
obtainVwVhFunction · 0.90
WindowClass · 0.90
rangeFunction · 0.85

Tested by 1

testGetWindowsMethod · 0.64