Enforce consistency in Android modules

This commit is contained in:
Nex 2022-01-31 11:30:49 +01:00
parent 8d15ff58dd
commit fb8a7ca104
3 changed files with 14 additions and 31 deletions

View File

@ -27,13 +27,9 @@ class DumpsysAccessibility(AndroidExtraction):
self.detected.append(result)
continue
def run(self):
self._adb_connect()
stats = self._adb_command("dumpsys accessibility")
def process_accessibility(self, output):
in_services = False
for line in stats.split("\n"):
for line in output.split("\n"):
if line.strip().startswith("installed services:"):
in_services = True
continue
@ -54,4 +50,10 @@ class DumpsysAccessibility(AndroidExtraction):
log.info("Identified a total of %d accessibility services", len(self.results))
def run(self):
self._adb_connect()
output = self._adb_command("dumpsys accessibility")
self.process_accessibility(output)
self._adb_disconnect()

View File

@ -30,18 +30,11 @@ class DumpsysActivities(AndroidExtraction):
self.detected.append({intent: activity})
continue
def parse_activity_resolver_table(self, data):
"""Parse output of dumpsys package.
:param data: Output of dumpsys package command.
:type data: str
"""
def parse_activity_resolver_table(self, output):
in_activity_resolver_table = False
in_non_data_actions = False
intent = None
for line in data:
for line in output.split("\n"):
if line.startswith("Activity Resolver Table:"):
in_activity_resolver_table = True
continue
@ -92,9 +85,6 @@ class DumpsysActivities(AndroidExtraction):
self._adb_connect()
output = self._adb_command("dumpsys package")
if not output:
return
self.parse_activity_resolver_table(output.split("\n"))
self.parse_activity_resolver_table(output)
self._adb_disconnect()

View File

@ -52,17 +52,11 @@ class DumpsysReceivers(AndroidExtraction):
self.detected.append({intent: receiver})
continue
def parse_receiver_resolver_table(self, data):
"""Parse output of dumpsys package.
:param data: Output of dumpsys package command.
:type data: str
"""
def parse_receiver_resolver_table(self, output):
in_receiver_resolver_table = False
in_non_data_actions = False
intent = None
for line in data:
for line in output.split("\n"):
if line.startswith("Receiver Resolver Table:"):
in_receiver_resolver_table = True
continue
@ -113,9 +107,6 @@ class DumpsysReceivers(AndroidExtraction):
self._adb_connect()
output = self._adb_command("dumpsys package")
if not output:
return
self.parse_receiver_resolver_table(output.split("\n"))
self.parse_receiver_resolver_table(output)
self._adb_disconnect()