thermal-hal: Add a fake temperature data for v2 APIs

In GKI builds, some thermal sensors may not be populated. With this
case thermal hal2.0 will return error for v2 APIs. For compliance,
return success with a dummy temperature data, in case sensors are
not available.

Change-Id: I5ab60aabc12b91ae30500eb9935c48f4f99dd75d
diff --git a/thermal.cpp b/thermal.cpp
index cb379c8..91b976d 100644
--- a/thermal.cpp
+++ b/thermal.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -59,6 +60,13 @@
 	.vrThrottlingThreshold = 40,
 };
 
+static const Temperature dummy_temp_2_0 = {
+	.type = TemperatureType::SKIN,
+	.name = "test sensor",
+	.value = 25.0,
+	.throttlingStatus = ThrottlingSeverity::NONE,
+};
+
 template <typename A, typename B>
 Return<void> exit_hal(A _cb, hidl_vec<B> _data, std::string_view _msg) {
 	ThermalStatus _status;
@@ -169,9 +177,15 @@
 		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.");
+	if (utils.readTemperatures(filterType, type, temperatures) <= 0) {
+		if (filterType && type != dummy_temp_2_0.type) {
+			status.code = ThermalStatusCode::FAILURE;
+			status.debugMessage = "Failed to read dummy temperature value";
+		} else {
+			temperatures = {dummy_temp_2_0};
+			LOG(INFO) << "Returning Dummy Temperature Value" << std::endl;
+		}
+	}
 
 	_hidl_cb(status, temperatures);