Revert "Coverity issues Fix"
[platform/core/system/sensord.git] / src / server / sensor_manager.cpp
index 8d79ed0..3af7ca9 100644 (file)
@@ -65,7 +65,7 @@ bool sensor_manager::init(void)
        m_loader.load_fusion_sensor(VIRTUAL_SENSOR_DIR_PATH, fusion_sensors);
        m_loader.load_external_sensor(EXTERNAL_SENSOR_DIR_PATH, external_sensors);
 
-       retvm_if(devices.empty(), false, "There is no sensors");
+       retvm_if(devices.empty() && external_sensors.empty(), false, "There is no sensors");
 
        /* TODO: support dynamic sensor */
        create_physical_sensors(devices, physical_sensors);
@@ -205,10 +205,15 @@ void sensor_manager::deregister_channel(ipc::channel *ch)
 
 sensor_handler *sensor_manager::get_sensor_by_type(const std::string uri)
 {
-       auto it = m_sensors.begin();
-       for (; it != m_sensors.end(); ++it) {
-               std::size_t found = it->first.rfind(uri);
-               if (found != std::string::npos)
+       for (auto it = m_sensors.begin(); it != m_sensors.end(); ++it) {
+               if (it->first == uri)
+                       return it->second;
+
+               std::size_t found = it->first.find_last_of("/");
+               if (found == std::string::npos)
+                       continue;
+
+               if (it->first.substr(0, found) == uri)
                        return it->second;
        }
 
@@ -252,7 +257,6 @@ void sensor_manager::create_physical_sensors(device_sensor_registry_t &devices,
                        m_sensors[sinfo.get_uri()] = psensor;
                }
        }
-
 }
 
 void sensor_manager::create_fusion_sensors(fusion_sensor_registry_t &fsensors)