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_SOUND_ENABLED = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL;
36 static const char *VCONF_VIBRATION_ENABLED = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL;
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))
53 value->b = (bool)vconf_value;
55 return RUNTIME_INFO_ERROR_NONE;
58 int runtime_info_flightmode_set_event_cb(void)
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(void)
65 runtime_info_vconf_unset_event_cb(VCONF_FLIGHT_MODE, 0);
68 int runtime_info_audiojack_get_value(runtime_info_value_h value)
73 ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value);
74 if (ret != RUNTIME_INFO_ERROR_NONE)
77 switch (vconf_value) {
78 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
79 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
91 int runtime_info_audiojack_set_event_cb(void)
93 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK, RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, 0);
96 void runtime_info_audiojack_unset_event_cb(void)
98 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK, 0);
101 int runtime_info_silent_mode_get_value(runtime_info_value_h value)
105 if (runtime_info_vconf_get_value_bool(VCONF_SOUND_ENABLED, &sound))
106 return RUNTIME_INFO_ERROR_IO_ERROR;
108 if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vib))
109 return RUNTIME_INFO_ERROR_IO_ERROR;
111 if (sound == 0 && vib == 0)
116 return RUNTIME_INFO_ERROR_NONE;
119 int runtime_info_silent_mode_set_event_cb(void)
123 ret = runtime_info_vconf_set_event_cb(VCONF_SOUND_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 0);
124 if (ret != RUNTIME_INFO_ERROR_NONE)
127 ret = runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 1);
128 if (ret != RUNTIME_INFO_ERROR_NONE)
129 runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0);
134 void runtime_info_silent_mode_unset_event_cb(void)
136 runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0);
137 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 1);
140 int runtime_info_vibration_enabled_get_value(runtime_info_value_h value)
145 ret = runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value);
146 if (ret == RUNTIME_INFO_ERROR_NONE)
147 value->b = (bool)vconf_value;
152 int runtime_info_vibration_enabled_set_event_cb(void)
154 return runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_VIBRATION_ENABLED, 0);
157 void runtime_info_vibration_enabled_unset_event_cb(void)
159 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 0);
162 int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value)
167 ret = runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value);
168 if (ret == RUNTIME_INFO_ERROR_NONE)
169 value->b = (bool)vconf_value;
174 int runtime_info_auto_rotation_enabled_set_event_cb(void)
176 return runtime_info_vconf_set_event_cb(VCONF_ROTATION_LOCK_ENABLED, RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, 0);
179 void runtime_info_auto_rotation_enabled_unset_event_cb(void)
181 runtime_info_vconf_unset_event_cb(VCONF_ROTATION_LOCK_ENABLED, 0);
184 int runtime_info_battery_charging_get_value(runtime_info_value_h value)
189 ret = runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value);
190 if (ret == RUNTIME_INFO_ERROR_NONE)
191 value->b = vconf_value;
196 int runtime_info_battery_charging_set_event_cb(void)
198 return runtime_info_vconf_set_event_cb(VCONF_BATTERY_CHARGING, RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, 0);
201 void runtime_info_battery_charging_unset_event_cb(void)
203 runtime_info_vconf_unset_event_cb(VCONF_BATTERY_CHARGING, 0);
207 int runtime_info_tvout_connected_get_value(runtime_info_value_h value)
212 ret = runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value);
213 if (ret != RUNTIME_INFO_ERROR_NONE)
216 switch (vconf_value) {
217 case VCONFKEY_SYSMAN_EARJACK_TVOUT:
229 int runtime_info_tvout_connected_set_event_cb(void)
231 return runtime_info_vconf_set_event_cb(VCONF_TVOUT_CONNECTED, RUNTIME_INFO_KEY_TV_OUT_CONNECTED, 1);
234 void runtime_info_tvout_connected_unset_event_cb(void)
236 runtime_info_vconf_unset_event_cb(VCONF_TVOUT_CONNECTED, 1);
240 int runtime_info_audio_jack_status_get_value(runtime_info_value_h value)
245 ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value);
246 if (ret != RUNTIME_INFO_ERROR_NONE)
249 switch (vconf_value) {
250 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
251 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE;
254 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
255 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE;
259 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED;
266 int runtime_info_audio_jack_status_set_event_cb(void)
268 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK_STATUS, RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, 2);
271 void runtime_info_audio_jack_status_unset_event_cb(void)
273 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK_STATUS, 2);
277 int runtime_info_sliding_keyboard_opened_get_value(runtime_info_value_h value)
281 if (runtime_info_vconf_get_value_int(VCONF_SLIDING_KEYBOARD_STATUS, &vconf_value))
282 vconf_value = VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED;
284 switch (vconf_value) {
285 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_AVAILABE:
289 case VCONFKEY_SYSMAN_SLIDING_KEYBOAED_AVAILABLE:
293 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED:
298 return RUNTIME_INFO_ERROR_IO_ERROR;
301 return RUNTIME_INFO_ERROR_NONE;
304 int runtime_info_sliding_keyboard_opened_set_event_cb(void)
306 return runtime_info_vconf_set_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, 0);
309 void runtime_info_sliding_keyboard_opened_unset_event_cb(void)
311 runtime_info_vconf_unset_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, 0);
315 int runtime_info_usb_connected_get_value(runtime_info_value_h value)
320 ret = runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value);
321 if (ret != RUNTIME_INFO_ERROR_NONE)
324 switch (vconf_value) {
325 case VCONFKEY_SYSMAN_USB_DISCONNECTED:
329 case VCONFKEY_SYSMAN_USB_CONNECTED:
333 case VCONFKEY_SYSMAN_USB_AVAILABLE:
338 return RUNTIME_INFO_ERROR_IO_ERROR;
344 int runtime_info_usb_connected_set_event_cb(void)
346 return runtime_info_vconf_set_event_cb(VCONF_USB_CONNECTED, RUNTIME_INFO_KEY_USB_CONNECTED, 0);
349 void runtime_info_usb_connected_unset_event_cb(void)
351 runtime_info_vconf_unset_event_cb(VCONF_USB_CONNECTED, 0);
354 int runtime_info_charger_connected_get_value(runtime_info_value_h value)
359 ret = runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value);
360 if (ret != RUNTIME_INFO_ERROR_NONE)
363 switch (vconf_value) {
364 case VCONFKEY_SYSMAN_CHARGER_DISCONNECTED:
368 case VCONFKEY_SYSMAN_CHARGER_CONNECTED:
373 return RUNTIME_INFO_ERROR_IO_ERROR;
379 int runtime_info_charger_connected_set_event_cb(void)
381 return runtime_info_vconf_set_event_cb(VCONF_CHARGER_CONNECTED, RUNTIME_INFO_KEY_CHARGER_CONNECTED, 0);
384 void runtime_info_charger_connected_unset_event_cb(void)
386 runtime_info_vconf_unset_event_cb(VCONF_CHARGER_CONNECTED, 0);
390 int runtime_info_vibration_level_haptic_feedback_get_value(runtime_info_value_h value)
394 if (runtime_info_vconf_get_value_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vconf_value))
395 return RUNTIME_INFO_ERROR_IO_ERROR;
397 value->i = vconf_value;
399 return RUNTIME_INFO_ERROR_NONE;
402 int runtime_info_vibration_level_haptic_feedback_set_event_cb(void)
404 return runtime_info_vconf_set_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, 0);
407 void runtime_info_vibration_level_haptic_feedback_unset_event_cb(void)
409 runtime_info_vconf_unset_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, 0);