Upgrading Walleye and Taimen's thermal HAL version to 2.0.

Bug: 118689758
Test: adb shell dumpsys hardware_properties
      adb shell su 0 lshal debug android.hardware.thermal@2.0::IThermal/default
      pts -m PtsThermalHalTestCases
      vts -m VtsHalThermalV1_0Target
      vts -m VtsHalThermalV2_0Target
Change-Id: I089c54c722089f12affae488c81c039405839b5e
Signed-off-by: Vincent Palomares <paillon@google.com>
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..fe633fc
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,5 @@
+soong_namespace {
+    imports: [
+        "hardware/google/pixel/thermalhal",
+    ],
+}
diff --git a/device.mk b/device.mk
index a550bd3..6500a80 100755
--- a/device.mk
+++ b/device.mk
@@ -29,6 +29,10 @@
 PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
     ro.adb.secure=1
 
+PRODUCT_SOONG_NAMESPACES += \
+    device/google/wahoo \
+    hardware/google/pixel/thermalhal
+
 # Telephony IWLAN operation mode
 PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
     ro.telephony.iwlan_operation_mode=0
@@ -439,9 +443,9 @@
 PRODUCT_PACKAGES += \
     android.hardware.vibrator@1.2-service.wahoo
 
-# Thermal packages
+# Thermal HAL
 PRODUCT_PACKAGES += \
-    android.hardware.thermal@1.1-impl-wahoo
+    android.hardware.thermal@2.0-service.pixel
 
 #GNSS HAL
 PRODUCT_PACKAGES += \
diff --git a/init.hardware.rc b/init.hardware.rc
index 73c5fd8..02b01b4 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -159,6 +159,9 @@
     write /sys/block/zram0/comp_algorithm lz4
     write /proc/sys/vm/page-cluster 0
 
+on init
+    setprop vendor.thermal.config thermal_info_config.json
+
 on fs
     mount_all /vendor/etc/fstab.${ro.hardware} --early
 
diff --git a/manifest.xml b/manifest.xml
index 62156b8..b66c2d7 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -286,15 +286,6 @@
         </interface>
     </hal>
     <hal format="hidl">
-        <name>android.hardware.thermal</name>
-        <transport>hwbinder</transport>
-        <version>1.1</version>
-        <interface>
-            <name>IThermal</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-    <hal format="hidl">
         <name>android.hardware.usb</name>
         <transport>hwbinder</transport>
         <version>1.1</version>
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
index 2dc57d5..fe35faf 100644
--- a/sepolicy/vendor/file_contexts
+++ b/sepolicy/vendor/file_contexts
@@ -190,6 +190,7 @@
 /vendor/bin/hw/android\.hardware\.keymaster@3\.0-service-qti         u:object_r:hal_keymaster_qti_exec:s0
 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service-qti        u:object_r:hal_gatekeeper_qti_exec:s0
 /vendor/bin/hw/android\.hardware\.gnss@1\.0-service-qti              u:object_r:hal_gnss_qti_exec:s0
+/vendor/bin/hw/android\.hardware\.thermal@2\.0-service\.pixel         u:object_r:hal_thermal_default_exec:s0
 
 ###############################################
 # same-process HAL files and their dependencies
diff --git a/sepolicy/vendor/hal_thermal_default.te b/sepolicy/vendor/hal_thermal_default.te
new file mode 100644
index 0000000..13c129f
--- /dev/null
+++ b/sepolicy/vendor/hal_thermal_default.te
@@ -0,0 +1,7 @@
+allow hal_thermal_default sysfs_thermal:dir r_dir_perms;
+allow hal_thermal_default sysfs_thermal:file r_file_perms;
+allow hal_thermal_default sysfs_thermal:lnk_file read;
+allow hal_thermal_default proc_stat:file r_file_perms;
+
+# read thermal_config
+get_prop(hal_thermal_default, thermal_prop)
diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts
index 18a87d6..96a5581 100644
--- a/sepolicy/vendor/property_contexts
+++ b/sepolicy/vendor/property_contexts
@@ -17,6 +17,7 @@
 sys.listeners.registered   u:object_r:tee_listener_prop:s0
 wc_transport.              u:object_r:wc_prop:s0
 vendor.qcom.thermalcfg     u:object_r:thermal_prop:s0
+vendor.thermal.config      u:object_r:thermal_prop:s0
 persist.sys.modem.diag.    u:object_r:modem_diag_prop:s0
 sys.modem.diag.            u:object_r:modem_diag_prop:s0
 sys.time.set               u:object_r:sys_time_prop:s0
diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te
index bc1ab54..2bd2bd9 100644
--- a/sepolicy/vendor/thermal-engine.te
+++ b/sepolicy/vendor/thermal-engine.te
@@ -19,8 +19,6 @@
 allow thermal-engine sysfs_rmtfs:file r_file_perms;
 # to read /proc/stat
 allow thermal-engine proc_stat:file { getattr open read };
-# IThermal Thermal HAL
-hal_server_domain(thermal-engine, hal_thermal)
 
 allow thermal-engine thermal_device:chr_file rw_file_perms;
 
diff --git a/thermal/Android.bp b/thermal/Android.bp
deleted file mode 100644
index 43c003e..0000000
--- a/thermal/Android.bp
+++ /dev/null
@@ -1,21 +0,0 @@
-cc_library {
-    name: "android.hardware.thermal@1.1-wahoo",
-    defaults: ["hidl_defaults"],
-    owner: "qcom",
-    vendor: true,
-    relative_install_path: "hw",
-    srcs: [
-	"sensors.cpp",
-        "Thermal.cpp",
-        "thermal-helper.cpp",
-    ],
-    export_include_dirs: ["."],
-    shared_libs: [
-        "libbase",
-        "libhidlbase",
-        "libhidltransport",
-        "libutils",
-        "android.hardware.thermal@1.0",
-        "android.hardware.thermal@1.1",
-    ],
-}
diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp
deleted file mode 100644
index b47a54d..0000000
--- a/thermal/Thermal.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <cerrno>
-#include <vector>
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-
-#include "Thermal.h"
-#include "thermal-helper.h"
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-Thermal::Thermal() : enabled(initThermal()) {}
-
-namespace {
-
-// Saves the IThermalCallback client object registered from the
-// framework for sending thermal events to the framework thermal event bus.
-sp<IThermalCallback> gThermalCallback;
-
-struct ThermalDeathRecipient : hidl_death_recipient {
-    virtual void serviceDied(
-        uint64_t cookie __unused, const wp<IBase>& who __unused) {
-        gThermalCallback = nullptr;
-        LOG(ERROR) << "IThermalCallback HIDL service died";
-    }
-};
-
-sp<ThermalDeathRecipient> gThermalCallbackDied = nullptr;
-
-} // anonymous namespace
-
-// Methods from ::android::hardware::thermal::V1_0::IThermal follow.
-Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb) {
-    ThermalStatus status;
-    status.code = ThermalStatusCode::SUCCESS;
-    hidl_vec<Temperature> temperatures;
-    temperatures.resize(kTemperatureNum);
-
-    if (!enabled) {
-        status.code = ThermalStatusCode::FAILURE;
-        status.debugMessage = "Unsupported hardware";
-        _hidl_cb(status, temperatures);
-        LOG(ERROR) << "ThermalHAL not initialized properly.";
-        return Void();
-    }
-
-    if (fillTemperatures(&temperatures) != kTemperatureNum) {
-        status.code = ThermalStatusCode::FAILURE;
-        status.debugMessage = "Error reading thermal sensors.";
-    }
-    _hidl_cb(status, temperatures);
-
-    for (auto& t : temperatures) {
-        LOG(DEBUG) << "getTemperatures "
-                   << " Type: " << static_cast<int>(t.type)
-                   << " Name: " << t.name
-                   << " CurrentValue: " << t.currentValue
-                   << " ThrottlingThreshold: " << t.throttlingThreshold
-                   << " ShutdownThreshold: " << t.shutdownThreshold
-                   << " VrThrottlingThreshold: " << t.vrThrottlingThreshold;
-    }
-
-    return Void();
-}
-
-Return<void> Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb) {
-    ThermalStatus status;
-    status.code = ThermalStatusCode::SUCCESS;
-    hidl_vec<CpuUsage> cpuUsages;
-    cpuUsages.resize(kCpuNum);
-
-    if (!enabled) {
-        status.code = ThermalStatusCode::FAILURE;
-        status.debugMessage = "Unsupported hardware";
-        _hidl_cb(status, cpuUsages);
-        LOG(ERROR) << "ThermalHAL not initialized properly.";
-        return Void();
-    }
-
-    ssize_t ret = fillCpuUsages(&cpuUsages);
-    if (ret < 0) {
-        status.code = ThermalStatusCode::FAILURE;
-        status.debugMessage = strerror(-ret);
-    }
-
-    for (auto& u : cpuUsages) {
-        LOG(DEBUG) << "getCpuUsages "
-                   << " Name: " << u.name
-                   << " Active: " << u.active
-                   << " Total: " << u.total
-                   << " IsOnline: " << u.isOnline;
-    }
-
-    _hidl_cb(status, cpuUsages);
-    return Void();
-}
-
-Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) {
-    ThermalStatus status;
-    status.code = ThermalStatusCode::SUCCESS;
-    hidl_vec<CoolingDevice> coolingDevices;
-
-    if (!enabled) {
-        status.code = ThermalStatusCode::FAILURE;
-        status.debugMessage = "Unsupported hardware";
-        _hidl_cb(status, coolingDevices);
-        LOG(ERROR) << "ThermalHAL not initialized properly.";
-        return Void();
-    }
-
-    LOG(DEBUG) << "No Cooling Device";
-    _hidl_cb(status, coolingDevices);
-    return Void();
-}
-
-// Methods from ::android::hardware::thermal::V1_1::IThermal follow.
-
-Return<void> Thermal::registerThermalCallback(
-    const sp<IThermalCallback>& callback) {
-    gThermalCallback = callback;
-
-    if (gThermalCallback != nullptr) {
-        if (gThermalCallbackDied == nullptr)
-            gThermalCallbackDied = new ThermalDeathRecipient();
-
-        if (gThermalCallbackDied != nullptr)
-            gThermalCallback->linkToDeath(
-                gThermalCallbackDied, 0x451F /* cookie, unused */);
-        LOG(INFO) << "ThermalCallback registered";
-    } else {
-        LOG(INFO) << "ThermalCallback unregistered";
-    }
-    return Void();
-}
-
-// Local functions used internally by thermal-engine follow.
-
-std::string Thermal::getSkinSensorType() {
-    return getTargetSkinSensorType();
-}
-
-void Thermal::notifyThrottling(
-    bool isThrottling, const Temperature& temperature) {
-    if (gThermalCallback != nullptr) {
-        Return<void> ret =
-            gThermalCallback->notifyThrottling(isThrottling, temperature);
-        if (!ret.isOk()) {
-          if (ret.isDeadObject()) {
-              gThermalCallback = nullptr;
-              LOG(WARNING) << "Dropped throttling event, ThermalCallback died";
-          } else {
-              LOG(WARNING) <<
-                  "Failed to send throttling event to ThermalCallback";
-          }
-        }
-    } else {
-        LOG(WARNING) <<
-            "Dropped throttling event, no ThermalCallback registered";
-    }
-}
-
-Return<void> Thermal::debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) {
-    if (handle != nullptr && handle->numFds >= 1) {
-        int fd = handle->data[0];
-        std::ostringstream dump_buf;
-
-        if (!enabled) {
-            dump_buf << "ThermalHAL not initialized properly." << std::endl;
-        } else {
-            hidl_vec<Temperature> temperatures;
-            hidl_vec<CpuUsage> cpu_usages;
-            cpu_usages.resize(kCpuNum);
-            temperatures.resize(kTemperatureNum);
-
-            dump_buf << "getTemperatures:" << std::endl;
-            if (fillTemperatures(&temperatures) != kTemperatureNum) {
-                dump_buf << "Failed to read thermal sensors." << std::endl;
-            } else {
-                for (const auto& t : temperatures) {
-                    dump_buf << "Name: " << t.name
-                             << " Type: " << android::hardware::thermal::V1_0::toString(t.type)
-                             << " CurrentValue: " << t.currentValue
-                             << " ThrottlingThreshold: " << t.throttlingThreshold
-                             << " ShutdownThreshold: " << t.shutdownThreshold
-                             << " VrThrottlingThreshold: " << t.vrThrottlingThreshold
-                             << std::endl;
-                }
-            }
-
-            dump_buf << "getCpuUsages:" << std::endl;
-            ssize_t ret = fillCpuUsages(&cpu_usages);
-            if (ret < 0) {
-                dump_buf << "Failed to get CPU usages." << std::endl;
-            } else {
-                for (const auto& usage : cpu_usages) {
-                    dump_buf << "Name: " << usage.name
-                             << " Active: " << usage.active
-                             << " Total: " << usage.total
-                             << " IsOnline: " << usage.isOnline
-                             << std::endl;
-                }
-            }
-
-        }
-        std::string buf = dump_buf.str();
-        if (!android::base::WriteStringToFd(buf, fd)) {
-            PLOG(ERROR) << "Failed to dump state to fd";
-        }
-        fsync(fd);
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
diff --git a/thermal/Thermal.h b/thermal/Thermal.h
deleted file mode 100644
index 270f066..0000000
--- a/thermal/Thermal.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 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 ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H
-#define ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H
-
-#include <android/hardware/thermal/1.1/IThermal.h>
-#include <android/hardware/thermal/1.1/IThermalCallback.h>
-#include <hidl/Status.h>
-#include <hidl/MQDescriptor.h>
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::thermal::V1_0::CoolingDevice;
-using ::android::hardware::thermal::V1_0::CpuUsage;
-using ::android::hardware::thermal::V1_0::Temperature;
-using ::android::hardware::thermal::V1_0::ThermalStatus;
-using ::android::hardware::thermal::V1_0::ThermalStatusCode;
-using ::android::hardware::thermal::V1_1::IThermal;
-using ::android::hardware::thermal::V1_1::IThermalCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_death_recipient;
-using ::android::hidl::base::V1_0::IBase;
-using ::android::sp;
-
-struct Thermal : public IThermal {
-    // Local functions used internally by thermal-engine follow.
-    std::string getSkinSensorType();
-    void notifyThrottling(bool isThrottling, const Temperature& temperature);
-    Thermal();
-    // Methods from ::android::hardware::thermal::V1_0::IThermal follow.
-    Return<void> getTemperatures(getTemperatures_cb _hidl_cb)  override;
-    Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb)  override;
-    Return<void> getCoolingDevices(getCoolingDevices_cb _hidl_cb)  override;
-    // Methods from ::android::hardware::thermal::V1_1::IThermal follow.
-    Return<void> registerThermalCallback(
-        const sp<IThermalCallback>& callback) override;
-    // Methods from ::android::hidl::base::V1_0::IBase follow.
-    Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
-  private:
-    bool enabled;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H
diff --git a/thermal/sensors.cpp b/thermal/sensors.cpp
deleted file mode 100644
index 7df880b..0000000
--- a/thermal/sensors.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.
- */
-
-#include <algorithm>
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/strings.h>
-#include <android-base/stringprintf.h>
-#include "sensors.h"
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-std::string Sensors::getSensorPath(const std::string& sensor_name) {
-    if (sensor_name_to_data_map_.find(sensor_name) !=
-            sensor_name_to_data_map_.end()) {
-        return std::get<0>(sensor_name_to_data_map_.at(sensor_name));
-    }
-    return "";
-}
-
-bool Sensors::addSensor(
-        const std::string& sensor_name, const std::string& path,
-        const float throttling_threshold, const float shutdown_threshold,
-        const float vr_threshold, const TemperatureType& type) {
-    return sensor_name_to_data_map_.emplace(
-        sensor_name, std::make_tuple(
-            path, throttling_threshold, shutdown_threshold,
-            vr_threshold, type)).second;
-}
-
-bool Sensors::readSensorFile(
-        const std::string& sensor_name, std::string* data,
-        std::string* file_path) const {
-    std::string sensor_reading;
-    if (sensor_name_to_data_map_.find(sensor_name) ==
-            sensor_name_to_data_map_.end()) {
-        *data = "";
-        *file_path = "";
-        return false;
-    }
-
-    android::base::ReadFileToString(
-        std::get<0>(sensor_name_to_data_map_.at(sensor_name)), &sensor_reading);
-    // Strip the newline.
-    *data = ::android::base::Trim(sensor_reading);
-    *file_path = std::get<0>(sensor_name_to_data_map_.at(sensor_name));
-    return true;
-}
-
-bool Sensors::readTemperature(
-        const std::string& sensor_name, const float mult,
-        Temperature* out) const {
-    if (sensor_name_to_data_map_.find(sensor_name) ==
-            sensor_name_to_data_map_.end()) {
-        return false;
-    }
-
-    std::string sensor_reading;
-    std::string path;
-    readSensorFile(sensor_name, &sensor_reading, &path);
-
-    auto sensor = sensor_name_to_data_map_.at(sensor_name);
-    out->name = sensor_name;
-    out->currentValue = std::stoi(sensor_reading) * mult;
-    out->throttlingThreshold = std::get<1>(sensor);
-    out->shutdownThreshold = std::get<2>(sensor);
-    out->vrThrottlingThreshold = std::get<3>(sensor);
-    out->type = std::get<4>(sensor);
-
-    LOG(DEBUG) << android::base::StringPrintf(
-        "readTemperature: %s, %d, %s, %g, %g, %g, %g",
-        path.c_str(), out->type, out->name.c_str(), out->currentValue,
-        out->throttlingThreshold, out->shutdownThreshold,
-        out->vrThrottlingThreshold);
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
diff --git a/thermal/sensors.h b/thermal/sensors.h
deleted file mode 100644
index 4924ac2..0000000
--- a/thermal/sensors.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 __SENSORS_H__
-#define __SENSORS_H__
-
-#include <string>
-#include <tuple>
-#include <unordered_map>
-
-#include <android/hardware/thermal/1.1/IThermal.h>
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::thermal::V1_0::Temperature;
-using ::android::hardware::thermal::V1_0::TemperatureType;
-
-class Sensors {
-    public:
-     Sensors() = default;
-     ~Sensors() = default;
-     Sensors(const Sensors&) = delete;
-     void operator=(const Sensors&) = delete;
-
-     std::string getSensorPath(const std::string& sensor_name);
-     // Returns true if add was successful, false otherwise.
-     bool addSensor(
-         const std::string& sensor_name, const std::string& path,
-         const float throttling_threshold, const float shutdown_threshold,
-         const float vr_threshold, const TemperatureType& type);
-     // If sensor is not found in the sensor names to path map, this will set
-     // data and file path to empty and return false.  If the sensor is found,
-     // this function will fill in data and file_path accordingly then return
-     // true.
-     bool readSensorFile(
-         const std::string& sensor_name, std::string* data,
-         std::string* file_path) const;
-     bool readTemperature(
-         const std::string& sensor_name, const float mult,
-         Temperature* out) const;
-     size_t getNumSensors() const { return sensor_name_to_data_map_.size(); }
-
-    private:
-     // A map containing sensor names along with its thermal zone number, its
-     // thresholds, and its type. The tuple is formatted as such:
-     // <path, throttling threshold, shutdown threshold, vr threshold, type>
-     std::unordered_map<std::string, std::tuple<
-         std::string, float, float, float, TemperatureType>>
-         sensor_name_to_data_map_;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
-
-#endif  // __SENSORS_H__
-
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
deleted file mode 100644
index 6e9cf17..0000000
--- a/thermal/thermal-helper.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <cctype>
-#include <cerrno>
-#include <cinttypes>
-#include <cmath>
-#include <cstdlib>
-#include <cstring>
-#include <tuple>
-#include <unordered_map>
-#include <vector>
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/strings.h>
-#include <android-base/stringprintf.h>
-
-#include "sensors.h"
-#include "thermal-helper.h"
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-constexpr const char kThermalSensorsRoot[] = "/sys/class/thermal";
-constexpr char kThermalZoneDirSuffix[] = "thermal_zone";
-constexpr char kSensorTypeFileSuffix[] = "type";
-constexpr char kTemperatureFileSuffix[] = "temp";
-// This is a golden set of thermal sensor names, their types, and their
-// multiplier. Used when we read in sensor values. The tuple value stored is
-// formatted as such:
-// <temperature type, multiplier value for reading temp>
-const std::unordered_map<std::string, std::tuple<TemperatureType, float>>
-kValidThermalSensorsMap = {
-    {"tsens_tz_sensor1", {TemperatureType::CPU, 0.1}},   // CPU0
-    {"tsens_tz_sensor2", {TemperatureType::CPU, 0.1}},   // CPU1
-    {"tsens_tz_sensor4", {TemperatureType::CPU, 0.1}},   // CPU2
-    {"tsens_tz_sensor3", {TemperatureType::CPU, 0.1}},   // CPU3
-    {"tsens_tz_sensor7", {TemperatureType::CPU, 0.1}},   // CPU4
-    {"tsens_tz_sensor8", {TemperatureType::CPU, 0.1}},   // CPU5
-    {"tsens_tz_sensor9", {TemperatureType::CPU, 0.1}},   // CPU6
-    {"tsens_tz_sensor10", {TemperatureType::CPU, 0.1}},  // CPU7
-    // GPU thermal sensor.
-    {"tsens_tz_sensor13", {TemperatureType::GPU, 0.1}},
-    // Battery thermal sensor.
-    {"battery", {TemperatureType::BATTERY, 0.001}},
-    // Skin thermal sensors. We use back_therm for walleye. For taimen we use
-    // bd_therm and bd_therm2.
-    {"back_therm", {TemperatureType::SKIN, 1.}},
-    {"bd_therm", {TemperatureType::SKIN, 1.}},
-    {"bd_therm2", {TemperatureType::SKIN, 1.}},
-    // USBC thermal sensor.
-    {"usb_port_temp", {TemperatureType::UNKNOWN, 0.1}},
-};
-
-namespace {
-
-using ::android::hardware::thermal::V1_0::TemperatureType;
-
-static std::string gSkinSensorType;
-static unsigned int gSkinThrottlingThreshold;
-static unsigned int gSkinShutdownThreshold;
-static unsigned int gVrThrottledBelowMin;
-Sensors gSensors;
-
-// A map containing hardcoded thresholds per sensor type.  Its not const
-// because initThermal() will modify the skin sensor thresholds depending on the
-// hardware type. The tuple is formatted as follows:
-// <throttling threshold, shutdown threshold, vr threshold>
-std::unordered_map<TemperatureType, std::tuple<float, float, float>>
-gSensorTypeToThresholdsMap = {
-    {TemperatureType::CPU, {kCpuThrottlingThreshold, kCpuShutdownThreshold,
-                             kCpuThrottlingThreshold}},
-    {TemperatureType::GPU, {NAN, NAN, NAN}},
-    {TemperatureType::BATTERY, {NAN, kBatteryShutdownThreshold, NAN}},
-    {TemperatureType::SKIN, {NAN, NAN, NAN}},
-    {TemperatureType::UNKNOWN, {NAN, NAN, NAN}}
-};
-
-bool initializeSensors() {
-    auto thermal_zone_dir = std::unique_ptr<DIR, int (*)(DIR*)>(
-        opendir(kThermalSensorsRoot), closedir);
-    struct dirent* dp;
-    size_t num_thermal_zones = 0;
-    while ((dp = readdir(thermal_zone_dir.get())) != nullptr) {
-        std::string dir_name(dp->d_name);
-        if (dir_name.find(kThermalZoneDirSuffix) != std::string::npos) {
-            ++num_thermal_zones;
-        }
-    }
-
-    for (size_t sensor_zone_num = 0; sensor_zone_num < num_thermal_zones;
-            ++sensor_zone_num) {
-        std::string path = android::base::StringPrintf("%s/%s%zu",
-                                                       kThermalSensorsRoot,
-                                                       kThermalZoneDirSuffix,
-                                                       sensor_zone_num);
-        std::string sensor_name;
-        if (android::base::ReadFileToString(
-                path + "/" + kSensorTypeFileSuffix, &sensor_name)) {
-            sensor_name = android::base::Trim(sensor_name);
-            if (kValidThermalSensorsMap.find(sensor_name) !=
-                kValidThermalSensorsMap.end()) {
-                  TemperatureType type = std::get<0>(
-                      kValidThermalSensorsMap.at(sensor_name));
-                  auto thresholds = gSensorTypeToThresholdsMap.at(type);
-                  if (!gSensors.addSensor(
-                          sensor_name, path + "/" + kTemperatureFileSuffix,
-                          std::get<0>(thresholds), std::get<1>(thresholds),
-                          std::get<2>(thresholds), type)) {
-                        LOG(ERROR) << "Could not add " << sensor_name
-                                   << "to sensors map";
-                  }
-            }
-        }
-    }
-    return (gSensors.getNumSensors() == kTemperatureNum);
-}
-
-}  // namespace
-
-/**
- * Initialization constants based on platform
- *
- * @return true on success or false on error.
- */
-bool initThermal() {
-    std::string hardware = android::base::GetProperty("ro.hardware", "");
-    if (hardware == "walleye") {
-        LOG(ERROR) << "Initialization on Walleye";
-        gSkinThrottlingThreshold = kWalleyeSkinThrottlingThreshold;
-        gSkinShutdownThreshold = kWalleyeSkinShutdownThreshold;
-        gVrThrottledBelowMin = kWalleyeVrThrottledBelowMin;
-    } else if (hardware == "taimen") {
-        std::string rev = android::base::GetProperty("ro.revision", "");
-        if (rev == "rev_a" || rev == "rev_b") {
-            LOG(ERROR) << "Initialization on Taimen pre revision C";
-            gSkinThrottlingThreshold = kTaimenRabSkinThrottlingThreshold;
-            gSkinShutdownThreshold = kTaimenRabSkinShutdownThreshold;
-            gVrThrottledBelowMin = kTaimenRabVrThrottledBelowMin;
-        } else {
-            LOG(ERROR) << "Initialization on Taimen revision C and later";
-            gSkinThrottlingThreshold = kTaimenRcSkinThrottlingThreshold;
-            gSkinShutdownThreshold = kTaimenRcSkinShutdownThreshold;
-            gVrThrottledBelowMin = kTaimenRcVrThrottledBelowMin;
-        }
-    } else {
-        LOG(ERROR) << "Unsupported hardware: " << hardware;
-        return false;
-    }
-    gSensorTypeToThresholdsMap[TemperatureType::SKIN] =
-        std::make_tuple(gSkinThrottlingThreshold, gSkinShutdownThreshold,
-                        gVrThrottledBelowMin);
-    return initializeSensors();
-}
-
-ssize_t fillTemperatures(hidl_vec<Temperature>* temperatures) {
-    temperatures->resize(gSensors.getNumSensors());
-    ssize_t current_index = 0;
-    for (const auto& name_type_mult_pair : kValidThermalSensorsMap) {
-        Temperature temp;
-        if (gSensors.readTemperature(name_type_mult_pair.first,
-                                     std::get<1>(name_type_mult_pair.second),
-                                     &temp)) {
-            (*temperatures)[current_index] = temp;
-            ++current_index;
-        }
-    }
-    return current_index;
-}
-
-ssize_t fillCpuUsages(hidl_vec<CpuUsage> *cpuUsages) {
-    int vals, cpu_num, online;
-    ssize_t read;
-    uint64_t user, nice, system, idle, active, total;
-    char *line = NULL;
-    size_t len = 0;
-    size_t size = 0;
-    char file_name[PATH_MAX];
-    FILE *file;
-    FILE *cpu_file;
-
-    if (cpuUsages == NULL || cpuUsages->size() < kCpuNum ) {
-        LOG(ERROR) << "fillCpuUsages: incorrect buffer";
-        return -EINVAL;
-    }
-
-    file = fopen(kCpuUsageFile, "r");
-    if (file == NULL) {
-        PLOG(ERROR) << "fillCpuUsages: failed to open file (" << kCpuUsageFile << ")";
-        return -errno;
-    }
-
-    while ((read = getline(&line, &len, file)) != -1) {
-        // Skip non "cpu[0-9]" lines.
-        if (strnlen(line, read) < 4 || strncmp(line, "cpu", 3) != 0 || !isdigit(line[3])) {
-            free(line);
-            line = NULL;
-            len = 0;
-            continue;
-        }
-
-        vals = sscanf(line, "cpu%d %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &cpu_num, &user,
-                &nice, &system, &idle);
-
-        free(line);
-        line = NULL;
-        len = 0;
-
-        if (vals != 5 || size == kCpuNum) {
-            if (vals != 5) {
-                PLOG(ERROR) << "fillCpuUsages: failed to read CPU information from file ("
-                            << kCpuUsageFile << ")";
-            } else {
-                PLOG(ERROR) << "fillCpuUsages: file has incorrect format ("
-                            << kCpuUsageFile << ")";
-            }
-            fclose(file);
-            return errno ? -errno : -EIO;
-        }
-
-        active = user + nice + system;
-        total = active + idle;
-
-        // Read online CPU information.
-        snprintf(file_name, PATH_MAX, kCpuOnlineFileFormat, cpu_num);
-        cpu_file = fopen(file_name, "r");
-        online = 0;
-        if (cpu_file == NULL) {
-            PLOG(ERROR) << "fillCpuUsages: failed to open file (" << file_name << ")";
-            fclose(file);
-            return -errno;
-        }
-        if (1 != fscanf(cpu_file, "%d", &online)) {
-            PLOG(ERROR) << "fillCpuUsages: failed to read CPU online information from file ("
-                        << file_name << ")";
-            fclose(file);
-            fclose(cpu_file);
-            return errno ? -errno : -EIO;
-        }
-        fclose(cpu_file);
-
-        (*cpuUsages)[size].name = kCpuLabel[size];
-        (*cpuUsages)[size].active = active;
-        (*cpuUsages)[size].total = total;
-        (*cpuUsages)[size].isOnline = static_cast<bool>(online);
-
-        LOG(DEBUG) << "fillCpuUsages: "<< kCpuLabel[size] << ": "
-                   << active << " " << total << " " <<  online;
-        size++;
-    }
-    fclose(file);
-
-    if (size != kCpuNum) {
-        PLOG(ERROR) << "fillCpuUsages: file has incorrect format (" << kCpuUsageFile << ")";
-        return -EIO;
-    }
-    return kCpuNum;
-}
-
-std::string getTargetSkinSensorType() {
-    return gSkinSensorType;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h
deleted file mode 100644
index ef0b61f..0000000
--- a/thermal/thermal-helper.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * *    * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __THERMAL_HELPER_H__
-#define __THERMAL_HELPER_H__
-
-#include <android/hardware/thermal/1.1/IThermal.h>
-
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::thermal::V1_0::CpuUsage;
-using ::android::hardware::thermal::V1_0::Temperature;
-using ::android::hardware::thermal::V1_0::TemperatureType;
-
-constexpr const char *kCpuUsageFile = "/proc/stat";
-constexpr const char *kTemperatureFileFormat = "/sys/class/thermal/thermal_zone%d/temp";
-constexpr const char *kCpuOnlineFileFormat = "/sys/devices/system/cpu/cpu%d/online";
-
-// thermal-engine.conf
-constexpr unsigned int kWalleyeSkinThrottlingThreshold = 40;
-constexpr unsigned int kWalleyeSkinShutdownThreshold = 56;
-constexpr unsigned int kWalleyeVrThrottledBelowMin = 52;
-
-constexpr unsigned int kTaimenRabSkinThrottlingThreshold = 49;
-constexpr unsigned int kTaimenRabSkinShutdownThreshold = 66;
-constexpr unsigned int kTaimenRabVrThrottledBelowMin = 62;
-
-constexpr unsigned int kTaimenRcSkinThrottlingThreshold = 38;
-constexpr unsigned int kTaimenRcSkinShutdownThreshold = 54;
-constexpr unsigned int kTaimenRcVrThrottledBelowMin = 50;
-
-constexpr unsigned int kCpuNum = 8;
-
-constexpr const char *kCpuLabel[kCpuNum] = {
-  "CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"};
-
-// Sum of kCpuNum + 4 for GPU, BATTERY, SKIN, and USB-C.
-constexpr unsigned int kTemperatureNum = 4 + kCpuNum;
-
-// qcom, therm-reset-temp
-constexpr unsigned int kCpuShutdownThreshold = 115;
-// qcom,freq-mitigation-temp
-constexpr unsigned int kCpuThrottlingThreshold = 95;
-
-// config_shutdownBatteryTemperature in overlay/frameworks/base/core/res/res/values/config.xml
-constexpr unsigned int kBatteryShutdownThreshold = 60;
-
-
-bool initThermal();
-ssize_t fillTemperatures(hidl_vec<Temperature> *temperatures);
-ssize_t fillCpuUsages(hidl_vec<CpuUsage> *cpuUsages);
-std::string getTargetSkinSensorType();
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
-
-#endif //__THERMAL_HELPER_H__