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

Add support for foreign tft package names #21

Merged
merged 1 commit into from
Jun 14, 2024
Merged
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
21 changes: 19 additions & 2 deletions alune/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,25 @@ async def is_tft_installed(self) -> bool:
Returns:
Whether the TFT package is in the list of the installed packages.
"""
shell_output = await self._device.shell(f"pm list packages {self.tft_package_name}")
return shell_output != ""
shell_output = await self._device.shell(f"pm list packages | grep {self.tft_package_name}")
if not shell_output:
return False

packages = shell_output.replace("package:", "").split("\n")
packages.remove("")

if len(packages) > 1:
logger.debug(f"More than one TFT package is installed ({packages}). Picking '{packages[0]}'.")

if not self.tft_package_name == packages[0]:
logger.debug(
f"The pre-defined TFT package '{self.tft_package_name}' "
f"is not the same as the installed one '{packages[0]}'. "
f"Switching to '{packages[0]}' for compatibility."
)
self.tft_package_name = packages[0]

return True

async def is_tft_active(self) -> bool:
"""
Expand Down