Skip to content

How to alternately connect two computers to the same phone? #5478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
madmax2615 opened this issue Nov 12, 2024 · 7 comments
Open

How to alternately connect two computers to the same phone? #5478

madmax2615 opened this issue Nov 12, 2024 · 7 comments

Comments

@madmax2615
Copy link

I would like to be able to alternately connect two computers (both with MX Linux 23.4 xfce 64-bit) to the same phone (Galaxy S21 FE G5), depending on which computer I'm currently using. How can I do this, please?

So far, this is what I'm doing:
Being on the first computer, I have to make a USB connection and then a WIFI connection. Then I go to the other computer and make one more USB connection and a WIFI connection.

But when I'm back on the first computer, scrcpy doesn't remember the first WIFI connection and therefore I have to make a new USB connection before I can go on with a WIFI connection.

What can I do to make a USB connection only once for both computers, and afterwards being able to only use WIFI connections, please?

@rom1v
Copy link
Collaborator

rom1v commented Nov 12, 2024

Once your device listens over TCP/IP, until the next device reboot, you can just adb connect xx.xx.xx.xx and adb disconnect as you want, without reconnecting USB.

(Note that adb server does not support 2 connected computers simultaneously though, so you must adb disconnect on one computer before connecting from the other.)

For convenience, you can use scrcpy --tcpip=xx.xx.xx.xx which performs the adb connect for you.

https://github.com/Genymobile/scrcpy/blob/master/doc/connection.md#tcpip-wireless

@madmax2615
Copy link
Author

madmax2615 commented Nov 12, 2024

I'm not sure if you understand what I'm trying to do.

I'm looking for a way to access only one(!) phone from two(!) computers (let's say, a desktop computer and a laptop).
So actually, I have two(!) computer IP's, but only one(!) phone IP.

It doesn't have to be these two computers connected at the same time, but one or the other one alternately, but without the need of repeating the USB connection each time I'm moving to the other computer.

If it is not possible yet, I would very much like to see such a feature in an upcoming version of scrcpy.

@rom1v
Copy link
Collaborator

rom1v commented Nov 12, 2024

I'm looking for a way to access only one(!) phone from two(!) computers (let's say, a desktop computer and a laptop).
So actually, I have two(!) computer IP's, but only one(!) phone IP.

Yes, exactly. My previous comment was for this situation. xx.xx.xx.xx is the device IP.

@madmax2615
Copy link
Author

Ok, thank you and sorry!
So the misunderstanding was on my(!) side.

@rom1v
Copy link
Collaborator

rom1v commented Nov 12, 2024

To clarify, basically, the first time, plug your device over USB, and run adb tcpip 5555 (or scrcpy --tcpip).
Find the device IP (it is printed in the scrcpy logs with scrcpy --tcpip).

Then unplug the device, and execute scrcpy --tcpip=xx.xx.xx.xx from one computer.
Then adb disconnect from the first computer to disconnect, then you can scrcpy --tcpip=xx.xx.xx.xx from the other computer.

@madmax2615
Copy link
Author

What about the adb key?
I mean, when I'm on USB on the first computer, the phone wants me to confirm an adb key and at the same time, there are adbkey files being created on the computer (in the ~/.android folder).

Now, when I'm on the second computer using WiFi, will I have to confirm another adb key on the phone, or do I have to copy the ~/.android folder from the first computer to the second one, or is another ~/.android folder being created on the second computer with some different data?

@rom1v
Copy link
Collaborator

rom1v commented Nov 13, 2024

Confirm another adb key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants