Skip to content
Open
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
17 changes: 10 additions & 7 deletions Framework/install_handler/android/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
import asyncio
import platform
import os
from Framework.install_handler.install_log_config import get_logger
from Framework.install_handler.utils import send_response
from Framework.install_handler.android.android_sdk import update_android_sdk_path

logger = get_logger()


async def check_status() -> bool:
"""Check if ADB (Android Debug Bridge) is installed."""
print("[installer][android-adb] Checking status...")
logger.info("[installer][android-adb] Checking status...")

try:

Expand All @@ -26,7 +29,7 @@ async def check_status() -> bool:
# If command succeeds (returncode = 0), ADB is installed
if result.returncode == 0:
version_output = (result.stdout or result.stderr).strip()
print(f"[installer][android-adb] Already installed")
logger.info("[installer][android-adb] Already installed")
await send_response({
"action": "status",
"data": {
Expand All @@ -38,7 +41,7 @@ async def check_status() -> bool:
})
return True
else:
print("[installer][android-adb] Not installed")
logger.info("[installer][android-adb] Not installed")
await send_response({
"action": "status",
"data": {
Expand All @@ -50,7 +53,7 @@ async def check_status() -> bool:
})
return False
except Exception as e:
print(f"[installer][android-adb] Error checking status: {e}")
logger.error("[installer][android-adb] Error checking status: %s", e)
await send_response({
"action": "status",
"data": {
Expand All @@ -67,15 +70,15 @@ async def check_status() -> bool:

async def install():
"""Install ADB - checks if already installed, otherwise prompts to install Android SDK."""
print("[installer][android-adb] Installing...")
logger.info("[installer][android-adb] Installing...")

# Check if ADB is already installed
if await check_status():
print("[installer][android-adb] ADB is already installed")
logger.info("[installer][android-adb] ADB is already installed")
return

# ADB is not installed, send response to install Android SDK
print("[installer][android-adb] ADB is not installed. Install Android SDK to get ADB.")
logger.info("[installer][android-adb] ADB is not installed. Install Android SDK to get ADB.")
await send_response({
"action": "status",
"data": {
Expand Down
79 changes: 75 additions & 4 deletions Framework/install_handler/android/android_emulator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,78 @@
async def check_status():
print("[android_emulator] Checking status...")
import platform

from Framework.install_handler.install_log_config import get_logger
from . import emulator as emulator_macos
from . import emulator_windows_linux

logger = get_logger()

def _is_darwin() -> bool:
return platform.system().lower() == "darwin"


async def check_emulator_list():
"""
OS router for AndroidEmulator system images services.
- macOS: uses `emulator.py`
- Windows/Linux: uses `emulator_windows_linux.py`
"""
system = platform.system().lower()
if system == "darwin":
logger.debug("[android_emulator] Routing to macOS emulator module")
return await emulator_macos.check_emulator_list()

logger.debug("[android_emulator] Routing to Windows/Linux emulator module")
return await emulator_windows_linux.check_emulator_list()


async def android_emulator_install():
"""
OS router for AndroidEmulator installation.
- macOS: uses `emulator.py`
- Windows/Linux: uses `emulator_windows_linux.py`
"""
system = platform.system().lower()
if system == "darwin":
logger.debug("[android_emulator] Routing to macOS emulator module")
return await emulator_macos.android_emulator_install()

logger.debug("[android_emulator] Routing to Windows/Linux emulator module")
return await emulator_windows_linux.android_emulator_install()


async def create_avd_from_system_image(device_param: str) -> bool:
"""
Create an AVD from a chosen system-image device param.
Routes to the correct platform implementation dynamically.
"""
if _is_darwin():
logger.debug("[android_emulator] Routing create_avd to macOS module")
return await emulator_macos.create_avd_from_system_image(device_param)
logger.debug("[android_emulator] Routing create_avd to Windows/Linux module")
return await emulator_windows_linux.create_avd_from_system_image(device_param)


async def get_filtered_avd_services():
"""
Return filtered AVD services to display on the installer UI.
Routes to the correct platform implementation dynamically.
"""
if _is_darwin():
logger.debug("[android_emulator] Routing get_filtered_avd_services to macOS module")
return await emulator_macos.get_filtered_avd_services()
logger.debug("[android_emulator] Routing get_filtered_avd_services to Windows/Linux module")
return await emulator_windows_linux.get_filtered_avd_services()


async def launch_avd(avd_name: str) -> bool:
"""
Launch an existing AVD.
Routes to the correct platform implementation dynamically.
"""
if _is_darwin():
logger.debug("[android_emulator] Routing launch_avd to macOS module")
return await emulator_macos.launch_avd(avd_name)
logger.debug("[android_emulator] Routing launch_avd to Windows/Linux module")
return await emulator_windows_linux.launch_avd(avd_name)

async def install():
print("[android_emulator] Installing...")

Loading
Loading