sensord: support original path to load HAL library 57/124557/4
authorkibak.yoon <seseki17@gmail.com>
Tue, 11 Apr 2017 18:06:21 +0000 (03:06 +0900)
committerKibak Yoon <kibak.yoon@samsung.com>
Wed, 12 Apr 2017 03:43:26 +0000 (20:43 -0700)
Change-Id: Id32a8e5d2f008766542ee9a46e5757a284667630
Signed-off-by: kibak.yoon <seseki17@gmail.com>
src/server/sensor_loader.cpp
src/server/sensor_manager.cpp

index d46a5cf..4d1d20e 100644 (file)
@@ -19,6 +19,9 @@
 
 #include "sensor_loader.h"
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <dlfcn.h>
 #include <dirent.h>
 #include <sensor_log.h>
@@ -112,6 +115,7 @@ bool sensor_loader::get_module_paths(const std::string &dir_path, std::vector<st
        DIR *dir = NULL;
        struct dirent entry;
        struct dirent *result;
+       struct stat buf;
        std::string filename;
 
        dir = opendir(dir_path.c_str());
@@ -130,7 +134,15 @@ bool sensor_loader::get_module_paths(const std::string &dir_path, std::vector<st
                if (filename == "." || filename == "..")
                        continue;
 
-               paths.push_back(dir_path + "/" + filename);
+               std::string full_path = dir_path + "/" + filename;
+
+               if (lstat(full_path.c_str(), &buf) != 0)
+                       break;
+
+               if (S_ISDIR(buf.st_mode))
+                       continue;
+
+               paths.push_back(full_path);
        }
        closedir(dir);
 
index 6b8bc91..7aa04fe 100644 (file)
@@ -35,6 +35,7 @@
 
 using namespace sensor;
 
+#define DEVICE_HAL_DIR_PATH_LEGACY LIBDIR "/sensor"
 #define DEVICE_HAL_DIR_PATH LIBDIR "/sensor/hal"
 #define PHYSICAL_SENSOR_DIR_PATH LIBDIR "/sensor/physical"
 #define VIRTUAL_SENSOR_DIR_PATH LIBDIR "/sensor/fusion"
@@ -56,6 +57,7 @@ sensor_manager::~sensor_manager()
 
 bool sensor_manager::init(void)
 {
+       m_loader.load_hal(DEVICE_HAL_DIR_PATH_LEGACY, devices);
        m_loader.load_hal(DEVICE_HAL_DIR_PATH, devices);
        m_loader.load_physical_sensor(PHYSICAL_SENSOR_DIR_PATH, physical_sensors);
        m_loader.load_fusion_sensor(VIRTUAL_SENSOR_DIR_PATH, fusion_sensors);