[ACR-746] Passive Location
[platform/core/api/location-manager.git] / src / locations.c
index 4a46c58..b148c9a 100755 (executable)
@@ -21,7 +21,7 @@
 #include "locations.h"
 #include "location_internal.h"
 
-static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS + 1];
+static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_PASSIVE + 1];
 
 static location_method_e __convert_location_method_e(LocationMethod method)
 {
@@ -56,6 +56,9 @@ static LocationMethod __convert_LocationMethod(location_method_e method)
        case LOCATIONS_METHOD_WPS:
                _method = LOCATION_METHOD_WPS;
                break;
+       case LOCATIONS_METHOD_PASSIVE:
+               _method = LOCATION_METHOD_PASSIVE;
+               break;
        case LOCATIONS_METHOD_NONE:
        default:
                _method = LOCATION_METHOD_NONE;
@@ -490,6 +493,11 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage
                        LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location feature", LOCATIONS_ERROR_NOT_SUPPORTED);
                        return LOCATIONS_ERROR_NOT_SUPPORTED;
                }
+       } else if (method == LOCATIONS_METHOD_PASSIVE) {
+               if (__is_location_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) {
+                       LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location feature", LOCATIONS_ERROR_NOT_SUPPORTED);
+                       return LOCATIONS_ERROR_NOT_SUPPORTED;
+               }
        }
 
        LocationMethod _method = __convert_LocationMethod(method);
@@ -591,7 +599,7 @@ EXPORT_API int location_manager_start(location_manager_h manager)
        if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED])
                handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = g_signal_connect(handle->object, "service-updated", G_CALLBACK(__cb_service_updated), handle);
 
-       if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_WPS) {
+       if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) {
                if (!handle->sig_id[_LOCATION_SIGNAL_ZONE_IN])
                        handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = g_signal_connect(handle->object, "zone-in", G_CALLBACK(__cb_zone_in), handle);
 
@@ -635,8 +643,13 @@ EXPORT_API int location_manager_request_single_location(location_manager_h manag
                return ret;
 
        ret = location_request_single_location(handle->object, timeout);
-       if (ret != LOCATION_ERROR_NONE)
+       if (ret != LOCATION_ERROR_NONE) {
+               if (ret == LOCATION_ERROR_NOT_SUPPORTED) {
+                       LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD : method - %d", handle->method);
+                       return LOCATIONS_ERROR_INCORRECT_METHOD;
+               }
                return __convert_error_code(ret);
+       }
 
        return LOCATIONS_ERROR_NONE;
 }
@@ -654,7 +667,7 @@ EXPORT_API int location_manager_stop(location_manager_h manager)
                handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = 0;
        }
 
-       if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_WPS) {
+       if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) {
                if (handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]) {
                        g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]);
                        handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = 0;
@@ -750,6 +763,9 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_
        case LOCATION_METHOD_WPS:
                *method = LOCATIONS_METHOD_WPS;
                break;
+       case LOCATION_METHOD_PASSIVE:
+               *method = LOCATIONS_METHOD_PASSIVE;
+               break;
        default: {
                LOCATIONS_LOGE("[LOCATIONS_ERROR_INVALID_PARAMETER] method : %d ", method);
                        return LOCATIONS_ERROR_INVALID_PARAMETER;