2.0_alpha release commit
[profile/ivi/system-info.git] / src / system_info_device.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*
18 ** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
19 ** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
20 ** Digital Equipment Corporation, Maynard, Mass.
21 ** Copyright (c) 1998 Microsoft.
22 ** To anyone who acknowledges that this file is provided "AS IS"
23 ** without any express or implied warranty: permission to use, copy,
24 ** modify, and distribute this file for any purpose is hereby
25 ** granted without fee, provided that the above copyright notices and
26 ** this notice appears in all source code copies, and that none of
27 ** the names of Open Software Foundation, Inc., Hewlett-Packard
28 ** Company, Microsoft, or Digital Equipment Corporation be used in
29 ** advertising or publicity pertaining to distribution of the software
30 ** without specific, written prior permission. Neither Open Software
31 ** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
32 ** Equipment Corporation makes any representations about the
33 ** suitability of this software for any purpose.
34 **
35 ** This license applies to all the permissions of the below mentioned functions.
36 ** Functions: format_uuid_v3or5, uuid_create_sha1_from_name
37 */
38
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <stdint.h>
44
45 #include <vconf.h>
46 #include <vconf-internal-csc-keys.h>
47 #include <dlog.h>
48
49 #include <system_info.h>
50 #include <system_info_private.h>
51
52 #include <devman_haptic.h>
53 #include <wifi.h>
54 #include <wifi-direct.h>
55
56 #include <X11/extensions/XI2.h>
57 #include <X11/extensions/XI2proto.h>
58 #include <X11/Xlib.h>
59 #include <X11/Xatom.h>
60 #include <X11/extensions/XInput2.h>
61
62 #include <openssl/sha.h>
63 #include <arpa/inet.h>
64
65 #include <net_nfc.h>
66 #include <net_nfc_typedef.h>
67
68 #include <location.h>
69 #include <location-types.h>
70
71 #include <bluetooth-api.h>
72
73 #include <mm_radio.h>
74 #include <mm_types.h>
75
76 #include <sound_manager.h>
77 #include <sensor.h>
78
79 #define PROP_MULTITOUCH "EvdevMultitouch MultiTouch"
80 #define DEVICE_UUID_STRING_SIZE 37
81
82 #ifdef LOG_TAG
83 #undef LOG_TAG
84 #endif
85
86 #define LOG_TAG "TIZEN_N_SYSTEM_INFO"
87
88 #define CAM_INI_FILE_PATH "/usr/etc/mmfw_camcorder.ini"
89 #define CAM_VIDEO_PRI_FILE_PATH "/usr/etc/mmfw_camcorder_dev_video_pri.ini"
90 #define CAM_VIDEO_SEC_FILE_PATH "/usr/etc/mmfw_camcorder_dev_video_sec.ini"
91
92 static char *KEYBOARD_TYPE;
93 static char *FRONT_CAM_PATH;
94 static char *BACK_CAM_PATH;
95 static const bool TVOUT_SUPPORT = true;
96 static const bool SIP_VOIP_SUPPROT = true;
97 static const bool SPEECH_RECOGNITION_SUPPROT = true;
98
99 typedef struct {
100         uint32_t  time_low;
101         uint16_t  time_mid;
102         uint16_t  time_hi_and_version;
103         uint8_t  clock_seq_hi_and_reserved;
104         uint8_t  clock_seq_low;
105         uint8_t node[6];
106 } _UUID_OBJECT;
107
108 /*
109     Tizen Default vender key = f7884739-3c9f-5f7c-af-e1-fc9f5da56003
110      This value should be modified by each venders.
111 */
112 _UUID_OBJECT VenderKey = {0xf7884739, 0x3c9f, 0x5f7c, 0xaf, 0xe1, {0xfc, 0x9f, 0x5d, 0xa5, 0x60, 0x3} };
113 /*
114     format_uuid_v3or5 -- make a UUID from a (pseudo)random 128-bit
115     number
116 */
117 void format_uuid_v3or5(_UUID_OBJECT *uuid, unsigned char hash[16], int v)
118 {
119         /* convert UUID to local byte order */
120         memcpy(uuid, hash, sizeof(*uuid));
121         uuid->time_low = ntohl(uuid->time_low);
122         uuid->time_mid = ntohs(uuid->time_mid);
123         uuid->time_hi_and_version = ntohs(uuid->time_hi_and_version);
124
125         /* put in the variant and version bits */
126         uuid->time_hi_and_version &= 0x0FFF;
127         uuid->time_hi_and_version |= (v << 12);
128         uuid->clock_seq_hi_and_reserved &= 0x3F;
129         uuid->clock_seq_hi_and_reserved |= 0x80;
130 }
131
132 void uuid_create_sha1_from_name(_UUID_OBJECT *uuid, _UUID_OBJECT nsid, void *name, int namelen)
133 {
134         SHA_CTX c;
135         unsigned char hash[20];
136         _UUID_OBJECT net_nsid;
137
138         /* put name space ID in network byte order so it hashes the same
139            no matter what endian machine we're on */
140         net_nsid = nsid;
141         net_nsid.time_low = htonl(net_nsid.time_low);
142         net_nsid.time_mid = htons(net_nsid.time_mid);
143         net_nsid.time_hi_and_version = htons(net_nsid.time_hi_and_version);
144
145         SHA1_Init(&c);
146         SHA1_Update(&c, &net_nsid, sizeof(net_nsid));
147         SHA1_Update(&c, name, namelen);
148         SHA1_Final(hash, &c);
149
150         /* the hash is in network byte order at this point */
151         format_uuid_v3or5(uuid, hash, 5);
152 }
153
154 int uuid_object_to_string(_UUID_OBJECT uuid, char **device_uuid_string)
155 {
156         *device_uuid_string = (char *) calloc(1, DEVICE_UUID_STRING_SIZE + 1);
157
158         if (*device_uuid_string == NULL)
159                 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
160
161         snprintf(*device_uuid_string, DEVICE_UUID_STRING_SIZE, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
162                 (unsigned long)uuid.time_low,
163                 (unsigned int)uuid.time_mid,
164                 (unsigned int)uuid.time_hi_and_version,
165                 (unsigned int)uuid.clock_seq_hi_and_reserved,
166                 (unsigned int)uuid.clock_seq_low,
167                 (unsigned int)uuid.node[0],
168                 (unsigned int)uuid.node[1],
169                 (unsigned int)uuid.node[2],
170                 (unsigned int)uuid.node[3],
171                 (unsigned int)uuid.node[4],
172                 (unsigned int)uuid.node[5]);
173
174         return SYSTEM_INFO_ERROR_NONE;
175 }
176
177 extern char *strcasestr(const char *s, const char *find);
178
179 int xinput_extension_init(Display *disp)
180 {
181         int opcode;
182         int event, error;
183         int major = XI_2_Major, minor = XI_2_Minor;
184
185         if (!XQueryExtension(disp, "XInputExtension", &opcode, &event, &error)) {
186                 LOGE("[%s] XInput Extension isn't supported.", __func__);
187                 return SYSTEM_INFO_ERROR_IO_ERROR;
188         }
189
190         if (XIQueryVersion(disp, &major, &minor) == BadRequest) {
191                 LOGE("[%s] Failed to query XI version.", __func__);
192                 return SYSTEM_INFO_ERROR_IO_ERROR;
193         }
194
195         if (!(major >= XI_2_Major && minor >= XI_2_Minor)) {
196                 LOGE("[%s] XI2 is not supported ! (major:%d, minor:%d)", __func__, major, minor);
197                 return SYSTEM_INFO_ERROR_IO_ERROR;
198         }
199         return opcode;
200 }
201
202 int get_device_property_value(Display *disp, int deviceid, Atom prop)
203 {
204         Atom act_type;
205         unsigned long nitems, bytes_after;
206         unsigned char *data;
207         int act_format, ret = -1;
208
209         if (XIGetProperty(disp, deviceid, prop, 0, 1000, False,
210                                                         XA_INTEGER, &act_type, &act_format,
211                                                         &nitems, &bytes_after, &data) != Success) {
212                 LOGE("[%s] Failed to get XI2 device property !(deviceid=%d)", __func__, deviceid);
213                 return SYSTEM_INFO_ERROR_IO_ERROR;
214         }
215
216         if (!nitems)
217                 goto out;
218
219         ret = (int)*data;
220
221 out:
222         if (data)
223                 XFree(data);
224
225         return ret;
226 }
227
228 int get_multitouch_max_count(Display *disp)
229 {
230         int i;
231         int max_count;
232         int ndevices;
233         XIDeviceInfo *dev, *info = NULL;
234         Atom atomMultiTouch;
235         int xi_opcode = xinput_extension_init(disp);
236
237         if (0 >= xi_opcode) {
238                 LOGE("[%s] Failed to initialize X Input Extension !", __func__);
239                 return SYSTEM_INFO_ERROR_IO_ERROR;
240         }
241
242         atomMultiTouch = XInternAtom(disp, PROP_MULTITOUCH, True);
243
244         if (!atomMultiTouch) {
245                 LOGE("[%s] Failed to make an atom for multitouch property !", __func__);
246                 return SYSTEM_INFO_ERROR_IO_ERROR;
247         }
248
249         info = XIQueryDevice(disp, XIAllDevices, &ndevices);
250
251         if (!info) {
252                 LOGE("[%s] Failed to query XI device.", __func__);
253                 return SYSTEM_INFO_ERROR_IO_ERROR;
254         }
255
256         for (i = 0; i < ndevices ; i++) {
257                 dev = &info[i];
258
259                 switch (dev->use) {
260                 case XISlavePointer:
261                         if (strcasestr(dev->name, "virtual") && !strcasestr(dev->name, "maru"))
262                                 continue;
263                         if (strcasestr(dev->name, "extended"))
264                                 continue;
265                         if (!strcasestr(dev->name, "touch"))
266                                 continue;
267                         max_count = get_device_property_value(disp, dev->deviceid, atomMultiTouch);
268                         goto out;
269                 }
270         }
271
272         return -1;
273
274 out:
275         XIFreeDeviceInfo(info);
276         return max_count;
277 }
278
279 /**
280  * @brief Setting face direction path
281  *
282  */
283
284 void set_camera_direction_path(void)
285 {
286         char str[MAXBUFSIZE];
287         char tmpStr[MAXBUFSIZE];
288         int direction = -1;
289         FILE *info = NULL;
290
291         info = fopen(CAM_VIDEO_PRI_FILE_PATH, "r");
292
293         if (NULL != info) {
294                 while (fgets(str, MAXBUFSIZE, info)) {
295                         if (!strncmp(";", str, strlen(";")))
296                                 continue;
297                         else if (!strncmp("FacingDirection", str, strlen("FacingDirection"))) {
298                                 sscanf(str, "%s = %d", tmpStr, &direction);
299                                 if (direction == 1) {
300                                         FRONT_CAM_PATH = strdup(CAM_VIDEO_PRI_FILE_PATH);
301                                         BACK_CAM_PATH = strdup(CAM_VIDEO_SEC_FILE_PATH);
302                                         fclose(info);
303                                         return;
304                                 }
305                         } else
306                                 continue;
307                 }
308
309                 fclose(info);
310         }
311
312         /* default setting */
313         FRONT_CAM_PATH = strdup(CAM_VIDEO_SEC_FILE_PATH);
314         BACK_CAM_PATH = strdup(CAM_VIDEO_PRI_FILE_PATH);
315
316         return;
317 }
318
319 int system_info_get_bluetooth_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
320 {
321         bool *supported;
322
323         supported = (bool *)value;
324
325         if (bluetooth_is_supported())
326                         *supported = true;
327                 else
328                         *supported = false;
329
330         return SYSTEM_INFO_ERROR_NONE;
331 }
332
333 int system_info_get_camera_count(system_info_key_e key, system_info_data_type_e data_type, void **value)
334 {
335         int *count;
336         char str[MAXBUFSIZE];
337         char tmpStr[MAXBUFSIZE];
338         FILE *info = NULL;
339
340         count = (int *)value;
341         /* default camera count is 2*/
342         *count = 2;
343
344         info = fopen(CAM_INI_FILE_PATH, "r");
345         if (NULL == info) {
346                 LOGE("[%s] cannot file open %s file!!!", __func__, CAM_INI_FILE_PATH);
347                 return SYSTEM_INFO_ERROR_IO_ERROR;
348         } else {
349                 while (fgets(str, MAXBUFSIZE, info)) {
350                         if (!strncmp(";", str, strlen(";")))
351                                 continue;
352                         else if (!strncmp("DeviceCount", str, strlen("DeviceCount"))) {
353                                 sscanf(str, "%s = %d", tmpStr, count);
354                                 break;
355                         } else
356                                 continue;
357                 }
358         }
359         fclose(info);
360         return SYSTEM_INFO_ERROR_NONE;
361 }
362
363 int system_info_get_fmradio_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
364 {
365         bool *supported;
366         MMHandleType hradio;
367
368         supported = (bool *)value;
369
370         memset(&hradio, 0x0, sizeof(MMHandleType));
371
372         if (MM_ERROR_NONE == mm_radio_create(&hradio))
373                 *supported = true;
374         else
375                 *supported = false;
376
377         mm_radio_destroy(hradio);
378
379         return SYSTEM_INFO_ERROR_NONE;
380 }
381
382 int system_info_get_gps_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
383 {
384         bool *supported;
385
386         supported = (bool *)value;
387
388         if (location_is_supported_method(LOCATION_METHOD_GPS))
389                 *supported = true;
390         else
391                 *supported = false;
392
393         return SYSTEM_INFO_ERROR_NONE;
394 }
395
396 int system_info_get_cps_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
397 {
398         bool *supported;
399
400         supported = (bool *)value;
401
402         if (location_is_supported_method(LOCATION_METHOD_CPS))
403                 *supported = true;
404         else
405                 *supported = false;
406
407         return SYSTEM_INFO_ERROR_NONE;
408 }
409
410 int system_info_get_wps_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
411 {
412         bool *supported;
413
414         supported = (bool *)value;
415
416         if (location_is_supported_method(LOCATION_METHOD_WPS))
417                 *supported = true;
418         else
419                 *supported = false;
420
421         return SYSTEM_INFO_ERROR_NONE;
422 }
423
424 int system_info_get_keyboard_type(system_info_key_e key, system_info_data_type_e data_type, void **value)
425 {
426         char *keyboard_type;
427
428         if (KEYBOARD_TYPE != NULL) {
429                 keyboard_type = strdup(KEYBOARD_TYPE);
430
431                 if (keyboard_type == NULL) {
432                         LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __func__, SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
433                         return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
434                 }
435
436                 *value = keyboard_type;
437         } else {
438                 *value = NULL;
439         }
440
441         return SYSTEM_INFO_ERROR_NONE;
442 }
443
444 int system_info_get_multi_point_touch_count(system_info_key_e key, system_info_data_type_e data_type, void **value)
445 {
446         int *count;
447         Display *disp;
448
449         count = (int *)value;
450
451         disp = XOpenDisplay(NULL);
452
453         if (!disp) {
454                 LOGE("[%s] Failed to open display!", __func__);
455                 return SYSTEM_INFO_ERROR_IO_ERROR;
456         }
457
458         *count = get_multitouch_max_count(disp);
459
460         return SYSTEM_INFO_ERROR_NONE;
461 }
462
463 int system_info_get_nfc_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
464 {
465         bool *supported;
466         int nfc_supported = 0;
467
468         supported = (bool *)value;
469
470         if (NET_NFC_OK == net_nfc_is_supported(&nfc_supported))
471                 *supported = true;
472         else
473                 *supported = false;
474
475         return SYSTEM_INFO_ERROR_NONE;
476 }
477
478 int system_info_get_tvout_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
479 {
480         bool *supported;
481
482         supported = (bool *)value;
483
484         *supported = TVOUT_SUPPORT;
485
486         return SYSTEM_INFO_ERROR_NONE;
487 }
488
489 int system_info_get_wifi_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
490 {
491         bool *supported;
492
493         supported = (bool *)value;
494
495         if (WIFI_ERROR_NONE == wifi_initialize())
496                 *supported = true;
497         else
498                 *supported = false;
499
500         wifi_deinitialize();
501
502         return SYSTEM_INFO_ERROR_NONE;
503 }
504
505 int system_info_get_wifi_direct_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
506 {
507         bool *supported;
508
509         supported = (bool *)value;
510
511         /* this is a temporary code by wifi-direct team request */
512         *supported = true;
513
514         return SYSTEM_INFO_ERROR_NONE;
515 }
516
517 int system_info_get_haptic_supproted(system_info_key_e key, system_info_data_type_e data_type, void **value)
518 {
519         bool *supported;
520         int count;
521
522         supported = (bool *)value;
523
524         count = device_haptic_get_device_count();
525
526         if (count < 0)
527                 *supported = false;
528         else
529                 *supported = true;
530
531         return SYSTEM_INFO_ERROR_NONE;
532 }
533
534 int system_info_get_csc_sales_code(system_info_key_e key, system_info_data_type_e data_type, void **value)
535 {
536         char *CSC_SALES_CODE;
537
538         CSC_SALES_CODE = (char *)value;
539
540         if (system_info_vconf_get_value_string(VCONFKEY_CSC_SALESCODE, &CSC_SALES_CODE))
541                         return SYSTEM_INFO_ERROR_IO_ERROR;
542
543         return SYSTEM_INFO_ERROR_NONE;
544 }
545
546 int system_info_get_device_uuid(system_info_key_e key, system_info_data_type_e data_type, void **value)
547 {
548         char *imei = NULL;
549         char *UUID;
550         _UUID_OBJECT device_uuid;
551
552         system_info_get_value_string(SYSTEM_INFO_KEY_MOBILE_DEVICE_ID, &imei);
553
554         if (imei) {
555                 uuid_create_sha1_from_name(&device_uuid, VenderKey, imei, strlen(imei));
556
557                 if (uuid_object_to_string(device_uuid, &UUID))
558                         return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
559
560                 *value = UUID;
561
562                 free(imei);
563                 return SYSTEM_INFO_ERROR_NONE;
564         } else {
565                 LOGE("[%s] imei is NULL!!!", __func__);
566                 return SYSTEM_INFO_ERROR_IO_ERROR;
567         }
568 }
569
570 int system_info_get_usb_host_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
571 {
572         bool *supported;
573         int usbhost_state = 0;
574
575         supported = (bool *)value;
576
577         if (vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &usbhost_state))
578                 *supported = false;
579         else
580                 *supported = true;
581
582         return SYSTEM_INFO_ERROR_NONE;
583 }
584
585 int system_info_get_usb_accessory_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
586 {
587         bool *supported;
588         int usbhost_state = 0;
589
590         supported = (bool *)value;
591
592         if (vconf_get_int(VCONFKEY_USB_ACCESSORY_STATUS, &usbhost_state))
593                 *supported = false;
594         else
595                 *supported = true;
596
597         return SYSTEM_INFO_ERROR_NONE;
598 }
599
600 int system_info_get_front_camera_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
601 {
602         bool *supported;
603
604         supported = (bool *)value;
605
606         /* setting camera direction */
607         set_camera_direction_path();
608
609         /* There is no FacingDirection field in ini file */
610         if (!access(FRONT_CAM_PATH, R_OK))
611                 *supported = true;
612         else
613                 *supported = false;
614
615         /* free used memory for camera direction */
616         free(FRONT_CAM_PATH);
617         free(BACK_CAM_PATH);
618
619         return SYSTEM_INFO_ERROR_NONE;
620 }
621
622 int system_info_get_front_camera_af_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
623 {
624         bool *supported;
625         char str[MAXBUFSIZE];
626         char tmpStr[MAXBUFSIZE];
627         int tmpInt[6];
628         FILE *info = NULL;
629
630         supported = (bool *)value;
631         /* default value is false */
632         *supported = false;
633
634         /* setting camera direction */
635         set_camera_direction_path();
636
637         /* Return false, if there is no "/usr/etc/mmfw_camcorder_dev_video_sec.ini" file */
638         if (access(FRONT_CAM_PATH, R_OK))
639                 return SYSTEM_INFO_ERROR_NONE;
640
641         info = fopen(FRONT_CAM_PATH, "r");
642         if (NULL == info) {
643                 LOGE("[%s] cannot file open %s file!!!", __func__, FRONT_CAM_PATH);
644                 return SYSTEM_INFO_ERROR_IO_ERROR;
645         } else {
646                 while (fgets(str, MAXBUFSIZE, info)) {
647                         if (!strncmp(";", str, strlen(";")))
648                                 continue;
649                         else if (!strncmp("FocusMode", str, strlen("FocusMode"))) {
650                                 sscanf(str, "%s = %d,%d,%d,%d,%d,%d", tmpStr, &tmpInt[0], &tmpInt[1], &tmpInt[2], &tmpInt[3], &tmpInt[4], &tmpInt[5]);
651                                 if (tmpInt[2] != -255 || tmpInt[4] != -255)
652                                         *supported = true;
653                                 break;
654                         } else
655                                 continue;
656                 }
657         }
658
659         /* free used memory for camera direction */
660         free(FRONT_CAM_PATH);
661         free(BACK_CAM_PATH);
662
663         fclose(info);
664         return SYSTEM_INFO_ERROR_NONE;
665 }
666
667 int system_info_get_front_camera_flash_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
668 {
669         bool *supported;
670         char str[MAXBUFSIZE];
671         char tmpStr[MAXBUFSIZE];
672         int tmpInt[8];
673         int i = 0;
674         FILE *info = NULL;
675
676         supported = (bool *)value;
677         /* default value is false */
678         *supported = false;
679
680         /* setting camera direction */
681         set_camera_direction_path();
682
683         /* Return false, if there is no "/usr/etc/mmfw_camcorder_dev_video_sec.ini" file */
684         if (access(FRONT_CAM_PATH, R_OK))
685                 return SYSTEM_INFO_ERROR_NONE;
686
687         info = fopen(FRONT_CAM_PATH, "r");
688         if (NULL == info) {
689                 LOGE("[%s] cannot file open %s file!!!", __func__, FRONT_CAM_PATH);
690                 return SYSTEM_INFO_ERROR_IO_ERROR;
691         } else {
692                 while (fgets(str, MAXBUFSIZE, info)) {
693                         if (!strncmp(";", str, strlen(";")))
694                                 continue;
695                         else if (!strncmp("StrobeMode", str, strlen("StrobeMode"))) {
696                                 sscanf(str, "%s = %d,%d,%d,%d,%d,%d,%d,%d", tmpStr, &tmpInt[0], &tmpInt[1], &tmpInt[2], &tmpInt[3], &tmpInt[4], &tmpInt[5], &tmpInt[6], &tmpInt[7]);
697                                 for (i = 1; i < 8; i++) {
698                                         if (tmpInt[i] != -255)
699                                                 *supported = true;
700                                 }
701                                 break;
702                         } else
703                                 continue;
704                 }
705         }
706
707         /* free used memory for camera direction */
708         free(FRONT_CAM_PATH);
709         free(BACK_CAM_PATH);
710
711         fclose(info);
712         return SYSTEM_INFO_ERROR_NONE;
713 }
714
715 int system_info_get_back_camera_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
716 {
717         bool *supported;
718
719         supported = (bool *)value;
720
721         /* setting camera direction */
722         set_camera_direction_path();
723
724         if (!access(BACK_CAM_PATH, R_OK))
725                 *supported = true;
726         else
727                 *supported = false;
728
729         /* free used memory for camera direction */
730         free(FRONT_CAM_PATH);
731         free(BACK_CAM_PATH);
732
733         return SYSTEM_INFO_ERROR_NONE;
734 }
735
736 int system_info_get_back_camera_af_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
737 {
738         bool *supported;
739         char str[MAXBUFSIZE];
740         char tmpStr[MAXBUFSIZE];
741         int tmpInt[6];
742         FILE *info = NULL;
743
744         supported = (bool *)value;
745         /* default value is false */
746         *supported = false;
747
748         /* setting camera direction */
749         set_camera_direction_path();
750
751         /* Return false, if there is no "/usr/etc/mmfw_camcorder_dev_video_pri.ini" file */
752         if (access(BACK_CAM_PATH, R_OK))
753                 return SYSTEM_INFO_ERROR_NONE;
754
755         info = fopen(BACK_CAM_PATH, "r");
756         if (NULL == info) {
757                 LOGE("[%s] cannot file open %s file!!!", __func__, BACK_CAM_PATH);
758                 return SYSTEM_INFO_ERROR_IO_ERROR;
759         } else {
760                 while (fgets(str, MAXBUFSIZE, info)) {
761                         if (!strncmp(";", str, strlen(";")))
762                                 continue;
763                         else if (!strncmp("FocusMode", str, strlen("FocusMode"))) {
764                                 sscanf(str, "%s = %d,%d,%d,%d,%d,%d", tmpStr, &tmpInt[0], &tmpInt[1], &tmpInt[2], &tmpInt[3], &tmpInt[4], &tmpInt[5]);
765                                 if (tmpInt[2] != -255 || tmpInt[4] != -255)
766                                         *supported = true;
767                                 break;
768                         } else
769                                 continue;
770                 }
771         }
772
773         /* free used memory for camera direction */
774         free(FRONT_CAM_PATH);
775         free(BACK_CAM_PATH);
776
777         fclose(info);
778         return SYSTEM_INFO_ERROR_NONE;
779 }
780
781 int system_info_get_back_camera_flash_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
782 {
783         bool *supported;
784         char str[MAXBUFSIZE];
785         char tmpStr[MAXBUFSIZE];
786         int tmpInt[8];
787         int i = 0;
788         FILE *info = NULL;
789
790         supported = (bool *)value;
791         /* default value is false */
792         *supported = false;
793
794         /* setting camera direction */
795         set_camera_direction_path();
796
797         /* Return false, if there is no "/usr/etc/mmfw_camcorder_dev_video_pri.ini" file */
798         if (access(BACK_CAM_PATH, R_OK))
799                 return SYSTEM_INFO_ERROR_NONE;
800
801         info = fopen(BACK_CAM_PATH, "r");
802         if (NULL == info) {
803                 LOGE("[%s] cannot file open %s file!!!", __func__, BACK_CAM_PATH);
804                 return SYSTEM_INFO_ERROR_IO_ERROR;
805         } else {
806                 while (fgets(str, MAXBUFSIZE, info)) {
807                         if (!strncmp(";", str, strlen(";")))
808                                 continue;
809                         else if (!strncmp("StrobeMode", str, strlen("StrobeMode"))) {
810                                 sscanf(str, "%s = %d,%d,%d,%d,%d,%d,%d,%d", tmpStr, &tmpInt[0], &tmpInt[1], &tmpInt[2], &tmpInt[3], &tmpInt[4], &tmpInt[5], &tmpInt[6], &tmpInt[7]);
811                                 for (i = 1; i < 8; i++) {
812                                         if (tmpInt[i] != -255)
813                                                 *supported = true;
814                                 }
815                                 break;
816                         } else
817                                 continue;
818                 }
819         }
820
821         /* free used memory for camera direction */
822         free(FRONT_CAM_PATH);
823         free(BACK_CAM_PATH);
824
825         fclose(info);
826         return SYSTEM_INFO_ERROR_NONE;
827 }
828
829
830 int system_info_get_sip_voip_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
831 {
832         bool *supported;
833
834         supported = (bool *)value;
835
836         *supported = SIP_VOIP_SUPPROT;
837
838         return SYSTEM_INFO_ERROR_NONE;
839 }
840
841 int system_info_get_microphone_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
842 {
843         bool *supported;
844         sound_device_in_e in;
845         sound_device_out_e out;
846
847         supported = (bool *)value;
848
849         if (SOUND_MANAGER_ERROR_NONE == sound_manager_get_active_device(&in, &out)) {
850                 if (in == SOUND_DEVICE_IN_MIC)
851                         *supported = true;
852                 else
853                         *supported = false;
854         } else
855                 *supported = false;
856
857         return SYSTEM_INFO_ERROR_NONE;
858 }
859
860 int system_info_get_speech_recognition_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
861 {
862         bool *supported;
863
864         supported = (bool *)value;
865
866         *supported = SPEECH_RECOGNITION_SUPPROT;
867
868         return SYSTEM_INFO_ERROR_NONE;
869 }
870
871 int system_info_get_barometer_sensor_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
872 {
873         bool *supported;
874
875         supported = (bool *)value;
876
877         if (sf_is_sensor_event_available(BAROMETER_SENSOR, 0))
878                 *supported = false;
879         else
880                 *supported = true;
881
882         return SYSTEM_INFO_ERROR_NONE;
883 }