summaryrefslogtreecommitdiff
path: root/thermal/utils/thermal_files.h
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2019-02-01 15:12:28 -0800
committerWei Wang <wvw@google.com>2019-02-04 15:13:53 -0800
commitbe44475ee233c0fb07742e246edb872798c45d33 (patch)
tree11a990b767fa94e285d8f1e74de23ce9e7ee9471 /thermal/utils/thermal_files.h
parent011ff4a73be5bedea8e46a0c3e1c5d20a9f4f8ff (diff)
downloadpixel-be44475ee233c0fb07742e246edb872798c45d33.tar.gz
Thermal: parse thermal paths at initialization
Bug: 118439547 Test: boot and lshal Change-Id: I3404752c8beac0127e3dbb36a5724df72eac9ed9
Diffstat (limited to 'thermal/utils/thermal_files.h')
-rw-r--r--thermal/utils/thermal_files.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/thermal/utils/thermal_files.h b/thermal/utils/thermal_files.h
new file mode 100644
index 00000000..e0a5e027
--- /dev/null
+++ b/thermal/utils/thermal_files.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __THERMAL_FILES_H__
+#define __THERMAL_FILES_H__
+
+#include <string>
+#include <unordered_map>
+
+namespace android {
+namespace hardware {
+namespace thermal {
+namespace V2_0 {
+namespace implementation {
+
+class ThermalFiles {
+ public:
+ ThermalFiles() = default;
+ ~ThermalFiles() = default;
+ ThermalFiles(const ThermalFiles &) = delete;
+ void operator=(const ThermalFiles &) = delete;
+
+ std::string getThermalFilePath(const std::string &thermal_name) const;
+ // Returns true if add was successful, false otherwise.
+ bool addThermalFile(const std::string &thermal_name, const std::string &path);
+ // If thermal_name is not found in the thermal names to path map, this will set
+ // data to empty and return false. If the thermal_name is found and its content
+ // is read, this function will fill in data accordingly then return true.
+ bool readThermalFile(const std::string &thermal_name, std::string *data) const;
+ size_t getNumThermalFiles() const { return thermal_name_to_path_map_.size(); }
+
+ private:
+ std::unordered_map<std::string, std::string> thermal_name_to_path_map_;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace thermal
+} // namespace hardware
+} // namespace android
+
+#endif // __THERMAL_FILES_H__