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_AUDIO_JACK = VCONFKEY_SYSMAN_EARJACK;
34 static const char *VCONF_VIBRATION_ENABLED = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL;
35 static const char *VCONF_ROTATION_LOCK_ENABLED = VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL;
36 static const char *VCONF_BATTERY_CHARGING = VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW;
37 static const char *VCONF_TVOUT_CONNECTED = VCONFKEY_SYSMAN_EARJACK;
38 static const char *VCONF_AUDIO_JACK_STATUS = VCONFKEY_SYSMAN_EARJACK;
39 static const char *VCONF_USB_CONNECTED = VCONFKEY_SYSMAN_USB_STATUS;
40 static const char *VCONF_CHARGER_CONNECTED = VCONFKEY_SYSMAN_CHARGER_STATUS;
43 int runtime_info_audiojack_get_value(runtime_info_value_h value)
48 ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value);
49 if (ret != RUNTIME_INFO_ERROR_NONE)
52 switch (vconf_value) {
53 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
54 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
66 int runtime_info_audiojack_set_event_cb(void)
68 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK, RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, 0);
71 void runtime_info_audiojack_unset_event_cb(void)
73 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK, 0);
76 int runtime_info_vibration_enabled_get_value(runtime_info_value_h value)
81 ret = runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value);
82 if (ret == RUNTIME_INFO_ERROR_NONE)
83 value->b = (bool)vconf_value;
88 int runtime_info_vibration_enabled_set_event_cb(void)
90 return runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_VIBRATION_ENABLED, 0);
93 void runtime_info_vibration_enabled_unset_event_cb(void)
95 runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 0);
98 int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value)
103 ret = runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value);
104 if (ret == RUNTIME_INFO_ERROR_NONE)
105 value->b = (bool)vconf_value;
110 int runtime_info_auto_rotation_enabled_set_event_cb(void)
112 return runtime_info_vconf_set_event_cb(VCONF_ROTATION_LOCK_ENABLED, RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, 0);
115 void runtime_info_auto_rotation_enabled_unset_event_cb(void)
117 runtime_info_vconf_unset_event_cb(VCONF_ROTATION_LOCK_ENABLED, 0);
120 int runtime_info_battery_charging_get_value(runtime_info_value_h value)
125 ret = runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value);
126 if (ret == RUNTIME_INFO_ERROR_NONE)
127 value->b = vconf_value;
132 int runtime_info_battery_charging_set_event_cb(void)
134 return runtime_info_vconf_set_event_cb(VCONF_BATTERY_CHARGING, RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, 0);
137 void runtime_info_battery_charging_unset_event_cb(void)
139 runtime_info_vconf_unset_event_cb(VCONF_BATTERY_CHARGING, 0);
143 int runtime_info_tvout_connected_get_value(runtime_info_value_h value)
148 ret = runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value);
149 if (ret != RUNTIME_INFO_ERROR_NONE)
152 switch (vconf_value) {
153 case VCONFKEY_SYSMAN_EARJACK_TVOUT:
165 int runtime_info_tvout_connected_set_event_cb(void)
167 return runtime_info_vconf_set_event_cb(VCONF_TVOUT_CONNECTED, RUNTIME_INFO_KEY_TV_OUT_CONNECTED, 1);
170 void runtime_info_tvout_connected_unset_event_cb(void)
172 runtime_info_vconf_unset_event_cb(VCONF_TVOUT_CONNECTED, 1);
176 int runtime_info_audio_jack_status_get_value(runtime_info_value_h value)
181 ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value);
182 if (ret != RUNTIME_INFO_ERROR_NONE)
185 switch (vconf_value) {
186 case VCONFKEY_SYSMAN_EARJACK_3WIRE:
187 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE;
190 case VCONFKEY_SYSMAN_EARJACK_4WIRE:
191 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE;
195 value->i = RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED;
202 int runtime_info_audio_jack_status_set_event_cb(void)
204 return runtime_info_vconf_set_event_cb(VCONF_AUDIO_JACK_STATUS, RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, 2);
207 void runtime_info_audio_jack_status_unset_event_cb(void)
209 runtime_info_vconf_unset_event_cb(VCONF_AUDIO_JACK_STATUS, 2);
212 int runtime_info_usb_connected_get_value(runtime_info_value_h value)
217 ret = runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value);
218 if (ret != RUNTIME_INFO_ERROR_NONE)
221 switch (vconf_value) {
222 case VCONFKEY_SYSMAN_USB_DISCONNECTED:
226 case VCONFKEY_SYSMAN_USB_CONNECTED:
230 case VCONFKEY_SYSMAN_USB_AVAILABLE:
235 return RUNTIME_INFO_ERROR_IO_ERROR;
241 int runtime_info_usb_connected_set_event_cb(void)
243 return runtime_info_vconf_set_event_cb(VCONF_USB_CONNECTED, RUNTIME_INFO_KEY_USB_CONNECTED, 0);
246 void runtime_info_usb_connected_unset_event_cb(void)
248 runtime_info_vconf_unset_event_cb(VCONF_USB_CONNECTED, 0);
251 int runtime_info_charger_connected_get_value(runtime_info_value_h value)
256 ret = runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value);
257 if (ret != RUNTIME_INFO_ERROR_NONE)
260 switch (vconf_value) {
261 case VCONFKEY_SYSMAN_CHARGER_DISCONNECTED:
265 case VCONFKEY_SYSMAN_CHARGER_CONNECTED:
270 return RUNTIME_INFO_ERROR_IO_ERROR;
276 int runtime_info_charger_connected_set_event_cb(void)
278 return runtime_info_vconf_set_event_cb(VCONF_CHARGER_CONNECTED, RUNTIME_INFO_KEY_CHARGER_CONNECTED, 0);
281 void runtime_info_charger_connected_unset_event_cb(void)
283 runtime_info_vconf_unset_event_cb(VCONF_CHARGER_CONNECTED, 0);