removed wrong contacts, added authors
[platform/core/location/lbs-location.git] / location / manager / location.c
index f36721e..b0ea74a 100755 (executable)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -25,7 +22,6 @@
 
 #include <glib.h>
 #include <stdio.h>
-#include <pthread.h>
 #include <vconf.h>
 
 #include "location.h"
 #include "location-hybrid.h"
 #include "location-gps.h"
 #include "location-wps.h"
-#include "location-mock.h"
+#include "location-passive.h"
 #include "location-position.h"
 #include "module-internal.h"
 #include "location-common-util.h"
-#ifndef TIZEN_PROFILE_TV
 #include "location-privacy.h"
-#endif
 
-#define LOCATION_PRIVILEGE     "http://tizen.org/privilege/location"
+#define LOCATION_PRIVILEGE                     "http://tizen.org/privilege/location"
 #define LOCATION_ENABLE_PRIVILEGE      "http://tizen.org/privilege/location.enable"
 
 typedef struct _LocationSetting {
@@ -66,7 +60,7 @@ static char *__convert_setting_key(LocationMethod method)
        case LOCATION_METHOD_WPS:
                key = g_strdup(VCONFKEY_LOCATION_NETWORK_ENABLED);
                break;
-       case LOCATION_METHOD_MOCK:
+       case INTERNAL_METHOD_MOCK:
                key = g_strdup(VCONFKEY_LOCATION_MOCK_ENABLED);
                break;
        default:
@@ -85,8 +79,6 @@ static LocationMethod __convert_method_from_key(const char *key)
                _method = LOCATION_METHOD_GPS;
        else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
                _method = LOCATION_METHOD_WPS;
-       else if (g_strcmp0(key, VCONFKEY_LOCATION_MOCK_ENABLED) == 0)
-               _method = LOCATION_METHOD_MOCK;
 
        return _method;
 }
@@ -122,10 +114,10 @@ int location_init(void)
 }
 
 EXPORT_API LocationObject *
-location_new(LocationMethod method)
+location_new(LocationMethod method, gboolean multi_handle)
 {
        LocationObject *self = NULL;
-       LOCATION_LOGD("method: %d", method);
+       LOCATION_LOGD("method : %d, multi_handle[%d]", method, multi_handle);
 
        switch (method) {
        case LOCATION_METHOD_HYBRID:
@@ -137,8 +129,9 @@ location_new(LocationMethod method)
        case LOCATION_METHOD_WPS:
                self = g_object_new(LOCATION_TYPE_WPS, NULL);
                break;
-       case LOCATION_METHOD_MOCK:
-               self = g_object_new(LOCATION_TYPE_MOCK, NULL);
+       case LOCATION_METHOD_PASSIVE:
+               self = g_object_new(LOCATION_TYPE_PASSIVE, NULL);
+               break;
        default:
                break;
        }
@@ -148,7 +141,7 @@ location_new(LocationMethod method)
 }
 
 EXPORT_API int
-location_free(LocationObject *obj)
+location_free(LocationObject *obj, gboolean multi_handle)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        g_object_unref(obj);
@@ -161,6 +154,10 @@ location_request_single_location(LocationObject *obj, int timeout)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
        int ret = LOCATION_ERROR_NONE;
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
        ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
        LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
 
@@ -168,15 +165,33 @@ location_request_single_location(LocationObject *obj, int timeout)
 }
 
 EXPORT_API int
+location_cancel_single_location(LocationObject *obj)
+{
+       g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
+
+       int ret = LOCATION_ERROR_NONE;
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
+
+       ret = location_ielement_cancel_single_location(LOCATION_IELEMENT(obj));
+       if (ret != LOCATION_ERROR_NONE)
+               LOCATION_LOGE("Fail to cancel single location. Error [%d]", ret);
+
+       return ret;
+}
+
+EXPORT_API int
 location_start(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
        int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_start(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
@@ -202,10 +217,10 @@ location_start_batch(LocationObject *obj)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
@@ -219,7 +234,7 @@ location_stop_batch(LocationObject *obj)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        int ret = LOCATION_ERROR_NONE;
        ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
-       LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%d]", err_msg(ret));
+       LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%s]", err_msg(ret));
 
        return ret;
 }
@@ -231,18 +246,18 @@ location_is_supported_method(LocationMethod method)
 
        switch (method) {
        case LOCATION_METHOD_HYBRID:
-                       if (module_is_supported("gps") || module_is_supported("wps") || module_is_supported("mock"))
-                               is_supported = TRUE;
-                       break;
+               if (module_is_supported("gps") || module_is_supported("wps"))
+                       is_supported = TRUE;
+               break;
        case LOCATION_METHOD_GPS:
-                       is_supported = module_is_supported("gps");
-                       break;
+               is_supported = module_is_supported("gps");
+               break;
        case LOCATION_METHOD_WPS:
-                       is_supported = module_is_supported("wps");
-                       break;
-       case LOCATION_METHOD_MOCK:
-                       is_supported = module_is_supported("mock");
-                       break;
+               is_supported = module_is_supported("wps");
+               break;
+       case LOCATION_METHOD_PASSIVE:
+               is_supported = module_is_supported("passive");
+               break;
        default:
                        break;
        }
@@ -281,10 +296,10 @@ location_enable_method(const LocationMethod method, const int enable)
        int ret = 0;
        char *_key = NULL;
 
-#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 (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
                LOCATION_SECLOG("Location setting is denied by DPM");
@@ -382,10 +397,10 @@ location_get_position(LocationObject *obj, LocationPosition **position, Location
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
        LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
@@ -403,10 +418,10 @@ location_get_position_ext(LocationObject *obj, LocationPosition **position, Loca
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
@@ -423,10 +438,10 @@ location_get_last_position(LocationObject *obj, LocationPosition **position, Loc
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
@@ -444,10 +459,10 @@ location_get_last_position_ext(LocationObject *obj, LocationPosition **position,
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
@@ -477,10 +492,10 @@ location_get_satellite(LocationObject *obj, LocationSatellite **satellite)
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
        LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
@@ -496,10 +511,10 @@ location_get_batch(LocationObject *obj, LocationBatch **batch)
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
        LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
@@ -515,10 +530,10 @@ location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite)
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
@@ -535,10 +550,10 @@ location_get_velocity(LocationObject *obj, LocationVelocity **velocity, Location
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
@@ -555,10 +570,10 @@ location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, Loc
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
@@ -569,22 +584,19 @@ location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, Loc
 EXPORT_API int
 location_get_accessibility_state(LocationAccessState *state)
 {
-       int auth = location_application_get_authority();
-       switch (auth) {
-       case LOCATION_APP_OFF:
-               *state = LOCATION_ACCESS_DENIED;
-               break;
-       case LOCATION_APP_ON:
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               int ret = location_check_cynara(LOCATION_PRIVILEGE);
+
+               if (ret == LOCATION_ERROR_NONE) {
+                       *state = LOCATION_ACCESS_ALLOWED;
+               } else {
+                       *state = LOCATION_ACCESS_DENIED;
+                       LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
+               }
+       } else {
                *state = LOCATION_ACCESS_ALLOWED;
-               break;
-       case LOCATION_APP_NOT_FOUND:
-               *state = LOCATION_ACCESS_NONE;
-               break;
-       default:
-               return LOCATION_ERROR_UNKNOWN;
        }
 
-       LOCATION_LOGD("get_accessibility_state [%d]", auth);
        return LOCATION_ERROR_NONE;
 }
 
@@ -624,10 +636,10 @@ location_set_option(LocationObject *obj, const char *option)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
        int ret = LOCATION_ERROR_NONE;
 
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
        ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
        LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
@@ -638,33 +650,15 @@ location_set_option(LocationObject *obj, const char *option)
 /*
  * Tizen 3.0
  */
-
 EXPORT_API int
-location_get_service_state(LocationObject *obj, int *state)
+location_enable_mock(const int enable)
 {
-       g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
-       g_return_val_if_fail(state, LOCATION_ERROR_PARAMETER);
-
        int ret = LOCATION_ERROR_NONE;
-       ret = location_ielement_get_status(LOCATION_IELEMENT(obj), state);
-       LOC_IF_FAIL(ret, _E, "Fail to get_position [%s]", err_msg(ret));
-
-       return ret;
-}
 
-
-EXPORT_API int
-location_enable_mock(const LocationMethod method, const int enable)
-{
-       int ret = 0;
-       char *_key = NULL;
-
-       LOC_COND_RET(method != LOCATION_METHOD_MOCK, LOCATION_ERROR_PARAMETER, _E, "Method is not mock [%s]", err_msg(LOCATION_ERROR_PARAMETER));
-
-#ifndef TIZEN_PROFILE_TV
-       ret = location_check_cynara(LOCATION_PRIVILEGE);
-       LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
 
 #if 0 /* Tizen platform didn't turn developer option on */
        gboolean developer_option = FALSE;
@@ -673,71 +667,14 @@ location_enable_mock(const LocationMethod method, const int enable)
        LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
 #endif
 
-       _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));
-
-       ret = vconf_set_int(_key, enable);
-       if (ret != VCONF_OK) {
-               LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
-               g_free(_key);
-               return LOCATION_ERROR_NOT_ALLOWED;
-       }
-
-       g_free(_key);
-
-       return ret;
-}
-
-#if 0
-static char *__convert_mock_setting_key(LocationMethod method)
-{
-       char *key = NULL;
-       switch (method) {
-       case LOCATION_METHOD_MOCK_GPS:
-                       key = g_strdup(VCONFKEY_LOCATION_MOCK_GPS_ENABLED);
-                       break;
-       case LOCATION_METHOD_MOCK_WPS:
-                       key = g_strdup(VCONFKEY_LOCATION_MOCK_NETWORK_ENABLED);
-                       break;
-       default:
-                       break;
-       }
-       return key;
-}
-
-EXPORT_API int
-location_set_mock_method_enabled(const LocationMethod method, const int enable)
-{
-       int ret = 0;
-       char *_key = NULL;
-       int vconf_val = 0;
-
-       _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));
-
-       ret = vconf_get_int(_key, &vconf_val);
+       ret = vconf_set_int(VCONFKEY_LOCATION_MOCK_ENABLED, enable);
        if (ret != VCONF_OK) {
-               LOCATION_SECLOG("failed [%s], error [%d]", _key, ret);
-               g_free(_key);
+               LOCATION_SECLOG("vconf_set_int failed [MOCK_ENABLED], ret=[%d]", ret);
                return LOCATION_ERROR_NOT_ALLOWED;
        }
 
-       if (vconf_val) {
-               _key = __convert_mock_setting_key(method);
-               LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method[%d]", method);
-               ret = vconf_set_int(_key, enable);
-               if (ret != VCONF_OK) {
-                       LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
-                       g_free(_key);
-                       return LOCATION_ERROR_NOT_ALLOWED;
-               }
-               g_free(_key);
-       }
-
        return ret;
 }
-#endif
-
 
 EXPORT_API int
 location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
@@ -748,6 +685,11 @@ location_set_mock_location(LocationObject *obj, const LocationPosition *position
        g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
 
        int ret = LOCATION_ERROR_NONE;
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
+
        ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
        LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
 
@@ -760,6 +702,11 @@ location_clear_mock_location(LocationObject *obj)
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
 
        int ret = LOCATION_ERROR_NONE;
+       if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
+
        ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
        LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
 
@@ -772,10 +719,10 @@ 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 (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+               ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+               LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+       }
        if (enable) {
                int value = 0;
                ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);