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
This commit is contained in:
Mark Salyzyn 2017-10-04 15:05:40 -07:00
parent 0a78cc1b76
commit 8f3b8873b0
3 changed files with 17 additions and 19 deletions

View File

@ -253,7 +253,7 @@ static void find_usb_device(const std::string& base,
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;
}

View File

@ -174,7 +174,7 @@ AndroidInterfaceAdded(io_iterator_t iterator)
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;

View File

@ -531,25 +531,23 @@ int recognized_device(usb_handle* handle) {
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() {