From: Jiyoung Yun Date: Mon, 9 Feb 2015 06:53:15 +0000 (+0900) Subject: runtime-info: Merge Tizen 2.3 source code into tizen branch X-Git-Tag: submit/tizen/20150210.060027^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F35102%2F3;p=platform%2Fcore%2Fapi%2Fruntime-info.git runtime-info: Merge Tizen 2.3 source code into tizen branch Details: https://developer.tizen.org/dev-guide/native/2.3.0/org.tizen.mobile.native.apireference/group__CAPI__SYSTEM__RUNTIME__INFO__MODULE.html Signed-off-by: Jiyoung Yun Change-Id: I0c49d941e426b1c6b1369bc15377b9bf65c81843 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5add3fb..70ed8d7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -29,7 +29,7 @@ ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DSLP_DEBUG") -SET(CMAKE_EXE_LINKER_FLAGS "-fvisibility=hidden -Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") aux_source_directory(src SOURCES) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) diff --git a/doc/runtime_info_doc.h b/doc/runtime_info_doc.h new file mode 100644 index 0000000..77dbb8d --- /dev/null +++ b/doc/runtime_info_doc.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_SYSTEM_RUNTIME_INFO_DOC_H__ +#define __TIZEN_SYSTEM_RUNTIME_INFO_DOC_H__ + +/** + * @ingroup CAPI_SYSTEM_FRAMEWORK + * @defgroup CAPI_SYSTEM_RUNTIME_INFO_MODULE Runtime information + * @brief The Runtime Information API provides functions to obtain runtime information. + * + * @section CAPI_SYSTEM_RUNTIME_INFO_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_SYSTEM_RUNTIME_INFO_MODULE_OVERVIEW Overview + * The Runtime Information API provides functions to obtain runtime information, containing miscellaneous system preference. + * The Runtime Information available is stored in key/value pairs, where there may be different data types for the value. + * + * The runtime_info_set_changed_cb() registers a callback function for a particular key, which will be invoked by the System Service if the state matching that key changes. +* +*/ + +#endif /* __TIZEN_SYSTEM_RUNTIME_INFO_DOC_H__ */ diff --git a/include/runtime_info.h b/include/runtime_info.h index ba730de..439f997 100644 --- a/include/runtime_info.h +++ b/include/runtime_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -30,162 +30,200 @@ extern "C" */ /** - * @brief Enumeration of error code for runtime information + * @brief Enumeration for error codes for runtime information. */ typedef enum { - 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_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_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the api */ } runtime_info_error_e; /** - * @brief Enumeration of key for runtime information + * @brief Enumeration for keys for runtime information.. */ typedef enum { - RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, /** - - - - diff --git a/packaging/capi-system-runtime-info.manifest b/packaging/capi-system-runtime-info.manifest index c00c25b..97e8c31 100644 --- a/packaging/capi-system-runtime-info.manifest +++ b/packaging/capi-system-runtime-info.manifest @@ -1,5 +1,5 @@ - - - + + + diff --git a/packaging/capi-system-runtime-info.spec b/packaging/capi-system-runtime-info.spec index 96bf54a..7805681 100644 --- a/packaging/capi-system-runtime-info.spec +++ b/packaging/capi-system-runtime-info.spec @@ -1,22 +1,24 @@ Name: capi-system-runtime-info -Summary: A Runtime Information library in Tizen Native API +Summary: A Runtime Information library in Core API Version: 0.0.3 Release: 0 Group: System/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest -Source1002: %{name}-devel.manifest + BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-base-common) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig %description -A Runtime Information library in Tizen Native API. + %package devel -Summary: A Runtime Information library in Tizen Native API (Development) +Summary: A Runtime Information library in Core API (Development) Group: Development/System Requires: %{name} = %{version}-%{release} Requires: pkgconfig(capi-base-common) @@ -28,8 +30,7 @@ Requires: pkgconfig(capi-base-common) %prep %setup -q -cp %{SOURCE1001} %{SOURCE1002} . - +cp %{SOURCE1001} . %build MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` @@ -52,7 +53,6 @@ make %{?jobs:-j%jobs} %{_libdir}/lib*.so.* %files devel -%manifest %{name}-devel.manifest %{_includedir}/system/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/lib*.so diff --git a/src/runtime_info.c b/src/runtime_info.c index 946e52f..f423341 100644 --- a/src/runtime_info.c +++ b/src/runtime_info.c @@ -136,15 +136,6 @@ runtime_info_item_s runtime_info_item_table[] = { NULL }, -{ - RUNTIME_INFO_KEY_LOCATION_SENSOR_AIDING_ENABLED, /**b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? true : false; @@ -140,7 +140,7 @@ int runtime_info_bt_hotspot_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_BT_HOTSPOT_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE; value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? true : false; @@ -162,7 +162,7 @@ int runtime_info_usb_hotspot_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_USB_HOTSPOT_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE; value->b = (vconf_value&VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? true : false; @@ -181,12 +181,12 @@ void runtime_info_usb_hotspot_unset_event_cb() int runtime_info_packet_data_get_value(runtime_info_value_h value) { - bool vconf_value; + int vconf_value; if (runtime_info_vconf_get_value_bool(VCONF_PACKET_DATA_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; - value->b = vconf_value; + value->b = (bool)vconf_value; return RUNTIME_INFO_ERROR_NONE; } @@ -203,12 +203,12 @@ void runtime_info_packet_data_unset_event_cb() int runtime_info_data_roaming_get_value(runtime_info_value_h value) { - bool vconf_value; + int vconf_value; if (runtime_info_vconf_get_value_bool(VCONF_DATA_ROAMING_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; - value->b = vconf_value; + value->b = (bool)vconf_value; return RUNTIME_INFO_ERROR_NONE; } @@ -228,7 +228,7 @@ int runtime_info_gps_status_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_GPS_STATUS, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_LOCATION_GPS_OFF; switch (vconf_value) { case VCONFKEY_LOCATION_GPS_OFF: diff --git a/src/runtime_info_locale.c b/src/runtime_info_locale.c index ea133b3..36bc70c 100644 --- a/src/runtime_info_locale.c +++ b/src/runtime_info_locale.c @@ -30,8 +30,8 @@ #define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO" -static const char *VCONF_24HOUR_FORMAT = "db/menu_widget/regionformat_time1224"; -static const char *VCONF_FIRST_DAY_OF_WEEK = "db/setting/weekofday_format"; +static const char *VCONF_24HOUR_FORMAT = VCONFKEY_REGIONFORMAT_TIME1224; +static const char *VCONF_FIRST_DAY_OF_WEEK = VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT; static const char *VCONF_LANGUAGE = VCONFKEY_LANGSET; static const char *VCONF_REGION = VCONFKEY_REGIONFORMAT; diff --git a/src/runtime_info_location.c b/src/runtime_info_location.c index c041063..09b6645 100644 --- a/src/runtime_info_location.c +++ b/src/runtime_info_location.c @@ -31,16 +31,15 @@ #define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO" static const char *VCONF_LOCATION_SERVICE_ENABLED = VCONFKEY_LOCATION_ENABLED; -static const char *VCONF_LOCATION_AGPS_ENABLED = "db/location/setting/AgpsEnabled"; +static const char *VCONF_LOCATION_AGPS_ENABLED = VCONFKEY_LOCATION_AGPS_ENABLED; static const char *VCONF_LOCATION_NETWORK_ENABLED = VCONFKEY_LOCATION_NETWORK_ENABLED; -static const char *VCONF_LOCATION_SENSOR_ENABLED = "db/location/setting/SensorEnabled"; int runtime_info_location_service_get_value(runtime_info_value_h value) { int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_LOCATION_SERVICE_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; value->b = vconf_value; @@ -62,7 +61,7 @@ int runtime_info_location_agps_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_LOCATION_AGPS_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; value->b = vconf_value; @@ -84,7 +83,7 @@ int runtime_info_location_network_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; value->b = vconf_value; @@ -100,26 +99,3 @@ void runtime_info_location_network_unset_event_cb() { runtime_info_vconf_unset_event_cb(VCONF_LOCATION_NETWORK_ENABLED, 0); } - -int runtime_info_location_sensor_get_value(runtime_info_value_h value) -{ - int vconf_value; - - if (runtime_info_vconf_get_value_int(VCONF_LOCATION_SENSOR_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; - - value->b = vconf_value; - - return RUNTIME_INFO_ERROR_NONE; -} - -int runtime_info_location_sensor_set_event_cb() -{ - return runtime_info_vconf_set_event_cb(VCONF_LOCATION_SENSOR_ENABLED, RUNTIME_INFO_KEY_LOCATION_SENSOR_AIDING_ENABLED, 0); -} - -void runtime_info_location_sensor_unset_event_cb() -{ - runtime_info_vconf_unset_event_cb(VCONF_LOCATION_SENSOR_ENABLED, 0); -} - diff --git a/src/runtime_info_system.c b/src/runtime_info_system.c index f244772..322f5a8 100644 --- a/src/runtime_info_system.c +++ b/src/runtime_info_system.c @@ -32,8 +32,8 @@ static const char *VCONF_FLIGHT_MODE = VCONFKEY_TELEPHONY_FLIGHT_MODE; static const char *VCONF_AUDIO_JACK = VCONFKEY_SYSMAN_EARJACK; -static const char *VCONF_SILENT_MODE = "db/setting/sound/sound_on"; -static const char *VCONF_VIBRATION_ENABLED = "db/setting/sound/vibration_on"; +static const char *VCONF_SOUND_ENABLED = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL; +static const char *VCONF_VIBRATION_ENABLED = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL; static const char *VCONF_ROTATION_LOCK_ENABLED = VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL; static const char *VCONF_BATTERY_CHARGING = VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW; static const char *VCONF_TVOUT_CONNECTED = VCONFKEY_SYSMAN_EARJACK; @@ -45,12 +45,12 @@ static const char *VCONF_CHARGER_CONNECTED = VCONFKEY_SYSMAN_CHARGER_STATUS; int runtime_info_flightmode_get_value(runtime_info_value_h value) { - bool vconf_value; + int vconf_value; if (runtime_info_vconf_get_value_bool(VCONF_FLIGHT_MODE, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; - value->b = vconf_value; + value->b = (bool)vconf_value; return RUNTIME_INFO_ERROR_NONE; } @@ -70,7 +70,7 @@ int runtime_info_audiojack_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED; switch (vconf_value) { case VCONFKEY_SYSMAN_EARJACK_3WIRE: @@ -98,34 +98,51 @@ void runtime_info_audiojack_unset_event_cb(void) int runtime_info_silent_mode_get_value(runtime_info_value_h value) { - bool vconf_value; + int sound, vib; - if (runtime_info_vconf_get_value_bool(VCONF_SILENT_MODE, &vconf_value)) + if (runtime_info_vconf_get_value_bool(VCONF_SOUND_ENABLED, &sound)) return RUNTIME_INFO_ERROR_IO_ERROR; - value->b = vconf_value; + if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vib)) + return RUNTIME_INFO_ERROR_IO_ERROR; + + if (sound == 0 && vib == 0) + value->b = true; + else + value->b = false; return RUNTIME_INFO_ERROR_NONE; } int runtime_info_silent_mode_set_event_cb(void) { - return runtime_info_vconf_set_event_cb(VCONF_SILENT_MODE, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 0); + int ret; + + ret = runtime_info_vconf_set_event_cb(VCONF_SOUND_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 0); + if (ret != RUNTIME_INFO_ERROR_NONE) + return ret; + + ret = runtime_info_vconf_set_event_cb(VCONF_VIBRATION_ENABLED, RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, 1); + if (ret != RUNTIME_INFO_ERROR_NONE) + runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0); + + return ret; } void runtime_info_silent_mode_unset_event_cb(void) { - runtime_info_vconf_unset_event_cb(VCONF_SILENT_MODE, 0); + runtime_info_vconf_unset_event_cb(VCONF_SOUND_ENABLED, 0); + runtime_info_vconf_unset_event_cb(VCONF_VIBRATION_ENABLED, 1); } int runtime_info_vibration_enabled_get_value(runtime_info_value_h value) { - bool vconf_value; + int vconf_value; if (runtime_info_vconf_get_value_bool(VCONF_VIBRATION_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; - value->b = vconf_value; + value->b = (bool)vconf_value; return RUNTIME_INFO_ERROR_NONE; } @@ -142,12 +159,12 @@ void runtime_info_vibration_enabled_unset_event_cb(void) int runtime_info_auto_rotation_enabled_get_value(runtime_info_value_h value) { - bool vconf_value; + int vconf_value; if (runtime_info_vconf_get_value_bool(VCONF_ROTATION_LOCK_ENABLED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = 0; - value->b = vconf_value; + value->b = (bool)vconf_value; return RUNTIME_INFO_ERROR_NONE; } @@ -190,7 +207,7 @@ int runtime_info_tvout_connected_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_TVOUT_CONNECTED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED; switch (vconf_value) { case VCONFKEY_SYSMAN_EARJACK_TVOUT: @@ -221,7 +238,7 @@ int runtime_info_audio_jack_status_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_AUDIO_JACK_STATUS, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_SYSMAN_EARJACK_REMOVED; switch (vconf_value) { case VCONFKEY_SYSMAN_EARJACK_3WIRE: @@ -256,7 +273,7 @@ int runtime_info_sliding_keyboard_opened_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_SLIDING_KEYBOARD_STATUS, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_SUPPORTED; switch (vconf_value) { case VCONFKEY_SYSMAN_SLIDING_KEYBOARD_NOT_AVAILABE: @@ -294,7 +311,7 @@ int runtime_info_usb_connected_get_value(runtime_info_value_h value) int vconf_value; if (runtime_info_vconf_get_value_int(VCONF_USB_CONNECTED, &vconf_value)) - return RUNTIME_INFO_ERROR_IO_ERROR; + vconf_value = VCONFKEY_SYSMAN_USB_DISCONNECTED; switch (vconf_value) { case VCONFKEY_SYSMAN_USB_DISCONNECTED: @@ -367,7 +384,7 @@ int runtime_info_vibration_level_haptic_feedback_get_value(runtime_info_value_h if (runtime_info_vconf_get_value_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vconf_value)) return RUNTIME_INFO_ERROR_IO_ERROR; - value->i = vconf_value; + value->i = vconf_value; return RUNTIME_INFO_ERROR_NONE; } diff --git a/src/runtime_info_vconf.c b/src/runtime_info_vconf.c index f2db3ef..4f40980 100644 --- a/src/runtime_info_vconf.c +++ b/src/runtime_info_vconf.c @@ -35,9 +35,9 @@ int runtime_info_vconf_get_value_int(const char *vconf_key, int *value) return vconf_get_int(vconf_key, value); } -int runtime_info_vconf_get_value_bool(const char *vconf_key, bool *value) +int runtime_info_vconf_get_value_bool(const char *vconf_key, int *value) { - return vconf_get_bool(vconf_key, (int *)value); + return vconf_get_bool(vconf_key, value); } int runtime_info_vconf_get_value_double(const char *vconf_key, double *value)