dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.61k stars 344 forks source link

Is there any way to connect to remote phone? #278

Closed JinzhuWu closed 1 year ago

JinzhuWu commented 4 years ago

I find that ViewClient can connect to multi phones by distinguishing different serialno on local PC, is there any way to connect to a phone in a remote PC(share USB serial) or connect by network?

device, serialno = ViewClient.connectToDeviceOrExit(serialno)

If it works, could you give me a demo?

dtmilano commented 4 years ago

Sure there is. You can find more information about adb over the network at https://developer.android.com/studio/command-line/adb.

Then you can connect using something like this in your command line

$ adb connect 192.168.1.100:555

and in you python script

device, serialno = ViewClient.connectToDeviceOrExit(serialno='192.168.0.1:5555')
JinzhuWu commented 4 years ago

Thank you for your answer, this is a good way to complete some actions through the IP address of mobile network, and it can meet some of my requirements, but in one of my scenarios I need to modify the airplane mode, this action will cause the loss of ip address. Is there any way to meet the needs of this scene, such as sharing USB? Looking forward to your reply!

Sure there is. You can find more information about adb over the network at https://developer.android.com/studio/command-line/adb.

Then you can connect using something like this in your command line

$ adb connect 192.168.1.100:555

and in you python script

device, serialno = ViewClient.connectToDeviceOrExit(serialno='192.168.0.1:5555')