From 3b19e99148131fa1d4f76fe6bf066d6cf5f89916 Mon Sep 17 00:00:00 2001 From: Andrew Chant Date: Mon, 12 Jun 2017 12:14:43 -0700 Subject: [PATCH] Add USB device descriptors to bug report. Reports product, version, and first 48 bytes of descriptors. Test: Took bugreports with and without USB device attached. With no USB Device: ------ USB Device Descriptors (/vendor/bin/sh -c cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96) ------ 0000000 With USB Device: ------ USB Device Descriptors (/vendor/bin/sh -c cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96) ------ Mir 0200 0000000 12 01 00 02 00 00 00 40 d1 18 25 50 00 02 03 01 0000020 02 01 09 02 1f 01 04 01 04 a0 32 09 04 00 00 01 0000040 01 01 00 05 0a 24 01 00 01 83 00 02 01 02 0c 24 0000060 02 01 01 02 00 02 03 00 00 00 0d 24 06 03 01 02 0000100 01 00 02 00 02 00 00 09 24 03 02 01 01 01 04 00 0000120 0c 24 02 22 01 02 00 02 03 00 00 18 0d 24 06 23 0000140 Bug: 38327094 Change-Id: I05cb5f6f3895b43b55ab4b1f434bb5b206b3bf4c Merged-In: I05cb5f6f3895b43b55ab4b1f434bb5b206b3bf4c --- dumpstate/DumpstateDevice.cpp | 1 + sepolicy/vendor/file.te | 1 + sepolicy/vendor/file_contexts | 1 + sepolicy/vendor/hal_dumpstate_impl.te | 2 ++ 4 files changed, 5 insertions(+) diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp index 4cfecac9..d08c3ed6 100755 --- a/dumpstate/DumpstateDevice.cpp +++ b/dumpstate/DumpstateDevice.cpp @@ -169,6 +169,7 @@ Return DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { DumpFileToFd(fd, "smblib-usb logs", "/d/ipc_logging/smblib/log"); DumpFileToFd(fd, "ipc-local-ports", "/d/msm_ipc_router/dump_local_ports"); DumpTouch(fd); + RunCommandToFd(fd, "USB Device Descriptors", {"/vendor/bin/sh", "-c", "cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96"}); /* Check if qsee_logger tool exists */ if (!access("/vendor/bin/qsee_logger", X_OK)) { diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te index b2c857b7..ca59c44e 100644 --- a/sepolicy/vendor/file.te +++ b/sepolicy/vendor/file.te @@ -12,6 +12,7 @@ type sysfs_soc, sysfs_type, fs_type; type sysfs_timestamp_switch, sysfs_type, fs_type; type sysfs_touch, sysfs_type, fs_type; type sysfs_usb_c, sysfs_type, fs_type; +type sysfs_usb_device, sysfs_type, fs_type; type debugfs_clk, debugfs_type, fs_type; type debugfs_ion, debugfs_type, fs_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index eb771d50..f9d0dc03 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -163,6 +163,7 @@ /sys/devices/soc/800f000\.qcom,spmi/spmi-0/spmi0-02/800f000\.qcom,spmi:qcom,pmi8998@2:qcom,usb-pdphy@1700/usbpd0/typec(/.*)? u:object_r:sysfs_usb_c:s0 /sys/devices/soc/soc:qcom,ipa_fws@[a-f0-9]+/subsys0/name u:object_r:sysfs_data:s0 /sys/module/diagchar(/.*)? u:object_r:sysfs_diag:s0 +/sys/devices/soc/a800000\.ssusb/a800000\.dwc3/xhci-hcd\.0\.auto/usb\d+(/.*)? u:object_r:sysfs_usb_device:s0 # files in debugfs /sys/kernel/debug/rpm_stats u:object_r:debugfs_rpm:s0 diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index 3118fcff..979536f5 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -21,6 +21,8 @@ userdebug_or_eng(` allow hal_dumpstate_impl netmgr_data_file:file r_file_perms; allow hal_dumpstate_impl debugfs_ipc:dir r_dir_perms; allow hal_dumpstate_impl debugfs_ipc:file r_file_perms; + allow hal_dumpstate_impl sysfs_usb_device:dir r_dir_perms; + allow hal_dumpstate_impl sysfs_usb_device:file r_file_perms; set_prop(hal_dumpstate_impl, modem_diag_prop) ')