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

In GKI builds, the thermal sensors may not be populated. With this case
thermal HAL will return error for all the v1 APIs.

For compliance, return success with a dummy data, in case the sensors
are not available.

Change-Id: I1ad141d4f1252567abed41566702125f41707276
diff --git a/thermal.cpp b/thermal.cpp
index 1d8cdcb..ea4272a 100644
--- a/thermal.cpp
+++ b/thermal.cpp
@@ -51,6 +51,15 @@
 
 using ::android::hardware::interfacesEqual;
 
+static const Temperature_1_0 dummy_temp_1_0 = {
+	.type = TemperatureType_1_0::SKIN,
+	.name = "test sensor",
+	.currentValue = 30,
+	.throttlingThreshold = 40,
+	.shutdownThreshold = 60,
+	.vrThrottlingThreshold = 40,
+};
+
 template <typename A, typename B>
 Return<void> exit_hal(A _cb, hidl_vec<B> _data, std::string_view _msg) {
 	ThermalStatus _status;
@@ -86,9 +95,12 @@
 	hidl_vec<Temperature_1_0> temperatures;
 
 	status.code = ThermalStatusCode::SUCCESS;
-	if (!utils.isSensorInitialized())
-		return exit_hal(_hidl_cb, temperatures,
-			"ThermalHAL not initialized properly.");
+	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();
+	}
 
 	if (utils.readTemperatures(temperatures) <= 0)
 		return exit_hal(_hidl_cb, temperatures,
@@ -106,9 +118,6 @@
 	hidl_vec<CpuUsage> cpu_usages;
 
 	status.code = ThermalStatusCode::SUCCESS;
-	if (!utils.isSensorInitialized())
-		return exit_hal(_hidl_cb, cpu_usages,
-			"ThermalHAL not initialized properly.");
 	if (utils.fetchCpuUsages(cpu_usages) <= 0)
 		return exit_hal(_hidl_cb, cpu_usages,
 				"CPU usage read failure.");
@@ -123,9 +132,6 @@
 	hidl_vec<CoolingDevice_1_0> cdev;
 
 	status.code = ThermalStatusCode::SUCCESS;
-	if (!utils.isCdevInitialized())
-		return exit_hal(_hidl_cb, cdev,
-			"ThermalHAL not initialized properly.");
 	/* V1 Cdev requires only Fan Support. */
 	_hidl_cb(status, cdev);
 	return Void();