#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>
DIR *dir = NULL;
struct dirent entry;
struct dirent *result;
+ struct stat buf;
std::string filename;
dir = opendir(dir_path.c_str());
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);
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"
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);