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
5 changes: 5 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 8 additions & 9 deletions phone_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
Phone Agent - An AI-powered phone automation framework.
from .adb_manager import ADBManager

This package provides tools for automating Android and iOS phone interactions
using AI models for visual understanding and decision making.
"""
# Other imports...

from phone_agent.agent import PhoneAgent
from phone_agent.agent_ios import IOSPhoneAgent
class PhoneAgent:
def __init__(self, device):
self.adb_manager = ADBManager(device)

__version__ = "0.1.0"
__all__ = ["PhoneAgent", "IOSPhoneAgent"]
def setup(self):
if not self.adb_manager.check_adb_keyboard():
print("Consider using another input method or check ADB permissions.")
21 changes: 21 additions & 0 deletions phone_agent/adb_commands.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions phone_agent/adb_control.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions phone_agent/adb_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess

class AdbManager:
def __init__(self, device_id):
self.device_id = device_id

def run_command(self, command):
try:
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 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