thermal-hal: AIDL migration

Changes to migrate from HDIL to AIDL

Signed-off-by: Bavyasritha Alahari <alahari@quicinc.com>
Change-Id: If865913acc1183562a67f508777ac545b0aaad99
diff --git a/Android.bp b/Android.bp
index 8acb48b..683f743 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,50 +1,18 @@
 cc_binary {
-	name: "android.hardware.thermal@2.0-service.qti",
-	defaults: [
-		"hidl_defaults",
-	],
-	vendor: true,
+	name: "android.hardware.thermal-service.qti",
 	relative_install_path: "hw",
-	init_rc: ["android.hardware.thermal@2.0-service.qti.rc"],
-	vintf_fragments: ["android.hardware.thermal@2.0-service.qti.xml"],
-	srcs: [
-		"service.cpp",
-		"thermal.cpp",
-		"thermalConfig.cpp",
-		"thermalCommon.cpp",
-		"thermalUtils.cpp",
-		"thermalMonitor.cpp",
-	],
+	init_rc: ["android.hardware.thermal-service.qti.rc"],
+	vintf_fragments: ["android.hardware.thermal-service.qti.xml"],
+	vendor: true,
 	shared_libs: [
-		"libbase",
-		"libcutils",
-		"libhidlbase",
-		"libhidltransport",
-		"libutils",
-		"liblog",
-		"android.hardware.thermal@1.0",
-		"android.hardware.thermal@2.0",
+	"libbase",
+	"libbinder_ndk",
+	"android.hardware.thermal-V1-ndk",
+	"libcutils",
+	"libutils",
+	"liblog",
+	"libnl",
 	],
-	header_libs: [
-		"liblog_headers",
-		"libcutils_headers"
-	],
-	cflags: [
-		"-Wno-unused-parameter",
-		"-Wno-unused-variable",
-		"-fexceptions",
-	],
-}
-
-cc_binary {
-	name: "android.hardware.thermal@2.0-service.qti-v2",
-	defaults: [
-		"hidl_defaults",
-	],
-	vendor: true,
-	relative_install_path: "hw",
-	init_rc: ["android.hardware.thermal@2.0-service.qti-v2.rc"],
-	vintf_fragments: ["android.hardware.thermal@2.0-service.qti.xml"],
 	srcs: [
 		"service.cpp",
 		"thermal.cpp",
@@ -53,16 +21,6 @@
 		"thermalUtilsNetlink.cpp",
 		"thermalMonitorNetlink.cpp",
 	],
-	shared_libs: [
-		"libbase",
-		"libcutils",
-		"libhidlbase",
-		"libutils",
-		"liblog",
-		"libnl",
-		"android.hardware.thermal@1.0",
-		"android.hardware.thermal@2.0",
-	],
 	header_libs: [
 		"liblog_headers",
 		"libcutils_headers",
diff --git a/android.hardware.thermal@2.0-service.qti-v2.rc b/android.hardware.thermal-service.qti.rc
similarity index 82%
rename from android.hardware.thermal@2.0-service.qti-v2.rc
rename to android.hardware.thermal-service.qti.rc
index 29d9cbc..a593a40 100644
--- a/android.hardware.thermal@2.0-service.qti-v2.rc
+++ b/android.hardware.thermal-service.qti.rc
@@ -27,9 +27,13 @@
 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-service android.thermal-hal /vendor/bin/hw/android.hardware.thermal@2.0-service.qti-v2
-	interface android.hardware.thermal@1.0::IThermal default
-	interface android.hardware.thermal@2.0::IThermal default
+#Changes from Qualcomm Innovation Center are provided under the following license:
+
+#Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+#SPDX-License-Identifier: BSD-3-Clause-Clear
+
+service vendor.thermal-hal /vendor/bin/hw/android.hardware.thermal-service.qti
+	interface aidl android.hardware.thermal.IThermal/default
 	class hal
 	user root
 	group root
diff --git a/android.hardware.thermal@2.0-service.qti.xml b/android.hardware.thermal-service.qti.xml
similarity index 83%
rename from android.hardware.thermal@2.0-service.qti.xml
rename to android.hardware.thermal-service.qti.xml
index 26c3e56..b47fe4f 100644
--- a/android.hardware.thermal@2.0-service.qti.xml
+++ b/android.hardware.thermal-service.qti.xml
@@ -28,15 +28,16 @@
 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
+<!-- Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear -->
+
 <manifest version="1.0" type="device">
-    <hal format="hidl">
+    <hal format="aidl">;
         <name>android.hardware.thermal</name>
-        <transport>hwbinder</transport>
-        <version>1.0</version>
-        <version>2.0</version>
-        <interface>
-            <name>IThermal</name>
-            <instance>default</instance>
-        </interface>
+        <version>1</version>
+        <fqname>IThermal/default</fqname>
     </hal>
 </manifest>
+
diff --git a/android.hardware.thermal@2.0-service.qti.rc b/android.hardware.thermal@2.0-service.qti.rc
deleted file mode 100644
index 4c9186c..0000000
--- a/android.hardware.thermal@2.0-service.qti.rc
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2020, 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.
-
-service android.thermal-hal /vendor/bin/hw/android.hardware.thermal@2.0-service.qti
-	interface android.hardware.thermal@1.0::IThermal default
-	interface android.hardware.thermal@2.0::IThermal default
-	class hal
-	user root
-	group root
diff --git a/service.cpp b/service.cpp
index f1350ec..d45a2ef 100644
--- a/service.cpp
+++ b/service.cpp
@@ -16,50 +16,39 @@
  * limitations under the License.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #define LOG_TAG "thermal_hal"
 
-#include <android-base/logging.h>
-#include <hidl/HidlTransportSupport.h>
 #include "thermal.h"
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
 
 using ::android::OK;
 using ::android::status_t;
+using aidl::android::hardware::thermal::Thermal;
 
-// libhwbinder:
-using ::android::hardware::configureRpcThreadpool;
-using ::android::hardware::joinRpcThreadpool;
+int main() {
 
-// Generated HIDL files:
-using ::android::hardware::thermal::V2_0::IThermal;
-using ::android::hardware::thermal::V2_0::implementation::Thermal;
+	LOG(INFO) << "Thermal HAL Service AIDL starting...";
 
-static int shutdown() {
-	LOG(ERROR) << "Thermal HAL Service is shutting down.";
-	return 1;
-}
+	ABinderProcess_setThreadPoolMaxThreadCount(0);
+	std::shared_ptr<Thermal> therm = ndk::SharedRefBase::make<Thermal>();
 
-int main(int /* argc */, char ** /* argv */) {
-	status_t status;
-	android::sp<IThermal> service = nullptr;
+	const std::string instance = std::string() + Thermal::descriptor + "/default";
 
-	LOG(INFO) << "Thermal HAL Service 2.0 starting...";
+	if(therm){
+		binder_status_t status =
+		AServiceManager_addService(therm->asBinder().get(), instance.c_str());
 
-	service = new Thermal();
-	if (service == nullptr) {
-		LOG(ERROR) << "Error creating an instance of Thermal HAL. Exiting...";
-		return shutdown();
+		CHECK(status == STATUS_OK);
 	}
 
-	configureRpcThreadpool(1, true /* callerWillJoin */);
-
-	status = service->registerAsService();
-	if (status != OK) {
-		LOG(ERROR) << "Could not register service for ThermalHAL (" << status << ")";
-		return shutdown();
-	}
-
-	LOG(INFO) << "Thermal HAL Service 2.0 started successfully.";
-	joinRpcThreadpool();
-	// We should not get past the joinRpcThreadpool().
-	return shutdown();
+	LOG(INFO) << "Thermal HAL Service AIDL started successfully.";
+	ABinderProcess_joinThreadPool();
+	return EXIT_FAILURE;  // should not reach
 }
diff --git a/thermal.cpp b/thermal.cpp
index cb379c8..4681453 100644
--- a/thermal.cpp
+++ b/thermal.cpp
@@ -28,6 +28,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <ctype.h>
 #include <errno.h>
 #include <inttypes.h>
@@ -38,231 +43,231 @@
 
 #include <android-base/file.h>
 #include <android-base/logging.h>
-#include <hidl/HidlTransportSupport.h>
 
 #include "thermal.h"
 
-namespace android {
-namespace hardware {
-namespace thermal {
-namespace V2_0 {
-namespace implementation {
+namespace aidl::android::hardware::thermal{
 
-using ::android::hardware::interfacesEqual;
+using ndk::ScopedAStatus;
 
-static const Temperature_1_0 dummy_temp_1_0 = {
-	.type = TemperatureType_1_0::SKIN,
+namespace {
+
+bool interfacesEqual(const std::shared_ptr<::ndk::ICInterface>& left,
+				const std::shared_ptr<::ndk::ICInterface>& right) {
+	if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
+		return left == right;
+	}
+    return left->asBinder() == right->asBinder();
+}
+
+}// namespace
+
+static const Temperature dummy_temp_1_0 = {
+	.type = TemperatureType::SKIN,
 	.name = "test sensor",
-	.currentValue = 30,
-	.throttlingThreshold = 40,
-	.shutdownThreshold = 60,
-	.vrThrottlingThreshold = 40,
+	.value = 30,
+	.throttlingStatus = ThrottlingSeverity::SEVERE,
 };
 
-template <typename A, typename B>
-Return<void> exit_hal(A _cb, hidl_vec<B> _data, std::string_view _msg) {
-	ThermalStatus _status;
-
-	_status.code = ThermalStatusCode::FAILURE;
-	_status.debugMessage = _msg.data();
-	LOG(ERROR) << _msg;
-	_cb(_status, _data);
-
-	return Void();
-}
-
-template <typename A>
-Return<void> exit_hal(A _cb, std::string_view _msg) {
-	ThermalStatus _status;
-
-	_status.code = ThermalStatusCode::FAILURE;
-	_status.debugMessage = _msg.data();
-	LOG(ERROR) << _msg;
-	_cb(_status);
-
-	return Void();
-}
-
 Thermal::Thermal():
 	utils(std::bind(&Thermal::sendThrottlingChangeCB, this,
 				std::placeholders::_1))
 { }
 
-Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb)
-{
-	ThermalStatus status;
-	hidl_vec<Temperature_1_0> temperatures;
+ScopedAStatus Thermal::getCoolingDevices(std::vector<CoolingDevice>* out_data) {
 
-	status.code = ThermalStatusCode::SUCCESS;
+	std::vector<CoolingDevice> cdev;
+
+	if (!utils.isCdevInitialized())
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+						"ThermalHAL not initialized properly.");
+	else {
+		if (utils.readCdevStates(cdev) <= 0)
+			LOG(VERBOSE) << __func__ << "Failed to read thermal cooling devices.";
+	}
+
+	if (out_data != nullptr)
+		*out_data = std::move(cdev);
+
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::getCoolingDevicesWithType(CoolingType in_type,
+				std::vector<CoolingDevice>* out_data) {
+
+	std::vector<CoolingDevice> cdev;
+
+	if (!utils.isCdevInitialized())
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+						"ThermalHAL not initialized properly.");
+	else {
+		if (utils.readCdevStates(in_type, cdev) <= 0)
+			LOG(VERBOSE) << __func__ << "Failed to read thermal cooling devices.";
+	}
+
+	if (out_data != nullptr)
+		*out_data = std::move(cdev);
+
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::getTemperatures(std::vector<Temperature>* out_temp) {
+	LOG(VERBOSE) << __func__;
+	std::vector<Temperature> temperatures;
+
 	if (!utils.isSensorInitialized()) {
-		std::vector<Temperature_1_0> _temp = {dummy_temp_1_0};
-		LOG(INFO) << "Returning Dummy Value" << std::endl;
-		_hidl_cb(status, _temp);
-		return Void();
+		std::vector<Temperature> _temp = {dummy_temp_1_0};
+		LOG(VERBOSE) << __func__ << " Returning Dummy Value";
+
+		if (out_temp != nullptr)
+			*out_temp = std::move(_temp);
+
+		return ScopedAStatus::ok();
 	}
 
 	if (utils.readTemperatures(temperatures) <= 0)
-		return exit_hal(_hidl_cb, temperatures,
-				"Sensor Temperature read failure.");
+		LOG(VERBOSE) << __func__ << "Sensor Temperature read failure.";
 
-	_hidl_cb(status, temperatures);
+	if (out_temp != nullptr)
+		*out_temp = std::move(temperatures);
 
-	return Void();
+	return ScopedAStatus::ok();
 }
 
-Return<void> Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb)
-{
+ScopedAStatus Thermal::getTemperaturesWithType(TemperatureType in_type,
+					std::vector<Temperature>* out_temp) {
 
-	ThermalStatus status;
-	hidl_vec<CpuUsage> cpu_usages;
+	std::vector<Temperature> temperatures;
 
-	status.code = ThermalStatusCode::SUCCESS;
-	if (utils.fetchCpuUsages(cpu_usages) <= 0)
-		return exit_hal(_hidl_cb, cpu_usages,
-				"CPU usage read failure.");
-
-	_hidl_cb(status, cpu_usages);
-	return Void();
-}
-
-Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb)
-{
-	ThermalStatus status;
-	hidl_vec<CoolingDevice_1_0> cdev;
-
-	status.code = ThermalStatusCode::SUCCESS;
-	/* V1 Cdev requires only Fan Support. */
-	_hidl_cb(status, cdev);
-	return Void();
-}
-
-Return<void> Thermal::getCurrentCoolingDevices(
-				bool filterType,
-				cdevType type,
-				getCurrentCoolingDevices_cb _hidl_cb)
-{
-	ThermalStatus status;
-	hidl_vec<CoolingDevice> cdev;
-
-	status.code = ThermalStatusCode::SUCCESS;
-	if (!utils.isCdevInitialized())
-		return exit_hal(_hidl_cb, cdev,
-			"ThermalHAL not initialized properly.");
-	if (utils.readCdevStates(filterType, type, cdev) <= 0)
-		return exit_hal(_hidl_cb, cdev,
-			"Failed to read thermal cooling devices.");
-
-	_hidl_cb(status, cdev);
-	return Void();
-}
-
-Return<void> Thermal::getCurrentTemperatures(
-				bool filterType,
-				TemperatureType type,
-				getCurrentTemperatures_cb _hidl_cb)
-{
-	ThermalStatus status;
-	hidl_vec<Temperature> temperatures;
-
-	status.code = ThermalStatusCode::SUCCESS;
 	if (!utils.isSensorInitialized())
-		return exit_hal(_hidl_cb, temperatures,
-			"ThermalHAL not initialized properly.");
-
-	if (utils.readTemperatures(filterType, type, temperatures) <= 0)
-		return exit_hal(_hidl_cb, temperatures,
-				"Sensor Temperature read failure.");
-
-	_hidl_cb(status, temperatures);
-
-	return Void();
-}
-
-Return<void> Thermal::getTemperatureThresholds(
-				bool filterType,
-				TemperatureType type,
-				getTemperatureThresholds_cb _hidl_cb)
-{
-	ThermalStatus status;
-	hidl_vec<TemperatureThreshold> thresh;
-
-	status.code = ThermalStatusCode::SUCCESS;
-	if (!utils.isSensorInitialized())
-		return exit_hal(_hidl_cb, thresh,
-			"ThermalHAL not initialized properly.");
-
-	if (utils.readTemperatureThreshold(filterType, type, thresh) <= 0)
-		return exit_hal(_hidl_cb, thresh,
-		"Sensor Threshold read failure or type not supported.");
-
-	_hidl_cb(status, thresh);
-
-	return Void();
-}
-
-Return<void> Thermal::registerThermalChangedCallback(
-				const sp<IThermalChangedCallback> &callback,
-				bool filterType,
-				TemperatureType type,
-				registerThermalChangedCallback_cb _hidl_cb)
-{
-	ThermalStatus status;
-	std::lock_guard<std::mutex> _lock(thermal_cb_mutex);
-
-        status.code = ThermalStatusCode::SUCCESS;
-	if (callback == nullptr)
-		return exit_hal(_hidl_cb, "Invalid nullptr callback");
-	if (type == TemperatureType::BCL_VOLTAGE ||
-		type == TemperatureType::BCL_CURRENT)
-		return exit_hal(_hidl_cb,
-			"BCL current and voltage notification not supported");
-
-	for (CallbackSetting _cb: cb) {
-		if (interfacesEqual(_cb.callback, callback))
-			return exit_hal(_hidl_cb,
-				"Same callback interface registered already");
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+					"ThermalHAL not initialized properly.");
+	else {
+		if (utils.readTemperatures(in_type, temperatures) <= 0)
+			LOG(VERBOSE) << __func__ << "Sensor Temperature read failure.";
 	}
-	cb.emplace_back(callback, filterType, type);
-	LOG(DEBUG) << "A callback has been registered to ThermalHAL, isFilter: " << filterType
-		<< " Type: " << android::hardware::thermal::V2_0::toString(type);
 
-	_hidl_cb(status);
-	return Void();
+	if (out_temp != nullptr)
+		*out_temp = std::move(temperatures);
+
+	return ScopedAStatus::ok();
 }
 
-Return<void> Thermal::unregisterThermalChangedCallback(
-				const sp<IThermalChangedCallback> &callback,
-				unregisterThermalChangedCallback_cb _hidl_cb)
-{
+ScopedAStatus Thermal::getTemperatureThresholds(std::vector<TemperatureThreshold>* out_temp_thresh) {
 
-	ThermalStatus status;
-	bool removed = false;
-	std::lock_guard<std::mutex> _lock(thermal_cb_mutex);
+	std::vector<TemperatureThreshold> thresh;
+
+	if (!utils.isSensorInitialized())
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+					"ThermalHAL not initialized properly.");
+
+	if (utils.readTemperatureThreshold(thresh) <= 0)
+		LOG(VERBOSE) << __func__ << "Sensor Threshold read failure or type not supported.";
+
+	if (out_temp_thresh != nullptr)
+		*out_temp_thresh = std::move(thresh);
+
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::getTemperatureThresholdsWithType(
+		TemperatureType in_type,
+		std::vector<TemperatureThreshold>* out_temp_thresh) {
+
+	std::vector<TemperatureThreshold> thresh;
+
+	if (!utils.isSensorInitialized())
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+					"ThermalHAL not initialized properly.");
+	else{
+		if (utils.readTemperatureThreshold(in_type, thresh) <= 0)
+			LOG(VERBOSE) << __func__ << "Sensor Threshold read failure or type not supported.";
+	}
+
+	if (out_temp_thresh != nullptr)
+		*out_temp_thresh = std::move(thresh);
+
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::registerThermalChangedCallback(
+		const std::shared_ptr<IThermalChangedCallback>& in_callback) {
+
+	if (in_callback == nullptr) {
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+				"Invalid nullptr callback");
+	}
+
+	{
+		std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+		TemperatureType in_type = TemperatureType::UNKNOWN;
+		for (CallbackSetting _cb: cb) {
+			if (interfacesEqual(_cb.callback, in_callback))
+				return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+								"Callback already registered");
+		}
+		cb.emplace_back(in_callback, in_type);
+		LOG(DEBUG) << "A callback has been registered to ThermalHAL ";
+	}
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::registerThermalChangedCallbackWithType(
+		const std::shared_ptr<IThermalChangedCallback>& in_callback, TemperatureType in_type) {
+	LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback
+			<< ", TemperatureType: " << static_cast<int32_t>(in_type);
+	if (in_callback == nullptr) {
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+						"Invalid nullptr callback");
+	}
+	if (in_type == TemperatureType::BCL_VOLTAGE ||
+		in_type == TemperatureType::BCL_CURRENT)
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+					"BCL current and voltage notification not supported");
+	{
+		std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+		for (CallbackSetting _cb: cb) {
+			if (interfacesEqual(_cb.callback, in_callback))
+				return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+								"Callback already registered");
+		}
+		cb.emplace_back(in_callback, in_type);
+		LOG(DEBUG) << "A callback has been registered to ThermalHAL Type: " << android::hardware::thermal::toString(in_type);
+	}
+	return ScopedAStatus::ok();
+}
+
+ScopedAStatus Thermal::unregisterThermalChangedCallback(
+		const std::shared_ptr<IThermalChangedCallback>& in_callback) {
+
+	if (in_callback == nullptr) {
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+						"Invalid nullptr callback");
+	}
+
+	std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
 	std::vector<CallbackSetting>::iterator it;
-
-        status.code = ThermalStatusCode::SUCCESS;
-	if (callback == nullptr)
-		return exit_hal(_hidl_cb, "Invalid nullptr callback");
-
+	bool removed = false;
 	for (it = cb.begin(); it != cb.end(); it++) {
-		if (interfacesEqual(it->callback, callback)) {
+		if (interfacesEqual(it->callback, in_callback)) {
 			cb.erase(it);
-			LOG(DEBUG) << "callback unregistered. isFilter: "
-				<< it->is_filter_type << " Type: "
-				<< android::hardware::thermal::V2_0::toString(it->type);
+			LOG(DEBUG) << "callback unregistered. isFilter: ";
 			removed = true;
 			break;
 		}
 	}
-	if (!removed)
-		return exit_hal(_hidl_cb, "The callback was not registered before");
-	_hidl_cb(status);
-	return Void();
+	if (!removed) {
+		return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+						"Callback wasn't registered");
+	}
+	LOG(DEBUG) << "A callback has been registered to ThermalHAL" ;
+
+	return ScopedAStatus::ok();
 }
 
 void Thermal::sendThrottlingChangeCB(const Temperature &t)
 {
-	std::lock_guard<std::mutex> _lock(thermal_cb_mutex);
+	std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
 	std::vector<CallbackSetting>::iterator it;
 
 	LOG(DEBUG) << "Throttle Severity change: " << " Type: " << (int)t.type
@@ -270,10 +275,10 @@
 		" ThrottlingStatus: " << (int)t.throttlingStatus;
 	it = cb.begin();
 	while (it != cb.end()) {
-		if (!it->is_filter_type || it->type == t.type) {
-			Return<void> ret = it->callback->notifyThrottling(t);
+		if (it->type == t.type || it->type == TemperatureType::UNKNOWN) {
+			::ndk::ScopedAStatus ret = it->callback->notifyThrottling(t);
 			if (!ret.isOk()) {
-				LOG(ERROR) << "Notify callback execution error. Removing";
+				LOG(ERROR) << "Notify callback execution error. Removing"<<ret.getMessage();
 				it = cb.erase(it);
 				continue;
 			}
@@ -282,8 +287,5 @@
 	}
 }
 
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
+
+}  // namespace aidl::android::hardware::thermal
diff --git a/thermal.h b/thermal.h
index d6b1c63..a36ab10 100644
--- a/thermal.h
+++ b/thermal.h
@@ -1,4 +1,4 @@
-/*
+	/*
  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,17 +28,20 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #ifndef ANDROID_QTI_VENDOR_THERMAL_H
 #define ANDROID_QTI_VENDOR_THERMAL_H
 
 #include <mutex>
 #include <thread>
+#include <set>
 
-#include <android/hardware/thermal/2.0/IThermal.h>
-#include <hidl/MQDescriptor.h>
-#include <android/hardware/thermal/2.0/IThermalChangedCallback.h>
-
-#include <hidl/Status.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
+#include <aidl/android/hardware/thermal/IThermalChangedCallback.h>
 
 #ifdef ENABLE_THERMAL_NETLINK
 #include "thermalUtilsNetlink.h"
@@ -48,72 +51,62 @@
 
 #include "thermalData.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 struct CallbackSetting {
-	sp<IThermalChangedCallback> callback;
-	bool is_filter_type;
-	TemperatureType type;
+ 	std::shared_ptr<IThermalChangedCallback> callback;
+ 	TemperatureType type;
 
-	CallbackSetting(sp<IThermalChangedCallback> callback,
-			bool is_filter_type, TemperatureType type)
-			: callback(callback),
-			is_filter_type(is_filter_type), type(type) {}
+ 	CallbackSetting(std::shared_ptr<IThermalChangedCallback> callback,
+ 			TemperatureType type)
+ 			: callback(callback), type(type) {}
+ };
+
+class Thermal : public BnThermal {
+  public:
+    Thermal();
+    ~Thermal() = default;
+
+    Thermal(const Thermal &) = delete;
+    void operator=(const Thermal &) = delete;
+    ndk::ScopedAStatus getCoolingDevices(std::vector<CoolingDevice>* out_devices) override;
+    ndk::ScopedAStatus getCoolingDevicesWithType(CoolingType in_type,
+                                                 std::vector<CoolingDevice>* out_devices) override;
+
+    ndk::ScopedAStatus getTemperatures(std::vector<Temperature>* out_temperatures) override;
+    ndk::ScopedAStatus getTemperaturesWithType(TemperatureType in_type,
+                                               std::vector<Temperature>* out_temperatures) override;
+
+    ndk::ScopedAStatus getTemperatureThresholds(
+            std::vector<TemperatureThreshold>* out_temperatureThresholds) override;
+
+    ndk::ScopedAStatus getTemperatureThresholdsWithType(
+            TemperatureType in_type,
+            std::vector<TemperatureThreshold>* out_temperatureThresholds) override;
+
+    ndk::ScopedAStatus registerThermalChangedCallback(
+            const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
+    ndk::ScopedAStatus registerThermalChangedCallbackWithType(
+            const std::shared_ptr<IThermalChangedCallback>& in_callback,
+            TemperatureType in_type) override;
+
+    ndk::ScopedAStatus unregisterThermalChangedCallback(
+            const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
+
+    void sendThrottlingChangeCB(const Temperature &t);
+
+  private:
+    std::mutex thermal_callback_mutex_;
+    std::vector<CallbackSetting> cb;
+    ThermalUtils utils;
 };
 
-class Thermal : public IThermal {
-	public:
-		Thermal();
-		~Thermal() = default;
-
-		Thermal(const Thermal &) = delete;
-		void operator=(const Thermal &) = delete;
-
-		Return<void> getTemperatures(
-				getTemperatures_cb _hidl_cb) override;
-		Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb) override;
-		Return<void> getCoolingDevices(
-				getCoolingDevices_cb _hidl_cb) override;
-
-		Return<void> getCurrentTemperatures(
-				bool filterType,
-				TemperatureType type,
-				getCurrentTemperatures_cb _hidl_cb) override;
-		Return<void> getTemperatureThresholds(
-				bool filterType,
-				TemperatureType type,
-				getTemperatureThresholds_cb _hidl_cb) override;
-		Return<void> registerThermalChangedCallback(
-				const sp<IThermalChangedCallback> &callback,
-				bool filterType,
-				TemperatureType type,
-				registerThermalChangedCallback_cb _hidl_cb)
-				override;
-		Return<void> unregisterThermalChangedCallback(
-				const sp<IThermalChangedCallback> &callback,
-				unregisterThermalChangedCallback_cb _hidl_cb)
-				override;
-		Return<void> getCurrentCoolingDevices(
-				bool filterType,
-				CoolingType type,
-				getCurrentCoolingDevices_cb _hidl_cb) override;
-
-		void sendThrottlingChangeCB(const Temperature &t);
-
-	private:
-		std::mutex thermal_cb_mutex;
-		std::vector<CallbackSetting> cb;
-		ThermalUtils utils;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // ANDROID_QTI_VENDOR_THERMAL_H
diff --git a/thermalCommon.cpp b/thermalCommon.cpp
index 0a98bda..d059ef5 100644
--- a/thermalCommon.cpp
+++ b/thermalCommon.cpp
@@ -28,6 +28,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <cstdio>
 #include <cinttypes>
 #include <string>
@@ -56,11 +61,10 @@
 #define CPU_USAGE_FILE		"/proc/stat"
 #define CPU_ONLINE_FILE_FORMAT	"/sys/devices/system/cpu/cpu%d/online"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 static std::unordered_map<std::string, cdevType> cdev_map = {
 	{"thermal-cpufreq-0", cdevType::CPU},
@@ -261,12 +265,9 @@
 	sensor.lastThrottleStatus = sensor.t.throttlingStatus =
 		ThrottlingSeverity::NONE;
 	sensor.thresh.type = sensor.t.type = cfg.type;
-	sensor.thresh.vrThrottlingThreshold =
-	UNKNOWN_TEMPERATURE;
 	for (idx = 0; idx <= (size_t)ThrottlingSeverity::SHUTDOWN; idx++) {
-		sensor.thresh.hotThrottlingThresholds[idx] =
-		sensor.thresh.coldThrottlingThresholds[idx] =
-			UNKNOWN_TEMPERATURE;
+		sensor.thresh.hotThrottlingThresholds.push_back(UNKNOWN_TEMPERATURE);
+		sensor.thresh.coldThrottlingThresholds.push_back(UNKNOWN_TEMPERATURE);
 	}
 
 	if (cfg.throt_thresh != 0 && cfg.positive_thresh_ramp)
@@ -283,11 +284,7 @@
 		sensor.thresh.coldThrottlingThresholds[(size_t)ThrottlingSeverity::SHUTDOWN] =
 			cfg.shutdwn_thresh / (float)sensor.mulFactor;
 
-	if (cfg.vr_thresh != 0)
-		sensor.thresh.vrThrottlingThreshold =
-			cfg.vr_thresh / (float)sensor.mulFactor;
 	sens.push_back(sensor);
-	//read_temperature((struct therm_sensor *)sensor);
 
 	return 0;
 }
@@ -574,92 +571,7 @@
 	return;
 }
 
-int ThermalCommon::get_cpu_usages(hidl_vec<CpuUsage>& list) {
-	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 cpu = 0;
-	char file_name[MAX_LENGTH];
-	FILE *file;
-	FILE *cpu_file;
-
-	list.resize(ncpus);
-	file = fopen(CPU_USAGE_FILE, "r");
-	if (file == NULL) {
-		LOG(ERROR) << "failed to open:" << CPU_USAGE_FILE <<
-			" err:" << strerror(errno);
-		return -errno;
-	}
-
-	while ((read = getline(&line, &len, file)) != -1) {
-		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 || cpu == ncpus) {
-			if (vals != 5) {
-				LOG(ERROR) <<
-				"failed to read CPU information from file: "
-				<< strerror(errno);
-			} else {
-				LOG(ERROR) <<
-					"/proc/stat file has incorrect format.";
-			}
-			fclose(file);
-			return errno ? -errno : -EIO;
-		}
-
-		active = user + nice + system;
-		total = active + idle;
-
-		// Read online CPU information.
-		snprintf(file_name, MAX_LENGTH, CPU_ONLINE_FILE_FORMAT,
-				cpu_num);
-		cpu_file = fopen(file_name, "r");
-		online = 0;
-		if (cpu_file == NULL) {
-			LOG(ERROR) << "failed to open file:" << file_name <<
-				" err: " << strerror(errno);
-			fclose(file);
-			return -errno;
-		}
-		if (1 != fscanf(cpu_file, "%d", &online)) {
-			LOG(ERROR) << "failed to read CPU online information" << strerror(errno);
-			fclose(file);
-			fclose(cpu_file);
-			return errno ? -errno : -EIO;
-		}
-		fclose(cpu_file);
-
-		list[cpu].name = std::string("CPU") + std::to_string(cpu_num);
-		list[cpu].active = active;
-		list[cpu].total = total;
-		list[cpu].isOnline = online;
-		cpu++;
-	}
-	fclose(file);
-	if (cpu != ncpus) {
-		LOG(ERROR) <<"/proc/stat file has incorrect format.";
-		return -EIO;
-	}
-	return ncpus;
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace thermal
-}  // namespace hardware
-}  // namespace android
+}// namespace thermal
+}// namespace hardware
+}// namespace android
+}// namespace aidl
diff --git a/thermalCommon.h b/thermalCommon.h
index e61bb2a..cff388b 100644
--- a/thermalCommon.h
+++ b/thermalCommon.h
@@ -33,11 +33,10 @@
 
 #include "thermalData.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 #define RETRY_CT 3
 
@@ -54,7 +53,6 @@
 		int read_cdev_state(struct therm_cdev& cdev);
 		int read_temperature(struct therm_sensor& sensor);
 		int estimateSeverity(struct therm_sensor& sensor);
-		int get_cpu_usages(hidl_vec<CpuUsage>& list);
 
 		std::vector<struct therm_sensor> fetch_sensor_list()
 		{
@@ -76,10 +74,8 @@
 					int sens_idx);
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
-
+}  // namespace aidl
 #endif  // THERMAL_THERMAL_COMMON_H__
diff --git a/thermalConfig.cpp b/thermalConfig.cpp
index fe26055..de34c49 100644
--- a/thermalConfig.cpp
+++ b/thermalConfig.cpp
@@ -32,18 +32,23 @@
  * SPDX-License-Identifier: BSD-3-Clause-Clear
  */
 
+ /* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <unordered_map>
 #include <android-base/logging.h>
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 
 #include "thermalData.h"
 #include "thermalConfig.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
+
 	constexpr std::string_view socIDPath("/sys/devices/soc0/soc_id");
 
 	std::vector<std::string> cpu_sensors_bengal =
@@ -66,7 +71,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -75,7 +79,6 @@
 			"GPU",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -84,7 +87,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -93,7 +95,6 @@
 			"vbat",
 			3000,
 			2800,
-			3000,
 			false,
 		},
 		{
@@ -102,7 +103,6 @@
 			"ibat",
 			4000,
 			4200,
-			4000,
 			true,
 		},
 		{
@@ -111,7 +111,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -135,7 +134,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -144,7 +142,6 @@
 			"GPU",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -153,7 +150,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -162,7 +158,6 @@
 			"vbat",
 			3000,
 			2800,
-			3000,
 			false,
 		},
 		{
@@ -171,7 +166,6 @@
 			"ibat",
 			5500,
 			6000,
-			5500,
 			true,
 		},
 		{
@@ -180,7 +174,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -205,7 +198,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -214,7 +206,6 @@
 			"GPU",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -223,7 +214,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -232,7 +222,6 @@
 			"vbat",
 			3000,
 			2800,
-			3000,
 			false,
 		},
 		{
@@ -241,7 +230,6 @@
 			"ibat",
 			4000,
 			4200,
-			4000,
 			true,
 		},
 		{
@@ -250,7 +238,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -275,7 +262,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -284,7 +270,6 @@
 			"GPU",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -293,7 +278,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -302,7 +286,6 @@
 			"ibat",
 			4500,
 			5000,
-			4500,
 			true,
 		},
 		{
@@ -311,7 +294,6 @@
 			"vbat",
 			3200,
 			3000,
-			3200,
 			false,
 		},
 		{
@@ -320,7 +302,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -333,7 +314,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -342,7 +322,6 @@
 			"GPU",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -351,7 +330,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -360,7 +338,6 @@
 			"vbat",
 			3000,
 			2800,
-			3000,
 			false,
 		},
 		{
@@ -369,7 +346,6 @@
 			"ibat",
 			5500,
 			6000,
-			5500,
 			true,
 		},
 		{
@@ -378,7 +354,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -391,7 +366,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -400,7 +374,6 @@
 			"gpu0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -409,7 +382,6 @@
 			"gpu1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -418,7 +390,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -427,7 +398,6 @@
 			"ibat",
 			5500,
 			6000,
-			5500,
 			true,
 		},
 	};
@@ -451,7 +421,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -460,7 +429,6 @@
 			"gpu0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -469,7 +437,6 @@
 			"gpu1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -478,7 +445,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 		{
@@ -487,7 +453,6 @@
 			"ibat",
 			4500,
 			5000,
-			4500,
 			true,
 		},
 		{
@@ -496,7 +461,6 @@
 			"vbat",
 			3200,
 			3000,
-			3200,
 			false,
 		},
 		{
@@ -505,7 +469,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 	};
@@ -517,7 +480,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -526,7 +488,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -535,7 +496,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -544,7 +504,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		}
 	};
@@ -556,7 +515,6 @@
 			"ibat",
 			4500,
 			5000,
-			4500,
 			true,
 		},
 		{
@@ -565,7 +523,6 @@
 			"vbat",
 			3200,
 			3000,
-			3200,
 			false,
 		},
 		{
@@ -574,7 +531,6 @@
 			"soc",
 			10,
 			2,
-			10,
 			false,
 		},
 		{
@@ -583,7 +539,6 @@
 			"npu",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 	};
@@ -607,7 +562,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -616,7 +570,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -625,7 +578,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -634,7 +586,6 @@
 			"ibat",
 			6000,
 			7500,
-			6000,
 			true,
 		},
 		{
@@ -643,7 +594,6 @@
 			"nsp0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -652,7 +602,6 @@
 			"nsp1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -661,7 +610,6 @@
 			"nsp2",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 	};
@@ -673,7 +621,6 @@
 			"skin",
 			55000,
 			95000,
-			55000,
 			true,
 		},
 	};
@@ -685,7 +632,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 	};
@@ -697,7 +643,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -706,7 +651,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -715,7 +659,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -724,7 +667,6 @@
 			"nsp0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -733,7 +675,6 @@
 			"nsp1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -742,7 +683,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 	};
@@ -766,7 +706,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -775,7 +714,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -784,7 +722,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -793,7 +730,6 @@
 			"nsp0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -802,7 +738,6 @@
 			"nsp1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -811,7 +746,6 @@
 			"nsp2",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 	};
@@ -823,7 +757,6 @@
 			"ibat",
 			6000,
 			7500,
-			6000,
 			true,
 		},
 		{
@@ -832,7 +765,6 @@
 			"skin",
 			55000,
 			95000,
-			55000,
 			true,
 		},
 	};
@@ -856,7 +788,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -865,7 +796,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -874,7 +804,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -883,7 +812,6 @@
 			"GPU2",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -892,7 +820,6 @@
 			"GPU3",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -901,7 +828,6 @@
 			"GPU4",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -910,7 +836,6 @@
 			"GPU5",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -919,7 +844,6 @@
 			"GPU6",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -928,7 +852,6 @@
 			"GPU7",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -937,7 +860,6 @@
 			"nsp0",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -946,7 +868,6 @@
 			"nsp1",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -955,7 +876,6 @@
 			"nsp2",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -964,7 +884,6 @@
 			"nsp3",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 	};
@@ -976,7 +895,6 @@
 			"ibat",
 			9000,
 			10000,
-			9000,
 			true,
 		},
 		{
@@ -985,7 +903,6 @@
 			"skin",
 			46500,
 			95000,
-			46500,
 			true,
 		},
 	};
@@ -997,7 +914,6 @@
 			"ibat",
 			6000,
 			7500,
-			6000,
 			true,
 		},
 		{
@@ -1006,7 +922,6 @@
 			"skin",
 			40000,
 			95000,
-			40000,
 			true,
 		},
 	};
@@ -1017,7 +932,6 @@
 		"battery",
 		80000,
 		90000,
-		80000,
 		true,
 	};
 
@@ -1028,7 +942,6 @@
 			"vbat",
 			3200,
 			3000,
-			3200,
 			false,
 		},
 		{
@@ -1037,7 +950,6 @@
 			"socd",
 			90,
 			99,
-			90,
 			true,
 		},
 	};
@@ -1060,7 +972,6 @@
 			"",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1069,7 +980,6 @@
 			"GPU0",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1078,7 +988,6 @@
 			"GPU1",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1087,7 +996,6 @@
 			"GPU2",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1096,7 +1004,6 @@
 			"GPU3",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1105,7 +1012,6 @@
 			"GPU4",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1114,7 +1020,6 @@
 			"GPU5",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1123,7 +1028,6 @@
 			"GPU6",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1132,7 +1036,6 @@
 			"GPU7",
 			95000,
 			115000,
-			95000,
 			true,
 		},
 		{
@@ -1141,7 +1044,6 @@
 			"nsp0",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -1150,7 +1052,6 @@
 			"nsp1",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -1159,7 +1060,6 @@
 			"nsp2",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -1168,7 +1068,6 @@
 			"nsp3",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -1177,7 +1076,6 @@
 			"nsp4",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 		{
@@ -1186,7 +1084,6 @@
 			"nsp5",
 			100000,
 			115000,
-			100000,
 			true,
 		},
 	};
@@ -1198,7 +1095,6 @@
 			"ibat",
 			9000,
 			10000,
-			9000,
 			true,
 		},
 		{
@@ -1207,7 +1103,6 @@
 			"skin",
 			46500,
 			95000,
-			46500,
 			true,
 		},
 	};
@@ -1347,9 +1242,9 @@
 				bcl_conf.begin(), bcl_conf.end());
 		LOG(DEBUG) << "Total sensors:" << thermalConfig.size();
 	}
-}  // namespace implementation
-}  // namespace V2_0
+
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
diff --git a/thermalConfig.h b/thermalConfig.h
index 07f3375..ae74111 100644
--- a/thermalConfig.h
+++ b/thermalConfig.h
@@ -28,19 +28,23 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+ /* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #ifndef THERMAL_THERMAL_CONFIG_H__
 #define THERMAL_THERMAL_CONFIG_H__
 
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 
 #include "thermalData.h"
 #include "thermalCommon.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 class ThermalConfig {
 	public:
@@ -58,10 +62,9 @@
 		ThermalCommon cmnInst;
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_CONFIG_H__
diff --git a/thermalData.h b/thermalData.h
index 93eb5cc..03866d6 100644
--- a/thermalData.h
+++ b/thermalData.h
@@ -28,6 +28,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+  /* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #ifndef THERMAL_THERMAL_DATA_H__
 #define THERMAL_THERMAL_DATA_H__
 
@@ -35,32 +40,26 @@
 #include <string>
 #include <mutex>
 #include <cmath>
-
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 
 #define UNKNOWN_TEMPERATURE (NAN)
 
+namespace aidl{
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
-using ::android::hardware::hidl_vec;
-using ::android::hardware::thermal::V1_0::CpuUsage;
-using CoolingDevice_1_0 = ::android::hardware::thermal::V1_0::CoolingDevice;
-using Temperature_1_0 = ::android::hardware::thermal::V1_0::Temperature;
-using TemperatureType_1_0 = ::android::hardware::thermal::V1_0::TemperatureType;
-using ::android::hardware::thermal::V1_0::ThermalStatus;
-using ::android::hardware::thermal::V1_0::ThermalStatusCode;
+using CoolingDevice = ::aidl::android::hardware::thermal::CoolingDevice;
+using Temperature = ::aidl::android::hardware::thermal::Temperature;
+using TemperatureType = ::aidl::android::hardware::thermal::TemperatureType;
 
-using cdevType = ::android::hardware::thermal::V2_0::CoolingType;
-using CoolingDevice = ::android::hardware::thermal::V2_0::CoolingDevice;
-using Temperature = ::android::hardware::thermal::V2_0::Temperature;
-using TemperatureType = ::android::hardware::thermal::V2_0::TemperatureType;
+using cdevType = ::aidl::android::hardware::thermal::CoolingType;
+using CoolingDevice = ::aidl::android::hardware::thermal::CoolingDevice;
+using Temperature = ::aidl::android::hardware::thermal::Temperature;
+using TemperatureType = ::aidl::android::hardware::thermal::TemperatureType;
 using TemperatureThreshold =
-	::android::hardware::thermal::V2_0::TemperatureThreshold;
-using ::android::hardware::thermal::V2_0::ThrottlingSeverity;
+	::aidl::android::hardware::thermal::TemperatureThreshold;
+using ::aidl::android::hardware::thermal::ThrottlingSeverity;
 
 	struct target_therm_cfg {
 		TemperatureType type;
@@ -68,7 +67,6 @@
 		std::string label;
 		int throt_thresh;
 		int shutdwn_thresh;
-		int vr_thresh;
 		bool positive_thresh_ramp;
 	};
 
@@ -87,10 +85,9 @@
 		CoolingDevice c;
 	};
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_DATA_H__
diff --git a/thermalMonitor.cpp b/thermalMonitor.cpp
index 176d121..57ab90a 100644
--- a/thermalMonitor.cpp
+++ b/thermalMonitor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2020,2023, 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
@@ -28,6 +28,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <unistd.h>
 #include <poll.h>
 #include <sys/socket.h>
@@ -59,11 +64,10 @@
 	TRIP=%d\n\
 	EVENT=%d\n"\
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using parseCB = std::function<void(char *inp_buf, ssize_t len)>;
 using pollCB = std::function<bool()>;
@@ -185,8 +189,7 @@
 	cb(sensor_name, temp);
 }
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
\ No newline at end of file
diff --git a/thermalMonitor.h b/thermalMonitor.h
index 3b6962f..64a7b81 100644
--- a/thermalMonitor.h
+++ b/thermalMonitor.h
@@ -28,18 +28,21 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
 
 #ifndef THERMAL_THERMAL_MONITOR_H__
 #define THERMAL_THERMAL_MONITOR_H__
 
 #include <thread>
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using ueventMonitorCB = std::function<void(std::string sensor_name, int temp)>;
 
@@ -60,10 +63,9 @@
 		ueventMonitorCB cb;
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_MONITOR_H__
diff --git a/thermalMonitorNetlink.cpp b/thermalMonitorNetlink.cpp
index f081363..d59a7be 100644
--- a/thermalMonitorNetlink.cpp
+++ b/thermalMonitorNetlink.cpp
@@ -29,6 +29,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+ /* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <unistd.h>
 #include <linux/thermal.h>
 #include <android-base/logging.h>
@@ -37,11 +42,10 @@
 
 #include "thermalMonitorNetlink.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using pollCB = std::function<bool()>;
 using familyCB = std::function<int(struct nl_msg *, void *)>;
@@ -301,8 +305,7 @@
 		std::bind(&ThermalMonitor::stopPolling, this));
 }
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/thermalMonitorNetlink.h b/thermalMonitorNetlink.h
index 7e42690..09d4efd 100644
--- a/thermalMonitorNetlink.h
+++ b/thermalMonitorNetlink.h
@@ -29,6 +29,10 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
 
 #ifndef THERMAL_THERMAL_MONITOR_NETLINK_H__
 #define THERMAL_THERMAL_MONITOR_NETLINK_H__
@@ -38,13 +42,12 @@
 #include <netlink/genl/mngt.h>
 #include <netlink/genl/ctrl.h>
 #include <netlink/netlink.h>
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 
+namespace aidl{
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using eventMonitorCB = std::function<void(int, int)>;
 using eventCreateMonitorCB = std::function<void(int, const char *)>;
@@ -77,10 +80,9 @@
 		int send_nl_msg(struct nl_msg *msg);
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_MONITOR_NETLINK_H__
diff --git a/thermalUtils.cpp b/thermalUtils.cpp
index 4cd94a2..803c3cf 100644
--- a/thermalUtils.cpp
+++ b/thermalUtils.cpp
@@ -28,21 +28,24 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/properties.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
-#include <hidl/HidlTransportSupport.h>
 
 #include "thermalConfig.h"
 #include "thermalUtils.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 ThermalUtils::ThermalUtils(const ueventCB &inp_cb):
 	cfg(),
@@ -106,44 +109,7 @@
 	return Notify(sens);
 }
 
-int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp)
-{
-	std::unordered_map<std::string, struct therm_sensor>::iterator it;
-	int ret = 0, idx = 0;
-	std::vector<Temperature_1_0> _temp_v;
-
-	if (!is_sensor_init)
-		return 0;
-	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
-	for (it = thermalConfig.begin(); it != thermalConfig.end();
-			it++, idx++) {
-		struct therm_sensor& sens = it->second;
-		Temperature_1_0 _temp;
-
-		/* v1 supports only CPU, GPU, Battery and SKIN */
-		if (sens.t.type > TemperatureType::SKIN)
-			continue;
-		ret = cmnInst.read_temperature(sens);
-		if (ret < 0)
-			return ret;
-		Notify(sens);
-		_temp.currentValue = sens.t.value;
-		_temp.name = sens.t.name;
-		_temp.type = (TemperatureType_1_0)sens.t.type;
-		_temp.throttlingThreshold = sens.thresh.hotThrottlingThresholds[
-					(size_t)ThrottlingSeverity::SEVERE];
-		_temp.shutdownThreshold = sens.thresh.hotThrottlingThresholds[
-					(size_t)ThrottlingSeverity::SHUTDOWN];
-		_temp.vrThrottlingThreshold = sens.thresh.vrThrottlingThreshold;
-		_temp_v.push_back(_temp);
-	}
-
-	temp = _temp_v;
-	return temp.size();
-}
-
-int ThermalUtils::readTemperatures(bool filterType, TemperatureType type,
-                                            hidl_vec<Temperature>& temp)
+int ThermalUtils::readTemperatures(std::vector<Temperature>& temp)
 {
 	std::unordered_map<std::string, struct therm_sensor>::iterator it;
 	int ret = 0;
@@ -153,7 +119,29 @@
 	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
 		struct therm_sensor& sens = it->second;
 
-		if (filterType && sens.t.type != type)
+		ret = cmnInst.read_temperature(sens);
+		if (ret < 0)
+			return ret;
+		Notify(sens);
+		_temp.push_back(sens.t);
+	}
+
+	temp = _temp;
+	return temp.size();
+}
+
+int ThermalUtils::readTemperatures(TemperatureType type,
+                                            std::vector<Temperature>& temp)
+{
+	std::unordered_map<std::string, struct therm_sensor>::iterator it;
+	int ret = 0;
+	std::vector<Temperature> _temp;
+
+	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
+	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
+		struct therm_sensor& sens = it->second;
+
+		if (sens.t.type != type)
 			continue;
 		ret = cmnInst.read_temperature(sens);
 		if (ret < 0)
@@ -166,8 +154,7 @@
 	return temp.size();
 }
 
-int ThermalUtils::readTemperatureThreshold(bool filterType, TemperatureType type,
-                                            hidl_vec<TemperatureThreshold>& thresh)
+int ThermalUtils::readTemperatureThreshold(std::vector<TemperatureThreshold>& thresh)
 {
 	std::unordered_map<std::string, struct therm_sensor>::iterator it;
 	std::vector<TemperatureThreshold> _thresh;
@@ -175,7 +162,23 @@
 	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
 		struct therm_sensor& sens = it->second;
 
-		if (filterType && sens.t.type != type)
+		_thresh.push_back(sens.thresh);
+	}
+
+	thresh = _thresh;
+	return thresh.size();
+}
+
+int ThermalUtils::readTemperatureThreshold(TemperatureType type,
+                                            std::vector<TemperatureThreshold>& thresh)
+{
+	std::unordered_map<std::string, struct therm_sensor>::iterator it;
+	std::vector<TemperatureThreshold> _thresh;
+
+	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
+		struct therm_sensor& sens = it->second;
+
+		if (sens.t.type != type)
 			continue;
 		_thresh.push_back(sens.thresh);
 	}
@@ -184,15 +187,33 @@
 	return thresh.size();
 }
 
-int ThermalUtils::readCdevStates(bool filterType, cdevType type,
-                                            hidl_vec<CoolingDevice>& cdev_out)
+int ThermalUtils::readCdevStates(std::vector<CoolingDevice>& cdev_out)
 {
 	int ret = 0;
 	std::vector<CoolingDevice> _cdev;
 
 	for (struct therm_cdev cdev: cdevList) {
 
-		if (filterType && cdev.c.type != type)
+		ret = cmnInst.read_cdev_state(cdev);
+		if (ret < 0)
+			return ret;
+		_cdev.push_back(cdev.c);
+	}
+
+	cdev_out = _cdev;
+
+	return cdev_out.size();
+}
+
+int ThermalUtils::readCdevStates(cdevType type,
+                                            std::vector<CoolingDevice>& cdev_out)
+{
+	int ret = 0;
+	std::vector<CoolingDevice> _cdev;
+
+	for (struct therm_cdev cdev: cdevList) {
+
+		if (cdev.c.type != type)
 			continue;
 		ret = cmnInst.read_cdev_state(cdev);
 		if (ret < 0)
@@ -205,13 +226,7 @@
 	return cdev_out.size();
 }
 
-int ThermalUtils::fetchCpuUsages(hidl_vec<CpuUsage>& cpu_usages)
-{
-	return cmnInst.get_cpu_usages(cpu_usages);
-}
-
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
\ No newline at end of file
diff --git a/thermalUtils.h b/thermalUtils.h
index a02f22f..e7f8a42 100644
--- a/thermalUtils.h
+++ b/thermalUtils.h
@@ -28,22 +28,27 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+ /* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #ifndef THERMAL_THERMAL_UTILS_H__
 #define THERMAL_THERMAL_UTILS_H__
 
 #include <unordered_map>
 #include <mutex>
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
+
 #include "thermalConfig.h"
 #include "thermalMonitor.h"
 #include "thermalCommon.h"
 #include "thermalData.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using ueventCB = std::function<void(Temperature &t)>;
 
@@ -59,14 +64,15 @@
 		{
 			return is_cdev_init;
 		};
-		int readTemperatures(hidl_vec<Temperature_1_0>& temp);
-		int readTemperatures(bool filterType, TemperatureType type,
-                                            hidl_vec<Temperature>& temperatures);
-		int readTemperatureThreshold(bool filterType, TemperatureType type,
-                                            hidl_vec<TemperatureThreshold>& thresh);
-		int readCdevStates(bool filterType, cdevType type,
-                                            hidl_vec<CoolingDevice>& cdev);
-		int fetchCpuUsages(hidl_vec<CpuUsage>& cpu_usages);
+		int readTemperatures(std::vector<Temperature>& temp);
+		int readTemperatures(TemperatureType type,
+                                            std::vector<Temperature>& temperatures);
+		int readTemperatureThreshold(std::vector<TemperatureThreshold>& thresh);
+		int readTemperatureThreshold(TemperatureType type,
+                                            std::vector<TemperatureThreshold>& thresh);
+		int readCdevStates(std::vector<CoolingDevice>& cdev);
+		int readCdevStates(cdevType type,
+                                            std::vector<CoolingDevice>& cdev);
 	private:
 		bool is_sensor_init;
 		bool is_cdev_init;
@@ -83,10 +89,9 @@
 		void Notify(struct therm_sensor& sens);
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_UTILS_H__
diff --git a/thermalUtilsNetlink.cpp b/thermalUtilsNetlink.cpp
index 2b340f8..7a6c86d 100644
--- a/thermalUtilsNetlink.cpp
+++ b/thermalUtilsNetlink.cpp
@@ -29,21 +29,24 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/properties.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
-#include <hidl/HidlTransportSupport.h>
 
 #include "thermalConfig.h"
 #include "thermalUtilsNetlink.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 ThermalUtils::ThermalUtils(const ueventCB &inp_cb):
 	cfg(),
@@ -164,44 +167,7 @@
 	}
 }
 
-int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp)
-{
-	std::unordered_map<int, struct therm_sensor>::iterator it;
-	int ret = 0, idx = 0;
-	std::vector<Temperature_1_0> _temp_v;
-
-	if (!is_sensor_init)
-		return 0;
-	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
-	for (it = thermalConfig.begin(); it != thermalConfig.end();
-			it++, idx++) {
-		struct therm_sensor& sens = it->second;
-		Temperature_1_0 _temp;
-
-		/* v1 supports only CPU, GPU, Battery and SKIN */
-		if (sens.t.type > TemperatureType::SKIN)
-			continue;
-		ret = cmnInst.read_temperature(sens);
-		if (ret < 0)
-			return ret;
-		Notify(sens);
-		_temp.currentValue = sens.t.value;
-		_temp.name = sens.t.name;
-		_temp.type = (TemperatureType_1_0)sens.t.type;
-		_temp.throttlingThreshold = sens.thresh.hotThrottlingThresholds[
-					(size_t)ThrottlingSeverity::SEVERE];
-		_temp.shutdownThreshold = sens.thresh.hotThrottlingThresholds[
-					(size_t)ThrottlingSeverity::SHUTDOWN];
-		_temp.vrThrottlingThreshold = sens.thresh.vrThrottlingThreshold;
-		_temp_v.push_back(_temp);
-	}
-
-	temp = _temp_v;
-	return temp.size();
-}
-
-int ThermalUtils::readTemperatures(bool filterType, TemperatureType type,
-                                            hidl_vec<Temperature>& temp)
+int ThermalUtils::readTemperatures(std::vector<Temperature>& temp)
 {
 	std::unordered_map<int, struct therm_sensor>::iterator it;
 	int ret = 0;
@@ -211,7 +177,29 @@
 	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
 		struct therm_sensor& sens = it->second;
 
-		if (filterType && sens.t.type != type)
+		ret = cmnInst.read_temperature(sens);
+		if (ret < 0)
+			return ret;
+		Notify(sens);
+		_temp.push_back(sens.t);
+	}
+
+	temp = _temp;
+	return temp.size();
+}
+
+int ThermalUtils::readTemperatures(TemperatureType type,
+                                            std::vector<Temperature>& temp)
+{
+	std::unordered_map<int, struct therm_sensor>::iterator it;
+	int ret = 0;
+	std::vector<Temperature> _temp;
+
+	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
+	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
+		struct therm_sensor& sens = it->second;
+
+		if (sens.t.type != type)
 			continue;
 		ret = cmnInst.read_temperature(sens);
 		if (ret < 0)
@@ -224,8 +212,7 @@
 	return temp.size();
 }
 
-int ThermalUtils::readTemperatureThreshold(bool filterType, TemperatureType type,
-                                            hidl_vec<TemperatureThreshold>& thresh)
+int ThermalUtils::readTemperatureThreshold(std::vector<TemperatureThreshold>& thresh)
 {
 	std::unordered_map<int, struct therm_sensor>::iterator it;
 	std::vector<TemperatureThreshold> _thresh;
@@ -233,7 +220,23 @@
 	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
 		struct therm_sensor& sens = it->second;
 
-		if (filterType && sens.t.type != type)
+		_thresh.push_back(sens.thresh);
+	}
+
+	thresh = _thresh;
+	return thresh.size();
+}
+
+int ThermalUtils::readTemperatureThreshold(TemperatureType type,
+                                            std::vector<TemperatureThreshold>& thresh)
+{
+	std::unordered_map<int, struct therm_sensor>::iterator it;
+	std::vector<TemperatureThreshold> _thresh;
+
+	for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
+		struct therm_sensor& sens = it->second;
+
+		if (sens.t.type != type)
 			continue;
 		_thresh.push_back(sens.thresh);
 	}
@@ -242,15 +245,33 @@
 	return thresh.size();
 }
 
-int ThermalUtils::readCdevStates(bool filterType, cdevType type,
-                                            hidl_vec<CoolingDevice>& cdev_out)
+int ThermalUtils::readCdevStates(std::vector<CoolingDevice>& cdev_out)
 {
 	int ret = 0;
 	std::vector<CoolingDevice> _cdev;
 
 	for (struct therm_cdev cdev: cdevList) {
 
-		if (filterType && cdev.c.type != type)
+		ret = cmnInst.read_cdev_state(cdev);
+		if (ret < 0)
+			return ret;
+		_cdev.push_back(cdev.c);
+	}
+
+	cdev_out = _cdev;
+
+	return cdev_out.size();
+}
+
+int ThermalUtils::readCdevStates(cdevType type,
+                                            std::vector<CoolingDevice>& cdev_out)
+{
+	int ret = 0;
+	std::vector<CoolingDevice> _cdev;
+
+	for (struct therm_cdev cdev: cdevList) {
+
+		if (cdev.c.type != type)
 			continue;
 		ret = cmnInst.read_cdev_state(cdev);
 		if (ret < 0)
@@ -263,13 +284,7 @@
 	return cdev_out.size();
 }
 
-int ThermalUtils::fetchCpuUsages(hidl_vec<CpuUsage>& cpu_usages)
-{
-	return cmnInst.get_cpu_usages(cpu_usages);
-}
-
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/thermalUtilsNetlink.h b/thermalUtilsNetlink.h
index dc72f5c..8900c9f 100644
--- a/thermalUtilsNetlink.h
+++ b/thermalUtilsNetlink.h
@@ -29,22 +29,26 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-3-Clause-Clear */
+
 #ifndef THERMAL_THERMAL_UTILS_H__
 #define THERMAL_THERMAL_UTILS_H__
 
 #include <unordered_map>
 #include <mutex>
-#include <android/hardware/thermal/2.0/IThermal.h>
+#include <aidl/android/hardware/thermal/BnThermal.h>
 #include "thermalConfig.h"
 #include "thermalMonitorNetlink.h"
 #include "thermalCommon.h"
 #include "thermalData.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace thermal {
-namespace V2_0 {
-namespace implementation {
 
 using ueventCB = std::function<void(Temperature &t)>;
 
@@ -60,14 +64,15 @@
 		{
 			return is_cdev_init;
 		};
-		int readTemperatures(hidl_vec<Temperature_1_0>& temp);
-		int readTemperatures(bool filterType, TemperatureType type,
-                                            hidl_vec<Temperature>& temperatures);
-		int readTemperatureThreshold(bool filterType, TemperatureType type,
-                                            hidl_vec<TemperatureThreshold>& thresh);
-		int readCdevStates(bool filterType, cdevType type,
-                                            hidl_vec<CoolingDevice>& cdev);
-		int fetchCpuUsages(hidl_vec<CpuUsage>& cpu_usages);
+		int readTemperatures(std::vector<Temperature>& temp);
+		int readTemperatures(TemperatureType type,
+                                            std::vector<Temperature>& temperatures);
+		int readTemperatureThreshold(std::vector<TemperatureThreshold>& thresh);
+		int readTemperatureThreshold(TemperatureType type,
+                                            std::vector<TemperatureThreshold>& thresh);
+		int readCdevStates(std::vector<CoolingDevice>& cdev);
+		int readCdevStates(cdevType type,
+                                            std::vector<CoolingDevice>& cdev);
 	private:
 		bool is_sensor_init;
 		bool is_cdev_init;
@@ -86,10 +91,9 @@
 		void Notify(struct therm_sensor& sens);
 };
 
-}  // namespace implementation
-}  // namespace V2_0
 }  // namespace thermal
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 #endif  // THERMAL_THERMAL_UTILS_H__