From d406d43bcb5563027f24a874119b72ece40a09d7 Mon Sep 17 00:00:00 2001 From: sashwinbalaji Date: Thu, 27 Jun 2024 23:44:49 +0800 Subject: [PATCH] thermal: Update init_thermal_config - Validate for display panel availability only in userdebug builds. - Add check to fall back to wingboard config for charging mode as well. - Move fallback to backup config for proto and wingboard to init rc file. Bug: 338295174 Flag: EXEMPT NDK Test: Local build and verify init_thermal_config and property Change-Id: I4b2db92df1d74be4038e256ab6e25ee616c5feb6 --- conf/init.comet.rc | 16 ++++++++++++-- thermal/init_thermal_config.cpp | 39 ++------------------------------- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/conf/init.comet.rc b/conf/init.comet.rc index 704f662..de143f7 100644 --- a/conf/init.comet.rc +++ b/conf/init.comet.rc @@ -57,10 +57,22 @@ service init_thermal_config /vendor/bin/init_thermal_config disabled oneshot -on late-init +on late-init && property:ro.boot.hardware.revision=PROTO1.0 + setprop vendor.thermal.config "thermal_info_config_backup.json" + +on late-init && property:ro.boot.hardware.revision=PROTO1.1 + setprop vendor.thermal.config "thermal_info_config_backup.json" + +on late-init && property:ro.boot.cdt_hwid=0x00060603000100020000000000000000 + setprop vendor.thermal.config "thermal_info_config_wingboard.json" + +on property:vendor.thermal.config=thermal_info_config_charge.json && property:ro.boot.cdt_hwid=0x00060603000100020000000000000000 + setprop vendor.thermal.config "thermal_info_config_wingboard.json" + +on late-init && property:ro.debuggable=1 start init_thermal_config -on property:vendor.thermal.config=thermal_info_config_charge +on property:vendor.thermal.config=thermal_info_config_charge.json && property:ro.debuggable=1 start init_thermal_config on property:vendor.thermal.link_ready=1 diff --git a/thermal/init_thermal_config.cpp b/thermal/init_thermal_config.cpp index 247df91..ae81d5a 100644 --- a/thermal/init_thermal_config.cpp +++ b/thermal/init_thermal_config.cpp @@ -16,46 +16,11 @@ #include #include -#include - -namespace { -constexpr std::string_view kWingBoardHwId("0x00060603000100020000000000000000"); -using android::base::GetProperty; -bool useThermalWingBoardConfig() { - const auto cdt_hwid = GetProperty("ro.boot.cdt_hwid", ""); - if (cdt_hwid == kWingBoardHwId) { - LOG(INFO) << "Using wingboard thermal config as found cdt_hwid " << cdt_hwid; - return true; - } - return false; -} - -bool useThermalBackupConfig() { - const auto panel_drv = GetProperty("ro.boot.primary_panel_drv", ""); +int main() { + const auto panel_drv = android::base::GetProperty("ro.boot.primary_panel_drv", ""); const auto is_panel_available = (panel_drv.find("panel-google-ct3a") != std::string::npos) || (panel_drv.find("panel-google-ct3b") != std::string::npos); if (!is_panel_available) { - LOG(INFO) << "Using backup thermal config as unknown panel [" << panel_drv << "] found."; - return true; - } - const auto hardware_revision = GetProperty("ro.boot.hardware.revision", ""); - if (hardware_revision == "PROTO1.0" || hardware_revision == "PROTO1.1") { - LOG(INFO) << "Using backup thermal config as hardware revision [" << hardware_revision - << "] found."; - return true; - } - return false; -} -} // namespace - -int main() { - if (useThermalWingBoardConfig()) { - if (!android::base::SetProperty("vendor.thermal.config", - "thermal_info_config_wingboard.json")) { - LOG(FATAL) << "Failed to set property vendor.thermal.config to " - "thermal_info_config_wingboard."; - } - } else if (useThermalBackupConfig()) { if (!android::base::SetProperty("vendor.thermal.config", "thermal_info_config_backup.json")) { LOG(FATAL) << "Failed to set property vendor.thermal.config to "