2 * Copyright (c) 2011 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.
24 #include <runtime_info.h>
25 #include <runtime_info_private.h>
31 #define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO"
33 static const char *VCONF_WIFI_STATUS = VCONFKEY_WIFI_STATE;
34 static const char *VCONF_BT_ENABLED = VCONFKEY_BT_STATUS;
35 static const char *VCONF_WIFI_HOTSPOT_ENABLED = VCONFKEY_MOBILE_HOTSPOT_MODE;
36 static const char *VCONF_BT_HOTSPOT_ENABLED = VCONFKEY_MOBILE_HOTSPOT_MODE;
37 static const char *VCONF_USB_HOTSPOT_ENABLED = VCONFKEY_MOBILE_HOTSPOT_MODE;
38 static const char *VCONF_PACKET_DATA_ENABLED = VCONFKEY_3G_ENABLE;
39 static const char *VCONF_DATA_ROAMING_ENABLED = VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL;
40 static const char *VCONF_GPS_STATUS = VCONFKEY_LOCATION_GPS_STATE;
42 int runtime_info_wifi_status_get_value(runtime_info_value_h value)
47 ret = runtime_info_vconf_get_value_int(VCONF_WIFI_STATUS, &vconf_value);
48 if (ret != RUNTIME_INFO_ERROR_NONE)
51 switch (vconf_value) {
52 case VCONFKEY_WIFI_OFF:
53 value->i = RUNTIME_INFO_WIFI_STATUS_DISABLED;
56 case VCONFKEY_WIFI_UNCONNECTED:
57 value->i = RUNTIME_INFO_WIFI_STATUS_UNCONNECTED;
60 case VCONFKEY_WIFI_CONNECTED:
61 case VCONFKEY_WIFI_TRANSFER:
62 value->i = RUNTIME_INFO_WIFI_STATUS_CONNECTED;
66 return RUNTIME_INFO_ERROR_IO_ERROR;
72 int runtime_info_wifi_status_set_event_cb()
74 return runtime_info_vconf_set_event_cb(VCONF_WIFI_STATUS, RUNTIME_INFO_KEY_WIFI_STATUS, 0);
77 void runtime_info_wifi_status_unset_event_cb()
79 runtime_info_vconf_unset_event_cb(VCONF_WIFI_STATUS, 0);
82 int runtime_info_bt_enabled_get_value(runtime_info_value_h value)
87 ret = runtime_info_vconf_get_value_int(VCONF_BT_ENABLED, &vconf_value);
88 if (ret != RUNTIME_INFO_ERROR_NONE)
91 switch (vconf_value) {
92 case VCONFKEY_BT_STATUS_OFF:
96 case VCONFKEY_BT_STATUS_ON:
97 case VCONFKEY_BT_STATUS_BT_VISIBLE:
98 case VCONFKEY_BT_STATUS_TRANSFER:
103 return RUNTIME_INFO_ERROR_IO_ERROR;
109 int runtime_info_bt_enabled_set_event_cb()
111 return runtime_info_vconf_set_event_cb(VCONF_BT_ENABLED, RUNTIME_INFO_KEY_BLUETOOTH_ENABLED, 0);
114 void runtime_info_bt_enabled_unset_event_cb()
116 runtime_info_vconf_unset_event_cb(VCONF_BT_ENABLED, 0);
120 int runtime_info_wifi_hotspot_get_value(runtime_info_value_h value)
125 ret = runtime_info_vconf_get_value_int(VCONF_WIFI_HOTSPOT_ENABLED, &vconf_value);
126 if (ret == RUNTIME_INFO_ERROR_NONE)
127 value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? true : false;
132 int runtime_info_wifi_hotspot_set_event_cb()
134 return runtime_info_vconf_set_event_cb(VCONF_WIFI_HOTSPOT_ENABLED, RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED, 0);
137 void runtime_info_wifi_hotspot_unset_event_cb()
139 runtime_info_vconf_unset_event_cb(VCONF_WIFI_HOTSPOT_ENABLED, 0);
142 int runtime_info_bt_hotspot_get_value(runtime_info_value_h value)
147 ret = runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value);
148 if (ret == RUNTIME_INFO_ERROR_NONE)
149 value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? true : false;
154 int runtime_info_bt_hotspot_set_event_cb()
156 return runtime_info_vconf_set_event_cb(VCONF_BT_HOTSPOT_ENABLED, RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED, 0);
159 void runtime_info_bt_hotspot_unset_event_cb()
161 runtime_info_vconf_unset_event_cb(VCONF_BT_HOTSPOT_ENABLED, 0);
164 int runtime_info_usb_hotspot_get_value(runtime_info_value_h value)
169 ret = runtime_info_vconf_get_value_int(VCONF_USB_HOTSPOT_ENABLED, &vconf_value);
170 if (ret == RUNTIME_INFO_ERROR_NONE)
171 value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? true : false;
176 int runtime_info_usb_hotspot_set_event_cb()
178 return runtime_info_vconf_set_event_cb(VCONF_USB_HOTSPOT_ENABLED, RUNTIME_INFO_KEY_USB_TETHERING_ENABLED, 0);
181 void runtime_info_usb_hotspot_unset_event_cb()
183 runtime_info_vconf_unset_event_cb(VCONF_USB_HOTSPOT_ENABLED, 0);
186 int runtime_info_packet_data_get_value(runtime_info_value_h value)
191 ret = runtime_info_vconf_get_value_bool(VCONF_PACKET_DATA_ENABLED, &vconf_value);
192 if (ret == RUNTIME_INFO_ERROR_NONE)
193 value->b = (bool)vconf_value;
198 int runtime_info_packet_data_set_event_cb()
200 return runtime_info_vconf_set_event_cb(VCONF_PACKET_DATA_ENABLED, RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, 0);
203 void runtime_info_packet_data_unset_event_cb()
205 runtime_info_vconf_unset_event_cb(VCONF_PACKET_DATA_ENABLED, 0);
208 int runtime_info_data_roaming_get_value(runtime_info_value_h value)
213 ret = runtime_info_vconf_get_value_bool(VCONF_DATA_ROAMING_ENABLED, &vconf_value);
214 if (ret == RUNTIME_INFO_ERROR_NONE)
215 value->b = (bool)vconf_value;
220 int runtime_info_data_roaming_set_event_cb()
222 return runtime_info_vconf_set_event_cb(VCONF_DATA_ROAMING_ENABLED, RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, 0);
225 void runtime_info_data_roaming_unset_event_cb()
227 runtime_info_vconf_unset_event_cb(VCONF_DATA_ROAMING_ENABLED, 0);
230 int runtime_info_gps_status_get_value(runtime_info_value_h value)
235 ret = runtime_info_vconf_get_value_int(VCONF_GPS_STATUS, &vconf_value);
236 if (ret != RUNTIME_INFO_ERROR_NONE)
239 switch (vconf_value) {
240 case VCONFKEY_LOCATION_GPS_OFF:
241 value->i = RUNTIME_INFO_GPS_STATUS_DISABLED;
244 case VCONFKEY_LOCATION_GPS_SEARCHING:
245 value->i = RUNTIME_INFO_GPS_STATUS_SEARCHING;
248 case VCONFKEY_LOCATION_GPS_CONNECTED:
249 value->i = RUNTIME_INFO_GPS_STATUS_CONNECTED;
253 return RUNTIME_INFO_ERROR_IO_ERROR;
259 int runtime_info_gps_status_set_event_cb()
261 return runtime_info_vconf_set_event_cb(VCONF_GPS_STATUS, RUNTIME_INFO_KEY_GPS_STATUS, 0);
264 void runtime_info_gps_status_unset_event_cb()
266 runtime_info_vconf_unset_event_cb(VCONF_GPS_STATUS, 0);