Skip to content
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

Add --no-kill-adb-before-hid option #4035

Closed
wants to merge 1 commit into from
Closed

Add --no-kill-adb-before-hid option #4035

wants to merge 1 commit into from

Conversation

wh201906
Copy link

Hi. This is for #4028 (comment)
I'm not sure if the option name is good or not.

rom1v pushed a commit that referenced this pull request Jun 1, 2023
Add an option not to kill the adb daemon on Windows if --otg is
specified.

Refs #4028 <#4028>
PR #4035 <#4035>

Signed-off-by: Romain Vimont <[email protected]>
@rom1v
Copy link
Collaborator

rom1v commented Jun 1, 2023

Thank you. I made some changes/fixes, and renamed hid to otg: branch no_kill_adb_before_otg.

However, after thinking about it, I think this option is useless. In #4032, you say:

To monitor the phone and control it at the same time, I need to use adb over TCP and keyboard simulation in OTG mode.
However, If I start scrcpy for monitoring first and start another instance in otg mode for keyboard simulation, the latter will kill the adb daemon. So I have to start the scrcpy in otg mode first, then start scrcpy for monitoring.
[…]
To start the two instances mentioned above in any sequence, I'd like to add an option to prevent killing adb daemon in otg mode

If you start the adb daemon first, and don't kill it, your device will not be detected in otg mode, so scrcpy --otg will fail. That's the reason why it kills adb (to make it work). So this new option will not help.

@wh201906
Copy link
Author

wh201906 commented Jun 2, 2023

You mean the scrcpy still uses adb to detect the Android device even with the --otg option, right?

@yume-chan
Copy link
Contributor

Maybe Scrcpy can call adb -s <serial> detach or adb -t <transport-id> detach to let ADB server release the USB device, so it doesn't need to kill the ADB server.

@rom1v
Copy link
Collaborator

rom1v commented Jun 2, 2023

You mean the scrcpy still uses adb to detect the Android device even with the --otg option, right?

No, but if the USB device is open by adb, then scrcpy will not be able to open it separately for OTG. On other OS, it is perfectly ok to open a USB device already open by another program, but not on Windows.

@yume-chan maybe, to be tested. 😃

@wh201906
Copy link
Author

wh201906 commented Jun 2, 2023

No, but if the USB device is open by adb, then scrcpy will not be able to open it separately for OTG. On other OS, it is perfectly ok to open a USB device already open by another program, but not on Windows.

How about the adb over TCP? I know it's impossible to use mirroring and otg on the same phone via USB, but I can use mirroring over TCP and otg over USB at the same time. Do you mean the device becomes undetectable if it is connected by adb, even via TCP?

@rom1v
Copy link
Collaborator

rom1v commented Jun 2, 2023

Do you mean the device becomes undetectable if it is connected by adb, even via TCP?

By default, IIRC, if you plug the device and USB debugging is enabled, the adb daemon will detect it and open it, even if you don't use it.

@wh201906
Copy link
Author

wh201906 commented Jun 2, 2023

By default, IIRC, if you plug the device and USB debugging is enabled, the adb daemon will detect it and open it, even if you don't use it.

If so, this option is useless indeed. Thank you for checking this.
Should I close this pull request now?

@yume-chan
Copy link
Contributor

Tried the adb detach command. First it outputs:

> adb detach
adb.exe: failed to detach: attach/detach only implemented for libusb backend
NativeCommandExitException: Program "adb.exe" ended with non-zero exit code: 1.

Launch adb with libusb backend:

> $env:ADB_LIBUSB="1"
> adb server nodaemon
adb.exe F 06-02 21:49:59 14088 15940 usb_libusb.cpp:972] failed to register libusb hotplug callback
NativeCommandExitException: Program "adb.exe" ended with non-zero exit code: -1073740791.

it crashes immediately (due to unknow error, not the error it logged).

@rom1v
Copy link
Collaborator

rom1v commented Jun 2, 2023

Thank you for the test 👍

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

Successfully merging this pull request may close these issues.

3 participants