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_FLIGHT_MODE = VCONFKEY_TELEPHONY_FLIGHT_MODE;
34 static const char *VCONF_AUDIO_JACK = VCONFKEY_SYSMAN_EARJACK;
35 static const char *VCONF_SILENT_MODE = "db/setting/sound/sound_on";
36 static const char *VCONF_VIBRATION_ENABLED = "db/setting/sound/vibration_on";
37 static const char *VCONF_ROTATION_LOCK_ENABLED = VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL;
38 static const char *VCONF_BATTERY_CHARGING = VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW;
39 static const char *VCONF_TVOUT_CONNECTED = VCONFKEY_SYSMAN_EARJACK;
40 static const char *VCONF_AUDIO_JACK_STATUS = VCONFKEY_SYSMAN_EARJACK;
41 static const char *VCONF_SLIDING_KEYBOARD_STATUS = VCONFKEY_SYSMAN_SLIDING_KEYBOARD;
42 static const char *VCONF_USB_CONNECTED = VCONFKEY_SYSMAN_USB_STATUS;
43 static const char *VCONF_CHARGER_CONNECTED = VCONFKEY_SYSMAN_CHARGER_STATUS;
46 int runtime_info_flightmode_get_value(runtime_info_value_h value)
50 if (runtime_info_vconf_get_value_bool(VCONF_FLIGHT_MODE, &vconf_value))
51 return RUNTIME_INFO_ERROR_IO_ERROR;
53 value->b = vconf_value;
55 return RUNTIME_INFO_ERROR_NONE;
58 int runtime_info_flightmode_set_event_cb()
60 return runtime_info_vconf_set_event_cb(VCONF_FLIGHT_MODE, RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, 0);
63 void runtime_info_flightmode_unset_event_cb()
65 runtime_info_vconf_unset_event_cb(VCONF_FLIGHT_MODE, 0);
68 int runtime_info_audiojack_get_value(runtime_info_value_h value)
72 if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value))
73 return RUNTIME_INFO_ERROR_IO_ERROR;
75 switch (vconf_value) {
76 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
77 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
86 return RUNTIME_INFO_ERROR_NONE;
89 int runtime_info_audiojack_set_event_cb()
91 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK, RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, 0);
94 void runtime_info_audiojack_unset_event_cb()
96 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK, 0);
99 int runtime_info_silent_mode_get_value(runtime_info_value_h value)
103 if (runtime_info_vconf_get_value_bool(VCONF_SILENT_MODE, &vconf_value))
104 return RUNTIME_INFO_ERROR_IO_ERROR;
106 value->b = vconf_value;
108 return RUNTIME_INFO_ERROR_NONE;
111 int runtime_info_silent_mode_set_event_cb()
113 return runtime_info_vconf_set_event_cb(VCONF_SILENT_MODE, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 0);
116 void runtime_info_silent_mode_unset_event_cb()
118 runtime_info_vconf_unset_event_cb(VCONF_SILENT_MODE, 0);
121 int runtime_info_vibration_enabled_get_value(runtime_info_value_h value)
125 if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value))
126 return RUNTIME_INFO_ERROR_IO_ERROR;
128 value->b = vconf_value;
130 return RUNTIME_INFO_ERROR_NONE;
133 int runtime_info_vibration_enabled_set_event_cb()
135 return runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_VIBRATION_ENABLED, 0);
138 void runtime_info_vibration_enabled_unset_event_cb()
140 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 0);
143 int runtime_info_rotation_lock_enabled_get_value(runtime_info_value_h value)
147 return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
150 int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value)
154 if (runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value))
155 return RUNTIME_INFO_ERROR_IO_ERROR;
157 value->b = vconf_value;
159 return RUNTIME_INFO_ERROR_NONE;
162 int runtime_info_auto_rotation_enabled_set_event_cb()
164 return runtime_info_vconf_set_event_cb(VCONF_ROTATION_LOCK_ENABLED, RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, 0);
167 void runtime_info_auto_rotation_enabled_unset_event_cb()
169 runtime_info_vconf_unset_event_cb(VCONF_ROTATION_LOCK_ENABLED, 0);
172 int runtime_info_battery_charging_get_value(runtime_info_value_h value)
176 if (runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value))
177 return RUNTIME_INFO_ERROR_IO_ERROR;
179 value->b = vconf_value;
181 return RUNTIME_INFO_ERROR_NONE;
184 int runtime_info_battery_charging_set_event_cb()
186 return runtime_info_vconf_set_event_cb(VCONF_BATTERY_CHARGING, RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, 0);
189 void runtime_info_battery_charging_unset_event_cb()
191 runtime_info_vconf_unset_event_cb(VCONF_BATTERY_CHARGING, 0);
195 int runtime_info_tvout_connected_get_value(runtime_info_value_h value)
199 if (runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value))
200 return RUNTIME_INFO_ERROR_IO_ERROR;
202 switch (vconf_value) {
203 case VCONFKEY_SYSMAN_EARJACK_TVOUT:
212 return RUNTIME_INFO_ERROR_NONE;
215 int runtime_info_tvout_connected_set_event_cb()
217 return runtime_info_vconf_set_event_cb(VCONF_TVOUT_CONNECTED, RUNTIME_INFO_KEY_TV_OUT_CONNECTED, 1);
220 void runtime_info_tvout_connected_unset_event_cb()
222 runtime_info_vconf_unset_event_cb(VCONF_TVOUT_CONNECTED, 1);
226 int runtime_info_audio_jack_status_get_value(runtime_info_value_h value)
230 if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value))
231 return RUNTIME_INFO_ERROR_IO_ERROR;
233 switch (vconf_value) {
234 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
235 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE;
238 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
239 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE;
243 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED;
247 return RUNTIME_INFO_ERROR_NONE;
250 int runtime_info_audio_jack_status_set_event_cb()
252 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK_STATUS, RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, 2);
255 void runtime_info_audio_jack_status_unset_event_cb()
257 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK_STATUS, 2);
261 int runtime_info_sliding_keyboard_opened_get_value(runtime_info_value_h value)
265 if (runtime_info_vconf_get_value_int(VCONF_SLIDING_KEYBOARD_STATUS, &vconf_value))
266 return RUNTIME_INFO_ERROR_IO_ERROR;
268 switch (vconf_value) {
269 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_AVAILABE:
273 case VCONFKEY_SYSMAN_SLIDING_KEYBOAED_AVAILABLE:
277 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED:
282 return RUNTIME_INFO_ERROR_IO_ERROR;
285 return RUNTIME_INFO_ERROR_NONE;
288 int runtime_info_sliding_keyboard_opened_set_event_cb()
290 return runtime_info_vconf_set_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, 0);
293 void runtime_info_sliding_keyboard_opened_unset_event_cb()
295 runtime_info_vconf_unset_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, 0);
299 int runtime_info_usb_connected_get_value(runtime_info_value_h value)
303 if (runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value))
304 return RUNTIME_INFO_ERROR_IO_ERROR;
306 switch (vconf_value) {
307 case VCONFKEY_SYSMAN_USB_DISCONNECTED:
311 case VCONFKEY_SYSMAN_USB_CONNECTED:
315 case VCONFKEY_SYSMAN_USB_AVAILABLE:
320 return RUNTIME_INFO_ERROR_IO_ERROR;
323 return RUNTIME_INFO_ERROR_NONE;
326 int runtime_info_usb_connected_set_event_cb()
328 return runtime_info_vconf_set_event_cb(VCONF_USB_CONNECTED, RUNTIME_INFO_KEY_USB_CONNECTED, 0);
331 void runtime_info_usb_connected_unset_event_cb()
333 runtime_info_vconf_unset_event_cb(VCONF_USB_CONNECTED, 0);
336 int runtime_info_charger_connected_get_value(runtime_info_value_h value)
340 if (runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value))
341 return RUNTIME_INFO_ERROR_IO_ERROR;
343 switch (vconf_value) {
344 case VCONFKEY_SYSMAN_CHARGER_DISCONNECTED:
348 case VCONFKEY_SYSMAN_CHARGER_CONNECTED:
353 return RUNTIME_INFO_ERROR_IO_ERROR;
356 return RUNTIME_INFO_ERROR_NONE;
359 int runtime_info_charger_connected_set_event_cb()
361 return runtime_info_vconf_set_event_cb(VCONF_CHARGER_CONNECTED, RUNTIME_INFO_KEY_CHARGER_CONNECTED, 0);
364 void runtime_info_charger_connected_unset_event_cb()
366 runtime_info_vconf_unset_event_cb(VCONF_CHARGER_CONNECTED, 0);
370 int runtime_info_vibration_level_haptic_feedback_get_value(runtime_info_value_h value)
374 if (runtime_info_vconf_get_value_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vconf_value))
375 return RUNTIME_INFO_ERROR_IO_ERROR;
377 value->i = vconf_value;
379 return RUNTIME_INFO_ERROR_NONE;
382 int runtime_info_vibration_level_haptic_feedback_set_event_cb()
384 return runtime_info_vconf_set_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, 0);
387 void runtime_info_vibration_level_haptic_feedback_unset_event_cb()
389 runtime_info_vconf_unset_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, 0);