From 53413080ccef9f6be2affb20717408b0bd3ed172 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 25 Jan 2020 19:15:58 -0500 Subject: [PATCH] initrd-usb: Follow AOSP init order more closely This is part of what may be required to fix ADB on google-marlin. --- modules/stage-1/tasks/usb-gadget-task.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/stage-1/tasks/usb-gadget-task.rb b/modules/stage-1/tasks/usb-gadget-task.rb index a2ed09c1..28325f57 100644 --- a/modules/stage-1/tasks/usb-gadget-task.rb +++ b/modules/stage-1/tasks/usb-gadget-task.rb @@ -106,6 +106,7 @@ end class System::AndroidUSB include Singleton attr_accessor :features + attr_accessor :id_vendor, :id_product ANDROID_USB = "/sys/class/android_usb" @@ -113,14 +114,6 @@ class System::AndroidUSB File.join(ANDROID_USB, "android0") end - def id_vendor=(value) - set_id("idVendor", value) - end - - def id_product=(value) - set_id("idProduct", value) - end - def manufacturer=(value) set_string("iManufacturer", value) end @@ -134,7 +127,7 @@ class System::AndroidUSB end def set_id(kind, value) - value = ["0", value.sub(/^0x/, "")].join("x") + value = value.sub(/^0x/, "") System.write(File.join(path_prefix, kind), value) end @@ -144,7 +137,11 @@ class System::AndroidUSB def activate!() System.write(File.join(path_prefix, "enable"), "0") + set_id("idVendor", @id_vendor) + set_id("idProduct", @id_product) System.write(File.join(path_prefix, "bDeviceClass"), "0") + System.write(File.join(path_prefix, "bDeviceSubClass"), "0") + System.write(File.join(path_prefix, "bDeviceProtocol"), "0") System.write(File.join(path_prefix, "functions"), @features.join(",")) sleep(0.1) System.write(File.join(path_prefix, "enable"), "1")