sensord: add location privilege to location-related sensors 15/128615/4
authorkibak.yoon <kibak.yoon@samsung.com>
Wed, 10 May 2017 13:20:27 +0000 (22:20 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Thu, 11 May 2017 02:12:26 +0000 (11:12 +0900)
Change-Id: Ib931902c518fd67e62fb7e7dc2d8cd6340d792b3
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/sensor_handler.cpp
src/server/server_channel_handler.cpp
src/shared/sensor_info.cpp
src/shared/sensor_info.h
src/shared/sensor_types_private.h
src/shared/sensor_utils.cpp

index d72cfb8..2a2eb6a 100644 (file)
@@ -22,6 +22,7 @@
 #include <message.h>
 #include <sensor_log.h>
 #include <sensor_utils.h>
+#include <sensor_types_private.h>
 
 using namespace sensor;
 
@@ -33,6 +34,16 @@ sensor_handler::sensor_handler(const sensor_info &info)
 
        sensor_type_t type = sensor::utils::get_type(m_info.get_uri());
        m_info.set_type(type);
+
+       /* TODO: temporary walkaround for sensors that require multiple privileges */
+       switch (m_info.get_type()) {
+       case EXTERNAL_EXERCISE_SENSOR:
+       case EXERCISE_STANDALONE_SENSOR:
+               m_info.add_privilege(PRIVILEGE_LOCATION_URI);
+               break;
+       default:
+               break;
+       }
 }
 
 bool sensor_handler::has_observer(sensor_observer *ob)
index 88c48e4..f20008c 100644 (file)
 #include <sensor_info.h>
 #include <sensor_handler.h>
 #include <sensor_utils.h>
+#include <sensor_types_private.h>
 #include <command_types.h>
 
 #include "permission_checker.h"
 #include "application_sensor_handler.h"
 
-#define PRIV_DELIMINATOR ";"
-
 using namespace sensor;
 using namespace ipc;
 
@@ -397,7 +396,7 @@ bool server_channel_handler::has_privilege(int fd, std::string &priv)
 bool server_channel_handler::has_privileges(int fd, std::string priv)
 {
        std::vector<std::string> privileges;
-       privileges = utils::tokenize(priv, PRIV_DELIMINATOR);
+       privileges = utils::tokenize(priv, PRIV_DELIMITER);
 
        for (auto it = privileges.begin(); it != privileges.end(); ++it) {
                if (!has_privilege(fd, *it))
index c2d95c3..e56be7e 100644 (file)
@@ -20,6 +20,7 @@
 #include "sensor_info.h"
 
 #include <sensor_types.h>
+#include <sensor_types_private.h>
 #include <sensor_log.h>
 #include <algorithm>
 #include <string>
@@ -207,6 +208,13 @@ void sensor_info::set_privilege(const char *privilege)
        m_privilege = privilege;
 }
 
+void sensor_info::add_privilege(const char *privilege)
+{
+       if (!m_privilege.empty())
+               m_privilege.append(PRIV_DELIMITER);
+       m_privilege.append(privilege);
+}
+
 void sensor_info::serialize(raw_data_t &data)
 {
        put(data, m_type);
index 91b6ba8..d07b5b8 100644 (file)
@@ -63,6 +63,7 @@ public:
        void set_max_batch_count(int max_batch_count);
        void set_wakeup_supported(bool supported);
        void set_privilege(const char *privilege);
+       void add_privilege(const char *privilege);
 
        void clear(void);
 
index b1c49f3..d0ed9e2 100644 (file)
 
 #define PREDEFINED_TYPE_URI "http://tizen.org/sensor/"
 
+#define PRIV_DELIMITER ";"
 #define URI_DELIMITER "/"
+
 #define PRIVILEGE_HEALTHINFO_STR "healthinfo"
 #define PRIVILEGE_HEALTHINFO_URI "http://tizen.org/privilege/healthinfo"
 
+#define PRIVILEGE_LOCATION_STR "location"
+#define PRIVILEGE_LOCATION_URI "http://tizen.org/privilege/location"
+
 #define URI_PRIV_INDEX 4
 #define URI_SENSOR_TYPE_INDEX 5
 
index 21e13ea..16341cc 100644 (file)
@@ -90,7 +90,7 @@ static std::map<sensor_type_t, const char *> types = {
 
        {ACTIVITY_TRACKER_SENSOR,        "http://tizen.org/sensor/general/activity_tracker"},
        {ACTIVITY_LEVEL_MONITOR_SENSOR,  "http://tizen.org/sensor/general/activity_level_monitor"},
-       {GPS_BATCH_SENSOR,               "http://tizen.org/sensor/general/gps_batch"},
+       {GPS_BATCH_SENSOR,               "http://tizen.org/sensor/location/gps_batch"},
 
        {HRM_CTRL_SENSOR,                "http://tizen.org/sensor/general/hrm_ctrl"},
 
@@ -151,6 +151,8 @@ const char *sensor::utils::get_privilege(std::string uri)
 
        if (uri.substr(start + 1, size) == PRIVILEGE_HEALTHINFO_STR)
                return PRIVILEGE_HEALTHINFO_URI;
+       else if (uri.substr(start + 1, size) == PRIVILEGE_LOCATION_STR)
+               return PRIVILEGE_LOCATION_URI;
 
        return "";
 }