Remote device example / 远程设备示例
(lang: str = "cn")
| 116 | |
| 117 | |
| 118 | def example_remote_device(lang: str = "cn"): |
| 119 | """Remote device example / 远程设备示例""" |
| 120 | from phone_agent.adb import ADBConnection |
| 121 | |
| 122 | msgs = get_messages(lang) |
| 123 | |
| 124 | # Create connection manager |
| 125 | conn = ADBConnection() |
| 126 | |
| 127 | # Connect to remote device |
| 128 | success, message = conn.connect("192.168.1.100:5555") |
| 129 | if not success: |
| 130 | print(f"{msgs['connection_failed']}: {message}") |
| 131 | return |
| 132 | |
| 133 | print(f"{msgs['connection_successful']}: {message}") |
| 134 | |
| 135 | # Create Agent with device specified |
| 136 | agent_config = AgentConfig( |
| 137 | device_id="192.168.1.100:5555", |
| 138 | verbose=True, |
| 139 | lang=lang, |
| 140 | ) |
| 141 | |
| 142 | agent = PhoneAgent(agent_config=agent_config) |
| 143 | |
| 144 | # Execute task |
| 145 | result = agent.run("打开微信查看消息") |
| 146 | print(f"{msgs['task_result']}: {result}") |
| 147 | |
| 148 | # Disconnect |
| 149 | conn.disconnect("192.168.1.100:5555") |
| 150 | |
| 151 | |
| 152 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected