Location setting restriction to support DPM 00/67700/8 accepted/tizen/common/20160517.173912 accepted/tizen/ivi/20160517.032407 accepted/tizen/ivi/20160607.235455 accepted/tizen/mobile/20160517.032444 accepted/tizen/mobile/20160607.235459 accepted/tizen/tv/20160517.032423 accepted/tizen/tv/20160607.235443 accepted/tizen/wearable/20160517.032458 accepted/tizen/wearable/20160607.235448 submit/tizen/20160516.091333 submit/tizen/20160607.094534
authorkj7.sung <kj7.sung@samsung.com>
Thu, 28 Apr 2016 05:51:24 +0000 (14:51 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Fri, 13 May 2016 02:24:04 +0000 (11:24 +0900)
Change-Id: I5c3d9aa8139a5c93ea18d1bb7a082f7c9ed1e56c
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
location/include/location-types.h
location/manager/location-gps.c
location/manager/location.c
location/manager/location.h
packaging/liblbs-location.changes
packaging/liblbs-location.spec

index 9e15897..95ed229 100644 (file)
@@ -91,6 +91,17 @@ typedef enum {
 } LocationAccessState;
 
 /**
+ * @brief This represents the setting type.
+ */
+typedef enum {
+       RESTRICT_OFF    = 0,
+       RESTRICT_NONE   = 0x01,
+       RESTRICT_GPS    = RESTRICT_NONE << 0x01,
+       RESTRICT_WPS    = RESTRICT_NONE << 0x02,
+       RESTRICT_HYBRID = RESTRICT_NONE << 0x03,
+} LocationRestrictType;
+
+/**
  * @brief Location object redefined by GObject.
  */
 typedef GObject LocationObject;
index 286d7b5..3e78d03 100755 (executable)
@@ -593,7 +593,7 @@ static int location_gps_stop_batch(LocationGps *self)
        if (__get_started(self) == TRUE) {
                __set_started(self, FALSE);
                ret = priv->mod->ops.stop_batch(priv->mod->handler);
-               LOC_IF_FAIL_LOG(ret, _E, "Failed to stop_batch [%s]", err_mgs(ret));
+               LOC_IF_FAIL_LOG(ret, _E, "Failed to stop_batch [%s]", err_msg(ret));
        } else {
                return LOCATION_ERROR_NONE;
        }
index b5ee57c..f36721e 100755 (executable)
@@ -286,6 +286,11 @@ location_enable_method(const LocationMethod method, const int enable)
        LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
 #endif
 
+       if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
+               LOCATION_SECLOG("Location setting is denied by DPM");
+               return LOCATION_ERROR_NOT_ALLOWED;
+       }
+
        /* for itself */
        _key = __convert_setting_key(method);
        LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
@@ -760,3 +765,74 @@ location_clear_mock_location(LocationObject *obj)
 
        return ret;
 }
+
+EXPORT_API int
+location_enable_restriction(const int enable)
+{
+       int ret = LOCATION_ERROR_NONE;
+       int restriction = 0;
+
+#ifndef TIZEN_PROFILE_TV
+       ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+#endif
+       if (enable) {
+               int value = 0;
+               ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
+               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+
+               if (restriction == RESTRICT_OFF) {
+
+                       if (location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
+                               value |= RESTRICT_GPS;
+                               ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       if (location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
+                               value |= RESTRICT_WPS;
+                               ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       if (location_setting_get_int(VCONFKEY_LOCATION_USE_MY_LOCATION)) {
+                               value |= RESTRICT_HYBRID;
+                               ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 0);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       if (value == 0)
+                               value = RESTRICT_NONE;
+
+                       ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, value);
+                       LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", value, err_msg(LOCATION_ERROR_NOT_ALLOWED));
+               }
+
+       } else {
+               ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
+               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+
+               if (restriction > RESTRICT_OFF) {
+
+                       if (restriction & RESTRICT_GPS) {
+                               ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       if (restriction & RESTRICT_WPS) {
+                               ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       if (restriction & RESTRICT_HYBRID) {
+                               ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 1);
+                               LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
+                       }
+
+                       ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, RESTRICT_OFF);
+                       LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", RESTRICT_OFF, err_msg(LOCATION_ERROR_NOT_ALLOWED));
+               }
+       }
+
+       return LOCATION_ERROR_NONE;
+}
index ebb1527..84d3ee7 100755 (executable)
@@ -877,6 +877,8 @@ int location_set_mock_method_enabled(const LocationMethod method, const int enab
 int location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy);
 int location_clear_mock_location(LocationObject *obj);
 
+int location_enable_restriction(const int enable);
+
 /**
  * @} @}
  */
index ba3b2ed..978b2fc 100644 (file)
@@ -1,3 +1,10 @@
+[Version]      libslp-location_1.3.0
+[Date]         12 May 2016
+[Changes]      Add location restriction to support DPM
+[Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
+
+================================================================================
+
 [Version]      libslp-location_1.2.1
 [Date]         9 May 2016
 [Changes]      Change tag style for error log
index a17aee4..d0432a0 100755 (executable)
@@ -1,6 +1,6 @@
 Name: liblbs-location
 Summary: Location Based Service Library
-Version: 1.2.1
+Version: 1.3.0
 Release: 1
 Group: Location/Libraries
 License: Apache-2.0