1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include <android-base/logging.h> 17 #include <android-base/properties.h> 18 19 #include <string> 20 21 namespace { 22 constexpr std::string_view kWingBoardHwId("0x00060603000100020000000000000000"); 23 using android::base::GetProperty; useThermalWingBoardConfig()24bool useThermalWingBoardConfig() { 25 const auto cdt_hwid = GetProperty("ro.boot.cdt_hwid", ""); 26 if (cdt_hwid == kWingBoardHwId) { 27 LOG(INFO) << "Using wingboard thermal config as found cdt_hwid " << cdt_hwid; 28 return true; 29 } 30 return false; 31 } 32 useThermalBackupConfig()33bool useThermalBackupConfig() { 34 const auto panel_drv = GetProperty("ro.boot.primary_panel_drv", ""); 35 const auto is_panel_available = (panel_drv.find("panel-google-ct3a") != std::string::npos) || 36 (panel_drv.find("panel-google-ct3b") != std::string::npos); 37 if (!is_panel_available) { 38 LOG(INFO) << "Using backup thermal config as unknown panel [" << panel_drv << "] found."; 39 return true; 40 } 41 const auto hardware_revision = GetProperty("ro.boot.hardware.revision", ""); 42 if (hardware_revision == "PROTO1.0" || hardware_revision == "PROTO1.1") { 43 LOG(INFO) << "Using backup thermal config as hardware revision [" << hardware_revision 44 << "] found."; 45 return true; 46 } 47 return false; 48 } 49 } // namespace 50 main()51int main() { 52 if (useThermalWingBoardConfig()) { 53 if (!android::base::SetProperty("vendor.thermal.config", 54 "thermal_info_config_wingboard.json")) { 55 LOG(FATAL) << "Failed to set property vendor.thermal.config to " 56 "thermal_info_config_wingboard."; 57 } 58 } else if (useThermalBackupConfig()) { 59 if (!android::base::SetProperty("vendor.thermal.config", 60 "thermal_info_config_backup.json")) { 61 LOG(FATAL) << "Failed to set property vendor.thermal.config to " 62 "thermal_info_config_backup."; 63 } 64 } 65 return 0; 66 }