hidl: usb: Rebrand to samsung and adjust paths
authorTim Zimmermann <tim@linux4.de>
Sat, 12 Feb 2022 19:59:15 +0000 (20:59 +0100)
committerJan Altensen <info@stricted.net>
Tue, 29 Mar 2022 22:44:18 +0000 (00:44 +0200)
Change-Id: I7e9342bcea0577f24414f35f24c5f8e6758a36b9

hidl/usb/Android.bp
hidl/usb/Usb.cpp
hidl/usb/Usb.h
hidl/usb/android.hardware.usb@1.3-service.gs101.rc [deleted file]
hidl/usb/android.hardware.usb@1.3-service.gs101.xml [deleted file]
hidl/usb/android.hardware.usb@1.3-service.samsung.rc [new file with mode: 0644]
hidl/usb/android.hardware.usb@1.3-service.samsung.xml [new file with mode: 0644]
hidl/usb/service.cpp

index 77fe0389373d69592d52155d27f32cb78ed336fd..d58539af09d2b8408668386637bb4251fefd3672 100644 (file)
 // 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"],
index 2899c24ed90c636ea851a2f90a3dd5be163b399a..2498e420f69c1f451720382910f9e755e604cb2b 100644 (file)
@@ -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 <android-base/logging.h>
 #include <android-base/properties.h>
@@ -57,16 +57,6 @@ Return<bool> 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<bool> 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<PortStatus> *currentPortStatus_1_2) {
     std::string enabled, status, path, DetectedPath;
 
@@ -165,16 +129,8 @@ Status queryMoistureDetectionStatus(hidl_vec<PortStatus> *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<void> Usb::queryPortStatus() {
 
 Return<void> 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<PortStatus> 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<PortStatus> currentPortStatus_1_2;
             queryVersionHelper(payload->usb, &currentPortStatus_1_2);
 
index 1026b611a63b9c87bb70e826dd9d6c6884c976aa..8e512972723d10f1237d41bb2477f3b949546fef 100644 (file)
@@ -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 (file)
index 2441aba..0000000
+++ /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.gs101.xml b/hidl/usb/android.hardware.usb@1.3-service.gs101.xml
deleted file mode 100644 (file)
index cd54268..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<manifest version="1.0" type="device">
-    <hal format="hidl">
-        <name>android.hardware.usb</name>
-        <transport>hwbinder</transport>
-        <version>1.3</version>
-        <interface>
-            <name>IUsb</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-</manifest>
-
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 (file)
index 0000000..5fb3194
--- /dev/null
@@ -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.samsung.xml b/hidl/usb/android.hardware.usb@1.3-service.samsung.xml
new file mode 100644 (file)
index 0000000..cd54268
--- /dev/null
@@ -0,0 +1,12 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.usb</name>
+        <transport>hwbinder</transport>
+        <version>1.3</version>
+        <interface>
+            <name>IUsb</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
+
index 761e60899183a06d82e20ba8d1ce7de7bdea512f..33bd64561539a8590c2a0791917318a0cec01e53 100644 (file)
@@ -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 <hidl/HidlTransportSupport.h>
 #include "Usb.h"