thermal-hal: Return failure only for uninitialized sensor request

Adapt legacy thermal utils according to commit
c5ea560f0f309699b1a0ba6cfc54552b29ba94df.

Change-Id: I9ff101882a5e4774fbdf3701b1a3f72ab4a1f22b
diff --git a/thermalUtils.cpp b/thermalUtils.cpp
index 200428a..fee8972 100644
--- a/thermalUtils.cpp
+++ b/thermalUtils.cpp
@@ -59,11 +59,9 @@
 	std::vector<struct therm_sensor> sensorList;
 	std::vector<struct target_therm_cfg> therm_cfg = cfg.fetchConfig();
 
-	is_sensor_init = false;
 	is_cdev_init = false;
 	ret = cmnInst.initThermalZones(therm_cfg);
 	if (ret > 0) {
-		is_sensor_init = true;
 		sensorList = cmnInst.fetch_sensor_list();
 		std::lock_guard<std::mutex> _lock(sens_cb_mutex);
 		for (struct therm_sensor sens: sensorList) {
@@ -81,6 +79,34 @@
 	}
 }
 
+bool ThermalUtils::isSensorInitialized()
+{
+	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
+
+	if (thermalConfig.begin() == thermalConfig.end())
+		return false;
+
+	return true;
+}
+
+bool ThermalUtils::isSensorInitialized(TemperatureType type)
+{
+	std::unordered_map<std::string, struct therm_sensor>::iterator it;
+	std::lock_guard<std::mutex> _lock(sens_cb_mutex);
+
+	if (thermalConfig.begin() == thermalConfig.end())
+		return false;
+
+	for (it = thermalConfig.begin(); it != thermalConfig.end();
+			it++) {
+		struct therm_sensor& sens = it->second;
+		if (sens.t.type == type)
+			return true;
+	}
+
+	return false;
+}
+
 void ThermalUtils::Notify(struct therm_sensor& sens)
 {
 	int severity = cmnInst.estimateSeverity(sens);
diff --git a/thermalUtils.h b/thermalUtils.h
index e7f8a42..ca07cfa 100644
--- a/thermalUtils.h
+++ b/thermalUtils.h
@@ -56,14 +56,12 @@
 	public:
 		ThermalUtils(const ueventCB &inp_cb);
 		~ThermalUtils() = default;
-		bool isSensorInitialized()
-		{
-			return is_sensor_init;
-		};
 		bool isCdevInitialized()
 		{
 			return is_cdev_init;
 		};
+		bool isSensorInitialized();
+		bool isSensorInitialized(TemperatureType type);
 		int readTemperatures(std::vector<Temperature>& temp);
 		int readTemperatures(TemperatureType type,
                                             std::vector<Temperature>& temperatures);
@@ -74,7 +72,6 @@
 		int readCdevStates(cdevType type,
                                             std::vector<CoolingDevice>& cdev);
 	private:
-		bool is_sensor_init;
 		bool is_cdev_init;
 		ThermalConfig cfg;
 		ThermalCommon cmnInst;