Merge "fastboot: Allow fastboot to asynchronously differentiate between fastboot and fastbootd."
This commit is contained in:
commit
e681cf01c8
6 changed files with 20 additions and 3 deletions
|
|
@ -146,7 +146,7 @@ static struct SsFuncDesc ss_descriptors = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STR_INTERFACE_ "fastboot"
|
#define STR_INTERFACE_ "fastbootd"
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
struct usb_functionfs_strings_head header;
|
struct usb_functionfs_strings_head header;
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,10 @@ static int match_fastboot(usb_ifc_info* info) {
|
||||||
static int list_devices_callback(usb_ifc_info* info) {
|
static int list_devices_callback(usb_ifc_info* info) {
|
||||||
if (match_fastboot_with_serial(info, nullptr) == 0) {
|
if (match_fastboot_with_serial(info, nullptr) == 0) {
|
||||||
std::string serial = info->serial_number;
|
std::string serial = info->serial_number;
|
||||||
|
std::string interface = info->interface;
|
||||||
|
if (interface.empty()) {
|
||||||
|
interface = "fastboot";
|
||||||
|
}
|
||||||
if (!info->writable) {
|
if (!info->writable) {
|
||||||
serial = UsbNoPermissionsShortHelpText();
|
serial = UsbNoPermissionsShortHelpText();
|
||||||
}
|
}
|
||||||
|
|
@ -266,9 +270,9 @@ static int list_devices_callback(usb_ifc_info* info) {
|
||||||
}
|
}
|
||||||
// output compatible with "adb devices"
|
// output compatible with "adb devices"
|
||||||
if (!g_long_listing) {
|
if (!g_long_listing) {
|
||||||
printf("%s\tfastboot", serial.c_str());
|
printf("%s\t%s", serial.c_str(), interface.c_str());
|
||||||
} else {
|
} else {
|
||||||
printf("%-22s fastboot", serial.c_str());
|
printf("%-22s %s", serial.c_str(), interface.c_str());
|
||||||
if (strlen(info->device_path) > 0) printf(" %s", info->device_path);
|
if (strlen(info->device_path) > 0) printf(" %s", info->device_path);
|
||||||
}
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ struct usb_ifc_info {
|
||||||
|
|
||||||
char serial_number[256];
|
char serial_number[256];
|
||||||
char device_path[256];
|
char device_path[256];
|
||||||
|
|
||||||
|
char interface[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
class UsbTransport : public Transport {
|
class UsbTransport : public Transport {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <linux/usb/ch9.h>
|
#include <linux/usb/ch9.h>
|
||||||
|
|
||||||
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/stringprintf.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
@ -263,6 +265,13 @@ static int filter_usb_device(char* sysfs_name,
|
||||||
info.has_bulk_in = (in != -1);
|
info.has_bulk_in = (in != -1);
|
||||||
info.has_bulk_out = (out != -1);
|
info.has_bulk_out = (out != -1);
|
||||||
|
|
||||||
|
std::string interface;
|
||||||
|
auto path = android::base::StringPrintf("/sys/bus/usb/devices/%s/%s:1.%d/interface",
|
||||||
|
sysfs_name, sysfs_name, ifc->bInterfaceNumber);
|
||||||
|
if (android::base::ReadFileToString(path, &interface)) {
|
||||||
|
snprintf(info.interface, sizeof(info.interface), "%s", interface.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if(callback(&info) == 0) {
|
if(callback(&info) == 0) {
|
||||||
*ept_in_id = in;
|
*ept_in_id = in;
|
||||||
*ept_out_id = out;
|
*ept_out_id = out;
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,7 @@ static int try_device(io_service_t device, usb_handle *handle) {
|
||||||
// device has no serial number
|
// device has no serial number
|
||||||
handle->info.serial_number[0] = 0;
|
handle->info.serial_number[0] = 0;
|
||||||
}
|
}
|
||||||
|
handle->info.interface[0] = 0;
|
||||||
handle->info.writable = 1;
|
handle->info.writable = 1;
|
||||||
|
|
||||||
if (try_interfaces(dev, handle)) {
|
if (try_interfaces(dev, handle)) {
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ int recognized_device(usb_handle* handle, ifc_match_func callback) {
|
||||||
&serial_number_len, true)) {
|
&serial_number_len, true)) {
|
||||||
info.serial_number[0] = 0;
|
info.serial_number[0] = 0;
|
||||||
}
|
}
|
||||||
|
info.interface[0] = 0;
|
||||||
|
|
||||||
info.device_path[0] = 0;
|
info.device_path[0] = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue