Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Update Droidbot tool to support Android API Level 32 #152

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion droidbot/adapter/droidbot_ime.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def disconnect(self):
"""
self.connected = False
r_disable = self.device.adb.shell("ime disable %s" % IME_SERVICE)
if r_disable.endswith("now disabled"):
if "now disabled" in r_disable:
self.connected = False
print("[CONNECTION] %s is disconnected" % self.__class__.__name__)
return
Expand Down
20 changes: 15 additions & 5 deletions droidbot/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def __init__(self, device_serial=None, is_emulator=False, output_dir=None,
self.logger.info("disable minicap on emulator")
self.adapters[self.minicap] = False

# minicap is not supporting android 32 and above
if self.get_sdk_version() >= 32:
self.logger.info("disable minicap on sdk >= 32")
self.adapters[self.minicap] = False

def check_connectivity(self):
"""
check if the device is available
Expand Down Expand Up @@ -504,7 +509,7 @@ def get_top_activity_name(self):
Get current activity
"""
r = self.adb.shell("dumpsys activity activities")
activity_line_re = re.compile('\* Hist #\d+: ActivityRecord{[^ ]+ [^ ]+ ([^ ]+) t(\d+)}')
activity_line_re = re.compile(r'\*\s*Hist\s*#\d+:\s*ActivityRecord\{[^ ]+\s*[^ ]+\s*([^ ]+)\s*t(\d+)}')
m = activity_line_re.search(r)
if m:
return m.group(1)
Expand Down Expand Up @@ -541,14 +546,19 @@ def get_task_activities(self):
task_to_activities = {}

lines = self.adb.shell("dumpsys activity activities").splitlines()
activity_line_re = re.compile('\* Hist #\d+: ActivityRecord{[^ ]+ [^ ]+ ([^ ]+) t(\d+)}')
activity_line_re = re.compile(r'\*\s*Hist\s*#\d+:\s*ActivityRecord\{[^ ]+\s*[^ ]+\s*([^ ]+)\s*t(\d+)}')

for line in lines:
line = line.strip()
if line.startswith("Task id #"):
task_id = line[9:]
activity_line_task_re = re.compile(r'^\s*Task\s*id\s*#(\d+)|^\s*Task\{\w+\s*#(\d+)')
activity_line_task_m = activity_line_task_re.match(line)
if activity_line_task_m:
if activity_line_task_m.group(1):
task_id = activity_line_task_m.group(1)
else:
task_id = activity_line_task_m.group(2)
task_to_activities[task_id] = []
elif line.startswith("* Hist #"):
elif re.match(r'\*\s*Hist\s*#', line):
m = activity_line_re.match(line)
if m:
activity = m.group(1)
Expand Down
2 changes: 2 additions & 0 deletions droidbot/device_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def __parse_views(self, raw_views):

def __assemble_view_tree(self, root_view, views):
if not len(self.view_tree): # bootstrap
if not len(views): # to fix if views is empty
return
self.view_tree = copy.deepcopy(views[0])
self.__assemble_view_tree(self.view_tree, views)
else:
Expand Down