diff options
author | Howard Yen <howardyen@google.com> | 2019-08-08 18:20:06 +0800 |
---|---|---|
committer | Howard Yen <howardyen@google.com> | 2020-02-20 23:05:41 +0800 |
commit | e126b9e361fe62367722d97591de17141aa13d0e (patch) | |
tree | 16183737ec8f9053907be8dcc0fc5717b566cd1b | |
parent | 1a015d54d3ed69e3b31fa69963e7673b200a1ba9 (diff) | |
download | device_google_wahoo-e126b9e361fe62367722d97591de17141aa13d0e.tar.gz device_google_wahoo-e126b9e361fe62367722d97591de17141aa13d0e.tar.bz2 device_google_wahoo-e126b9e361fe62367722d97591de17141aa13d0e.zip |
Update USB Gadget HAL to V1.1 implementation
Bug: 138702846
Test: build pass, function works
Change-Id: I80c295a73aa982b09c81b7cbc3f3a1003c273101
-rw-r--r-- | manifest.xml | 18 | ||||
-rw-r--r-- | usb/Android.bp | 5 | ||||
-rw-r--r-- | usb/UsbGadget.cpp | 15 | ||||
-rw-r--r-- | usb/UsbGadget.h | 30 | ||||
-rw-r--r-- | usb/android.hardware.usb.gadget@1.1-service.wahoo.xml | 11 | ||||
-rw-r--r-- | usb/android.hardware.usb@1.1-service.wahoo.xml | 12 | ||||
-rw-r--r-- | usb/service.cpp | 4 |
7 files changed, 57 insertions, 38 deletions
diff --git a/manifest.xml b/manifest.xml index 1abb8053..27526081 100644 --- a/manifest.xml +++ b/manifest.xml @@ -293,24 +293,6 @@ </interface> </hal> <hal format="hidl"> - <name>android.hardware.usb</name> - <transport>hwbinder</transport> - <version>1.1</version> - <interface> - <name>IUsb</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.usb.gadget</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IUsbGadget</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> <name>android.hardware.weaver</name> <transport>hwbinder</transport> <version>1.0</version> diff --git a/usb/Android.bp b/usb/Android.bp index aa58163a..d5fda661 100644 --- a/usb/Android.bp +++ b/usb/Android.bp @@ -16,6 +16,10 @@ cc_binary { name: "android.hardware.usb@1.1-service.wahoo", relative_install_path: "hw", init_rc: ["android.hardware.usb@1.1-service.wahoo.rc"], + vintf_fragments: [ + "android.hardware.usb@1.1-service.wahoo.xml", + "android.hardware.usb.gadget@1.1-service.wahoo.xml", + ], srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"], shared_libs: [ "libbase", @@ -26,6 +30,7 @@ cc_binary { "android.hardware.usb@1.0", "android.hardware.usb@1.1", "android.hardware.usb.gadget@1.0", + "android.hardware.usb.gadget@1.1", "libcutils", ], proprietary: true, diff --git a/usb/UsbGadget.cpp b/usb/UsbGadget.cpp index 2263da1a..e407c490 100644 --- a/usb/UsbGadget.cpp +++ b/usb/UsbGadget.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.usb.gadget@1.0-service.wahoo" +#define LOG_TAG "android.hardware.usb.gadget@1.1-service.wahoo" #include "UsbGadget.h" #include <dirent.h> @@ -57,7 +57,7 @@ namespace android { namespace hardware { namespace usb { namespace gadget { -namespace V1_0 { +namespace V1_1 { namespace implementation { volatile bool gadgetPullup; @@ -258,6 +258,15 @@ V1_0::Status UsbGadget::tearDownGadget() { return Status::SUCCESS; } +Return<Status> UsbGadget::reset() { + if (!WriteStringToFile("none", PULLUP_PATH)) { + ALOGI("Gadget cannot be pulled down"); + return Status::ERROR; + } + + return Status::SUCCESS; +} + static int linkFunction(const char *function, int index) { char functionPath[MAX_FILE_PATH_LENGTH]; char link[MAX_FILE_PATH_LENGTH]; @@ -645,7 +654,7 @@ error: return Void(); } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware diff --git a/usb/UsbGadget.h b/usb/UsbGadget.h index 9a2c4dd3..3d302332 100644 --- a/usb/UsbGadget.h +++ b/usb/UsbGadget.h @@ -14,29 +14,28 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_USB_GADGET_V1_0_USBGADGET_H -#define ANDROID_HARDWARE_USB_GADGET_V1_0_USBGADGET_H +#pragma once #include <android-base/file.h> #include <android-base/properties.h> #include <android-base/unique_fd.h> -#include <android/hardware/usb/gadget/1.0/IUsbGadget.h> +#include <android/hardware/usb/gadget/1.1/IUsbGadget.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> -#include <string> #include <sys/epoll.h> #include <sys/eventfd.h> -#include <thread> #include <utils/Log.h> #include <chrono> #include <condition_variable> #include <mutex> +#include <string> +#include <thread> namespace android { namespace hardware { namespace usb { namespace gadget { -namespace V1_0 { +namespace V1_1 { namespace implementation { using ::android::sp; @@ -50,6 +49,9 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; +using ::android::hardware::usb::gadget::V1_0::GadgetFunction; +using ::android::hardware::usb::gadget::V1_0::Status; +using ::android::hardware::usb::gadget::V1_1::IUsbGadget; using ::std::lock_guard; using ::std::move; using ::std::mutex; @@ -78,24 +80,22 @@ struct UsbGadget : public IUsbGadget { bool mCurrentUsbFunctionsApplied; Return<void> setCurrentUsbFunctions(uint64_t functions, - const sp<IUsbGadgetCallback>& callback, + const sp<V1_0::IUsbGadgetCallback> &callback, uint64_t timeout) override; - Return<void> getCurrentUsbFunctions( - const sp<IUsbGadgetCallback>& callback) override; + Return<void> getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback> &callback) override; + + Return<Status> reset() override; - private: +private: Status tearDownGadget(); - Status setupFunctions(uint64_t functions, - const sp<IUsbGadgetCallback>& callback, + Status setupFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback, uint64_t timeout); }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware } // namespace android - -#endif // ANDROID_HARDWARE_USB_V1_2_USBGADGET_H diff --git a/usb/android.hardware.usb.gadget@1.1-service.wahoo.xml b/usb/android.hardware.usb.gadget@1.1-service.wahoo.xml new file mode 100644 index 00000000..a6f9a1f4 --- /dev/null +++ b/usb/android.hardware.usb.gadget@1.1-service.wahoo.xml @@ -0,0 +1,11 @@ +<manifest version="1.0" type="device"> + <hal format="hidl"> + <name>android.hardware.usb.gadget</name> + <transport>hwbinder</transport> + <version>1.1</version> + <interface> + <name>IUsbGadget</name> + <instance>default</instance> + </interface> + </hal> +</manifest> diff --git a/usb/android.hardware.usb@1.1-service.wahoo.xml b/usb/android.hardware.usb@1.1-service.wahoo.xml new file mode 100644 index 00000000..5ce2ff45 --- /dev/null +++ b/usb/android.hardware.usb@1.1-service.wahoo.xml @@ -0,0 +1,12 @@ +<manifest version="1.0" type="device"> + <hal format="hidl"> + <name>android.hardware.usb</name> + <transport>hwbinder</transport> + <version>1.1</version> + <interface> + <name>IUsb</name> + <instance>default</instance> + </interface> + </hal> +</manifest> + diff --git a/usb/service.cpp b/usb/service.cpp index e540608b..9162c22d 100644 --- a/usb/service.cpp +++ b/usb/service.cpp @@ -27,10 +27,10 @@ using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; // Generated HIDL files +using android::hardware::usb::gadget::V1_1::IUsbGadget; +using android::hardware::usb::gadget::V1_1::implementation::UsbGadget; using android::hardware::usb::V1_1::IUsb; -using android::hardware::usb::gadget::V1_0::IUsbGadget; using android::hardware::usb::V1_1::implementation::Usb; -using android::hardware::usb::gadget::V1_0::implementation::UsbGadget; using android::OK; using android::status_t; |