Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 761d8450 authored by Muhammad Qureshi's avatar Muhammad Qureshi Committed by Android (Google) Code Review
Browse files

Merge "Revert "Migrate IUsb implementation to AIDL""

parents 99355407 85a3efe5
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -130,11 +130,8 @@ ifeq ($(wildcard vendor/google_devices/redfin/proprietary/device-vendor-redfin.m
    BUILD_WITHOUT_VENDOR := true
endif

# USB HAL
PRODUCT_PACKAGES += \
    android.hardware.usb-service.redfin
PRODUCT_PACKAGES += \
    android.hardware.usb.gadget-service.redfin
    android.hardware.usb@1.3-service.redfin

# Vibrator HAL
PRODUCT_PACKAGES += \
+9 −4
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.
@@ -18,14 +18,19 @@ package {
}

cc_binary {
    name: "android.hardware.usb.gadget-service.redfin",
    name: "android.hardware.usb@1.3-service.redfin",
    relative_install_path: "hw",
    init_rc: ["android.hardware.usb.gadget-service.redfin.rc"],
    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.1-service.redfin.xml",
    ],
    srcs: ["service_gadget.cpp", "UsbGadget.cpp"],
    srcs: ["service.cpp", "Usb.cpp", "UsbGadget.cpp"],
    shared_libs: [
        "android.hardware.usb@1.0",
        "android.hardware.usb@1.1",
        "android.hardware.usb@1.2",
        "android.hardware.usb@1.3",
        "android.hardware.usb.gadget@1.0",
        "android.hardware.usb.gadget@1.1",
        "libbase",
+840 −0

File changed and moved.

Preview size limit exceeded, changes collapsed.

+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 * Copyright (C) 2021 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.
@@ -13,12 +13,14 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <android-base/file.h>
#include <aidl/android/hardware/usb/BnUsb.h>
#include <aidl/android/hardware/usb/BnUsbCallback.h>
#include <android/hardware/usb/1.2/IUsbCallback.h>
#include <android/hardware/usb/1.2/types.h>
#include <android/hardware/usb/1.3/IUsb.h>
#include <hidl/Status.h>
#include <pixelusb/UsbGadgetCommon.h>
#include <utils/Log.h>

#define UEVENT_MSG_LEN 2048
@@ -28,45 +30,57 @@
// structures created and uvent fired.
#define PORT_TYPE_TIMEOUT 8

namespace aidl {
namespace android {
namespace hardware {
namespace usb {
namespace V1_3 {
namespace implementation {

using ::aidl::android::hardware::usb::IUsbCallback;
using ::aidl::android::hardware::usb::PortRole;
using ::android::base::ReadFileToString;
using ::android::base::WriteStringToFile;
using ::android::sp;
using ::ndk::ScopedAStatus;
using ::std::shared_ptr;
using ::std::string;
using ::android::base::WriteStringToFile;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::usb::V1_0::PortDataRole;
using ::android::hardware::usb::V1_0::PortPowerRole;
using ::android::hardware::usb::V1_0::PortRole;
using ::android::hardware::usb::V1_0::PortRoleType;
using ::android::hardware::usb::V1_0::Status;
using ::android::hardware::usb::V1_1::PortMode_1_1;
using ::android::hardware::usb::V1_1::PortStatus_1_1;
using ::android::hardware::usb::V1_2::PortStatus;
using ::android::hardware::usb::V1_2::IUsbCallback;
using ::android::hardware::usb::V1_3::IUsb;
using ::android::hidl::base::V1_0::DebugInfo;
using ::android::hidl::base::V1_0::IBase;

enum class HALVersion{
    V1_0,
    V1_1,
    V1_2,
    V1_3
};

constexpr char kGadgetName[] = "a600000.dwc3";
#define ID_PATH SOC_PATH "id"
#define PULLUP_PATH "/config/usb_gadget/g1/UDC"
#define SOC_PATH "/sys/devices/platform/soc/a600000.ssusb/"
#define USB_DATA_PATH SOC_PATH "usb_data_enabled"
#define ID_PATH SOC_PATH "id"
#define VBUS_PATH SOC_PATH "b_sess"
#define USB_DATA_PATH SOC_PATH "usb_data_enabled"

struct Usb : public BnUsb {
struct Usb : public IUsb {
    Usb();

    ScopedAStatus enableContaminantPresenceDetection(const std::string& in_portName,
            bool in_enable, int64_t in_transactionId) override;
    ScopedAStatus queryPortStatus(int64_t in_transactionId) override;
    ScopedAStatus setCallback(const shared_ptr<IUsbCallback>& in_callback) override;
    ScopedAStatus switchRole(const string& in_portName, const PortRole& in_role,
            int64_t in_transactionId) override;
    ScopedAStatus enableUsbData(const string& in_portName, bool in_enable,
            int64_t in_transactionId) override;
    ScopedAStatus enableUsbDataWhileDocked(const string& in_portName,
            int64_t in_transactionId) override;
    ScopedAStatus limitPowerTransfer(const string& in_portName, bool in_limit,
            int64_t in_transactionId) override;
    ScopedAStatus resetUsbPort(const string& in_portName, int64_t in_transactionId) override;
    Return<void> switchRole(const hidl_string &portName, const V1_0::PortRole &role) override;
    Return<void> setCallback(const sp<V1_0::IUsbCallback> &callback) override;
    Return<void> queryPortStatus() override;
    Return<void> enableContaminantPresenceDetection(const hidl_string& portName, bool enable);
    Return<void> enableContaminantPresenceProtection(const hidl_string& portName, bool enable);
    Return<bool> enableUsbDataSignal(bool enable) override;

    std::shared_ptr<::aidl::android::hardware::usb::IUsbCallback> mCallback;
    sp<V1_0::IUsbCallback> mCallback_1_0;
    // Protects mCallback variable
    pthread_mutex_t mLock;
    // Protects roleSwitch operation
@@ -77,14 +91,13 @@ struct Usb : public BnUsb {
    pthread_mutex_t mPartnerLock;
    // Variable to signal partner coming back online after type switch
    bool mPartnerUp;
    // Usb Data status
    bool mUsbDataEnabled;

  private:
    pthread_t mPoll;
};

}  // namespace implementation
}  // namespace V1_3
}  // namespace usb
}  // namespace hardware
}  // namespace android
} // aidl
+0 −0

File moved.

Loading