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)
72 if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value))
73 vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
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(void)
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(void)
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_SOUND_ENABLED, &sound))
104 return RUNTIME_INFO_ERROR_IO_ERROR;
106 if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vib))
107 return RUNTIME_INFO_ERROR_IO_ERROR;
109 if (sound == 0 && vib == 0)
114 return RUNTIME_INFO_ERROR_NONE;
117 int runtime_info_silent_mode_set_event_cb(void)
121 ret = runtime_info_vconf_set_event_cb(VCONF_SOUND_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 0);
122 if (ret != RUNTIME_INFO_ERROR_NONE)
125 ret = runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 1);
126 if (ret != RUNTIME_INFO_ERROR_NONE)
127 runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0);
132 void runtime_info_silent_mode_unset_event_cb(void)
134 runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0);
135 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 1);
138 int runtime_info_vibration_enabled_get_value(runtime_info_value_h value)
142 if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value))
145 value->b = (bool)vconf_value;
147 return RUNTIME_INFO_ERROR_NONE;
150 int runtime_info_vibration_enabled_set_event_cb(void)
152 return runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_VIBRATION_ENABLED, 0);
155 void runtime_info_vibration_enabled_unset_event_cb(void)
157 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 0);
160 int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value)
164 if (runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value))
167 value->b = (bool)vconf_value;
169 return RUNTIME_INFO_ERROR_NONE;
172 int runtime_info_auto_rotation_enabled_set_event_cb(void)
174 return runtime_info_vconf_set_event_cb(VCONF_ROTATION_LOCK_ENABLED, RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, 0);
177 void runtime_info_auto_rotation_enabled_unset_event_cb(void)
179 runtime_info_vconf_unset_event_cb(VCONF_ROTATION_LOCK_ENABLED, 0);
182 int runtime_info_battery_charging_get_value(runtime_info_value_h value)
186 if (runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value))
187 return RUNTIME_INFO_ERROR_IO_ERROR;
189 /* regard not supported as disconnected */
190 if (vconf_value == -ENOTSUP)
193 value->b = vconf_value;
195 return RUNTIME_INFO_ERROR_NONE;
198 int runtime_info_battery_charging_set_event_cb(void)
200 return runtime_info_vconf_set_event_cb(VCONF_BATTERY_CHARGING, RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, 0);
203 void runtime_info_battery_charging_unset_event_cb(void)
205 runtime_info_vconf_unset_event_cb(VCONF_BATTERY_CHARGING, 0);
209 int runtime_info_tvout_connected_get_value(runtime_info_value_h value)
213 if (runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value))
214 vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
216 switch (vconf_value) {
217 case VCONFKEY_SYSMAN_EARJACK_TVOUT:
226 return RUNTIME_INFO_ERROR_NONE;
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)
244 if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value))
245 vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
247 switch (vconf_value) {
248 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
249 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE;
252 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
253 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE;
257 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED;
261 return RUNTIME_INFO_ERROR_NONE;
264 int runtime_info_audio_jack_status_set_event_cb(void)
266 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK_STATUS, RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, 2);
269 void runtime_info_audio_jack_status_unset_event_cb(void)
271 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK_STATUS, 2);
275 int runtime_info_sliding_keyboard_opened_get_value(runtime_info_value_h value)
279 if (runtime_info_vconf_get_value_int(VCONF_SLIDING_KEYBOARD_STATUS, &vconf_value))
280 vconf_value = VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED;
282 switch (vconf_value) {
283 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_AVAILABE:
287 case VCONFKEY_SYSMAN_SLIDING_KEYBOAED_AVAILABLE:
291 case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED:
296 return RUNTIME_INFO_ERROR_IO_ERROR;
299 return RUNTIME_INFO_ERROR_NONE;
302 int runtime_info_sliding_keyboard_opened_set_event_cb(void)
304 return runtime_info_vconf_set_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, 0);
307 void runtime_info_sliding_keyboard_opened_unset_event_cb(void)
309 runtime_info_vconf_unset_event_cb(VCONF_SLIDING_KEYBOARD_STATUS, 0);
313 int runtime_info_usb_connected_get_value(runtime_info_value_h value)
317 if (runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value))
318 vconf_value = VCONFKEY_SYSMAN_USB_DISCONNECTED;
320 switch (vconf_value) {
321 case VCONFKEY_SYSMAN_USB_DISCONNECTED:
325 case VCONFKEY_SYSMAN_USB_CONNECTED:
329 case VCONFKEY_SYSMAN_USB_AVAILABLE:
334 return RUNTIME_INFO_ERROR_IO_ERROR;
337 return RUNTIME_INFO_ERROR_NONE;
340 int runtime_info_usb_connected_set_event_cb(void)
342 return runtime_info_vconf_set_event_cb(VCONF_USB_CONNECTED, RUNTIME_INFO_KEY_USB_CONNECTED, 0);
345 void runtime_info_usb_connected_unset_event_cb(void)
347 runtime_info_vconf_unset_event_cb(VCONF_USB_CONNECTED, 0);
350 int runtime_info_charger_connected_get_value(runtime_info_value_h value)
354 if (runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value))
355 return RUNTIME_INFO_ERROR_IO_ERROR;
357 switch (vconf_value) {
358 case VCONFKEY_SYSMAN_CHARGER_DISCONNECTED:
359 /* regard not supported as disconnected */
364 case VCONFKEY_SYSMAN_CHARGER_CONNECTED:
369 return RUNTIME_INFO_ERROR_IO_ERROR;
372 return RUNTIME_INFO_ERROR_NONE;
375 int runtime_info_charger_connected_set_event_cb(void)
377 return runtime_info_vconf_set_event_cb(VCONF_CHARGER_CONNECTED, RUNTIME_INFO_KEY_CHARGER_CONNECTED, 0);
380 void runtime_info_charger_connected_unset_event_cb(void)
382 runtime_info_vconf_unset_event_cb(VCONF_CHARGER_CONNECTED, 0);
386 int runtime_info_vibration_level_haptic_feedback_get_value(runtime_info_value_h value)
390 if (runtime_info_vconf_get_value_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vconf_value))
391 return RUNTIME_INFO_ERROR_IO_ERROR;
393 value->i = vconf_value;
395 return RUNTIME_INFO_ERROR_NONE;
398 int runtime_info_vibration_level_haptic_feedback_set_event_cb(void)
400 return runtime_info_vconf_set_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, 0);
403 void runtime_info_vibration_level_haptic_feedback_unset_event_cb(void)
405 runtime_info_vconf_unset_event_cb(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, 0);