* @brief Enumeration for error codes for runtime information.
*/
typedef enum {
- RUNTIME_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ RUNTIME_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
RUNTIME_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- RUNTIME_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- RUNTIME_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when read value from system */
+ RUNTIME_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ RUNTIME_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when read value from system */
+ RUNTIME_INFO_ERROR_REMOTE_IO = TIZEN_ERROR_REMOTE_IO, /**< Remote I/O error occured */
RUNTIME_INFO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the api */
+ RUNTIME_INFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported parameter @if MOBILE (Since 2.3.1) @endif */
} runtime_info_error_e;
/**
* @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
* @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
+ * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
*/
int runtime_info_get_value_int(runtime_info_key_e key, int *value);
* @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
* @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
+ * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
*/
int runtime_info_get_value_bool(runtime_info_key_e key, bool *value);
* @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
* @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
+ * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
*/
int runtime_info_get_value_double(runtime_info_key_e key, double *value);
* @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
* @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY Out of memory
* @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
+ * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
*/
int runtime_info_get_value_string(runtime_info_key_e key, char **value);
* @retval #RUNTIME_INFO_ERROR_NONE Successful
* @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
+ * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
* @post runtime_info_changed_cb() will be invoked.
*
* @see runtime_info_unset_changed_cb()
}
ret = get_value(value);
- if (ret != RUNTIME_INFO_ERROR_NONE) {
- LOGE("ERROR(0x%08x) : fail to get the runtime information / key(%d)", ret, key);
- return ret;
- }
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ LOGE("IO_ERROR(0x%08x) : failed to get the runtime informaion / key(%d)", ret, key);
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
API int runtime_info_get_value_int(runtime_info_key_e key, int *value)
int runtime_info_bt_enabled_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_BT_ENABLED, &vconf_value))
- vconf_value = VCONFKEY_BT_STATUS_OFF;
+ ret = runtime_info_vconf_get_value_int(VCONF_BT_ENABLED, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_BT_STATUS_OFF:
return RUNTIME_INFO_ERROR_IO_ERROR;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_bt_enabled_set_event_cb()
int runtime_info_wifi_hotspot_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_WIFI_HOTSPOT_ENABLED, &vconf_value))
- vconf_value = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
-
- value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? true : false;
+ ret = runtime_info_vconf_get_value_int(VCONF_WIFI_HOTSPOT_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? true : false;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_wifi_hotspot_set_event_cb()
int runtime_info_bt_hotspot_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value))
- vconf_value = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
+ ret = runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? true : false;
- value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? true : false;
-
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_bt_hotspot_set_event_cb()
int runtime_info_usb_hotspot_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_USB_HOTSPOT_ENABLED, &vconf_value))
- vconf_value = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
-
- value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? true : false;
+ ret = runtime_info_vconf_get_value_int(VCONF_USB_HOTSPOT_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? true : false;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_usb_hotspot_set_event_cb()
int runtime_info_packet_data_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_bool(VCONF_PACKET_DATA_ENABLED, &vconf_value))
- vconf_value = 0;
-
- value->b = (bool)vconf_value;
+ ret = runtime_info_vconf_get_value_bool(VCONF_PACKET_DATA_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (bool)vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_packet_data_set_event_cb()
int runtime_info_data_roaming_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_bool(VCONF_DATA_ROAMING_ENABLED, &vconf_value))
- vconf_value = 0;
+ ret = runtime_info_vconf_get_value_bool(VCONF_DATA_ROAMING_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (bool)vconf_value;
- value->b = (bool)vconf_value;
-
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_data_roaming_set_event_cb()
int runtime_info_gps_status_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_GPS_STATUS, &vconf_value))
- vconf_value = VCONFKEY_LOCATION_GPS_OFF;
+ ret = runtime_info_vconf_get_value_int(VCONF_GPS_STATUS, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_LOCATION_GPS_OFF:
return RUNTIME_INFO_ERROR_IO_ERROR;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_gps_status_set_event_cb()
int runtime_info_location_service_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_LOCATION_SERVICE_ENABLED, &vconf_value))
- vconf_value = 0;
+ ret = runtime_info_vconf_get_value_int(VCONF_LOCATION_SERVICE_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = vconf_value;
- value->b = vconf_value;
-
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_location_service_set_event_cb()
int runtime_info_location_agps_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_LOCATION_AGPS_ENABLED, &vconf_value))
- vconf_value = 0;
-
- value->b = vconf_value;
+ ret = runtime_info_vconf_get_value_int(VCONF_LOCATION_AGPS_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_location_agps_set_event_cb()
int runtime_info_location_network_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value))
- vconf_value = 0;
-
- value->b = vconf_value;
+ ret = runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_location_network_set_event_cb()
int runtime_info_audiojack_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value))
- vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
+ ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_SYSMAN_EARJACK_3WIRE:
break;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_audiojack_set_event_cb(void)
int runtime_info_vibration_enabled_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value))
- vconf_value = 0;
-
- value->b = (bool)vconf_value;
+ ret = runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (bool)vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_vibration_enabled_set_event_cb(void)
int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value))
- vconf_value = 0;
-
- value->b = (bool)vconf_value;
+ ret = runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = (bool)vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_auto_rotation_enabled_set_event_cb(void)
int runtime_info_battery_charging_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value))
- return RUNTIME_INFO_ERROR_IO_ERROR;
-
- /* regard not supported as disconnected */
- if (vconf_value == -ENOTSUP)
- vconf_value = false;
-
- value->b = vconf_value;
+ ret = runtime_info_vconf_get_value_int(VCONF_BATTERY_CHARGING, &vconf_value);
+ if (ret == RUNTIME_INFO_ERROR_NONE)
+ value->b = vconf_value;
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_battery_charging_set_event_cb(void)
int runtime_info_tvout_connected_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value))
- vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
+ ret = runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_SYSMAN_EARJACK_TVOUT:
break;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_tvout_connected_set_event_cb(void)
int runtime_info_audio_jack_status_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value))
- vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED;
+ ret = runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_SYSMAN_EARJACK_3WIRE:
break;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_audio_jack_status_set_event_cb(void)
int runtime_info_usb_connected_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value))
- vconf_value = VCONFKEY_SYSMAN_USB_DISCONNECTED;
+ ret = runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_SYSMAN_USB_DISCONNECTED:
return RUNTIME_INFO_ERROR_IO_ERROR;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_usb_connected_set_event_cb(void)
int runtime_info_charger_connected_get_value(runtime_info_value_h value)
{
int vconf_value;
+ int ret;
- if (runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value))
- return RUNTIME_INFO_ERROR_IO_ERROR;
+ ret = runtime_info_vconf_get_value_int(VCONF_CHARGER_CONNECTED, &vconf_value);
+ if (ret != RUNTIME_INFO_ERROR_NONE)
+ return ret;
switch (vconf_value) {
case VCONFKEY_SYSMAN_CHARGER_DISCONNECTED:
- /* regard not supported as disconnected */
- case -ENOTSUP:
value->b = false;
break;
return RUNTIME_INFO_ERROR_IO_ERROR;
}
- return RUNTIME_INFO_ERROR_NONE;
+ return ret;
}
int runtime_info_charger_connected_set_event_cb(void)
#define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO"
+#define CHECK_VCONF_RESULT(ret) \
+ do { \
+ if (ret < 0) { \
+ ret = vconf_get_ext_errno(); \
+ if (ret == VCONF_ERROR_FILE_NO_ENT) \
+ ret = RUNTIME_INFO_ERROR_NOT_SUPPORTED; \
+ else \
+ ret = RUNTIME_INFO_ERROR_IO_ERROR; \
+ } else { \
+ ret = RUNTIME_INFO_ERROR_NONE; \
+ } \
+ } while (0);
+
int runtime_info_vconf_get_value_int(const char *vconf_key, int *value)
{
- return vconf_get_int(vconf_key, value);
+ int ret = vconf_get_int(vconf_key, value);
+ CHECK_VCONF_RESULT(ret);
+ return ret;
}
int runtime_info_vconf_get_value_bool(const char *vconf_key, int *value)
{
- return vconf_get_bool(vconf_key, value);
+ int ret = vconf_get_bool(vconf_key, value);
+ CHECK_VCONF_RESULT(ret);
+ return ret;
}
int runtime_info_vconf_get_value_double(const char *vconf_key, double *value)
{
- return vconf_get_dbl(vconf_key, value);
+ int ret = vconf_get_dbl(vconf_key, value);
+ CHECK_VCONF_RESULT(ret);
+ return ret;
}
int runtime_info_vconf_get_value_string(const char *vconf_key, char **value)
{
char *str_value = NULL;
+ int ret;
str_value = vconf_get_str(vconf_key);
-
- if (str_value != NULL) {
- *value = str_value;
- return 0;
- } else {
- return -1;
+ if (!str_value) {
+ ret = -1;
+ CHECK_VCONF_RESULT(ret);
+ return ret;
}
+
+ *value = str_value;
+ return RUNTIME_INFO_ERROR_NONE;
}
typedef void (*runtime_info_vconf_event_cb)(keynode_t *node, void *event_data);
int runtime_info_vconf_set_event_cb(const char *vconf_key, runtime_info_key_e runtime_info_key, int slot)
{
runtime_info_vconf_event_cb vconf_event_cb;
+ int ret;
vconf_event_cb = runtime_info_vconf_get_event_cb_slot(slot);
if (vconf_event_cb == NULL)
return RUNTIME_INFO_ERROR_IO_ERROR;
- if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)runtime_info_key))
- return RUNTIME_INFO_ERROR_IO_ERROR;
-
- return RUNTIME_INFO_ERROR_NONE;
+ ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)runtime_info_key);
+ CHECK_VCONF_RESULT(ret);
+ return ret;
}
void runtime_info_vconf_unset_event_cb(const char *vconf_key, int slot)