From 1baf9edfeb2fc1bf47ef0b691ea700c488b1a9b2 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 01:39:29 +0800 Subject: [PATCH 1/7] Fix ADB permission handling for OPPO devices --- phone_agent/adb_commands.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 phone_agent/adb_commands.py diff --git a/phone_agent/adb_commands.py b/phone_agent/adb_commands.py new file mode 100644 index 00000000..967c2a40 --- /dev/null +++ b/phone_agent/adb_commands.py @@ -0,0 +1,21 @@ +import subprocess + +def check_adb_permissions(): + try: + # Attempting to list input methods + result = subprocess.run(['adb', 'shell', 'ime', 'list', '-s'], capture_output=True, text=True) + if 'java.lang.SecurityException' in result.stderr: + raise PermissionError("Permission denied: ADB commands cannot be executed due to device restrictions.") + return result.stdout + except Exception as e: + return str(e) + +def execute_adb_command(command): + try: + result = subprocess.run(command, capture_output=True, text=True) + if result.returncode != 0: + raise RuntimeError(f"Command failed: {result.stderr}") + return result.stdout + except PermissionError as pe: + print(pe) + return None \ No newline at end of file From c10f161f54df4841167dbe239ad4b386fbcffbd6 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 01:39:31 +0800 Subject: [PATCH 2/7] Fix ADB permission handling for OPPO devices --- phone_agent/__init__.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/phone_agent/__init__.py b/phone_agent/__init__.py index f39d7e0d..e86ff097 100644 --- a/phone_agent/__init__.py +++ b/phone_agent/__init__.py @@ -1,12 +1,3 @@ -""" -Phone Agent - An AI-powered phone automation framework. +from .adb_commands import check_adb_permissions, execute_adb_command -This package provides tools for automating Android and iOS phone interactions -using AI models for visual understanding and decision making. -""" - -from phone_agent.agent import PhoneAgent -from phone_agent.agent_ios import IOSPhoneAgent - -__version__ = "0.1.0" -__all__ = ["PhoneAgent", "IOSPhoneAgent"] +__all__ = ['check_adb_permissions', 'execute_adb_command'] \ No newline at end of file From 603feb916351527b68bc3ce293567d06e57b54e2 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 02:09:25 +0800 Subject: [PATCH 3/7] Handle ADB permission issues on OPPO devices more gracefully --- phone_agent/adb_manager.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phone_agent/adb_manager.py diff --git a/phone_agent/adb_manager.py b/phone_agent/adb_manager.py new file mode 100644 index 00000000..9aabc6da --- /dev/null +++ b/phone_agent/adb_manager.py @@ -0,0 +1,15 @@ +import subprocess + +class ADBManager: + def __init__(self, device): + self.device = device + + def check_adb_keyboard(self): + try: + output = subprocess.check_output(['adb', '-s', self.device, 'shell', 'ime', 'list', '-s', 'com.android.adbkeyboard/.AdbIME']) + return 'adbkeyboard' in output.decode() + except subprocess.CalledProcessError as e: + if 'SecurityException' in str(e): + print("Permission denied. Please ensure ADB permissions are set correctly.") + return False + raise e \ No newline at end of file From 7f44d92237c4e23b0a64e5483f33e5b9e1f21122 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 02:09:27 +0800 Subject: [PATCH 4/7] Handle ADB permission issues on OPPO devices more gracefully --- phone_agent/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phone_agent/__init__.py b/phone_agent/__init__.py index e86ff097..9143bffc 100644 --- a/phone_agent/__init__.py +++ b/phone_agent/__init__.py @@ -1,3 +1,11 @@ -from .adb_commands import check_adb_permissions, execute_adb_command +from .adb_manager import ADBManager -__all__ = ['check_adb_permissions', 'execute_adb_command'] \ No newline at end of file +# Other imports... + +class PhoneAgent: + def __init__(self, device): + self.adb_manager = ADBManager(device) + + def setup(self): + if not self.adb_manager.check_adb_keyboard(): + print("Consider using another input method or check ADB permissions.") \ No newline at end of file From 1df74e5e5d17241175860de9f37df35ad1cb9ba5 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:16:15 +0800 Subject: [PATCH 5/7] Fix ADB keyboard detection issue on OPPO devices --- phone_agent/adb_control.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 phone_agent/adb_control.py diff --git a/phone_agent/adb_control.py b/phone_agent/adb_control.py new file mode 100644 index 00000000..5274e6f8 --- /dev/null +++ b/phone_agent/adb_control.py @@ -0,0 +1,11 @@ +import subprocess + +def check_adb_keyboard(): + try: + output = subprocess.check_output(["adb", "shell", "ime", "list", "-s", "com.android.adbkeyboard/.AdbIME"]) + return output.decode().strip() + except subprocess.CalledProcessError as e: + print(f"Error checking ADB keyboard: {e}") + # Provide guidance for OPPO users + print("If you're using an OPPO device, please check ADB permissions.") + return None \ No newline at end of file From 6535f3edc5109967f5c98d54df331e09eb420475 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:16:17 +0800 Subject: [PATCH 6/7] Fix ADB keyboard detection issue on OPPO devices --- docs/installation.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/installation.md diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..06d40d10 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,5 @@ +# Installation Guide + +## Troubleshooting ADB on OPPO Devices + +If you encounter issues with ADB commands on OPPO phones, ensure that your device allows ADB debugging and has the necessary permissions granted in the developer options. Refer to the OPPO support documentation for detailed guidance. \ No newline at end of file From 83b2068fcce161b98d7fb32401c234968c45bf77 Mon Sep 17 00:00:00 2001 From: loganionian <103104454+loganionian@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:43:36 +0800 Subject: [PATCH 7/7] Handle OPPO ADB permission issues gracefully --- phone_agent/adb_manager.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/phone_agent/adb_manager.py b/phone_agent/adb_manager.py index 9aabc6da..d749f4ea 100644 --- a/phone_agent/adb_manager.py +++ b/phone_agent/adb_manager.py @@ -1,15 +1,20 @@ import subprocess -class ADBManager: - def __init__(self, device): - self.device = device - - def check_adb_keyboard(self): +class AdbManager: + def __init__(self, device_id): + self.device_id = device_id + + def run_command(self, command): try: - output = subprocess.check_output(['adb', '-s', self.device, 'shell', 'ime', 'list', '-s', 'com.android.adbkeyboard/.AdbIME']) - return 'adbkeyboard' in output.decode() + result = subprocess.run(['adb', '-s', self.device_id] + command, capture_output=True, text=True, check=True) + return result.stdout except subprocess.CalledProcessError as e: - if 'SecurityException' in str(e): - print("Permission denied. Please ensure ADB permissions are set correctly.") - return False - raise e \ No newline at end of file + if 'SecurityException' in e.stderr: + return "Permission denied. Please ensure that ADB debugging is enabled and permissions are granted." + return f"Error: {e.stderr}" + + def check_adb_keyboard(self): + output = self.run_command(['shell', 'ime', 'list', '-s', 'com.android.adbkeyboard/.AdbIME']) + if "Permission denied" in output: + print("Please grant the necessary permissions for ADB.") + return output \ No newline at end of file