aports/community/android-tools/0001-Fix-libusb-enumeration.patch
Arnav Singh 7ed0e563a5 community/android-tools: fix using adb with PINE64 PinePhone modem
adb v35 switched to using the libusb backend by default. With this it stopped
being possible to use adb to connect to the PINE64 PinePhone's modem.
That modem exposes itself as an adb-accessible device over USB
but its device class is LIBUSB_CLASS_MISCELLANEOUS, which adb's libusb backend
filters out by default since the code only allows LIBUSB_CLASS_PER_INTERFACE.
The code does have a comment that the author wasn't sure just this device class
is sufficient, and indeed it isn't.

This commit adds a patch to also allow devices with LIBUSB_CLASS_MISCELLANEOUS
device class.

Fixes #16326
Fixes !70140
2024-08-03 06:46:13 -07:00

39 lines
1.9 KiB
Diff

From d349fae010f6c780d76e89c5d6b81d45119137c0 Mon Sep 17 00:00:00 2001
From: Arnav Singh <me@arnavion.dev>
Date: Sat, 3 Aug 2024 21:55:23 -0700
Subject: [PATCH] Fix libusb enumeration to handle PINE64 PinePhone modem.
The PINE64 PinePhone modem exposes itself as an adb-accessible device over USB
but its device class is LIBUSB_CLASS_MISCELLANEOUS, so allow that too.
---
vendor/adb/client/usb_libusb.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vendor/adb/client/usb_libusb.cpp b/vendor/adb/client/usb_libusb.cpp
index 6133e7c8..9af91eb7 100644
--- a/vendor/adb/client/usb_libusb.cpp
+++ b/vendor/adb/client/usb_libusb.cpp
@@ -364,8 +364,8 @@ struct LibusbConnection : public Connection {
}
bool FindInterface(libusb_device_descriptor* device_desc) {
- if (device_desc->bDeviceClass != LIBUSB_CLASS_PER_INTERFACE) {
- // Assume that all Android devices have the device class set to per interface.
+ if (device_desc->bDeviceClass != LIBUSB_CLASS_PER_INTERFACE && device_desc->bDeviceClass != LIBUSB_CLASS_MISCELLANEOUS) {
+ // Assume that all Android devices have the device class set to per interface or miscellaneous.
// TODO: Is this assumption valid?
VLOG(USB) << "skipping device with incorrect class at " << device_address_;
return false;
@@ -1039,7 +1039,7 @@ void usb_init() {
static_cast<libusb_hotplug_event>(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT),
LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
- LIBUSB_CLASS_PER_INTERFACE, hotplug_callback, nullptr, nullptr);
+ LIBUSB_HOTPLUG_MATCH_ANY, hotplug_callback, nullptr, nullptr);
if (rc != LIBUSB_SUCCESS) {
LOG(FATAL) << "failed to register libusb hotplug callback";
--
2.46.0