mirror of
https://github.com/mvt-project/mvt.git
synced 2024-06-29 07:39:00 +00:00
Potential fix for user issue on android package module
This commit is contained in:
parent
63c4dea3d0
commit
499ded4e7b
|
@ -105,6 +105,7 @@ class Packages(AndroidExtraction):
|
||||||
log=log,
|
log=log,
|
||||||
results=results,
|
results=results,
|
||||||
)
|
)
|
||||||
|
self._user_needed = False
|
||||||
|
|
||||||
def serialize(self, record: dict) -> Union[dict, list]:
|
def serialize(self, record: dict) -> Union[dict, list]:
|
||||||
records = []
|
records = []
|
||||||
|
@ -236,7 +237,10 @@ class Packages(AndroidExtraction):
|
||||||
return parse_dumpsys_package_for_details("\n".join(lines))
|
return parse_dumpsys_package_for_details("\n".join(lines))
|
||||||
|
|
||||||
def _get_files_for_package(self, package_name: str) -> list:
|
def _get_files_for_package(self, package_name: str) -> list:
|
||||||
output = self._adb_command(f"pm path {package_name}")
|
command = f"pm path {package_name}"
|
||||||
|
if self._user_needed:
|
||||||
|
command += " --user 0"
|
||||||
|
output = self._adb_command(command)
|
||||||
output = output.strip().replace("package:", "")
|
output = output.strip().replace("package:", "")
|
||||||
if not output:
|
if not output:
|
||||||
return []
|
return []
|
||||||
|
@ -270,6 +274,9 @@ class Packages(AndroidExtraction):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
packages = self._adb_command("pm list packages -u -i -f")
|
packages = self._adb_command("pm list packages -u -i -f")
|
||||||
|
if "java.lang.SecurityException" in packages or packages.strip() == "":
|
||||||
|
self._user_needed = True
|
||||||
|
packages = self._adb_command("pm list packages -u -i -f --user 0")
|
||||||
|
|
||||||
for line in packages.splitlines():
|
for line in packages.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -310,7 +317,10 @@ class Packages(AndroidExtraction):
|
||||||
{"field": "third_party", "arg": "-3"},
|
{"field": "third_party", "arg": "-3"},
|
||||||
]
|
]
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
output = self._adb_command(f"pm list packages {cmd['arg']}")
|
command = f"pm list packages {cmd['arg']}"
|
||||||
|
if self._user_needed:
|
||||||
|
command += " --user 0"
|
||||||
|
output = self._adb_command(command)
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line.startswith("package:"):
|
if not line.startswith("package:"):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user