From 24f630f6560b990d76b38cfb5dce4e4ca92825cb Mon Sep 17 00:00:00 2001 From: dengshiwei Date: Wed, 17 Dec 2025 21:45:19 +0800 Subject: [PATCH] fix ADB Keyboard detection failures on different Android versions --- main.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 624d2bf7..5073aa61 100644 --- a/main.py +++ b/main.py @@ -154,15 +154,24 @@ def check_system_requirements(device_type: DeviceType = DeviceType.ADB) -> bool: if device_type == DeviceType.ADB: print("3. Checking ADB Keyboard...", end=" ") try: - result = subprocess.run( + ADB_IME_ID = "com.android.adbkeyboard/.AdbIME" + ime_ok = (ADB_IME_ID in subprocess.run( ["adb", "shell", "ime", "list", "-s"], capture_output=True, text=True, timeout=10, - ) - ime_list = result.stdout.strip() - - if "com.android.adbkeyboard/.AdbIME" in ime_list: + ).stdout or ADB_IME_ID in subprocess.run( + ["adb", "shell", "dumpsys", "input_method"], + capture_output=True, + text=True, + timeout=3, + ).stdout or ADB_IME_ID in subprocess.run( + ["adb", "shell", "settings", "get", "secure", "enabled_input_methods"], + capture_output=True, + text=True, + timeout=3, + ).stdout) + if ime_ok: print("✅ OK") else: print("❌ FAILED") @@ -261,8 +270,8 @@ def check_model_api(base_url: str, model_name: str, api_key: str = "EMPTY") -> b print(" 1. Check your network connection") print(" 2. Verify the server is responding") elif ( - "Name or service not known" in error_msg - or "nodename nor servname" in error_msg + "Name or service not known" in error_msg + or "nodename nor servname" in error_msg ): print(f" Error: Cannot resolve hostname") print(" Solution:") @@ -603,4 +612,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file