From dc71585783eef3e8ddc6354664c71a48f28d40cf Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Sat, 12 Feb 2022 20:40:06 +0100 Subject: [PATCH] hidl: usb: Remove overheat reporting * Not supported Change-Id: I6b6b6a1fd00a1e28a3b00cd721d885552a9bb865 --- hidl/usb/Android.bp | 12 ------- hidl/usb/Usb.cpp | 79 +++------------------------------------------ hidl/usb/Usb.h | 10 ------ 3 files changed, 5 insertions(+), 96 deletions(-) diff --git a/hidl/usb/Android.bp b/hidl/usb/Android.bp index ebd56935..77fe0389 100644 --- a/hidl/usb/Android.bp +++ b/hidl/usb/Android.bp @@ -34,20 +34,8 @@ cc_binary { "android.hardware.usb@1.1", "android.hardware.usb@1.2", "android.hardware.usb@1.3", - "android.hardware.thermal@1.0", - "android.hardware.thermal@2.0", "libcutils", - "android.frameworks.stats-V1-ndk_platform", - "pixelatoms-cpp", "libbinder_ndk", ], - static_libs: [ - "libpixelusb", - "libpixelstats", - ], - export_shared_lib_headers: [ - "android.frameworks.stats-V1-ndk_platform", - "pixelatoms-cpp", - ], proprietary: true, } diff --git a/hidl/usb/Usb.cpp b/hidl/usb/Usb.cpp index eba61f63..2899c24e 100644 --- a/hidl/usb/Usb.cpp +++ b/hidl/usb/Usb.cpp @@ -37,14 +37,7 @@ #include "Usb.h" -#include -#include - -using aidl::android::frameworks::stats::IStats; using android::base::GetProperty; -using android::hardware::google::pixel::getStatsService; -using android::hardware::google::pixel::PixelAtoms::VendorUsbPortOverheat; -using android::hardware::google::pixel::reportUsbPortOverheat; namespace android { namespace hardware { @@ -93,13 +86,6 @@ constexpr char kContaminantDetectionPath[] = "i2c-max77759tcpc/contaminant_detec constexpr char kStatusPath[] = "i2c-max77759tcpc/contaminant_detection_status"; constexpr char kTypecPath[] = "/sys/class/typec"; constexpr char kDisableContatminantDetection[] = "vendor.usb.contaminantdisable"; -constexpr char kOverheatStatsPath[] = "/sys/devices/platform/google,usbc_port_cooling_dev/"; -constexpr char kOverheatStatsDev[] = "DRIVER=google,usbc_port_cooling_dev"; -constexpr char kThermalZoneForTrip[] = "VIRTUAL-USB-THROTTLING"; -constexpr char kThermalZoneForTempReadPrimary[] = "usb_pwr_therm2"; -constexpr char kThermalZoneForTempReadSecondary1[] = "usb_pwr_therm"; -constexpr char kThermalZoneForTempReadSecondary2[] = "qi_therm"; -constexpr int kSamplingIntervalSec = 5; int32_t readFile(const std::string &filename, std::string *contents) { FILE *fp; @@ -331,15 +317,7 @@ Usb::Usb() : mLock(PTHREAD_MUTEX_INITIALIZER), mRoleSwitchLock(PTHREAD_MUTEX_INITIALIZER), mPartnerLock(PTHREAD_MUTEX_INITIALIZER), - mPartnerUp(false), - mOverheat(ZoneInfo(TemperatureType::USB_PORT, kThermalZoneForTrip, - ThrottlingSeverity::CRITICAL), - {ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadPrimary, - ThrottlingSeverity::NONE), - ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary1, - ThrottlingSeverity::NONE), - ZoneInfo(TemperatureType::UNKNOWN, kThermalZoneForTempReadSecondary2, - ThrottlingSeverity::NONE)}, kSamplingIntervalSec) { + mPartnerUp(false) { pthread_condattr_t attr; if (pthread_condattr_init(&attr)) { ALOGE("pthread_condattr_init failed: %s", strerror(errno)); @@ -537,8 +515,7 @@ bool canSwitchRoleHelper(const std::string &portName, PortRoleType /*type*/) { * The caller of this method would reconstruct the V1_0::PortStatus * object if required. */ -Status getPortStatusHelper(hidl_vec *currentPortStatus_1_2, HALVersion version, - android::hardware::usb::V1_3::implementation::Usb *usb) { +Status getPortStatusHelper(hidl_vec *currentPortStatus_1_2, HALVersion version) { std::unordered_map names; Status result = getTypeCPortNamesHelper(&names); int i = -1; @@ -599,12 +576,6 @@ Status getPortStatusHelper(hidl_vec *currentPortStatus_1_2, HALVersi (*currentPortStatus_1_2)[i].status_1_1.status.currentMode = V1_0::PortMode::NONE; } - // Query temperature for the first connect - if (port.second && !usb->mPluggedTemperatureCelsius) { - usb->mOverheat.getCurrentTemperature(kThermalZoneForTempReadPrimary, - &usb->mPluggedTemperatureCelsius); - ALOGV("USB Initial temperature: %f", usb->mPluggedTemperatureCelsius); - } ALOGI( "%d:%s connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d " "supportedModes:%d", @@ -631,16 +602,16 @@ void queryVersionHelper(android::hardware::usb::V1_3::implementation::Usb *usb, pthread_mutex_lock(&usb->mLock); if (usb->mCallback_1_0 != NULL) { if (callback_V1_2 != NULL) { - status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_2, usb); + status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_2); if (status == Status::SUCCESS) queryMoistureDetectionStatus(currentPortStatus_1_2); } else if (callback_V1_1 != NULL) { - status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_1, usb); + status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_1); currentPortStatus_1_1.resize(currentPortStatus_1_2->size()); for (unsigned long i = 0; i < currentPortStatus_1_2->size(); i++) currentPortStatus_1_1[i] = (*currentPortStatus_1_2)[i].status_1_1; } else { - status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_0, usb); + status = getPortStatusHelper(currentPortStatus_1_2, HALVersion::V1_0); currentPortStatus.resize(currentPortStatus_1_2->size()); for (unsigned long i = 0; i < currentPortStatus_1_2->size(); i++) currentPortStatus[i] = (*currentPortStatus_1_2)[i].status_1_1.status; @@ -692,39 +663,6 @@ Return Usb::enableContaminantPresenceProtection(const hidl_string & /*port return Void(); } -void report_overheat_event(android::hardware::usb::V1_3::implementation::Usb *usb) { - VendorUsbPortOverheat overheat_info; - std::string contents; - - overheat_info.set_plug_temperature_deci_c(usb->mPluggedTemperatureCelsius * 10); - overheat_info.set_max_temperature_deci_c(usb->mOverheat.getMaxOverheatTemperature() * 10); - if (ReadFileToString(std::string(kOverheatStatsPath) + "trip_time", &contents)) { - overheat_info.set_time_to_overheat_secs(stoi(contents)); - } else { - ALOGE("Unable to read trip_time"); - return; - } - if (ReadFileToString(std::string(kOverheatStatsPath) + "hysteresis_time", &contents)) { - overheat_info.set_time_to_hysteresis_secs(stoi(contents)); - } else { - ALOGE("Unable to read hysteresis_time"); - return; - } - if (ReadFileToString(std::string(kOverheatStatsPath) + "cleared_time", &contents)) { - overheat_info.set_time_to_inactive_secs(stoi(contents)); - } else { - ALOGE("Unable to read cleared_time"); - return; - } - - const std::shared_ptr stats_client = getStatsService(); - if (!stats_client) { - ALOGE("Unable to get AIDL Stats service"); - } else { - reportUsbPortOverheat(stats_client, overheat_info); - } -} - struct data { int uevent_fd; android::hardware::usb::V1_3::implementation::Usb *usb; @@ -752,10 +690,6 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) { payload->usb->mPartnerUp = true; pthread_cond_signal(&payload->usb->mPartnerCV); pthread_mutex_unlock(&payload->usb->mPartnerLock); - // Update Plugged temperature - payload->usb->mOverheat.getCurrentTemperature(kThermalZoneForTempReadPrimary, - &payload->usb->mPluggedTemperatureCelsius); - ALOGI("Usb Plugged temp: %f", payload->usb->mPluggedTemperatureCelsius); } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_")) || !strncmp(cp, "DRIVER=max77759tcpc", strlen("DRIVER=max77759tcpc"))) { @@ -781,9 +715,6 @@ static void uevent_event(uint32_t /*epevents*/, struct data *payload) { pthread_mutex_unlock(&payload->usb->mRoleSwitchLock); } break; - } else if (!strncmp(cp, kOverheatStatsDev, strlen(kOverheatStatsDev))) { - ALOGV("Overheat Cooling device suez update"); - report_overheat_event(payload->usb); } /* advance to after the next \0 */ while (*cp++) { diff --git a/hidl/usb/Usb.h b/hidl/usb/Usb.h index 73bafdeb..1026b611 100644 --- a/hidl/usb/Usb.h +++ b/hidl/usb/Usb.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #define UEVENT_MSG_LEN 2048 @@ -45,10 +44,6 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::google::pixel::usb::UsbOverheatEvent; -using ::android::hardware::google::pixel::usb::ZoneInfo; -using ::android::hardware::thermal::V2_0::TemperatureType; -using ::android::hardware::thermal::V2_0::ThrottlingSeverity; using ::android::hardware::usb::V1_0::PortRole; using ::android::hardware::usb::V1_0::PortRoleType; using ::android::hardware::usb::V1_0::PortDataRole; @@ -100,11 +95,6 @@ struct Usb : public IUsb { // Variable to signal partner coming back online after type switch bool mPartnerUp; - // Usb Overheat object for push suez event - UsbOverheatEvent mOverheat; - // Temperature when connected - float mPluggedTemperatureCelsius; - private: pthread_t mPoll; };