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
This commit is contained in:
Arnav Singh 2024-08-03 06:46:13 -07:00
parent c0bfde2ac4
commit 7ed0e563a5
2 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,38 @@
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

View file

@ -2,7 +2,7 @@
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=android-tools
pkgver=35.0.2
pkgrel=0
pkgrel=1
pkgdesc="Android platform tools"
url="https://sites.google.com/a/android.com/tools/"
# s390x, ppc64le: Unsupported by vendored BoringSSL
@ -13,7 +13,8 @@ depends="python3"
makedepends="pcre2-dev linux-headers gtest-dev go perl cmake protobuf-dev
brotli-dev zstd-dev lz4-dev samurai abseil-cpp-dev fmt-dev"
subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
source="https://github.com/nmeum/android-tools/releases/download/$pkgver/android-tools-$pkgver.tar.xz"
source="https://github.com/nmeum/android-tools/releases/download/$pkgver/android-tools-$pkgver.tar.xz
0001-Fix-libusb-enumeration.patch"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
@ -40,4 +41,5 @@ bashcomp() {
sha512sums="
391ce4d638b274d7bbae24a3df8de8b5812a982570f29b2aef37d12a3ba7ed6f66b5c0b7f908759e0b0da30d152b5319af0fef16c54bdc3b9f4074fb22f80d10 android-tools-35.0.2.tar.xz
941dddf82725b1f44d158e4ce361355004a63292f72f91e2008436bd687cf55e09cef12875f94057702d056e35cc0ba1df13432caefee7d37d039aa1fd31c65e 0001-Fix-libusb-enumeration.patch
"