patch tizen_2.0_build
[framework/api/device.git] / test / system-device.c
1 /*
2  * 
3  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4  * PROPRIETARY/CONFIDENTIAL
5  * 
6  * This software is the confidential and proprietary information of SAMSUNG 
7  * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
8  * this software is owned by Samsung and you shall not disclose such 
9  * Confidential Information and shall use it only in accordance with the terms 
10  * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
11  * make no representations or warranties about the suitability of the software, 
12  * either express or implied, including but not limited to the implied 
13  * warranties of merchantability, fitness for a particular purpose, or 
14  * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
15  * licensee arising out of or related to this software.
16  * 
17  */
18
19 #include <stdio.h>
20 #include <stdbool.h>
21 #include <stdlib.h>
22 #include <glib.h>
23 #include <device.h>
24
25 int main(int argc, char *argv[])
26 {
27         int pct;
28         bool is_full;
29         int brt, max, cnt;
30
31         if(device_battery_get_percent(&pct) == DEVICE_ERROR_NONE){
32                 printf("battery percent is %d %%\n", pct);
33         }else{
34                 printf("device_battery_get_percent error\n");
35         }
36
37         if(device_battery_is_full(&is_full) == DEVICE_ERROR_NONE){
38                 printf("battery is %s\n", is_full ? "full" : "not full");
39         }else{
40                 printf("device_battery_is_full error\n");
41         }
42
43         if(device_get_max_brightness(0, &max) == DEVICE_ERROR_NONE){
44                 printf("display brightness max is %d\n", max);
45         }else{
46                 printf("device_get_max_brightness error\n");
47         }
48
49     cnt = device_get_display_count();
50     printf("display count is %d\n", cnt);
51
52         if(argc > 1){
53                 brt = atoi(argv[1]);
54         }else{
55                 brt = max / 2;
56         }
57         if(device_set_brightness(0, brt) == DEVICE_ERROR_NONE){
58                 printf("set brightness %d\n", brt);
59         }else{
60                 printf("device_set_brightness error\n");
61         }
62
63         if(device_get_brightness(0, &brt) == DEVICE_ERROR_NONE){
64                 printf("display brightness is %d\n", brt);
65         }else{
66                 printf("device_get_brightness error\n");
67         }
68
69         return 0;
70 }