Some newer Android devices cannot be taken into use via vhclient

We are using the latest generic Linux vhclient and vhserver versions, all running on Ubuntu 20.04 PCs. We have several Android phones connected to the vhserver PC to be shared between our development team. While majority of Android devices (several Samsung and other manufacturer's devices) can be connected properly from the server to the clients, some models (Samsung S21+ and  Samsung XCover6 Pro, for example) with Android 12 cannot be taken into use. When using the vhui client (right click the device in the server's list and select use), the device just shortly flashes in the client side and then disconnects immediately.

Would you happen to know some tricks to fix the situation and if not, what kind of logs or other info do you need to debug the issue?

#2

Right click on the problematic samsung device and select Custom Event Handler and paste this line in:

onReset.$VENDOR_ID$.$PRODUCT_ID$=

Then try to use the phone via virtualhere again.

 

#3

Thank you for the quick reply. Unfortunately adding the custom event handler did not help. Here are /var/log/syslog entries from client side, maybe you see something that could solve the issue?

Nov 29 07:26:18 60NB608514 kernel: [  576.103873] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(15)
Nov 29 07:26:18 60NB608514 kernel: [  576.103878] vhci_hcd vhci_hcd.0: devid(5) speed(3) speed_str(high-speed)
Nov 29 07:26:18 60NB608514 kernel: [  576.103885] vhci_hcd vhci_hcd.0: Device attached
Nov 29 07:26:18 60NB608514 kernel: [  576.336650] usb 3-1: new high-speed USB device number 3 using vhci_hcd
Nov 29 07:26:18 60NB608514 kernel: [  576.464933] usb 3-1: SetAddress Request (3) to port 0
Nov 29 07:26:18 60NB608514 kernel: [  576.513839] usb 3-1: New USB device found, idVendor=04e8, idProduct=6860, bcdDevice= 5.04
Nov 29 07:26:18 60NB608514 kernel: [  576.513858] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Nov 29 07:26:18 60NB608514 kernel: [  576.513865] usb 3-1: Product: SAMSUNG_Android
Nov 29 07:26:18 60NB608514 kernel: [  576.513871] usb 3-1: Manufacturer: SAMSUNG
Nov 29 07:26:18 60NB608514 kernel: [  576.513876] usb 3-1: SerialNumber: RFCR1087KHE
Nov 29 07:26:18 60NB608514 kernel: [  576.555957] cdc_acm 3-1:1.1: ttyACM0: USB ACM device
Nov 29 07:26:19 60NB608514 kernel: [  576.584674] vhci_hcd: connection closed
Nov 29 07:26:19 60NB608514 kernel: [  576.584779] vhci_hcd: stop threads
Nov 29 07:26:19 60NB608514 kernel: [  576.584787] vhci_hcd: release socket
Nov 29 07:26:19 60NB608514 kernel: [  576.584796] vhci_hcd: disconnect device
Nov 29 07:26:19 60NB608514 kernel: [  576.584891] usb 3-1: USB disconnect, device number 3
Nov 29 07:25:58 60NB608514 cntlm[1515]: 127.0.0.1 CONNECT safebrowsing.googleapis.com:443
Nov 29 07:26:19 60NB608514 colord[963]: CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_
Nov 29 07:26:19 60NB608514 colord[963]: message repeated 3 times: [ CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_]
Nov 29 07:26:19 60NB608514 ModemManager[971]: <info>  [base-manager] port ttyACM0 released by device '/sys/devices/platform/vhci_hcd.0/usb3'
Nov 29 07:26:19 60NB608514 ModemManager[971]: <info>  [base-manager] couldn't check support for device '/sys/devices/platform/vhci_hcd.0/usb3': Operation was cancelled
Nov 29 07:26:19 60NB608514 gnome-shell[1977]: Object .GProxyVolume (0x55d827404610), has been already deallocated — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
Nov 29 07:26:19 60NB608514 gnome-shell[1977]: g_volume_mount_finish: assertion 'G_IS_VOLUME (volume)' failed
Nov 29 07:26:19 60NB608514 gnome-shell[1977]: == Stack trace for context 0x55d8213f18c0 ==
Nov 29 07:26:19 60NB608514 gnome-shell[1977]: #0   55d8271167c8 i   resource:///org/gnome/shell/ui/components/automountManager.js:190 (111ff6ad0088 @ 38)
Nov 29 07:26:19 60NB608514 gnome-shell[1977]: #1   7ffe0458b3b0 b   self-hosted:1011 (29fed7a0d30 @ 454)
Nov 29 07:26:25 60NB608514 gnome-shell[1977]: Some code accessed the property 'discreteGpuAvailable' on the module 'appDisplay'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway.

 

Here are the server side logs as well:

 

Nov 29 07:29:59 FIDTI000032 vhusbdx86_64[1979]: Set custom event "onReset.04e8.6860="
Nov 29 07:30:01 FIDTI000032 CRON[2452]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Nov 29 07:30:05 FIDTI000032 vhusbdx86_64[1979]: Set custom event "onReset.04e8.6860="
Nov 29 07:30:07 FIDTI000032 vhusbdx86_64[1979]: Executed "" for onReset.04e8.6860
Nov 29 07:30:07 FIDTI000032 vhusbdx86_64[1979]: Device 31 [04e8:6860] BOUND to connection 8
Nov 29 07:30:08 FIDTI000032 kernel: [ 1116.677690] usb 3-1: USB disconnect, device number 9
Nov 29 07:30:08 FIDTI000032 vhusbdx86_64[1979]: Device 31 [04e8:6860] SURPRISE UNBOUND from connection 8
Nov 29 07:30:08 FIDTI000032 vhusbdx86_64[1979]: Unmanaging device 31 [04e8:6860]
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.128877] usb 3-1: new high-speed USB device number 12 using xhci_hcd
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.284346] usb 3-1: New USB device found, idVendor=04e8, idProduct=6860, bcdDevice= 5.04
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.284351] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.284354] usb 3-1: Product: SAMSUNG_Android
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.284356] usb 3-1: Manufacturer: SAMSUNG
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.284358] usb 3-1: SerialNumber: RFCR1087KHE
Nov 29 07:30:08 FIDTI000032 kernel: [ 1117.309388] cdc_acm 3-1:1.1: ttyACM0: USB ACM device
Nov 29 07:30:08 FIDTI000032 vhusbdx86_64[1979]: Found High speed device [04e8:6860] "SAMSUNG, SAMSUNG_Android" at address 31
Nov 29 07:30:08 FIDTI000032 colord[1551]: CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs_SAMSUNG_SAMSUNG_Android
Nov 29 07:30:08 FIDTI000032 colord[1551]: CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_
Nov 29 07:30:08 FIDTI000032 colord[1551]: message repeated 4 times: [ CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_]
Nov 29 07:30:08 FIDTI000032 snapd[779]: hotplug.go:200: hotplug device add event ignored, enable experimental.hotplug
Nov 29 07:30:11 FIDTI000032 ModemManager[888]: <info>  [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:1c.7/0000:08:00.0/usb3/3-1': not supported by any plugin

 

 

#4

OK i dont know unfortunately. SURPRISE UNBOUND means that the device itself disconnected from the USB bus without virtualhere telling it to do so.  Are you connecting in Android "Developer Mode" or just normal sync mode to the phone?  Because you might get a popup on the phone about approval if you are in Developer Mode

#5

We are using the developer mode, but sharing the same adb key in all places, so no popups are appearing. Also there should be no difference in settings between the devices that are successfully connected and these that are immediately disconnected.

So I guess we have to throw in the towel with this one then.

#6

I cannot give up just yet, we have an amazing Android device farm system running thanks to VirtualHere and I am worried that in the future more and more devices will not work in that system.

I tested briefly using the built-in usbip program in Ubuntu. That worked well for Android 9 devices (Samsung A8 and Samsung S8 for example), but not anymore for Android 11 devices, such as Samsung A32. The same immediate disconnect after BIND happened there, which initially forced me to start asking here for help. In that respect, VirtualHere works much better than usbip, because it has no problems with A32, sharing the device over network is working nicely even after applying Android 12 update to A32. I have to mention also that when USB debugging is set OFF in developer settings, all devices work OK in VirtualHere, but that is not feasible, since we need adb to work.

So I am still hoping you could help us to find a solution for getting the XCover6 Pro, S20, S21 and possibly S22 devices working. I have now spent whole Saturday trying to find differences between the A32 and XCover6 Pro, that would indicate the problem. The only clear difference I noticed was that when running the command: "adb shell svc usb getFunctions"

XCover6 returns: mtp,conn_gadget,adb

A32 returns: mtp,adb

So might the conn_gadget be the cause for the problems? I cannot say. Also the USB configuration for XCover6 is "mtp_conn_adb", where as in A32 it is "mtp_acm_adb".

I have taken some adb logs, but they are messy when posted here. Would those help or do you think that the problem might be in the kernel level?

#7

What about if you try the client on windows instead? Does the phone work ok via virtualhere and adb?

#8

Tested using a Windows client, while server was running on the same Ubuntu 20.04 PC. The behaviour is identical to Linux client, immediate disconnect of XCover6 device, when USB debugging enabled. When USB debugging disabled, sharing the XCover6 from server to client works OK and sharing of Samsung A32 device works in well in both modes (USB debugging enable and disabled).

I tested even running a trial version of VirtualHere server in Windows and client in Linux, but that combination did not work on any device. Currently I do not have 2 Windows PCs to test communication between Windows server and Windows client, but in any case that combination would not be of any use for me.

#9

Second update today, see the previous post about the results in testing in Windows client...

So I got a bit forward. When starting adb server in the Ubuntu PC running the VirtualHere server AND putting "onReset.04e8=" to the server config.ini, I can now have the device in use at the client side ... BUT ... the adb connection is still hooked on the server side :(

The server syslog says:

Dec  4 13:19:09 kernel: [ 7250.602024] usb 2-5: usbfs: interface 4 claimed by usbfs while 'vhusbdx86_64' sets config #1

Any ideas? I tried setting the Samsung quirk:

onEnumeration.04e8=echo '4' > $DEVPATH$/bConfigurationValue

but then I got almost the opposite:

Dec  4 13:11:34 kernel: [ 6795.807293] usb 2-5: usbfs: interface 1 claimed by cdc_acm while 'vhusbdx86_64' sets config #4

The client side has the device in use with this also, but the adb connection is still left behind at the server side.

But in general when having the adb server started at the VirtualHere server PC, all of the previously working devices are not recognizing to the client side adb, so I guess this path is a no-go for us in that sense.

#10

Im not sure sorry. Its possible this is basically a security issue google is gradually closing. Thats just a guess, but they may not want people remotely adbing into phones without them being physically present at least once.

 

#11

I wish I had come across this sooner.

Has anyone found any workaround for this?

#12

Another thing to try:

On the virtualhere server, stop the virtualhere server process(systemctl stop virtualhere) then edit the config.ini file and add the lines

ClaimPorts=1

AutoAttachToKernel=0

then save the config.ini file and start the virtualhere server again. Unplug/replug the phones and then try to use via virtualhere. If it drops off try to use it again

 

 

#13

Thank you, Michael the config change resolved the issue

#14

I wonder, can the VirtualHere USB Server for Android also add these 2 switches in UI?

ClaimPorts=1

AutoAttachToKernel=0

Since it's not possible to edit VirtualHere USB Server configuration file on Android without root.

#15

No, Android doesnt allow either of those flags