2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <system_info.h>
26 #include <system_info_private.h>
32 #define LOG_TAG "TIZEN_N_SYSTEM_INFO"
34 #define SYSTEM_INFO_MAX -1
37 system_info_key_e key;
38 system_info_data_type_e data_type;
39 system_info_get_value_cb get_value_cb;
42 typedef system_info_s *system_info_h;
44 system_info_s system_info_table[] = {
47 /**< The model of the device */
48 SYSTEM_INFO_KEY_MODEL,
49 SYSTEM_INFO_DATA_TYPE_STRING,
54 /**< The version of the Tizen supported by the platform */
55 SYSTEM_INFO_KEY_TIZEN_VERSION,
56 SYSTEM_INFO_DATA_TYPE_STRING,
57 system_info_get_tizen_version
61 /**< Indicates whether the device supports Bluetooth */
62 SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED,
63 SYSTEM_INFO_DATA_TYPE_BOOL,
64 system_info_get_bluetooth_supported
68 /**< The number of cameras in the device */
69 SYSTEM_INFO_KEY_CAMERA_COUNT,
70 SYSTEM_INFO_DATA_TYPE_INT,
71 system_info_get_camera_count
75 /**< Indicates whether the device supports FM radio */
76 SYSTEM_INFO_KEY_FMRADIO_SUPPORTED,
77 SYSTEM_INFO_DATA_TYPE_BOOL,
78 system_info_get_fmradio_supported
82 /**< Indicates whether the device supports GPS */
83 SYSTEM_INFO_KEY_GPS_SUPPORTED,
84 SYSTEM_INFO_DATA_TYPE_BOOL,
85 system_info_get_gps_supported
89 /**< The type of the keyboard */
90 SYSTEM_INFO_KEY_KEYBOARD_TYPE,
91 SYSTEM_INFO_DATA_TYPE_STRING,
92 system_info_get_keyboard_type
96 /**< The maximum number of concurrent touch points supported in the device */
97 SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT,
98 SYSTEM_INFO_DATA_TYPE_INT,
99 system_info_get_multi_point_touch_count
103 /**< The supported network type */
104 SYSTEM_INFO_KEY_NETWORK_TYPE,
105 SYSTEM_INFO_DATA_TYPE_STRING,
106 system_info_get_network_type
110 /**< Indicates whether the device supports NFC */
111 SYSTEM_INFO_KEY_NFC_SUPPORTED,
112 SYSTEM_INFO_DATA_TYPE_BOOL,
113 system_info_get_nfc_supported
117 /**< The supported version of the OpenGL ES */
118 SYSTEM_INFO_KEY_OPENGLES_VERSION,
119 SYSTEM_INFO_DATA_TYPE_STRING,
120 system_info_get_opengles_version
124 /**< The number of bits per pixel */
125 SYSTEM_INFO_KEY_SCREEN_BITS_PER_PIXEL,
126 SYSTEM_INFO_DATA_TYPE_INT,
127 system_info_get_screen_bits_per_pixel
131 /**< The height of the screen in pixels */
132 SYSTEM_INFO_KEY_SCREEN_HEIGHT,
133 SYSTEM_INFO_DATA_TYPE_INT,
134 system_info_get_screen_height
138 /**< The width of the screen in pixels */
139 SYSTEM_INFO_KEY_SCREEN_WIDTH,
140 SYSTEM_INFO_DATA_TYPE_INT,
141 system_info_get_screen_width
145 /**< Indicates whether the device supports TV-out */
146 SYSTEM_INFO_KEY_TVOUT_SUPPORTED,
147 SYSTEM_INFO_DATA_TYPE_BOOL,
148 system_info_get_tvout_supported
152 /**< Indicates whether the device supports Wi-Fi */
153 SYSTEM_INFO_KEY_WIFI_SUPPORTED,
154 SYSTEM_INFO_DATA_TYPE_BOOL,
155 system_info_get_wifi_supported
159 /**< The unique ID to identify GSM, and UMTS mobile devices */
160 SYSTEM_INFO_KEY_MOBILE_DEVICE_ID,
161 SYSTEM_INFO_DATA_TYPE_STRING,
162 system_info_get_mobile_device_id
166 SYSTEM_INFO_MAX, -1, NULL
171 static int system_info_get(system_info_key_e key, system_info_h *system_info)
175 while (system_info_table[index].key != SYSTEM_INFO_MAX)
177 if (system_info_table[index].key == key)
179 *system_info = &system_info_table[index];
189 int system_info_get_value(system_info_key_e key, system_info_data_type_e data_type, void **value)
191 system_info_h system_info;
192 system_info_get_value_cb system_info_getter;
196 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid output param", __FUNCTION__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
197 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
200 if (system_info_get(key, &system_info))
202 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
203 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
206 if (system_info->data_type != data_type)
208 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
209 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
212 system_info_getter = system_info->get_value_cb;
214 if (system_info_getter == NULL)
216 LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system information", __FUNCTION__, SYSTEM_INFO_ERROR_IO_ERROR);
217 return SYSTEM_INFO_ERROR_IO_ERROR;
220 return system_info_getter(key, system_info->data_type, value);
223 int system_info_get_value_int(system_info_key_e key, int *value)
225 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_INT, (void**)value);
228 int system_info_get_value_bool(system_info_key_e key, bool *value)
230 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_BOOL, (void**)value);
233 int system_info_get_value_double(system_info_key_e key, double *value)
235 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_DOUBLE, (void**)value);
238 int system_info_get_value_string(system_info_key_e key, char **value)
240 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_STRING, (void**)value);