summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:45:51 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:45:51 +0900
commit51e698761ed52249496990a6ca5362460af2ca2b (patch)
tree10fe8022c6f0e1f83bc941283bf56349fdafd595
parentcb9665baa95abaeac5268efb421afd4f2e3d5152 (diff)
downloaddevice-51e698761ed52249496990a6ca5362460af2ca2b.tar.gz
device-51e698761ed52249496990a6ca5362460af2ca2b.tar.bz2
device-51e698761ed52249496990a6ca5362460af2ca2b.zip
Tizen 2.1 base
-rw-r--r--AUTHORS1
-rwxr-xr-xCMakeLists.txt96
-rw-r--r--LICENSE204
-rw-r--r--NOTICE3
-rwxr-xr-xTC/_export_env.sh8
-rwxr-xr-xTC/_export_target_env.sh7
-rwxr-xr-xTC/build.sh16
-rwxr-xr-xTC/clean.sh11
-rw-r--r--TC/config2
-rwxr-xr-xTC/execute.sh15
-rwxr-xr-xTC/testcase/Makefile28
-rw-r--r--TC/testcase/tslist3
-rw-r--r--TC/testcase/utc_system_device_battery.c157
-rw-r--r--TC/testcase/utc_system_device_brightness.c331
-rwxr-xr-xTC/tet_scen7
-rw-r--r--TC/tetbuild.cfg5
-rw-r--r--TC/tetclean.cfg5
-rw-r--r--TC/tetexec.cfg5
-rw-r--r--capi-system-device.pc.in15
-rwxr-xr-xinclude/device.h562
-rw-r--r--include/device_log.h30
-rw-r--r--packaging/capi-system-device.manifest5
-rw-r--r--packaging/capi-system-device.spec57
-rw-r--r--src/battery.c343
-rw-r--r--src/cpu.c171
-rw-r--r--src/device.c211
-rw-r--r--src/memory.c136
27 files changed, 2434 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..4ae9d23
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Jiyoung Yun <jy910.yun@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..0cde0c6
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,96 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-device")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "devman dlog vconf capi-base-common")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+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_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/system
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "*_log.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a06208b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100755
index 0000000..72a11ec
--- /dev/null
+++ b/TC/_export_env.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100755
index 0000000..5ddaa53
--- /dev/null
+++ b/TC/_export_target_env.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755
index 0000000..72aad6c
--- /dev/null
+++ b/TC/build.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755
index 0000000..29743e0
--- /dev/null
+++ b/TC/clean.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
diff --git a/TC/config b/TC/config
new file mode 100644
index 0000000..8b68019
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/idkiller/work/tetware/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/tetware/TETware
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755
index 0000000..a4f6095
--- /dev/null
+++ b/TC/execute.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
new file mode 100755
index 0000000..8cc3da8
--- /dev/null
+++ b/TC/testcase/Makefile
@@ -0,0 +1,28 @@
+CC = gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = dlog capi-system-device capi-system-power
+
+#TET_ROOT = /home/idkiller/work/tetware/TETware/tetware-target
+
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+LDFLAGS += `pkg-config --libs $(PKGS)`
+
+CFLAGS += `pkg-config --cflags $(PKGS)`
+CFLAGS += -I.
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644
index 0000000..9517124
--- /dev/null
+++ b/TC/testcase/tslist
@@ -0,0 +1,3 @@
+/testcase/utc_system_device_battery
+/testcase/utc_system_device_brightness
+
diff --git a/TC/testcase/utc_system_device_battery.c b/TC/testcase/utc_system_device_battery.c
new file mode 100644
index 0000000..b92fb59
--- /dev/null
+++ b/TC/testcase/utc_system_device_battery.c
@@ -0,0 +1,157 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <tet_api.h>
+#include <device.h>
+
+#define API_NAME_DEVICE_BATTERY_GET_PERCENT "device_battery_get_percent"
+#define API_NAME_DEVICE_BATTERY_IS_FULL "device_battery_is_full"
+#define API_NAME_DEVICE_BATTERY_IS_CHARGING "device_battery_is_charging"
+#define API_NAME_DEVICE_BATTERY_SET_CB "device_battery_set_cb"
+#define API_NAME_DEVICE_BATTERY_UNSET_CB "device_battery_unset_cb"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_system_device_battery_get_percent_p(void);
+static void utc_system_device_battery_get_percent_n(void);
+static void utc_system_device_battery_is_full_p(void);
+static void utc_system_device_battery_is_full_n(void);
+static void utc_system_device_battery_is_charging_p(void);
+static void utc_system_device_battery_is_charging_n(void);
+static void utc_system_device_battery_set_cb_p(void);
+static void utc_system_device_battery_set_cb_n(void);
+static void utc_system_device_battery_unset_cb_p(void);
+
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_system_device_battery_get_percent_p, POSITIVE_TC_IDX },
+ { utc_system_device_battery_get_percent_n, NEGATIVE_TC_IDX },
+ { utc_system_device_battery_is_full_p, POSITIVE_TC_IDX },
+ { utc_system_device_battery_is_full_n, NEGATIVE_TC_IDX },
+ { utc_system_device_battery_is_charging_p, POSITIVE_TC_IDX },
+ { utc_system_device_battery_is_charging_n, NEGATIVE_TC_IDX },
+ { utc_system_device_battery_set_cb_p, POSITIVE_TC_IDX },
+ { utc_system_device_battery_set_cb_n, NEGATIVE_TC_IDX },
+ { utc_system_device_battery_unset_cb_p, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+ /* start of TC */
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+/**
+ * @brief Positive test case of device_battery_get_percent()
+ */
+static void utc_system_device_battery_get_percent_p(void)
+{
+ int percent = 0;
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_get_percent(&percent);
+
+ dts_check_eq(API_NAME_DEVICE_BATTERY_GET_PERCENT, error, DEVICE_ERROR_NONE);
+}
+
+/**
+ * @brief Negative test case of device_battery_get_percent()
+ */
+static void utc_system_device_battery_get_percent_n(void)
+{
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_get_percent(NULL);
+
+ dts_check_ne(API_NAME_DEVICE_BATTERY_GET_PERCENT, error, DEVICE_ERROR_NONE);
+}
+
+/**
+ * @brief Positive test case of device_battery_is_full()
+ */
+static void utc_system_device_battery_is_full_p(void)
+{
+ bool full;
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_is_full(&full);
+ dts_check_eq(API_NAME_DEVICE_BATTERY_IS_FULL, error, DEVICE_ERROR_NONE);
+}
+
+/**
+ * @brief Negative test case of device_battery_is_full()
+ */
+static void utc_system_device_battery_is_full_n(void)
+{
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_is_full(NULL);
+ dts_check_ne(API_NAME_DEVICE_BATTERY_IS_FULL, error, DEVICE_ERROR_NONE);
+}
+
+
+static void utc_system_device_battery_is_charging_p(void)
+{
+ bool charging;
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_is_charging(&charging);
+ dts_check_eq(API_NAME_DEVICE_BATTERY_IS_CHARGING, error, DEVICE_ERROR_NONE);
+}
+
+static void utc_system_device_battery_is_charging_n(void)
+{
+ bool charging;
+ int error = DEVICE_ERROR_NONE;
+ error = device_battery_is_charging(NULL);
+ dts_check_ne(API_NAME_DEVICE_BATTERY_IS_CHARGING, error, DEVICE_ERROR_NONE);
+}
+
+static void battery_cb(int percent, void *user_data)
+{
+}
+
+static void utc_system_device_battery_set_cb_p(void)
+{
+ int error = device_battery_set_cb(battery_cb, NULL);
+ device_battery_unset_cb();
+ dts_check_eq(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);
+}
+
+static void utc_system_device_battery_set_cb_n(void)
+{
+ int error = device_battery_set_cb(NULL, NULL);
+ device_battery_unset_cb();
+ dts_check_ne(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);
+}
+
+static void utc_system_device_battery_unset_cb_p(void)
+{
+ device_battery_set_cb(battery_cb, NULL);
+ int error = device_battery_unset_cb();
+ dts_check_eq(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);
+}
diff --git a/TC/testcase/utc_system_device_brightness.c b/TC/testcase/utc_system_device_brightness.c
new file mode 100644
index 0000000..61ed563
--- /dev/null
+++ b/TC/testcase/utc_system_device_brightness.c
@@ -0,0 +1,331 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <tet_api.h>
+#include <device.h>
+#include <power.h>
+
+#define API_NAME_DEVICE_GET_DISPLAY_COUNT "device_get_display_numbers"
+#define API_NAME_DEVICE_GET_BRIGHTNESS "device_get_brightness"
+#define API_NAME_DEVICE_GET_MAX_BRIGHTNESS "device_get_max_brightness"
+#define API_NAME_DEVICE_SET_BRIGHTNESS "device_set_brightness"
+#define API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS "device_set_brightness_from_settings"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+
+static void utc_system_device_get_display_numbers_p(void);
+static void utc_system_device_get_brightness_p(void);
+static void utc_system_device_get_brightness_n_1(void);
+static void utc_system_device_get_brightness_n_2(void);
+static void utc_system_device_get_max_brightness_p(void);
+static void utc_system_device_get_max_brightness_n_1(void);
+static void utc_system_device_get_max_brightness_n_2(void);
+static void utc_system_device_set_brightness_p_1(void);
+static void utc_system_device_set_brightness_p_2(void);
+static void utc_system_device_set_brightness_n_1(void);
+static void utc_system_device_set_brightness_n_2(void);
+static void utc_system_device_set_brightness_from_settings_p(void);
+static void utc_system_device_set_brightness_from_settings_n(void);
+
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_system_device_get_display_numbers_p, POSITIVE_TC_IDX},
+ { utc_system_device_get_brightness_p, POSITIVE_TC_IDX },
+ { utc_system_device_get_brightness_n_1, NEGATIVE_TC_IDX },
+ { utc_system_device_get_brightness_n_2, NEGATIVE_TC_IDX },
+ { utc_system_device_get_max_brightness_p, POSITIVE_TC_IDX },
+ { utc_system_device_get_max_brightness_n_1, NEGATIVE_TC_IDX },
+ { utc_system_device_get_max_brightness_n_2, NEGATIVE_TC_IDX },
+ { utc_system_device_set_brightness_p_1, POSITIVE_TC_IDX },
+ { utc_system_device_set_brightness_p_2, POSITIVE_TC_IDX },
+ { utc_system_device_set_brightness_n_1, NEGATIVE_TC_IDX },
+ { utc_system_device_set_brightness_n_2, NEGATIVE_TC_IDX },
+ { utc_system_device_set_brightness_from_settings_p, POSITIVE_TC_IDX },
+ { utc_system_device_set_brightness_from_settings_n, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static int cnt;
+
+static void startup(void)
+{
+ /* start of TC */
+ power_wakeup(false);
+ power_lock_state(POWER_STATE_NORMAL, 0);
+
+ device_get_display_numbers(&cnt);
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ power_unlock_state(POWER_STATE_NORMAL);
+}
+
+static void utc_system_device_get_display_numbers_p(void)
+{
+ int _cnt, err;
+ err = device_get_display_numbers(&_cnt);
+
+ if(err < 0){
+ dts_fail(API_NAME_DEVICE_GET_DISPLAY_COUNT);
+ }
+ else{
+ dts_pass(API_NAME_DEVICE_GET_DISPLAY_COUNT);
+ }
+}
+
+/**
+ * @brief Positive test case of device_get_brightness()
+ */
+static void utc_system_device_get_brightness_p(void)
+{
+ int i;
+ int value = 0;
+ int error = DEVICE_ERROR_NONE;
+
+ for(i=0; i<cnt; i++){
+ error = device_get_brightness(i, &value);
+
+ if (error != DEVICE_ERROR_NONE){
+ dts_fail(API_NAME_DEVICE_GET_BRIGHTNESS);
+ }
+
+ if (value < 0){
+ dts_fail(API_NAME_DEVICE_GET_BRIGHTNESS);
+ }
+ }
+
+ dts_pass(API_NAME_DEVICE_GET_BRIGHTNESS);
+}
+
+/**
+ * @brief Negative test case of device_get_brightness() with bad display parameter
+ */
+static void utc_system_device_get_brightness_n_1(void)
+{
+ int value = 0;
+ int error = DEVICE_ERROR_NONE;
+
+ error = device_get_brightness(cnt+1, &value);
+ dts_check_ne(API_NAME_DEVICE_GET_BRIGHTNESS, error, DEVICE_ERROR_NONE);
+}
+
+/**
+ * @brief Negative test case of device_get_brightness() with null pointer
+ */
+static void utc_system_device_get_brightness_n_2(void)
+{
+ int value = 0, i=0;
+ int error = DEVICE_ERROR_NONE;
+
+ for(i=0; i<cnt; i++){
+ error = device_get_brightness(i, NULL);
+
+ if(error == DEVICE_ERROR_NONE){
+ dts_fail(API_NAME_DEVICE_GET_BRIGHTNESS);
+ }
+ }
+ dts_pass(API_NAME_DEVICE_GET_BRIGHTNESS);
+}
+
+/**
+ * @brief Positive test case of device_get_max_brightness()
+ */
+static void utc_system_device_get_max_brightness_p(void)
+{
+ int value = 0, i=0;
+ int error = DEVICE_ERROR_NONE;
+
+ for(i=0; i<cnt; i++){
+ error = device_get_max_brightness(i, &value);
+
+ if(error != DEVICE_ERROR_NONE){
+ dts_fail(API_NAME_DEVICE_GET_MAX_BRIGHTNESS);
+ }
+ }
+ dts_pass(API_NAME_DEVICE_GET_MAX_BRIGHTNESS);
+}
+
+/**
+ * @brief Negative test case of device_get_max_brightness() with bad display parameter
+ */
+static void utc_system_device_get_max_brightness_n_1(void)
+{
+ int value = 0;
+ int error = DEVICE_ERROR_NONE;
+ error = device_get_max_brightness(cnt+1, &value);
+
+ dts_check_ne(API_NAME_DEVICE_GET_MAX_BRIGHTNESS, error, DEVICE_ERROR_NONE);
+}
+
+/**
+ * @brief Negative test case of device_get_max_brightness() with null pointer
+ */
+static void utc_system_device_get_max_brightness_n_2(void)
+{
+ int error = DEVICE_ERROR_NONE, i=0;
+
+ for(i=0; i<cnt; i++){
+ error = device_get_max_brightness(i, NULL);
+
+ if(error == DEVICE_ERROR_NONE){
+ dts_fail(API_NAME_DEVICE_GET_MAX_BRIGHTNESS);
+ }
+ }
+ dts_pass(API_NAME_DEVICE_GET_MAX_BRIGHTNESS);
+}
+
+/**
+ * @brief Positive test case of device_set_brightness()
+ */
+static void utc_system_device_set_brightness_p_1(void)
+{
+ int i=0;
+ int err;
+
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS, "!@#$ cnt=%d", cnt);
+
+ for(i=0; i<cnt; i++){
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS, "index=%d", i);
+ err = device_set_brightness(i, 0);
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS, "error=%d", err);
+ if(err != DEVICE_ERROR_NONE) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+ }
+ dts_pass(API_NAME_DEVICE_SET_BRIGHTNESS);
+}
+
+/**
+ * @brief Positive test case of device_set_brightness()
+ */
+static void utc_system_device_set_brightness_p_2(void)
+{
+ int setting = 0;
+ int max_value = 0;
+ int value = 0, i=0;
+
+ for(i=0; i<cnt; i++){
+ if( device_get_max_brightness(i, &max_value) != DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+
+ if( max_value < 0 ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+
+ setting = max_value > 1 ? max_value / 2 : 1;
+
+ if( device_set_brightness(i, setting) != DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS, "brightness=%d", setting);
+
+
+ if ( device_get_brightness(i, &value) != DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS, "brightness=%d", value);
+
+ if ( value != setting ){
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+ }
+
+ dts_pass(API_NAME_DEVICE_SET_BRIGHTNESS);
+}
+
+/**
+ * @brief Negative test case of device_set_brightness()
+ */
+static void utc_system_device_set_brightness_n_1(void)
+{
+ int i=0;
+ int max_value = 0;
+
+ for(i=0; i<cnt; i++){
+ if( device_get_max_brightness(i, &max_value) != DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS, "fail get_max_brightness");
+ }
+
+ if( device_set_brightness(i, max_value+1) == DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS, "fail set_brightness");
+ }
+ }
+
+ dts_pass(API_NAME_DEVICE_SET_BRIGHTNESS);
+}
+
+/**
+ * @brief Negative test case of device_set_brightness()
+ */
+static void utc_system_device_set_brightness_n_2(void)
+{
+ int i=0;
+
+ for(i=0; i<cnt; i++){
+ if( device_set_brightness(i, -1) == DEVICE_ERROR_NONE ) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS);
+ }
+ }
+
+ dts_pass(API_NAME_DEVICE_SET_BRIGHTNESS);
+}
+
+/**
+ * @brief Positive test case of device_set_brightness_from_settings()
+ */
+static void utc_system_device_set_brightness_from_settings_p(void)
+{
+ int i, error;
+
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS, "display cnt=%d", cnt);
+
+ for(i=0; i<cnt; i++){
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS, "index=%d", i);
+ error = device_set_brightness_from_settings(i);
+ dts_message(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS, "error=%d", error);
+ if(error != DEVICE_ERROR_NONE) {
+ dts_fail(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS);
+ }
+ }
+ dts_pass(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS);
+}
+
+/**
+ * @brief Negative test case of device_set_brightness_from_settings() with bad display parameter
+ */
+static void utc_system_device_set_brightness_from_settings_n(void)
+{
+ int error = DEVICE_ERROR_NONE;
+
+ error = device_set_brightness_from_settings(cnt+1);
+
+ dts_check_ne(API_NAME_DEVICE_SET_BRIGHTNESS_FROM_SETTINGS, error, DEVICE_ERROR_NONE);
+}
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755
index 0000000..03f029a
--- /dev/null
+++ b/TC/tet_scen
@@ -0,0 +1,7 @@
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644
index 0000000..f7eda55
--- /dev/null
+++ b/TC/tetbuild.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644
index 0000000..02d7030
--- /dev/null
+++ b/TC/tetclean.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644
index 0000000..ef3e452
--- /dev/null
+++ b/TC/tetexec.cfg
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/capi-system-device.pc.in b/capi-system-device.pc.in
new file mode 100644
index 0000000..d0610b9
--- /dev/null
+++ b/capi-system-device.pc.in
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/system
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/include/device.h b/include/device.h
new file mode 100755
index 0000000..f53c087
--- /dev/null
+++ b/include/device.h
@@ -0,0 +1,562 @@
+/*
+ * Copyright (c) 2011 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_DEVICE_H__
+#define __TIZEN_SYSTEM_DEVICE_H__
+
+#include <stdbool.h>
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_DEVICE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of error code for Device.
+ */
+typedef enum
+{
+ DEVICE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ DEVICE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ DEVICE_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x12, /**< Operation failed */
+ DEVICE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_SYSTEM_CLASS | 0x13, /**< Not supported in this device */
+} device_error_e;
+
+/**
+ * @brief Enumerations of the battery warning status
+ */
+typedef enum
+{
+ DEVICE_BATTERY_WARN_EMPTY, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */
+ DEVICE_BATTERY_WARN_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */
+ DEVICE_BATTERY_WARN_LOW, /**< The battery has little charge left. */
+ DEVICE_BATTERY_WARN_NORMAL, /**< The battery status is not to be careful. */
+ DEVICE_BATTERY_WARN_FULL, /**< The battery status is full. */
+} device_battery_warn_e;
+
+/**
+ * @brief Enumerations of the battery remaining time type
+ */
+typedef enum
+{
+ DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED,
+ DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED
+} device_battery_remaining_time_type_e;
+
+/**
+ * @brief Structure of the time information system spent, measured in units of USER_HZ
+ */
+typedef struct {
+ unsigned long long total;
+ unsigned long long user;
+ unsigned long long nice;
+ unsigned long long system;
+ unsigned long long idle;
+ unsigned long long iowait;
+ unsigned long long irq;
+ unsigned long long softirq;
+} device_system_time_s;
+
+/**
+ * @}
+*/
+
+ /**
+ * @addtogroup CAPI_SYSTEM_DEVICE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an battery charge percentage changed
+ *
+ * @param[in] percent The remaining battery charge percentage (0 ~ 100)
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ */
+typedef void (*device_battery_cb)(int percent, void *user_data);
+
+/**
+ * @brief Called when the device warn about the battery status.
+ *
+ * @param[in] status The battery warning status
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ */
+typedef void (*device_battery_warn_cb)(device_battery_warn_e status, void *user_data);
+
+/**
+ * @brief This callback take remained time for fully charged or discharged.
+ *
+ * @param[in] time The battery remainig seconds to fully chagred or discharged
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ */
+typedef void (*device_battery_remaining_time_changed_cb)(int time, void* user_data);
+
+/**
+ * @brief Gets the battery warning status.
+ *
+ * @param[out] status The battery warning status.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_battery_status_e
+ * @see device_battery_status_set_cb()
+ */
+int device_battery_get_warning_status(device_battery_warn_e *status);
+
+/**
+ * @brief Set callback to be observing battery warning.
+ *
+ * @param[in] callback The callback function to set
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_battery_status_e
+ * @see device_battery_get_status()
+ */
+int device_battery_warning_set_cb(device_battery_warn_cb callback, void* user_data);
+
+/**
+ * @brief Unset battery warning callback function.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_battery_warning_unset_cb(void);
+
+/**
+ * @brief Gets the battery charge percentage.
+ * @details It returns integer value from 0 to 100 that indicates remaining battery charge
+ * as a percentage of the maximum level.
+ * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
+ *
+ * @param[out] percent The remaining battery charge percentage (0 ~ 100)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_battery_is_full()
+ * @see device_battery_get_detail()
+ * @see device_battery_set_cb()
+ */
+int device_battery_get_percent(int *percent);
+
+/**
+ * @brief Gets the battery detail charge as a per ten thousand.
+ * @details It return integer value from 0 to 10000 that indicates remaining battery charge as a per ten thousand of the maximum level.
+ * @remarks this function return #DEVICE_ERROR_NOT_SUPPORTED when device can not be supported detail battery information.
+ *
+ * @param[out] detail The remaining battery charge as a per ten thousand. (0 ~ 10000)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
+ *
+ * @see device_battery_is_full()
+ * @see device_battery_get_percent()
+ * @see device_battery_set_cb()
+ */
+int device_battery_get_detail(int *detail);
+
+/**
+ * @brief Get charging state
+ *
+ * @param[out] charging The battery charging state.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ */
+int device_battery_is_charging(bool *charging);
+
+/**
+ * @brief Set callback to be observing battery charge percentage.
+ *
+ * @param[in] callback The callback function to set
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_battery_set_cb(device_battery_cb callback, void* user_data);
+
+/**
+ * @brief Unset battery charge percentage callback function.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_battery_unset_cb(void);
+
+/**
+ * @brief Checks whether the battery is fully charged.
+ * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
+ *
+ * @param[out] full @c true when the battery is fully charged, otherwise @c false.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_battery_get_percent()
+ * @see system_info_set_changed_cb()
+ * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_PERCENTAGE, ...)
+ * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_CHARGE, ...)
+ */
+int device_battery_is_full(bool *full);
+
+/**
+ * @brief Retrive the remaining time for fully charged or discharged.
+ *
+ * @remark @a time will be retrieved the time to fully charged or discharged depending on @a type
+ *
+ * @param[in] type The type of battery remaining time
+ * @param[out] time battery remainig seconds to fully chagred or discharged
+
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_battery_set_remaining_time_changed_cb()
+ * @see device_battery_unset_remaining_time_changed_cb()
+ */
+int device_battery_get_remaining_time(device_battery_remaining_time_type_e type, int* time);
+
+/**
+ * @brief Set callback to be return battery remaining time to fully charged or discharged.
+ *
+ * @remark @a callback will be retrieved the time to fully charged or discharged depending on @a type
+ *
+ * @param[in] callback The callback function to set
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ */
+int device_battery_set_remaining_time_changed_cb(
+ device_battery_remaining_time_type_e type,
+ device_battery_remaining_time_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unset battery remaining time callback function.
+ *
+ * @param[in] type The type of battery remainig time
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_battery_unset_remaining_time_changed_cb(device_battery_remaining_time_type_e type);
+
+/**
+ * @brief Gets the number of display devices.
+ *
+ * @return The number of display devices that the device provides.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see device_get_brightness()
+ * @see device_set_brightness()
+ * @see device_get_max_brightness()
+ * @see device_set_brightness_from_settings()
+ * @see device_set_brightness_to_settings()
+ */
+int device_get_display_numbers(int* device_number);
+
+/**
+ * @brief Gets the display brightness value.
+ *
+ * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
+ * the number of displays returned by device_get_display_numbers().\n
+ * The index zero is always assigned to the main display.
+ * @param[out] brightness The current brightness value of the display
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_get_display_numbers()
+ * @see device_set_brightness()
+ * @see device_get_max_brightness()
+ * @see device_set_brightness_from_settings()
+ * @see device_set_brightness_to_settings()
+ */
+int device_get_brightness(int display_index, int *brightness);
+
+/**
+ * @brief Sets the display brightness value.
+ *
+ * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
+ * the number of displays returned by device_get_display_numbers().\n
+ * The index zero is always assigned to the main display.
+ * @param[in] brightness The new brightness value to set \n
+ * The maximum value can be represented by device_get_max_brightness()
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_get_display_numbers()
+ * @see device_get_max_brightness()
+ * @see device_get_brightness()
+ * @see device_set_brightness_from_settings()
+ * @see device_set_brightness_to_settings()
+ */
+int device_set_brightness(int display_index, int brightness);
+
+/**
+ * @brief Gets the maximum brightness value that can be set.
+ *
+ * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
+ * the number of displays returned by device_get_display_numbers().\n
+ * The index zero is always assigned to the main display.
+ * @param[out] max_brightness The maximum brightness value of the display
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_get_display_numbers()
+ * @see device_set_brightness()
+ * @see device_get_brightness()
+ * @see device_set_brightness_from_settings()
+ * @see device_set_brightness_to_settings()
+ */
+int device_get_max_brightness(int display_index, int *max_brightness);
+
+/**
+ * @brief Sets the display brightness value from registed in settings.
+ *
+ * @details
+ * This function set display brightness to condition in the settings.
+ * if auto brightness option is enabled in setting, display's brightness will be changed automatically.
+ *
+ * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
+ * the number of displays returned by device_get_display_numbers().\n
+ * The index zero is always assigned to the main display.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_get_display_numbers()
+ * @see device_get_max_brightness()
+ * @see device_set_brightness()
+ * @see device_get_brightness()
+ * @see device_set_brightness_to_settings()
+ */
+int device_set_brightness_from_settings(int display_index);
+
+/**
+ * @brief Sets the display brightness value to specific display and set to variable in settings.
+ *
+ * @details
+ * This function set given brightness value to given index of display.
+ * And also brightness variable in settings will be changed to given brightness value too.
+ *
+ * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
+ * the number of displays returned by device_get_display_numbers().\n
+ * The index zero is always assigned to the main display.
+ * @param[in] brightness The new brightness value to set \n
+ * The maximum value can be represented by device_get_max_brightness()
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @see device_get_display_numbers()
+ * @see device_get_max_brightness()
+ * @see device_set_brightness()
+ * @see device_get_brightness()
+ * @see device_set_brightness_from_settings()
+ */
+int device_set_brightness_to_settings(int display_index, int brightness);
+
+/**
+ * @brief Get brightness value of LED that placed to camera flash.
+ *
+ * @param[out] brightness brightness value of LED (0 ~ MAX)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_flash_get_brightness(int *brightness);
+
+/**
+ * @brief Set brightness value of LED that placed to camera flash.
+ *
+ * @param[in] brightness brightness value of LED (0 ~ MAX)
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_flash_set_brightness(int brightness);
+
+/**
+ * @brief Get max brightness value of LED that placed to camera flash.
+ *
+ * @remark
+ * Brightness control does not support yet. so this functioon always return 1. \n
+ * Set function can only use to switch on/off the flash. \n
+ * Get function can only use to retrive on/off state of flash.
+ *
+ * @param[out] max_brightness max brightness value of LED
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_flash_get_max_brightness(int *max_brightness);
+
+/**
+ * @brief Get total amount of physical RAM, in kilobytes
+ *
+ * @remark
+ *
+ * @param[out] total_mem total amount of physical RAM
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_memory_get_total(unsigned int *total_mem);
+
+/**
+ * @brief Get available amount of physical RAM, in kilobytes
+ *
+ * @remark
+ * Available amount is defined by following formula currently.
+ * available mem = MemFree+Buffers+Cached+SwapCached-Shmem
+ *
+ * @param[out] avail_mem available amount of physical RAM
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_memory_get_available(unsigned int *avail_mem);
+
+/**
+ * @brief Get time information the CPU has spent performing work.
+ *
+ * @remark
+ * Time units are in USER_HZ (typically hundredths of a second).
+ *
+ * @param[out] time structure of time information the CPU has spent
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_cpu_get_system_time(device_system_time_s *time);
+
+/**
+ * @brief Get all of CPU count
+ *
+ * @remark
+ *
+ * @param[out] cpu_cnt total count of CPU
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_cpu_get_count(int *cpu_cnt);
+
+/**
+ * @brief Get currently frequency of CPU
+ *
+ * @remark
+ *
+ * @param[in] cpu the index of CPU which want to know
+ * @param[out] cur_freq currently frequency value of CPU
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_cpu_get_current_freq(int cpu, unsigned int *cur_freq);
+
+/**
+ * @brief Get max frequency of CPU
+ *
+ * @remark
+ *
+ * @param[in] cpu the index of CPU which want to know
+ * @param[out] max_freq max frequency value of CPU
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DEVICE_ERROR_NONE Successful
+ * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ */
+int device_cpu_get_max_freq(int cpu, unsigned int *max_freq);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __TIZEN_SYSTEM_DEVICE_H__
diff --git a/include/device_log.h b/include/device_log.h
new file mode 100644
index 0000000..8752926
--- /dev/null
+++ b/include/device_log.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 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 __DEVICE_LOG_H__
+#define __DEVICE_LOG_H__
+
+#ifdef FEATURE_DEVICE_DLOG
+ #define LOG_TAG "SYSTEM_DEVICE"
+ #include <dlog.h>
+ #define DEVICE_LOG(fmt, args...) SLOGD(fmt, ##args)
+ #define DEVICE_ERROR(fmt, args...) SLOGE(fmt, ##args)
+#else
+ #define DEVICE_LOG(x, ...)
+ #define DEVICE_ERROR(x, ...)
+#endif
+
+#endif /* __DEVICE_LOG_H__ */
diff --git a/packaging/capi-system-device.manifest b/packaging/capi-system-device.manifest
new file mode 100644
index 0000000..b631abe
--- /dev/null
+++ b/packaging/capi-system-device.manifest
@@ -0,0 +1,5 @@
+<manifest>
+<request>
+ <domain name="_"/>
+</request>
+</manifest>
diff --git a/packaging/capi-system-device.spec b/packaging/capi-system-device.spec
new file mode 100644
index 0000000..9a443e4
--- /dev/null
+++ b/packaging/capi-system-device.spec
@@ -0,0 +1,57 @@
+Name: capi-system-device
+Summary: A Device library in TIZEN C API
+Version: 0.1.0
+Release: 18
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Source1: capi-system-device.manifest
+BuildRequires: cmake
+BuildRequires: pkgconfig(devman)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary: A Device library in TIZEN C API (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cp %{SOURCE1} .
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-system-device.manifest
+%{_libdir}/libcapi-system-device.so.*
+
+%files devel
+%{_includedir}/system/device.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-system-device.so
diff --git a/src/battery.c b/src/battery.c
new file mode 100644
index 0000000..61cf854
--- /dev/null
+++ b/src/battery.c
@@ -0,0 +1,343 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <devman.h>
+#include <vconf.h>
+#include "device.h"
+#include "device_log.h"
+
+#define CHECK_ERR(val) \
+ do { \
+ if (val == DEVMAN_ERROR_NOT_SUPPORTED) \
+ return DEVICE_ERROR_NOT_SUPPORTED; \
+ else if (val == DEVMAN_ERROR_OPERATION_FAILED) \
+ return DEVICE_ERROR_OPERATION_FAILED; \
+ } while(0)
+
+int device_battery_get_percent(int* percent)
+{
+ if (percent == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ int pct = device_get_battery_pct();
+ CHECK_ERR(pct);
+
+ *percent = pct;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_get_detail(int* percent)
+{
+ if (percent == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ int pct = device_get_battery_pct_raw();
+ CHECK_ERR(pct);
+
+ *percent = pct;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_is_full(bool* full)
+{
+ if (full == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ int f = device_is_battery_full();
+ CHECK_ERR(f);
+
+ *full = (f == 1) ? true : false;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_is_charging(bool *charging)
+{
+ // VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW
+ int value, err;
+
+ if (charging == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ err = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ if (value == 1) {
+ *charging = true;
+ } else if (value == 0) {
+ *charging = false;
+ } else {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ }
+
+ return DEVICE_ERROR_NONE;
+}
+
+static device_battery_cb changed_callback = NULL;
+static void* changed_callback_user_data = NULL;
+
+static void battery_changed_inside_cb(keynode_t* key, void* user_data)
+{
+ char* keyname = vconf_keynode_get_name(key);
+
+ if (keyname != NULL && changed_callback != NULL && strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_CAPACITY) == 0) {
+ int percent = 0;
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &percent) == 0) {
+ changed_callback(percent, changed_callback_user_data);
+ }
+ }
+}
+
+int device_battery_set_cb(device_battery_cb callback, void* user_data)
+{
+ // VCONFKEY_SYSMAN_BATTERY_CAPACITY
+ int err;
+ if (callback == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ changed_callback = callback;
+ changed_callback_user_data = user_data;
+
+ err = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery_changed_inside_cb, NULL);
+ if (err < 0)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_unset_cb(void)
+{
+ int err = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, battery_changed_inside_cb);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ changed_callback = NULL;
+ changed_callback_user_data = NULL;
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_get_warning_status(device_battery_warn_e *status)
+{
+ if (status == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ int value, err;
+
+ err = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &value);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ if (value == VCONFKEY_SYSMAN_BAT_POWER_OFF) {
+ *status = DEVICE_BATTERY_WARN_EMPTY;
+ } else if (value == VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) {
+ *status = DEVICE_BATTERY_WARN_CRITICAL;
+ } else if (value == VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
+ *status = DEVICE_BATTERY_WARN_LOW;
+ } else if (value == VCONFKEY_SYSMAN_BAT_NORMAL) {
+ *status = DEVICE_BATTERY_WARN_NORMAL;
+ } else if (value == VCONFKEY_SYSMAN_BAT_FULL) {
+ *status = DEVICE_BATTERY_WARN_FULL;
+ } else {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ }
+
+ return DEVICE_ERROR_NONE;
+}
+
+static device_battery_warn_cb warn_changed_callback = NULL;
+static void* warn_changed_callback_user_data = NULL;
+
+static void battery_warn_changed_inside_cb(keynode_t* key, void* user_data)
+{
+ char* keyname = vconf_keynode_get_name(key);
+
+ if (keyname != NULL && warn_changed_callback != NULL && strcmp(keyname, VCONFKEY_SYSMAN_BATTERY_STATUS_LOW) == 0) {
+ int bat_state = 0;
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) == 0) {
+ warn_changed_callback(bat_state-1, warn_changed_callback_user_data);
+ }
+ }
+}
+
+int device_battery_warning_set_cb(device_battery_warn_cb callback, void* user_data)
+{
+ // VCONFKEY_SYSMAN_BATTERY_STATUS_LOW
+ int err;
+
+ if (callback == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ warn_changed_callback = callback;
+ warn_changed_callback_user_data = user_data;
+
+ err = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery_warn_changed_inside_cb, NULL);
+ if (err < 0)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_warning_unset_cb(void)
+{
+ int err = vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, battery_warn_changed_inside_cb);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ warn_changed_callback = NULL;
+ warn_changed_callback_user_data = NULL;
+
+ return DEVICE_ERROR_NONE;
+}
+
+static device_battery_remaining_time_changed_cb timetofull_changed_cb = NULL;
+static device_battery_remaining_time_changed_cb timetoempty_changed_cb = NULL;
+static void* timetofull_cb_user_data = NULL;
+static void* timetoempty_cb_user_data = NULL;
+
+static void device_battery_time_timetofull_inside_cb(keynode_t* key, void* user_data)
+{
+ char* keyname = vconf_keynode_get_name(key);
+ int time = -1, err= -1;
+
+ if (keyname == NULL)
+ return;
+
+ if (strcmp(keyname, VCONFKEY_PM_BATTERY_TIMETOFULL) == 0) {
+ if (timetofull_changed_cb != NULL) {
+ err = device_battery_get_remaining_time(
+ DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED, &time);
+ if ((err == DEVICE_ERROR_NONE) && (time >= 0))
+ timetofull_changed_cb(time, timetofull_cb_user_data);
+ }
+ }
+}
+
+static void device_battery_time_timetoempty_inside_cb(keynode_t* key, void* user_data)
+{
+ char* keyname = vconf_keynode_get_name(key);
+ int time = -1, err= -1;
+
+ if (keyname == NULL)
+ return;
+
+ if (strcmp(keyname, VCONFKEY_PM_BATTERY_TIMETOEMPTY) == 0) {
+ if (timetoempty_changed_cb != NULL) {
+ err = device_battery_get_remaining_time(
+ DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED, &time);
+ if ((err == DEVICE_ERROR_NONE) && (time >= 0))
+ timetoempty_changed_cb(time, timetoempty_cb_user_data);
+ }
+ }
+}
+
+int device_battery_get_remaining_time(device_battery_remaining_time_type_e type, int* time)
+{
+ bool charging = false;
+ int err = -1;
+
+ err = device_battery_is_charging(&charging);
+ if (err != DEVICE_ERROR_NONE)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ switch(type) {
+ case DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED:
+ if (charging == false) {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ } else {
+ err = vconf_get_int(VCONFKEY_PM_BATTERY_TIMETOFULL, time);
+ if (err < 0 || time < 0) {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ }
+ }
+ break;
+ case DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED:
+ if (charging == true) {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ } else {
+ err = vconf_get_int(VCONFKEY_PM_BATTERY_TIMETOEMPTY, time);
+ if (err < 0 || time < 0) {
+ return DEVICE_ERROR_OPERATION_FAILED;
+ }
+ }
+ break;
+ default:
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_set_remaining_time_changed_cb(device_battery_remaining_time_type_e type,
+ device_battery_remaining_time_changed_cb callback, void* user_data)
+{
+ int err;
+
+ if (callback == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ switch(type) {
+ case DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED:
+ timetofull_changed_cb = callback;
+ timetofull_cb_user_data = user_data;
+ err = vconf_notify_key_changed(VCONFKEY_PM_BATTERY_TIMETOFULL,
+ device_battery_time_timetofull_inside_cb, NULL);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+ break;
+ case DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED:
+ timetoempty_changed_cb = callback;
+ timetoempty_cb_user_data = user_data;
+ err = vconf_notify_key_changed(VCONFKEY_PM_BATTERY_TIMETOEMPTY,
+ device_battery_time_timetoempty_inside_cb, NULL);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+ break;
+ default:
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+ return DEVICE_ERROR_NONE;
+}
+
+int device_battery_unset_remaining_time_changed_cb(device_battery_remaining_time_type_e type)
+{
+ int err;
+
+ switch(type) {
+ case DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED:
+ err = vconf_ignore_key_changed(VCONFKEY_PM_BATTERY_TIMETOFULL,
+ device_battery_time_timetofull_inside_cb);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+ timetofull_changed_cb = NULL;
+ timetofull_cb_user_data = NULL;
+ break;
+ case DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED:
+ err = vconf_ignore_key_changed(VCONFKEY_PM_BATTERY_TIMETOEMPTY,
+ device_battery_time_timetoempty_inside_cb);
+ if (err < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+ timetoempty_changed_cb = NULL;
+ timetoempty_cb_user_data = NULL;
+ break;
+ default:
+ return DEVICE_ERROR_INVALID_PARAMETER;
+ }
+ return DEVICE_ERROR_NONE;
+}
diff --git a/src/cpu.c b/src/cpu.c
new file mode 100644
index 0000000..5754026
--- /dev/null
+++ b/src/cpu.c
@@ -0,0 +1,171 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "device.h"
+#include "device_log.h"
+
+#define PROC_STAT "/proc/stat"
+
+#define PROC_CPU_PRESENT "/sys/devices/system/cpu/present"
+#define PROC_SCALING_CUR_FREQ "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq"
+#define PROC_SCALING_MAX_FREQ "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq"
+
+
+int device_cpu_get_count(int *cpu_cnt)
+{
+ FILE *fp;
+ int ret;
+ int st, ed;
+
+ if (cpu_cnt == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ fp = fopen(PROC_CPU_PRESENT, "r");
+ if (!fp)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ ret = fscanf(fp, "%u-%u", &st, &ed);
+ fclose(fp);
+ if (ret != 2)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ *cpu_cnt = ed+1;
+ return DEVICE_ERROR_NONE;
+}
+
+static int _get_systime(device_system_time_s *st)
+{
+ FILE *fp;
+ char buf[4096];
+ char *s;
+
+ assert(st);
+
+ fp = fopen(PROC_STAT, "r");
+ if (!fp)
+ return -1;
+
+ s = fgets(buf, sizeof(buf), fp);
+ fclose(fp);
+ if (!s)
+ return -1;
+
+ s = strchr(buf, ' ');
+ if (!s)
+ return -1;
+
+ s++;
+ st->user = strtol(s, &s, 10);
+ st->nice = strtol(s, &s, 10);
+ st->system = strtol(s, &s, 10);
+ st->idle = strtol(s, &s, 10);
+ st->iowait = strtol(s, &s, 10);
+ st->irq = strtol(s, &s, 10);
+ st->softirq = strtol(s, &s, 10);
+
+ return 0;
+}
+
+int device_cpu_get_system_time(device_system_time_s *time)
+{
+ int ret;
+ device_system_time_s st;
+
+ if (time == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = _get_systime(&st);
+ if (ret < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ st.total = st.user+st.nice+st.system+st.idle+st.iowait+st.irq+st.softirq;
+ *time = st;
+ return DEVICE_ERROR_NONE;
+}
+
+static int _get_uint(const char *path, unsigned int *val)
+{
+ FILE *fp;
+ unsigned int num;
+ int ret;
+
+ assert(path);
+ assert(val);
+
+ fp = fopen(path, "r");
+ if (!fp)
+ return -1;
+
+ ret = fscanf(fp, "%u", &num);
+ fclose(fp);
+ if (ret != 1)
+ return -1;
+
+ *val = num;
+ return 0;
+}
+
+int device_cpu_get_current_freq(int cpu, unsigned int *cur_freq)
+{
+ char path[FILENAME_MAX];
+ int ret;
+ int count;
+ unsigned int cur;
+
+ if (cur_freq == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_cpu_get_count(&count);
+ if (ret != DEVICE_ERROR_NONE || cpu < 0 || cpu >= count)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ snprintf(path, sizeof(path), PROC_SCALING_CUR_FREQ, cpu);
+ ret = _get_uint(path, &cur);
+ if (ret < 0)
+ cur = 0;
+
+ *cur_freq = cur;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_cpu_get_max_freq(int cpu, unsigned int *max_freq)
+{
+ char path[FILENAME_MAX];
+ int ret;
+ int count;
+ unsigned int max;
+
+ if (max_freq == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_cpu_get_count(&count);
+ if (ret != DEVICE_ERROR_NONE || cpu < 0 || cpu >= count)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ snprintf(path, sizeof(path), PROC_SCALING_MAX_FREQ, cpu);
+ ret = _get_uint(path, &max);
+ if (ret < 0)
+ max = 0;
+
+ *max_freq = max;
+ return DEVICE_ERROR_NONE;
+}
diff --git a/src/device.c b/src/device.c
new file mode 100644
index 0000000..d4fb899
--- /dev/null
+++ b/src/device.c
@@ -0,0 +1,211 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <devman.h>
+#include "device.h"
+#include "device_log.h"
+
+#define CHECK_ERR(val) \
+ do { \
+ if (val == DEVMAN_ERROR_NOT_SUPPORTED) \
+ return DEVICE_ERROR_NOT_SUPPORTED; \
+ else if (val == DEVMAN_ERROR_OPERATION_FAILED) \
+ return DEVICE_ERROR_OPERATION_FAILED; \
+ } while(0)
+
+static int _display[] = {
+ DEV_DISPLAY_0,
+ DEV_DISPLAY_1,
+};
+
+int device_get_display_numbers(int* device_number)
+{
+ if(device_number == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ *device_number = device_get_display_count();
+ CHECK_ERR(*device_number);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_get_brightness(int disp_idx, int* value)
+{
+ int val, disp, max_id, ret;
+
+ if(value == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_get_display_numbers(&max_id);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(disp_idx < 0 || disp_idx >= max_id)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ disp = _display[disp_idx];
+ val = device_get_display_brt(disp);
+ CHECK_ERR(val);
+
+ *value = val;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_set_brightness(int disp_idx, int new_value)
+{
+ int max_value, val;
+ int disp, max_id, ret;
+
+ if(new_value < 0)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_get_display_numbers(&max_id);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(disp_idx < 0 || disp_idx >= max_id)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ disp = _display[disp_idx];
+ ret = device_get_max_brightness(disp, &max_value);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(new_value > max_value)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ val = device_set_display_brt(disp, new_value);
+ CHECK_ERR(val);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_get_max_brightness(int disp_idx, int* max_value)
+{
+ int val, disp, max_id, ret;
+
+ if(max_value == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_get_display_numbers(&max_id);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(disp_idx < 0 || disp_idx >= max_id)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ disp = _display[disp_idx];
+ val = device_get_max_brt(disp);
+ CHECK_ERR(val);
+
+ *max_value = val;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_set_brightness_from_settings(int disp_idx)
+{
+ int max_id, disp, val, ret;
+
+ ret = device_get_display_numbers(&max_id);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(disp_idx < 0 || disp_idx >= max_id)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ disp = _display[disp_idx];
+ val = device_release_brt_ctrl(disp);
+ CHECK_ERR(val);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_set_brightness_to_settings(int disp_idx, int new_value)
+{
+ int max_value, val;
+ int disp, max_id, ret;
+
+ if(new_value < 0)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = device_get_display_numbers(&max_id);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(disp_idx < 0 || disp_idx >= max_id)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ disp = _display[disp_idx];
+ ret = device_get_max_brightness(disp, &max_value);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if(new_value > max_value)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ val = device_set_display_brt_with_settings(disp, new_value);
+ CHECK_ERR(val);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_flash_get_brightness(int *brightness)
+{
+ int value;
+
+ if (brightness == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ value = device_get_led_brt();
+ CHECK_ERR(value);
+
+ *brightness = value;
+ return DEVICE_ERROR_NONE;
+}
+
+int device_flash_set_brightness(int brightness)
+{
+ int max_value, value, ret;
+
+ ret = device_flash_get_max_brightness(&max_value);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+
+ if (brightness < 0 || brightness > max_value)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ value = device_set_led_brt(brightness);
+ CHECK_ERR(value);
+
+ return DEVICE_ERROR_NONE;
+}
+
+int device_flash_get_max_brightness(int *max_brightness)
+{
+ int value;
+
+ if (max_brightness == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ value = device_get_max_led();
+ CHECK_ERR(value);
+
+ *max_brightness = value;
+ return DEVICE_ERROR_NONE;
+}
diff --git a/src/memory.c b/src/memory.c
new file mode 100644
index 0000000..04c0a7d
--- /dev/null
+++ b/src/memory.c
@@ -0,0 +1,136 @@
+/*
+ * capi-system-device
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "device.h"
+#include "device_log.h"
+
+#define PROC_MEMORY "/proc/meminfo"
+
+enum {
+ _MI_TOTAL,
+ _MI_FREE,
+ _MI_BUF,
+ _MI_CACHED,
+ _MI_SWAP,
+ _MI_SHMEM,
+ _MI_MAX,
+};
+
+struct meminfo {
+ unsigned long l[_MI_MAX];
+};
+
+static const char *_mi_str[] = {
+ [_MI_TOTAL] = "MemTotal",
+ [_MI_FREE] = "MemFree",
+ [_MI_BUF] = "Buffers",
+ [_MI_CACHED] = "Cached",
+ [_MI_SWAP] = "SwapCached",
+ [_MI_SHMEM] = "Shmem",
+};
+
+static inline int _get_idx(const char *name)
+{
+ int i;
+
+ for (i = 0; i < sizeof(_mi_str)/sizeof(_mi_str[0]); ++i) {
+ if (name && _mi_str[i] && !strcmp(name, _mi_str[i]))
+ return i;
+ }
+
+ return -1;
+}
+
+static int _get_meminfo(struct meminfo *mi)
+{
+ FILE *fp;
+ char buf[4096];
+ char *s, *name, *num;
+ int idx;
+
+ assert(mi);
+
+ fp = fopen(PROC_MEMORY, "r");
+ if (!fp)
+ return -1;
+
+ memset(mi, 0, sizeof(*mi));
+
+ while (!feof(fp)) {
+ s = fgets(buf, sizeof(buf), fp);
+ if (!s)
+ break;
+
+ s = strchr(buf, ':');
+ if (!s)
+ continue;
+
+ *s = '\0';
+ name = buf;
+
+ s++;
+ while (*s == ' ')
+ s++;
+ num = s;
+
+ idx = _get_idx(name);
+ if (idx < 0)
+ continue;
+
+ mi->l[idx] = strtol(num, NULL, 10);
+ }
+
+ fclose(fp);
+ return 0;
+}
+
+int device_memory_get_total(unsigned int *total_mem)
+{
+ struct meminfo mi;
+ int ret;
+
+ if (total_mem == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = _get_meminfo(&mi);
+ if (ret < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ *total_mem = mi.l[_MI_TOTAL];
+ return DEVICE_ERROR_NONE;
+}
+
+int device_memory_get_available(unsigned int *avail_mem)
+{
+ struct meminfo mi;
+ int ret;
+
+ if (avail_mem == NULL)
+ return DEVICE_ERROR_INVALID_PARAMETER;
+
+ ret = _get_meminfo(&mi);
+ if (ret < 0)
+ return DEVICE_ERROR_OPERATION_FAILED;
+
+ *avail_mem = mi.l[_MI_FREE] + mi.l[_MI_BUF] + mi.l[_MI_CACHED] + mi.l[_MI_SWAP] - mi.l[_MI_SHMEM];
+ return DEVICE_ERROR_NONE;
+}