我想通过 usbip 将三星 Android 手机连接到远程服务器,然后在服务器设备上构建一个 Android 应用程序到手机上进行一些测试。我遇到了 usbip 实用程序,它可以通过 IP 将设备连接到远程计算机。我可以使用以下命令和输出正确连接我的设备,并查看它在服务器计算机上的连接:
在主机设备(我的电脑)上
root@emir-work:~$ usbip bind -b 1-5 usbip: info: bind device on busid 1-5: complete root@emir-work:~$ usbip list -r localhost Exportable USB devices ====================== - localhost 1-5: Samsung Electronics Co., Ltd : Galaxy series, misc. (MTP mode) (04e8:6860) : /sys/devices/pci0000:00/0000:00:14.0/usb1/1-5 : (Defined at Interface level) (00/00/00)
在远程设备(服务器)上
root[~] # usbip list -r 192.168.0.184 Exportable USB devices ====================== - 192.168.0.184 1-5: Samsung Electronics Co., Ltd : Galaxy series, misc. (MTP mode) (04e8:6860) : /sys/devices/pci0000:00/0000:00:14.0/usb1/1-5 : (Defined at Interface level) (00/00/00) root[~] # usbip attach -r 192.168.0.184 -b 1-5
在这些命令之后,我可以从服务器设备访问手机并查看内容等。但是,由于未启用 USB 调试选项,Android 调试桥无法识别该设备。当我启用USB调试时,连接立即断开,并且设备自动与主机设备上的usbip解除绑定。当尝试再次绑定它时,它不会显示在可导出 USB 设备列表中,并且不会绑定。
以下是主机上相关的journalctl日志:
Eki 30 10:18:56 emir-work ModemManager[1091]: <info> [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5': not supported by any plugin
Eki 30 10:18:54 emir-work gvfsd[3747621]: Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
Eki 30 10:18:54 emir-work dbus-daemon[2259]: [session uid=1000 pid=2259] Successfully activated service 'org.gnome.Shell.HotplugSniffer'
Eki 30 10:18:54 emir-work dbus-daemon[2259]: [session uid=1000 pid=2259] Activating service name='org.gnome.Shell.HotplugSniffer' requested by ':1.37' (uid=1000 pid=2482 comm="/usr/bin/gnome-shell " lab>
Eki 30 10:18:54 emir-work gvfsd[3747831]: Error 1: Get Storage information failed.
Eki 30 10:18:54 emir-work snapd[1031]: hotplug.go:200: hotplug device add event ignored, enable experimental.hotplug
Eki 30 10:18:54 emir-work colord[2177]: 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_
Eki 30 10:18:54 emir-work colord[2177]: 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_
Eki 30 10:18:54 emir-work colord[2177]: 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_
Eki 30 10:18:54 emir-work kernel: cdc_acm 1-5:1.1: ttyACM0: USB ACM device
Eki 30 10:18:54 emir-work kernel: usb 1-5: SerialNumber: 330069a3272ba2a5
Eki 30 10:18:54 emir-work kernel: usb 1-5: Manufacturer: SAMSUNG
Eki 30 10:18:54 emir-work kernel: usb 1-5: Product: SAMSUNG_Android
Eki 30 10:18:54 emir-work kernel: usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Eki 30 10:18:54 emir-work kernel: usb 1-5: New USB device found, idVendor=04e8, idProduct=6860, bcdDevice= 4.00
Eki 30 10:18:53 emir-work kernel: usb 1-5: new high-speed USB device number 123 using xhci_hcd
Eki 30 10:18:53 emir-work kernel: usbip-host 1-5: USB disconnect, device number 122
和journalctl登录远程机器:
Eki 30 10:18:36 android-devel gvfsd[10990]: Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
Eki 30 10:18:34 android-devel systemd-udevd[11072]: 2-1: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_ippeveprinter /devices/platform/vhci_hcd.0/usb2/2-1 189:134' failed with exit code 1.
Eki 30 10:18:34 android-devel systemd-udevd[11072]: 2-1: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_cupsd /devices/platform/vhci_hcd.0/usb2/2-1 189:134' failed with exit code 1.
Eki 30 10:18:34 android-devel systemd-udevd[11072]: 2-1:1.0: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_ippeveprinter /devices/platform/vhci_hcd.0/usb2/2-1/2-1:1.0 0:0' failed with exit code 1.
Eki 30 10:18:34 android-devel systemd-udevd[11072]: 2-1:1.0: Process '/usr/lib/snapd/snap-device-helper unbind snap_cups_cupsd /devices/platform/vhci_hcd.0/usb2/2-1/2-1:1.0 0:0' failed with exit code 1.
Eki 30 10:18:34 android-devel kernel: usb 2-1: USB disconnect, device number 7
Eki 30 10:18:34 android-devel kernel: vhci_hcd: disconnect device
Eki 30 10:18:34 android-devel kernel: vhci_hcd: release socket
Eki 30 10:18:34 android-devel kernel: vhci_hcd: stop threads
Eki 30 10:18:34 android-devel kernel: vhci_hcd: connection closed
Eki 30 10:18:34 android-devel gvfsd[10990]: PTP: reading event an error 0x05 occurred
发生此行为时,调试模式下的 usbip deamon 不会显示任何警告或错误。
值得注意的是两台机器上的usbip version
输出。(usbip-utils 2.0)
最后,两台机器都运行 Ubuntu 20.04.6 LTS,远程机器上的 Android Studio 版本是 2022.3.1