Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions manager/windowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ def get_window_list(self, update=False):
def _get_windows_data(self):
'''获取windows数据并解析
'''
window_name = None
result = self._device.adb.run_shell_cmd('dumpsys window windows')
result = result.replace('\r', '')
# print result
current_activity = self._device.adb.run_shell_cmd("dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8")
if '/' in current_activity:
package_name, activity_name = current_activity.split('/')
window_name = package_name + '/' + package_name + activity_name
# print result
windows = []
window = None
p1 = re.compile(r'^ Window #(\d+) Window{(\w{6,9}) (.*)}:$')
Expand All @@ -189,6 +194,8 @@ def _get_windows_data(self):
items = title.split(' ')
if 'u0' == items[0]: title = items[1]
else: title = items[0]
if title == window_name:
self._current_window = Window(self, int(ret.group(1)), ret.group(2), title)
window = Window(self, int(ret.group(1)), ret.group(2), title) # 此逻辑可能有bug
windows.append(window)
elif 'mObscuringWindow' in line:
Expand All @@ -200,14 +207,6 @@ def _get_windows_data(self):
else:
Log.w("WindowManager", line)
self._current_window = None
else:
ret = p2.search(line)
if ret:
title = ret.group(3)
self._current_window = Window(self, 0, ret.group(1), title)
else:
Log.w("WindowManager", line)
self._current_window = None
elif 'mInputMethodTarget' in line:
ret = p2.search(line)
self._current_input_target = Window(self, 0, ret.group(1), ret.group(2) if ret.group(2) and len(ret.group(2)) > 5 else ret.group(3))
Expand Down