summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-08-29 01:26:05 -0700
committerXin Li <delphij@google.com>2020-08-29 01:26:05 -0700
commit1a1014488b39456d4cf414076e12bb6cfb77cb45 (patch)
tree291a5743878c0df5edfb4edd5b50c7a2e6c119e3 /usb
parent44766b66e1c29dc4ed0a7ebe8bce349b6ec7ccfb (diff)
parentb87b2a1fc9e841cc8b8f65d586abd50d3faad52e (diff)
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507 Merged-In: I62d8804c8b70e4d8ec1dd12e4e10952fa069bfaf Change-Id: I85283f312c12ada3aff38b68cab65e6c8bd564ea
Diffstat (limited to 'usb')
-rw-r--r--usb/Android.bp8
-rw-r--r--usb/UsbGadget.cpp17
-rw-r--r--usb/UsbGadget.h32
-rw-r--r--usb/android.hardware.usb.gadget@1.1-service.bonito.xml11
-rw-r--r--usb/android.hardware.usb@1.1-service.bonito.xml12
-rw-r--r--usb/service.cpp4
6 files changed, 61 insertions, 23 deletions
diff --git a/usb/Android.bp b/usb/Android.bp
index 449b0678..67b33493 100644
--- a/usb/Android.bp
+++ b/usb/Android.bp
@@ -16,17 +16,21 @@ cc_binary {
name: "android.hardware.usb@1.1-service.bonito",
relative_install_path: "hw",
init_rc: ["android.hardware.usb@1.1-service.bonito.rc"],
+ vintf_fragments: [
+ "android.hardware.usb@1.1-service.bonito.xml",
+ "android.hardware.usb.gadget@1.1-service.bonito.xml",
+ ],
srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"],
shared_libs: [
"libbase",
"libhidlbase",
- "libhidltransport",
"liblog",
"libutils",
"libhardware",
"android.hardware.usb@1.0",
"android.hardware.usb@1.1",
- "android.hardware.usb.gadget@1.0",
+ "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 82916a22..58daf242 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.bonito"
+#define LOG_TAG "android.hardware.usb.gadget@1.1-service.bonito"
#include "UsbGadget.h"
#include <dirent.h>
@@ -58,7 +58,7 @@ namespace android {
namespace hardware {
namespace usb {
namespace gadget {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
volatile bool gadgetPullup;
@@ -283,6 +283,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];
@@ -527,6 +536,8 @@ V1_0::Status UsbGadget::setupFunctions(
if ((functions & GadgetFunction::ADB) != 0) {
ffsEnabled = true;
ALOGI("setCurrentUsbFunctions Adb");
+ if (!WriteStringToFile("1", DESC_USE_PATH))
+ return Status::ERROR;
if (inotify_add_watch(inotifyFd, "/dev/usb-ffs/adb/", IN_ALL_EVENTS) == -1)
return Status::ERROR;
@@ -643,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 a0aa42b1..327be9ad 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,7 +49,9 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
-using ::std::chrono::steady_clock;
+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;
@@ -58,6 +59,7 @@ using ::std::string;
using ::std::thread;
using ::std::unique_ptr;
using ::std::vector;
+using ::std::chrono::steady_clock;
using namespace std::chrono;
using namespace std::chrono_literals;
@@ -80,24 +82,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;
- private:
+ Return<Status> reset() override;
+
+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.bonito.xml b/usb/android.hardware.usb.gadget@1.1-service.bonito.xml
new file mode 100644
index 00000000..a6f9a1f4
--- /dev/null
+++ b/usb/android.hardware.usb.gadget@1.1-service.bonito.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.bonito.xml b/usb/android.hardware.usb@1.1-service.bonito.xml
new file mode 100644
index 00000000..5ce2ff45
--- /dev/null
+++ b/usb/android.hardware.usb@1.1-service.bonito.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 ec9d3f06..f3e8b330 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;