Usb
adb權限不足情況如何調試
很久以前,我通過設置一個組,用我的手機(設備)為 adb 編寫了一個 udev 規則。一切都很好,直到最近發生了一些變化:
- 設備ROM
- udev 數據包
- adb 數據包
現在我得到使用者:
$ adb shell * daemon not running. starting it now on port 5037 * * daemon started successfully * error: insufficient permissions for device: verify udev rules. See [http://developer.android.com/tools/device.html] for more information. $ adb devices -l List of devices attached xxxxxxx no permissions (verify udev rules); see [http://developer.android.com/tools/device.html] usb:2-1 $ lsusb // here we have the mentioned device Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub // udev rules newly added after i received an error (did'd change anything - still error i can open adb only using root) SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", MODE="0666", GROUP="adbusers" SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", GROUP="adbusers" // this rule was added very long time ago was working perfect till now SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0666", GROUP="adbusers" listed now as Bus 002 Device 007: ID 18d1:4ee7 Google Inc.
// 使用者在 adbuser 組中
PS。我確實檢查了設備上的權限,我得到:
$ ls -l /dev/bus/usb/002/001 crw-rw-r-- 1 root root 189, 128 kwi 22 13:26 /dev/bus/usb/002/001
udev 規則不適用?
ps2。1) 啟用 udev deug 2) 修改規則 + 添加符號連結以跟踪 udev 的更改
SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", MODE="0666", GROUP="adbusers", SYMLINK+="android%n" SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", GROUP="adbusers", SYMLINK+="x-android%n" SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0666", GROUP="adbusers", SYMLINK+="s-android%n"
設備插頭後
Apr 22 18:50:04 et27 systemd-udevd[304]: seq 2437 queued, 'add' 'usb' Apr 22 18:50:04 et27 systemd-udevd[304]: Validate module index Apr 22 18:50:04 et27 systemd-udevd[304]: Check if link configuration needs reloading. Apr 22 18:50:04 et27 systemd-udevd[304]: seq 2437 forked new worker [1143] Apr 22 18:50:04 et27 systemd-udevd[1143]: seq 2437 running Apr 22 18:50:04 et27 systemd-udevd[1143]: IMPORT builtin 'usb_id' /lib/udev/rules.d/50-udev-default.rules:13 Apr 22 18:50:04 et27 systemd-udevd[304]: seq 2438 queued, 'add' 'usb' Apr 22 18:50:04 et27 systemd-udevd[1143]: IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:13 Apr 22 18:50:04 et27 systemd-udevd[1143]: MODE 0664 /lib/udev/rules.d/50-udev-default.rules:41 Apr 22 18:50:04 et27 systemd-udevd[1143]: GROUP 1008 /etc/udev/rules.d/51-android.rules:4 Apr 22 18:50:04 et27 systemd-udevd[1143]: MODE 0666 /etc/udev/rules.d/51-android.rules:4 Apr 22 18:50:04 et27 systemd-udevd[1143]: LINK 's-android1' /etc/udev/rules.d/51-android.rules:4 Apr 22 18:50:04 et27 systemd-udevd[1143]: RUN '/usr/lib/virtualbox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}' /etc/udev/rules.d/60-vboxdrv.rules:5 Apr 22 18:50:04 et27 systemd-udevd[1143]: PROGRAM 'mtp-probe /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1 2 5' /lib/udev/rules.d/69-libmtp.rules:2283 Apr 22 18:50:04 et27 systemd-udevd[1144]: starting 'mtp-probe /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1 2 5' Apr 22 18:50:04 et27 systemd-udevd[1144]: failed to execute '/lib/udev/mtp-probe' 'mtp-probe /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1 2 5': No such file or directory Apr 22 18:50:04 et27 systemd-udevd[1143]: Process 'mtp-probe /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1 2 5' failed with exit code 2. Apr 22 18:50:04 et27 systemd-udevd[1143]: handling device node '/dev/bus/usb/002/005', devnum=c189:132, mode=0666, uid=0, gid=1008 Apr 22 18:50:04 et27 systemd-udevd[1143]: set permissions /dev/bus/usb/002/005, 020666, uid=0, gid=1008 Apr 22 18:50:04 et27 systemd-udevd[1143]: creating symlink '/dev/char/189:132' to '../bus/usb/002/005' Apr 22 18:50:04 et27 systemd-udevd[1143]: creating link '/dev/s-android1' to '/dev/bus/usb/002/005' Apr 22 18:50:04 et27 systemd-udevd[1143]: creating symlink '/dev/s-android1' to 'bus/usb/002/005' Apr 22 18:50:04 et27 systemd-udevd[1143]: created db file '/run/udev/data/c189:132' for '/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1' Apr 22 18:50:04 et27 systemd-udevd[1145]: starting '/usr/lib/virtualbox/VBoxCreateUSBNode.sh 189 132 00' Apr 22 18:50:04 et27 systemd-udevd[1143]: Process '/usr/lib/virtualbox/VBoxCreateUSBNode.sh 189 132 00' succeeded. Apr 22 18:50:04 et27 systemd-udevd[1143]: passed device to netlink monitor 0x562b37096e00 Apr 22 18:50:04 et27 systemd-udevd[1143]: seq 2437 processed Apr 22 18:50:04 et27 systemd-udevd[304]: passed 308 byte device to netlink monitor 0x562b37076610 Apr 22 18:50:04 et27 systemd-udevd[1143]: seq 2438 running Apr 22 18:50:04 et27 systemd-udevd[1143]: IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:15 Apr 22 18:50:04 et27 systemd-udevd[1143]: IMPORT builtin 'usb_id' /lib/udev/rules.d/60-libgphoto2-6.rules:9 Apr 22 18:50:04 et27 systemd-udevd[1143]: unable to access usb_interface device of '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1/2-1:1.0' Apr 22 18:50:04 et27 systemd-udevd[1143]: IMPORT builtin 'usb_id' returned non-zero Apr 22 18:50:04 et27 systemd-udevd[1143]: RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5 Apr 22 18:50:04 et27 systemd-udevd[1143]: created db file '/run/udev/data/+usb:2-1:1.0' for '/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/usb2/2-1/2-1:1.0' Apr 22 18:50:04 et27 systemd-udevd[1143]: Execute 'load' 'usb:v18D1p4EE7d0232dc00dsc00dp00icFFisc42ip01in00' Apr 22 18:50:04 et27 systemd-udevd[1143]: No module matches 'usb:v18D1p4EE7d0232dc00dsc00dp00icFFisc42ip01in00' Apr 22 18:50:04 et27 systemd-udevd[1143]: passed device to netlink monitor 0x562b37096e00 Apr 22 18:50:04 et27 systemd-udevd[1143]: seq 2438 processed Apr 22 18:50:04 et27 systemd-udevd[304]: cleanup idle workers Apr 22 18:50:04 et27 systemd-udevd[1143]: Unload module index Apr 22 18:50:04 et27 systemd-udevd[1143]: Unloaded link configuration context. Apr 22 18:50:04 et27 systemd-udevd[304]: worker [1143] exited
該組不適用於我獲得的設備
$ ls -al /dev/android1 lrwxrwxrwx 1 root root 15 kwi 22 18:42 /dev/android1 -> bus/usb/001/001 $ ls -al /dev/s-android1 lrwxrwxrwx 1 root root 15 kwi 22 18:50 /dev/s-android1 -> bus/usb/002/005
可能是字元串而不是數字組值的問題?還是 GROUP="" 代替 GROUP:="" ?如果是這樣,為什麼 udev 不屈服於這個?
- 符號 no 因為符號連結適用於舊符號所以…
- 字元串而不是數字 no,因為它在日誌中正確解析為 -> 1008
ok 權限按預期設置 - 因為符號連結未顯示權限
$ ls -al /dev/bus/usb/002/001 crw-rw-rw- 1 root adbusers 189, 128 kwi 22 19:04 /dev/bus/usb/002/001
但我還是不夠
好的,發現了什麼問題:
文件 ~/android 包含一些文件,可能儲存設備刷新/擦除後不同的調試密鑰 - 只需刪除它們
確切地說:
~/.android/adbkey
我有同樣的問題,(使用者是 plugdev 組的成員)我缺少的部分是:
插入後我必須在設備上啟用 USB 進行數據交換(使用 Android 7.1.2)