adb: cleanup some portions of client usb interfaces
Cleanup to remove open coded functions.
Test: build
Bug: 63736262
Bug: 38446744
Bug: 66912053
Change-Id: I3e6e5a22542934837b6a03523987141dc2776d48
diff --git a/adb/client/usb_linux.cpp b/adb/client/usb_linux.cpp
index a7df0ed..1f376a4 100644
--- a/adb/client/usb_linux.cpp
+++ b/adb/client/usb_linux.cpp
@@ -253,7 +253,7 @@
continue;
}
/* aproto 01 needs 0 termination */
- if (interface->bInterfaceProtocol == 0x01) {
+ if (interface->bInterfaceProtocol == ADB_PROTOCOL) {
max_packet_size = ep1->wMaxPacketSize;
zero_mask = ep1->wMaxPacketSize - 1;
}
diff --git a/adb/client/usb_osx.cpp b/adb/client/usb_osx.cpp
index 4e1480f..2e999ee 100644
--- a/adb/client/usb_osx.cpp
+++ b/adb/client/usb_osx.cpp
@@ -174,7 +174,7 @@
kr = (*iface)->GetInterfaceClass(iface, &if_class);
kr = (*iface)->GetInterfaceSubClass(iface, &subclass);
kr = (*iface)->GetInterfaceProtocol(iface, &protocol);
- if(if_class != ADB_CLASS || subclass != ADB_SUBCLASS || protocol != ADB_PROTOCOL) {
+ if (!is_adb_interface(if_class, subclass, protocol)) {
// Ignore non-ADB devices.
LOG(DEBUG) << "Ignoring interface with incorrect class/subclass/protocol - " << if_class
<< ", " << subclass << ", " << protocol;
diff --git a/adb/client/usb_windows.cpp b/adb/client/usb_windows.cpp
index aff5229..61981b1 100644
--- a/adb/client/usb_windows.cpp
+++ b/adb/client/usb_windows.cpp
@@ -531,25 +531,23 @@
return 0;
}
- if (is_adb_interface(interf_desc.bInterfaceClass, interf_desc.bInterfaceSubClass,
- interf_desc.bInterfaceProtocol)) {
- if (interf_desc.bInterfaceProtocol == 0x01) {
- AdbEndpointInformation endpoint_info;
- // assuming zero is a valid bulk endpoint ID
- if (AdbGetEndpointInformation(handle->adb_interface, 0, &endpoint_info)) {
- handle->max_packet_size = endpoint_info.max_packet_size;
- handle->zero_mask = endpoint_info.max_packet_size - 1;
- D("device zero_mask: 0x%x", handle->zero_mask);
- } else {
- D("AdbGetEndpointInformation failed: %s",
- android::base::SystemErrorCodeToString(GetLastError()).c_str());
- }
- }
-
- return 1;
+ if (!is_adb_interface(interf_desc.bInterfaceClass, interf_desc.bInterfaceSubClass,
+ interf_desc.bInterfaceProtocol)) {
+ return 0;
}
- return 0;
+ AdbEndpointInformation endpoint_info;
+ // assuming zero is a valid bulk endpoint ID
+ if (AdbGetEndpointInformation(handle->adb_interface, 0, &endpoint_info)) {
+ handle->max_packet_size = endpoint_info.max_packet_size;
+ handle->zero_mask = endpoint_info.max_packet_size - 1;
+ D("device zero_mask: 0x%x", handle->zero_mask);
+ } else {
+ D("AdbGetEndpointInformation failed: %s",
+ android::base::SystemErrorCodeToString(GetLastError()).c_str());
+ }
+
+ return 1;
}
void find_devices() {