2 * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <system_info.h>
21 #include "location_internal.h"
23 int __convert_error_code(int code)
26 const char *msg = NULL;
28 case LOCATION_ERROR_NONE:
29 ret = LOCATIONS_ERROR_NONE;
30 msg = "LOCATIONS_ERROR_NONE";
32 case LOCATION_ERROR_PARAMETER:
33 ret = LOCATIONS_ERROR_INVALID_PARAMETER;
34 msg = "LOCATIONS_ERROR_INVALID_PARAMETER";
37 case LOCATION_ERROR_NOT_ALLOWED:
38 ret = LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED;
39 msg = "LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED";
41 case LOCATION_ERROR_NOT_SUPPORTED:
42 ret = LOCATIONS_ERROR_NOT_SUPPORTED;
43 msg = "LOCATIONS_ERROR_NOT_SUPPORTED";
45 case LOCATION_ERROR_NETWORK_FAILED:
46 case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
47 ret = LOCATIONS_ERROR_NETWORK_FAILED;
48 msg = "LOCATIONS_ERROR_NETWORK_FAILED";
50 case LOCATION_ERROR_SETTING_OFF:
51 ret = LOCATIONS_ERROR_SETTING_OFF;
52 msg = "LOCATIONS_ERROR_SETTING_OFF";
54 case LOCATION_ERROR_SECURITY_DENIED:
55 ret = LOCATIONS_ERROR_SECURITY_RESTRICTED;
56 msg = "LOCATIONS_ERROR_SECURITY_RESTRICTED";
58 case LOCATION_ERROR_NOT_AVAILABLE:
59 case LOCATION_ERROR_CONFIGURATION:
60 case LOCATION_ERROR_UNKNOWN:
62 msg = "LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE";
63 ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
67 if (ret != LOCATIONS_ERROR_NONE)
68 LOCATIONS_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code);
73 int __is_gps_supported(void)
75 bool is_supported = false;
78 retval = system_info_get_platform_bool("http://tizen.org/feature/location.gps", &is_supported);
79 if (retval != SYSTEM_INFO_ERROR_NONE)
80 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval); //LCOV_EXCL_LINE
82 if (is_supported == false)
83 return LOCATIONS_ERROR_NOT_SUPPORTED;
85 return LOCATIONS_ERROR_NONE;
88 int __is_gps_satellite_supported(void)
90 bool is_supported = false;
93 retval = system_info_get_platform_bool("http://tizen.org/feature/location.gps.satellite", &is_supported);
94 if (retval != SYSTEM_INFO_ERROR_NONE)
95 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval); //LCOV_EXCL_LINE
97 if (is_supported == false)
98 return LOCATIONS_ERROR_NOT_SUPPORTED;
100 return LOCATIONS_ERROR_NONE;
103 int __is_wps_supported(void)
105 bool is_supported = false;
108 retval = system_info_get_platform_bool("http://tizen.org/feature/location.wps", &is_supported);
109 if (retval != SYSTEM_INFO_ERROR_NONE)
111 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval);
113 if (is_supported == false)
114 return LOCATIONS_ERROR_NOT_SUPPORTED;
116 return LOCATIONS_ERROR_NONE;
120 int __is_location_supported(void)
122 if (__is_gps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) {
124 if (__is_wps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED)
125 return LOCATIONS_ERROR_NOT_SUPPORTED;
127 return LOCATIONS_ERROR_NONE;
131 return LOCATIONS_ERROR_NONE;
134 int __is_batch_supported(void)
136 bool is_supported = false;
139 retval = system_info_get_platform_bool("http://tizen.org/feature/location.batch", &is_supported);
140 if (retval != SYSTEM_INFO_ERROR_NONE)
141 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval);
143 if (is_supported == false)
144 return LOCATIONS_ERROR_NOT_SUPPORTED;
146 return LOCATIONS_ERROR_NONE; //LCOV_EXCL_LINE
149 int __is_fused_supported(void)
151 bool is_supported = false;
154 retval = system_info_get_platform_bool("http://tizen.org/feature/location.fused", &is_supported);
155 if (retval != SYSTEM_INFO_ERROR_NONE)
156 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval);
158 if (is_supported == false)
159 return LOCATIONS_ERROR_NOT_SUPPORTED;
161 return LOCATIONS_ERROR_NONE; //LCOV_EXCL_LINE
164 int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data)
166 LOCATIONS_NULL_ARG_CHECK(manager);
167 LOCATIONS_NULL_ARG_CHECK(callback);
168 location_manager_s *handle = (location_manager_s *) manager;
169 handle->user_cb[type] = callback;
170 handle->user_data[type] = user_data;
171 LOCATIONS_LOGD("event type : %d", type);
172 return LOCATIONS_ERROR_NONE;
175 int __unset_callback(_location_event_e type, location_manager_h manager)
177 LOCATIONS_NULL_ARG_CHECK(manager);
178 location_manager_s *handle = (location_manager_s *) manager;
179 handle->user_cb[type] = NULL;
180 handle->user_data[type] = NULL;
181 LOCATIONS_LOGD("event type : %d", type);
182 return LOCATIONS_ERROR_NONE;