Loading usb/Android.bp +2 −3 Original line number Diff line number Diff line // // Copyright (C) 2021 The Android Open Source Project // Copyright (C) 2018 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. Loading @@ -23,7 +23,7 @@ cc_binary { init_rc: ["android.hardware.usb@1.3-service.redfin.rc"], vintf_fragments: [ "android.hardware.usb@1.3-service.redfin.xml", "android.hardware.usb.gadget@1.2-service.redfin.xml", "android.hardware.usb.gadget@1.1-service.redfin.xml", ], srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"], shared_libs: [ Loading @@ -33,7 +33,6 @@ cc_binary { "android.hardware.usb@1.3", "android.hardware.usb.gadget@1.0", "android.hardware.usb.gadget@1.1", "android.hardware.usb.gadget@1.2", "libbase", "libcutils", "libhardware", Loading usb/UsbGadget.cpp +4 −38 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "android.hardware.usb.gadget@1.2-service.redfin" #define LOG_TAG "android.hardware.usb.gadget@1.1-service.redfin" #include "UsbGadget.h" #include <dirent.h> Loading @@ -30,7 +30,7 @@ namespace android { namespace hardware { namespace usb { namespace gadget { namespace V1_2 { namespace V1_1 { namespace implementation { UsbGadget::UsbGadget() { Loading @@ -55,40 +55,6 @@ Return<void> UsbGadget::getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback return Void(); } Return<void> UsbGadget::getUsbSpeed(const sp<V1_2::IUsbGadgetCallback> &callback) { std::string current_speed; if (ReadFileToString(SPEED_PATH, ¤t_speed)) { current_speed = Trim(current_speed); ALOGI("current USB speed is %s", current_speed.c_str()); if (current_speed == "low-speed") mUsbSpeed = UsbSpeed::LOWSPEED; else if (current_speed == "full-speed") mUsbSpeed = UsbSpeed::FULLSPEED; else if (current_speed == "high-speed") mUsbSpeed = UsbSpeed::HIGHSPEED; else if (current_speed == "super-speed") mUsbSpeed = UsbSpeed::SUPERSPEED; else if (current_speed == "super-speed-plus") mUsbSpeed = UsbSpeed::SUPERSPEED_10Gb; else if (current_speed == "UNKNOWN") mUsbSpeed = UsbSpeed::UNKNOWN; else mUsbSpeed = UsbSpeed::RESERVED_SPEED; } else { ALOGE("Fail to read current speed"); mUsbSpeed = UsbSpeed::UNKNOWN; } if (callback) { Return<void> ret = callback->getUsbSpeedCb(mUsbSpeed); if (!ret.isOk()) ALOGE("Call to getUsbSpeedCb failed %s", ret.description().c_str()); } return Void(); } V1_0::Status UsbGadget::tearDownGadget() { if (resetGadget() != Status::SUCCESS) return Status::ERROR; Loading Loading @@ -391,7 +357,7 @@ error: return Void(); } } // namespace implementation } // namespace V1_2 } // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware Loading usb/UsbGadget.h +6 −17 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -19,9 +19,7 @@ #include <android-base/file.h> #include <android-base/properties.h> #include <android-base/unique_fd.h> #include <android-base/strings.h> #include <android/hardware/usb/gadget/1.2/types.h> #include <android/hardware/usb/gadget/1.2/IUsbGadget.h> #include <android/hardware/usb/gadget/1.1/IUsbGadget.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> #include <pixelusb/UsbGadgetCommon.h> Loading @@ -38,15 +36,13 @@ namespace android { namespace hardware { namespace usb { namespace gadget { namespace V1_2 { namespace V1_1 { namespace implementation { using ::android::sp; using ::android::base::GetProperty; using ::android::base::SetProperty; using ::android::base::Trim; using ::android::base::unique_fd; using ::android::base::ReadFileToString; using ::android::base::WriteStringToFile; using ::android::hardware::hidl_array; using ::android::hardware::hidl_memory; Loading @@ -64,18 +60,14 @@ using ::android::hardware::google::pixel::usb::MonitorFfs; using ::android::hardware::google::pixel::usb::resetGadget; using ::android::hardware::google::pixel::usb::setVidPid; using ::android::hardware::google::pixel::usb::unlinkFunctions; using ::android::hardware::usb::gadget::V1_0::IUsbGadgetCallback; using ::android::hardware::usb::gadget::V1_0::GadgetFunction; using ::android::hardware::usb::gadget::V1_0::Status; using ::android::hardware::usb::gadget::V1_2::IUsbGadget; using ::android::hardware::usb::gadget::V1_2::GadgetFunction; using ::android::hardware::usb::gadget::V1_1::IUsbGadget; using ::std::string; constexpr char kGadgetName[] = "a600000.dwc3"; static MonitorFfs monitorFfs(kGadgetName); #define UDC_PATH "/sys/class/udc/a600000.dwc3/" #define SPEED_PATH UDC_PATH "current_speed" struct UsbGadget : public IUsbGadget { UsbGadget(); Loading @@ -83,7 +75,6 @@ struct UsbGadget : public IUsbGadget { std::mutex mLockSetCurrentFunction; uint64_t mCurrentUsbFunctions; bool mCurrentUsbFunctionsApplied; UsbSpeed mUsbSpeed; Return<void> setCurrentUsbFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback, Loading @@ -93,8 +84,6 @@ struct UsbGadget : public IUsbGadget { Return<Status> reset() override; Return<void> getUsbSpeed(const sp<V1_2::IUsbGadgetCallback> &callback) override; private: Status tearDownGadget(); Status setupFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback, Loading @@ -102,7 +91,7 @@ private: }; } // namespace implementation } // namespace V1_2 } // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware Loading usb/android.hardware.usb.gadget@1.2-service.redfin.xml→usb/android.hardware.usb.gadget@1.1-service.redfin.xml +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ <hal format="hidl"> <name>android.hardware.usb.gadget</name> <transport>hwbinder</transport> <version>1.2</version> <version>1.1</version> <interface> <name>IUsbGadget</name> <instance>default</instance> Loading usb/service.cpp +3 −3 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -27,8 +27,8 @@ using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; // Generated HIDL files using android::hardware::usb::gadget::V1_2::IUsbGadget; using android::hardware::usb::gadget::V1_2::implementation::UsbGadget; using android::hardware::usb::gadget::V1_1::IUsbGadget; using android::hardware::usb::gadget::V1_1::implementation::UsbGadget; using android::hardware::usb::V1_3::IUsb; using android::hardware::usb::V1_3::implementation::Usb; Loading Loading
usb/Android.bp +2 −3 Original line number Diff line number Diff line // // Copyright (C) 2021 The Android Open Source Project // Copyright (C) 2018 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. Loading @@ -23,7 +23,7 @@ cc_binary { init_rc: ["android.hardware.usb@1.3-service.redfin.rc"], vintf_fragments: [ "android.hardware.usb@1.3-service.redfin.xml", "android.hardware.usb.gadget@1.2-service.redfin.xml", "android.hardware.usb.gadget@1.1-service.redfin.xml", ], srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"], shared_libs: [ Loading @@ -33,7 +33,6 @@ cc_binary { "android.hardware.usb@1.3", "android.hardware.usb.gadget@1.0", "android.hardware.usb.gadget@1.1", "android.hardware.usb.gadget@1.2", "libbase", "libcutils", "libhardware", Loading
usb/UsbGadget.cpp +4 −38 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "android.hardware.usb.gadget@1.2-service.redfin" #define LOG_TAG "android.hardware.usb.gadget@1.1-service.redfin" #include "UsbGadget.h" #include <dirent.h> Loading @@ -30,7 +30,7 @@ namespace android { namespace hardware { namespace usb { namespace gadget { namespace V1_2 { namespace V1_1 { namespace implementation { UsbGadget::UsbGadget() { Loading @@ -55,40 +55,6 @@ Return<void> UsbGadget::getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback return Void(); } Return<void> UsbGadget::getUsbSpeed(const sp<V1_2::IUsbGadgetCallback> &callback) { std::string current_speed; if (ReadFileToString(SPEED_PATH, ¤t_speed)) { current_speed = Trim(current_speed); ALOGI("current USB speed is %s", current_speed.c_str()); if (current_speed == "low-speed") mUsbSpeed = UsbSpeed::LOWSPEED; else if (current_speed == "full-speed") mUsbSpeed = UsbSpeed::FULLSPEED; else if (current_speed == "high-speed") mUsbSpeed = UsbSpeed::HIGHSPEED; else if (current_speed == "super-speed") mUsbSpeed = UsbSpeed::SUPERSPEED; else if (current_speed == "super-speed-plus") mUsbSpeed = UsbSpeed::SUPERSPEED_10Gb; else if (current_speed == "UNKNOWN") mUsbSpeed = UsbSpeed::UNKNOWN; else mUsbSpeed = UsbSpeed::RESERVED_SPEED; } else { ALOGE("Fail to read current speed"); mUsbSpeed = UsbSpeed::UNKNOWN; } if (callback) { Return<void> ret = callback->getUsbSpeedCb(mUsbSpeed); if (!ret.isOk()) ALOGE("Call to getUsbSpeedCb failed %s", ret.description().c_str()); } return Void(); } V1_0::Status UsbGadget::tearDownGadget() { if (resetGadget() != Status::SUCCESS) return Status::ERROR; Loading Loading @@ -391,7 +357,7 @@ error: return Void(); } } // namespace implementation } // namespace V1_2 } // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware Loading
usb/UsbGadget.h +6 −17 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -19,9 +19,7 @@ #include <android-base/file.h> #include <android-base/properties.h> #include <android-base/unique_fd.h> #include <android-base/strings.h> #include <android/hardware/usb/gadget/1.2/types.h> #include <android/hardware/usb/gadget/1.2/IUsbGadget.h> #include <android/hardware/usb/gadget/1.1/IUsbGadget.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> #include <pixelusb/UsbGadgetCommon.h> Loading @@ -38,15 +36,13 @@ namespace android { namespace hardware { namespace usb { namespace gadget { namespace V1_2 { namespace V1_1 { namespace implementation { using ::android::sp; using ::android::base::GetProperty; using ::android::base::SetProperty; using ::android::base::Trim; using ::android::base::unique_fd; using ::android::base::ReadFileToString; using ::android::base::WriteStringToFile; using ::android::hardware::hidl_array; using ::android::hardware::hidl_memory; Loading @@ -64,18 +60,14 @@ using ::android::hardware::google::pixel::usb::MonitorFfs; using ::android::hardware::google::pixel::usb::resetGadget; using ::android::hardware::google::pixel::usb::setVidPid; using ::android::hardware::google::pixel::usb::unlinkFunctions; using ::android::hardware::usb::gadget::V1_0::IUsbGadgetCallback; using ::android::hardware::usb::gadget::V1_0::GadgetFunction; using ::android::hardware::usb::gadget::V1_0::Status; using ::android::hardware::usb::gadget::V1_2::IUsbGadget; using ::android::hardware::usb::gadget::V1_2::GadgetFunction; using ::android::hardware::usb::gadget::V1_1::IUsbGadget; using ::std::string; constexpr char kGadgetName[] = "a600000.dwc3"; static MonitorFfs monitorFfs(kGadgetName); #define UDC_PATH "/sys/class/udc/a600000.dwc3/" #define SPEED_PATH UDC_PATH "current_speed" struct UsbGadget : public IUsbGadget { UsbGadget(); Loading @@ -83,7 +75,6 @@ struct UsbGadget : public IUsbGadget { std::mutex mLockSetCurrentFunction; uint64_t mCurrentUsbFunctions; bool mCurrentUsbFunctionsApplied; UsbSpeed mUsbSpeed; Return<void> setCurrentUsbFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback, Loading @@ -93,8 +84,6 @@ struct UsbGadget : public IUsbGadget { Return<Status> reset() override; Return<void> getUsbSpeed(const sp<V1_2::IUsbGadgetCallback> &callback) override; private: Status tearDownGadget(); Status setupFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback> &callback, Loading @@ -102,7 +91,7 @@ private: }; } // namespace implementation } // namespace V1_2 } // namespace V1_1 } // namespace gadget } // namespace usb } // namespace hardware Loading
usb/android.hardware.usb.gadget@1.2-service.redfin.xml→usb/android.hardware.usb.gadget@1.1-service.redfin.xml +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ <hal format="hidl"> <name>android.hardware.usb.gadget</name> <transport>hwbinder</transport> <version>1.2</version> <version>1.1</version> <interface> <name>IUsbGadget</name> <instance>default</instance> Loading
usb/service.cpp +3 −3 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -27,8 +27,8 @@ using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; // Generated HIDL files using android::hardware::usb::gadget::V1_2::IUsbGadget; using android::hardware::usb::gadget::V1_2::implementation::UsbGadget; using android::hardware::usb::gadget::V1_1::IUsbGadget; using android::hardware::usb::gadget::V1_1::implementation::UsbGadget; using android::hardware::usb::V1_3::IUsb; using android::hardware::usb::V1_3::implementation::Usb; Loading