From 005229f4cec7d51d114c36a0b9cee78750c4faff Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Sat, 12 Feb 2022 20:59:15 +0100 Subject: [PATCH] hidl: usb: Rebrand to samsung and adjust paths Change-Id: I7e9342bcea0577f24414f35f24c5f8e6758a36b9 --- hidl/usb/Android.bp | 6 +- hidl/usb/Usb.cpp | 64 +++---------------- hidl/usb/Usb.h | 6 +- .../android.hardware.usb@1.3-service.gs101.rc | 21 ------ ...ndroid.hardware.usb@1.3-service.samsung.rc | 16 +++++ ...roid.hardware.usb@1.3-service.samsung.xml} | 0 hidl/usb/service.cpp | 2 +- 7 files changed, 30 insertions(+), 85 deletions(-) delete mode 100644 hidl/usb/android.hardware.usb@1.3-service.gs101.rc create mode 100644 hidl/usb/android.hardware.usb@1.3-service.samsung.rc rename hidl/usb/{android.hardware.usb@1.3-service.gs101.xml => android.hardware.usb@1.3-service.samsung.xml} (100%) diff --git a/hidl/usb/Android.bp b/hidl/usb/Android.bp index 77fe0389..d58539af 100644 --- a/hidl/usb/Android.bp +++ b/hidl/usb/Android.bp @@ -15,11 +15,11 @@ // limitations under the License. cc_binary { - name: "android.hardware.usb@1.3-service.gs101", + name: "android.hardware.usb@1.3-service.samsung", relative_install_path: "hw", - init_rc: ["android.hardware.usb@1.3-service.gs101.rc"], + init_rc: ["android.hardware.usb@1.3-service.samsung.rc"], vintf_fragments: [ - "android.hardware.usb@1.3-service.gs101.xml", + "android.hardware.usb@1.3-service.samsung.xml", ], srcs: ["service.cpp", "Usb.cpp"], cflags: ["-Wall", "-Werror"], diff --git a/hidl/usb/Usb.cpp b/hidl/usb/Usb.cpp index 2899c24e..2498e420 100644 --- a/hidl/usb/Usb.cpp +++ b/hidl/usb/Usb.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.usb@1.3-service.gs101" +#define LOG_TAG "android.hardware.usb@1.3-service.samsung" #include #include @@ -57,16 +57,6 @@ Return Usb::enableUsbDataSignal(bool enable) { } } else { - if (!WriteStringToFile("1", ID_PATH)) { - ALOGE("Not able to turn off host mode"); - result = false; - } - - if (!WriteStringToFile("0", VBUS_PATH)) { - ALOGE("Not able to set Vbus state"); - result = false; - } - if (!WriteStringToFile("0", USB_DATA_PATH)) { ALOGE("Not able to turn off usb connection notification"); result = false; @@ -79,13 +69,10 @@ Return Usb::enableUsbDataSignal(bool enable) { // Set by the signal handler to destroy the thread volatile bool destroyThread; -std::string enabledPath; -constexpr char kHsi2cPath[] = "/sys/devices/platform/10d50000.hsi2c"; -constexpr char kI2CPath[] = "/sys/devices/platform/10d50000.hsi2c/i2c-"; -constexpr char kContaminantDetectionPath[] = "i2c-max77759tcpc/contaminant_detection"; -constexpr char kStatusPath[] = "i2c-max77759tcpc/contaminant_detection_status"; +bool moistureDetectionEnabled = true; +constexpr char kContaminantDetectionPath[] = "/sys/devices/virtual/sec/ccic/water"; constexpr char kTypecPath[] = "/sys/class/typec"; -constexpr char kDisableContatminantDetection[] = "vendor.usb.contaminantdisable"; +constexpr char kDisableContaminantDetection[] = "vendor.usb.contaminantdisable"; int32_t readFile(const std::string &filename, std::string *contents) { FILE *fp; @@ -126,29 +113,6 @@ int32_t writeFile(const std::string &filename, const std::string &contents) { return -1; } -Status getContaminantDetectionNamesHelper(std::string *name) { - DIR *dp; - - dp = opendir(kHsi2cPath); - if (dp != NULL) { - struct dirent *ep; - - while ((ep = readdir(dp))) { - if (ep->d_type == DT_DIR) { - if (std::string::npos != std::string(ep->d_name).find("i2c-")) { - std::strtok(ep->d_name, "-"); - *name = std::strtok(NULL, "-"); - } - } - } - closedir(dp); - return Status::SUCCESS; - } - - ALOGE("Failed to open %s", kHsi2cPath); - return Status::ERROR; -} - Status queryMoistureDetectionStatus(hidl_vec *currentPortStatus_1_2) { std::string enabled, status, path, DetectedPath; @@ -165,16 +129,8 @@ Status queryMoistureDetectionStatus(hidl_vec *currentPortStatus_1_2) (*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceDetection = true; (*currentPortStatus_1_2)[0].supportsEnableContaminantPresenceProtection = false; - getContaminantDetectionNamesHelper(&path); - enabledPath = kI2CPath + path + "/" + kContaminantDetectionPath; - if (readFile(enabledPath, &enabled)) { - ALOGE("Failed to open moisture_detection_enabled"); - return Status::ERROR; - } - - if (enabled == "1") { - DetectedPath = kI2CPath + path + "/" + kStatusPath; - if (readFile(DetectedPath, &status)) { + if (moistureDetectionEnabled) { + if (readFile(kContaminantDetectionPath, &status)) { ALOGE("Failed to open moisture_detected"); return Status::ERROR; } @@ -643,11 +599,10 @@ Return Usb::queryPortStatus() { Return Usb::enableContaminantPresenceDetection(const hidl_string & /*portName*/, bool enable) { - - std::string disable = GetProperty(kDisableContatminantDetection, ""); + std::string disable = GetProperty(kDisableContaminantDetection, ""); if (disable != "true") - writeFile(enabledPath, enable ? "1" : "0"); + moistureDetectionEnabled = enable; hidl_vec currentPortStatus_1_2; @@ -691,8 +646,7 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) { pthread_cond_signal(&payload->usb->mPartnerCV); pthread_mutex_unlock(&payload->usb->mPartnerLock); } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_")) || - !strncmp(cp, "DRIVER=max77759tcpc", - strlen("DRIVER=max77759tcpc"))) { + !strncmp(cp, "CCIC=WATER", strlen("CCIC=WATER"))) { hidl_vec currentPortStatus_1_2; queryVersionHelper(payload->usb, ¤tPortStatus_1_2); diff --git a/hidl/usb/Usb.h b/hidl/usb/Usb.h index 1026b611..8e512972 100644 --- a/hidl/usb/Usb.h +++ b/hidl/usb/Usb.h @@ -67,11 +67,7 @@ enum class HALVersion{ V1_3 }; -#define NEW_UDC_PATH "/sys/devices/platform/11110000.usb/" - -#define ID_PATH NEW_UDC_PATH "dwc3_exynos_otg_id" -#define VBUS_PATH NEW_UDC_PATH "dwc3_exynos_otg_b_sess" -#define USB_DATA_PATH NEW_UDC_PATH "usb_data_enabled" +#define USB_DATA_PATH "/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled" struct Usb : public IUsb { Usb(); diff --git a/hidl/usb/android.hardware.usb@1.3-service.gs101.rc b/hidl/usb/android.hardware.usb@1.3-service.gs101.rc deleted file mode 100644 index 2441aba6..00000000 --- a/hidl/usb/android.hardware.usb@1.3-service.gs101.rc +++ /dev/null @@ -1,21 +0,0 @@ -service vendor.usb-hal-1-3 /vendor/bin/hw/android.hardware.usb@1.3-service.gs101 - class hal - user system - group system shell mtp wakelock - capabilities WAKE_ALARM BLOCK_SUSPEND - -on post-fs - chown root system /sys/class/typec/port0/power_role - chown root system /sys/class/typec/port0/data_role - chown root system /sys/class/typec/port0/port_type - chown root system /sys/devices/platform/10d50000.hsi2c/i2c-5/i2c-max77759tcpc/contaminant_detection - chown root system /sys/devices/platform/10d50000.hsi2c/i2c-6/i2c-max77759tcpc/contaminant_detection - chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess - chown root system /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id - chown root system /sys/devices/platform/11110000.usb/usb_data_enabled - chmod 664 /sys/class/typec/port0/power_role - chmod 664 /sys/class/typec/port0/data_role - chmod 664 /sys/class/typec/port0/port_type - chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_b_sess - chmod 664 /sys/devices/platform/11110000.usb/dwc3_exynos_otg_id - chmod 664 /sys/devices/platform/11110000.usb/usb_data_enabled diff --git a/hidl/usb/android.hardware.usb@1.3-service.samsung.rc b/hidl/usb/android.hardware.usb@1.3-service.samsung.rc new file mode 100644 index 00000000..5fb31946 --- /dev/null +++ b/hidl/usb/android.hardware.usb@1.3-service.samsung.rc @@ -0,0 +1,16 @@ +service vendor.usb-hal-1-3 /vendor/bin/hw/android.hardware.usb@1.3-service.samsung + class hal + user system + group system shell mtp wakelock + capabilities WAKE_ALARM BLOCK_SUSPEND + +on post-fs + chown root system /sys/class/typec/port0/power_role + chown root system /sys/class/typec/port0/data_role + chown root system /sys/class/typec/port0/port_type + chown root system /sys/devices/virtual/sec/ccic/water + chown root system /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled + chmod 664 /sys/class/typec/port0/power_role + chmod 664 /sys/class/typec/port0/data_role + chmod 664 /sys/class/typec/port0/port_type + chmod 664 /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled diff --git a/hidl/usb/android.hardware.usb@1.3-service.gs101.xml b/hidl/usb/android.hardware.usb@1.3-service.samsung.xml similarity index 100% rename from hidl/usb/android.hardware.usb@1.3-service.gs101.xml rename to hidl/usb/android.hardware.usb@1.3-service.samsung.xml diff --git a/hidl/usb/service.cpp b/hidl/usb/service.cpp index 761e6089..33bd6456 100644 --- a/hidl/usb/service.cpp +++ b/hidl/usb/service.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.usb@1.3-service.gs101" +#define LOG_TAG "android.hardware.usb@1.3-service.samsung" #include #include "Usb.h"