Closed fhteagle closed 5 years ago
Snaps run under a restrictive security sandbox. The adb-support interface installs its own apparmor and udev rules. Please check if your phone's vendor id is listed in the udev rule file created by the interface in /etc/udev/rules.d/70-snap.scrcpy.rules
If not, then try to create your own udev rule,
/etc/udev/rules.d/99-add-device-to-scrcpy.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", TAG+="snap_scrcpy_adb"
SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", TAG+="snap_scrcpy_scrcpy"
Where XXXX is the vendor id reported by lsusb
restart udev and kill any running adb server, then check if the builtin adb detects your device:
sudo udevadm control --reload
sudo udevadm trigger
adb kill-server
scrcpy.adb kill-server
scrcpy.adb devices
Thanks, sisco311
@sisco311 Thanks for that, we are getting closer. After following your directions, the OnePlus and a second ZTE phone over USB each do show up in the output from scrcpy.adb devices
. However, there is no serial number reported in the output of scrcpy.adb devices list
for either phone. scrcpy.adb devices -l
turns up accurate information (except for serial number of course). Unfortunately, specifying the known serial number of the device in scrcpy -s 4a....39
fails. See below:
$ scrcpy.adb devices
List of devices attached
(no serial number) device
emulator-5..8 offline
$ scrcpy.adb devices -l
List of devices attached
emulator-5558 device product:anbox_x86_64 model:Anbox device:x86_64
(no serial number) device usb:1-1.1 product:OnePlus6 model:ONEPLUS_A6003 device:OnePlus6
$ scrcpy.adb -s 4a....39 shell
error: device '4a....39' not found
However, if I manually kill the anbox emulator instance, so that the OnePlus or ZTE is the only device in scrcpy.adb devices
, scrcpy works as expected.
As a future goal, I am trying to work towards a script that would automatically startup scrcpy on plug-in, but I cannot see a way to force scrcpy to select a phone instead of an emulator without a serial number. None of the flags that work in adb or scrcpy.adb such as -d work in straight scrcpy.
We have found a bug! The apparmor profile generated by the adb-support interface grants read access for /sys/devices/**/usb*/*/serial r,
but the serial file on my system is one level deeper in the directory hierarchy.
If I change the relevant lines in /var/lib/snapd/apparmor/profiles/snap.scrcpy.scrcpy and /var/lib/snapd/apparmor/profiles/snap.scrcpy.adb to /sys/devices/**/usb*/**/serial r,
and reload the profiles sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.scrcpy.scrcpy
sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.scrcpy.adb
everything works as expected.
@sisco311 Good find! I was able to duplicate your fix on my machine as well! Second command should probably be sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.scrcpy.adb
.
Changing bug title to reflect causes and symptoms.
Two things are still not quite working right, though:
/snap/bin/scrcpy.adb devices
twice to get the OnePlus device to show up. Only the ZTE device shows up on the first time the command is executed. OnePlus always shows up on the second issuing of the command. Waiting arbitrary time between plug in and issuing the command seems to have no effect. Odd.`audit: type=1400 audit(1553362545.429:2780): apparmor="DENIED" operation="open" profile="snap.scrcpy.scrcpy" name="/media/home/pr....se/.cache/mesa_shader_cache/index" pid=21102 comm="scrcpy" requested_mask="wrc" denied_mask="wrc" fsuid=1000 ouid=1000
Permissions on this file are 644 when ls'ing . Cool.
Reported the apparmor bug.
Please post the output of:
lsusb --verbose -d xxxx:
Where xxxx is the vendor id of the OnePlus
I will make a feature request upstream to include your device to the trusted ones.
One thing is still not quite working right, though. I have to issue /snap/bin/scrcpy.adb devices twice to get the OnePlus device to show up. Only the ZTE device shows up on the first time the command is executed. OnePlus always shows up on the second issuing of the command. Waiting arbitrary time between plug in and issuing the command seems to have no effect. Odd.
Please open a new issue for this I will look into it
Here is the lsusb output:
Bus 001 Device 045: ID 2a70:4ee7
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x2a70
idProduct 0x4ee7
bcdDevice 4.09
iManufacturer 1 OnePlus
iProduct 2 OnePlus
iSerial 3 4a....39
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 adb
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 66
bInterfaceProtocol 1
iInterface 5 ADB Interface
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 12
bNumDeviceCaps 1
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000006
Link Power Management (LPM) Supported
Device Status: 0x0000
(Bus Powered)
Closing this.
Feature request for including OnePlus @ https://bugs.launchpad.net/snapd/+bug/1821474
UPDATE:
Your devices will be supported in snapd 2.39: https://bugs.launchpad.net/snapd/+bug/1821474
The apparmor issue is addressed as well and will be fixed in 2.39: https://bugs.launchpad.net/snapd/+bug/1821474
One more thing. The OnePlus was added to the trusted devices: https://github.com/snapcore/snapd/pull/6645
But, as pointed out by zyga, your device is not listed at http://www.linux-usb.org/usb.ids
When you have a little time please add it the database: http://www.linux-usb.org/usb-ids.html
Thanks, sisco311
Odd thing is that that U:D pair appears in their web portal: https://usb-ids.gowdy.us/read/UD/2a70/4ee7 From the commentary, it looks like 2a70:4ee7 has been used by several models of OnePlus 6 phones when connecting in android debug mode. I emailed the curators of the list to see if the U:D pair can be added to the official usb.ids file after all.
Migrating this bug from scrcpy issues ( https://github.com/Genymobile/scrcpy/issues/464 ) to here:
System adb version is not used when scrcpy is installed via snap on Ubuntu 18.10. This was noticed on snap version 18, no other snap versions tested. System adb version is reported as 39, is capable of seeing USB attached phones, works as expected. Scrcpy.adb version is reported as 36, does not list USB connected phones (possibly due to udev rules), which makes scrcpy unusable over USB. Scrcpy and Scrcpy.adb via tcpip requires first setting tcpip mode on device with system adb.
Steps tried with no success:
$sudo snap connect scrcpy:adb-support :adb-support