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>
27 #include <sys/utsname.h>
33 #define LOG_TAG "CAPI_SYSTEM_INFO"
35 #define SYSTEM_INFO_MAX -1
38 system_info_key_e key;
39 system_info_data_type_e data_type;
40 system_info_get_value_cb get_value_cb;
43 typedef system_info_s * system_info_h;
45 system_info_s system_info_table[] = {
48 /**< The model of the device */
49 SYSTEM_INFO_KEY_MODEL,
50 SYSTEM_INFO_DATA_TYPE_STRING,
55 /**< The version of the Tizen supported by the platform */
56 SYSTEM_INFO_KEY_TIZEN_VERSION,
57 SYSTEM_INFO_DATA_TYPE_STRING,
58 system_info_get_tizen_version
62 /**< Indicates whether the device supports Bluetooth */
63 SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED,
64 SYSTEM_INFO_DATA_TYPE_BOOL,
65 system_info_get_bluetooth_supported
69 /**< The number of cameras in the device */
70 SYSTEM_INFO_KEY_CAMERA_COUNT,
71 SYSTEM_INFO_DATA_TYPE_INT,
72 system_info_get_camera_count
76 /**< Indicates whether the device supports FM radio */
77 SYSTEM_INFO_KEY_FMRADIO_SUPPORTED,
78 SYSTEM_INFO_DATA_TYPE_BOOL,
79 system_info_get_fmradio_supported
83 /**< Indicates whether the device supports GPS */
84 SYSTEM_INFO_KEY_GPS_SUPPORTED,
85 SYSTEM_INFO_DATA_TYPE_BOOL,
86 system_info_get_gps_supported
90 /**< The type of the keyboard */
91 SYSTEM_INFO_KEY_KEYBOARD_TYPE,
92 SYSTEM_INFO_DATA_TYPE_STRING,
93 system_info_get_keyboard_type
97 /**< The maximum number of concurrent touch points supported
99 SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT,
100 SYSTEM_INFO_DATA_TYPE_INT,
101 system_info_get_multi_point_touch_count
105 /**< The supported network type */
106 SYSTEM_INFO_KEY_NETWORK_TYPE,
107 SYSTEM_INFO_DATA_TYPE_STRING,
108 system_info_get_network_type
112 /**< Indicates whether the device supports NFC */
113 SYSTEM_INFO_KEY_NFC_SUPPORTED,
114 SYSTEM_INFO_DATA_TYPE_BOOL,
115 system_info_get_nfc_supported
119 /**< The supported version of the OpenGL ES */
120 SYSTEM_INFO_KEY_OPENGLES_VERSION,
121 SYSTEM_INFO_DATA_TYPE_STRING,
122 system_info_get_opengles_version
126 /**< The number of bits per pixel */
127 SYSTEM_INFO_KEY_SCREEN_BITS_PER_PIXEL,
128 SYSTEM_INFO_DATA_TYPE_INT,
129 system_info_get_screen_bits_per_pixel
133 /**< The height of the screen in pixels */
134 SYSTEM_INFO_KEY_SCREEN_HEIGHT,
135 SYSTEM_INFO_DATA_TYPE_INT,
136 system_info_get_screen_height
140 /**< The width of the screen in pixels */
141 SYSTEM_INFO_KEY_SCREEN_WIDTH,
142 SYSTEM_INFO_DATA_TYPE_INT,
143 system_info_get_screen_width
147 /**< Indicates whether the device supports TV-out */
148 SYSTEM_INFO_KEY_TVOUT_SUPPORTED,
149 SYSTEM_INFO_DATA_TYPE_BOOL,
150 system_info_get_tvout_supported
154 /**< Indicates whether the device supports Wi-Fi */
155 SYSTEM_INFO_KEY_WIFI_SUPPORTED,
156 SYSTEM_INFO_DATA_TYPE_BOOL,
157 system_info_get_wifi_supported
161 /**< The unique ID to identify GSM, and UMTS mobile devices */
162 SYSTEM_INFO_KEY_MOBILE_DEVICE_ID,
163 SYSTEM_INFO_DATA_TYPE_STRING,
164 system_info_get_mobile_device_id
168 /**< The sales code of the CSC */
169 SYSTEM_INFO_KEY_CSC_SALES_CODE,
170 SYSTEM_INFO_DATA_TYPE_STRING,
171 system_info_get_csc_sales_code
175 /**< The Name of the Platform */
176 SYSTEM_INFO_KEY_PLATFORM_NAME,
177 SYSTEM_INFO_DATA_TYPE_STRING,
178 system_info_get_platform_name
182 /**< The Name of the Tizen version */
183 SYSTEM_INFO_KEY_TIZEN_VERSION_NAME,
184 SYSTEM_INFO_DATA_TYPE_STRING,
185 system_info_get_tizen_version_name
189 /**< Indicates whether the device supports HAPTIC */
190 SYSTEM_INFO_KEY_HAPTIC_SUPPORTED,
191 SYSTEM_INFO_DATA_TYPE_BOOL,
192 system_info_get_haptic_supproted
196 /**< Indicates whether the device supports HAPTIC */
197 SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED,
198 SYSTEM_INFO_DATA_TYPE_BOOL,
199 system_info_get_wifi_direct_supported
203 /**< The height of the screen DPI */
204 SYSTEM_INFO_KEY_SCREEN_DPI,
205 SYSTEM_INFO_DATA_TYPE_INT,
206 system_info_get_screen_DPI
210 /**< The Device unique ID to identify */
211 SYSTEM_INFO_KEY_DEVICE_UUID,
212 SYSTEM_INFO_DATA_TYPE_STRING,
213 system_info_get_device_uuid
217 /**< Indicates whether the device supports GPS */
218 SYSTEM_INFO_KEY_CPS_SUPPORTED,
219 SYSTEM_INFO_DATA_TYPE_BOOL,
220 system_info_get_cps_supported
224 /**< Indicates whether the device supports GPS */
225 SYSTEM_INFO_KEY_WPS_SUPPORTED,
226 SYSTEM_INFO_DATA_TYPE_BOOL,
227 system_info_get_wps_supported
231 /**< Indicates whether the device supports USB host */
232 SYSTEM_INFO_KEY_USB_HOST_SUPPORTED,
233 SYSTEM_INFO_DATA_TYPE_BOOL,
234 system_info_get_usb_host_supported
238 /**< Indicates whether the device supports USB accessory */
239 SYSTEM_INFO_KEY_USB_ACCESSORY_SUPPORTED,
240 SYSTEM_INFO_DATA_TYPE_BOOL,
241 system_info_get_usb_accessory_supported
245 /**< The CORE CPU architecture of model */
246 SYSTEM_INFO_KEY_CORE_CPU_ARCH,
247 SYSTEM_INFO_DATA_TYPE_STRING,
248 system_info_get_core_cpu_arch
252 /**< The CORE FPU architecture of model */
253 SYSTEM_INFO_KEY_CORE_FPU_ARCH,
254 SYSTEM_INFO_DATA_TYPE_STRING,
255 system_info_get_core_fpu_arch
259 /**< Indicates whether the device supports front camera */
260 SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED,
261 SYSTEM_INFO_DATA_TYPE_BOOL,
262 system_info_get_front_camera_supported
266 /**< Indicates whether the device supports front camera auto focus */
267 SYSTEM_INFO_KEY_FRONT_CAMERA_AF_SUPPORTED,
268 SYSTEM_INFO_DATA_TYPE_BOOL,
269 system_info_get_front_camera_af_supported
273 /**< Indicates whether the device supports front camera flash */
274 SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED,
275 SYSTEM_INFO_DATA_TYPE_BOOL,
276 system_info_get_front_camera_flash_supported
280 /**< Indicates whether the device supports back camera */
281 SYSTEM_INFO_KEY_BACK_CAMERA_SUPPORTED,
282 SYSTEM_INFO_DATA_TYPE_BOOL,
283 system_info_get_back_camera_supported
287 /**< Indicates whether the device supports back camera auto focus */
288 SYSTEM_INFO_KEY_BACK_CAMERA_AF_SUPPORTED,
289 SYSTEM_INFO_DATA_TYPE_BOOL,
290 system_info_get_back_camera_af_supported
294 /**< Indicates whether the device supports back camera flash */
295 SYSTEM_INFO_KEY_BACK_CAMERA_FLASH_SUPPORTED,
296 SYSTEM_INFO_DATA_TYPE_BOOL,
297 system_info_get_back_camera_flash_supported
301 /**< Indicates whether the device supports HDMI */
302 SYSTEM_INFO_KEY_HDMI_SUPPORTED,
303 SYSTEM_INFO_DATA_TYPE_BOOL,
304 system_info_get_hdmi_supported
308 /**< Indicates whether the device supports RCA */
309 SYSTEM_INFO_KEY_RCA_SUPPORTED,
310 SYSTEM_INFO_DATA_TYPE_BOOL,
311 system_info_get_rca_supported
315 /**< Indicates whether the device supports SIP VOIP */
316 SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED,
317 SYSTEM_INFO_DATA_TYPE_BOOL,
318 system_info_get_sip_voip_supported
322 /**< Indicates whether the device supports Microphone */
323 SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED,
324 SYSTEM_INFO_DATA_TYPE_BOOL,
325 system_info_get_microphone_supported
329 /**< Indicates whether the device supports stt */
330 SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED,
331 SYSTEM_INFO_DATA_TYPE_BOOL,
332 system_info_get_speech_recognition_supported
336 /**< Indicates whether the device supports barometer sensor */
337 SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED,
338 SYSTEM_INFO_DATA_TYPE_BOOL,
339 system_info_get_barometer_sensor_supported
343 /**< The supported texture format of the OpenGL ES */
344 SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT,
345 SYSTEM_INFO_DATA_TYPE_STRING,
346 system_info_get_opengles_texture_format
350 /**< The CORE CPU frequency of model */
351 SYSTEM_INFO_KEY_CORE_CPU_FREQ,
352 SYSTEM_INFO_DATA_TYPE_DOUBLE,
353 system_info_get_core_cpu_freq
357 /**< The height of the physical screen size in millimeters */
358 SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT,
359 SYSTEM_INFO_DATA_TYPE_INT,
360 system_info_get_physical_screen_height
364 /**< The width of the physical screen size in millimeters */
365 SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH,
366 SYSTEM_INFO_DATA_TYPE_INT,
367 system_info_get_physical_screen_width
371 /**< The build string of the platform binary */
372 SYSTEM_INFO_KEY_BUILD_STRING,
373 SYSTEM_INFO_DATA_TYPE_STRING,
374 system_info_get_build_string
378 /**< The build date of the platform binary */
379 SYSTEM_INFO_KEY_BUILD_DATE,
380 SYSTEM_INFO_DATA_TYPE_STRING,
381 system_info_get_build_date
385 /**< The build time of the platform binary */
386 SYSTEM_INFO_KEY_BUILD_TIME,
387 SYSTEM_INFO_DATA_TYPE_STRING,
388 system_info_get_build_time
392 /**< The manufacturer of the device */
393 SYSTEM_INFO_KEY_MANUFACTURER,
394 SYSTEM_INFO_DATA_TYPE_STRING,
395 system_info_get_manufacturer
399 /**< The method of interface with CP */
400 SYSTEM_INFO_KEY_CP_INTERFACE,
401 SYSTEM_INFO_DATA_TYPE_STRING,
402 system_info_get_cp_interface
406 SYSTEM_INFO_MAX, -1, NULL
411 static system_info_mode_type_e system_info_system_info_model_type;
412 static int system_info_initialized;
414 int system_info_get_system_info_initialized()
416 return system_info_initialized;
419 void system_info_set_system_info_initialized(int value)
421 system_info_initialized = value;
424 system_info_mode_type_e system_info_get_system_info_model_type()
426 return system_info_system_info_model_type;
429 int system_info_init(void)
431 struct utsname device_name;
432 extern char *strcasestr(const char *s, const char *find);
434 int error = uname(&device_name);
437 LOGE("uname returns error!!!");
438 return SYSTEM_INFO_ERROR_IO_ERROR;
440 if (strcasestr(device_name.machine, "emulated"))
441 system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_EMULATOR;
443 system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_TARGET;
445 system_info_set_system_info_initialized(1);
447 return SYSTEM_INFO_ERROR_NONE;
450 static int system_info_get(system_info_key_e key, system_info_h *system_info)
455 if (0 == system_info_get_system_info_initialized()) {
456 ret_val = system_info_init();
458 LOGE("system information initialize fail!!!");
463 while (system_info_table[index].key != SYSTEM_INFO_MAX) {
464 if (system_info_table[index].key == key) {
465 *system_info = &system_info_table[index];
475 int system_info_get_value(system_info_key_e key, system_info_data_type_e data_type, void **value)
477 system_info_h system_info;
478 system_info_get_value_cb system_info_getter;
481 LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", SYSTEM_INFO_ERROR_INVALID_PARAMETER);
482 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
485 if (system_info_get(key, &system_info)) {
486 LOGE("INVALID_PARAMETER(0x%08x) : invalid key", SYSTEM_INFO_ERROR_INVALID_PARAMETER);
487 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
490 if (system_info->data_type != data_type) {
491 LOGE("INVALID_PARAMETER(0x%08x) : invalid data type", SYSTEM_INFO_ERROR_INVALID_PARAMETER);
492 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
495 system_info_getter = system_info->get_value_cb;
497 if (system_info_getter == NULL) {
498 LOGE("IO_ERROR(0x%08x) : failed to call getter for the system information", SYSTEM_INFO_ERROR_IO_ERROR);
499 return SYSTEM_INFO_ERROR_IO_ERROR;
502 return system_info_getter(key, system_info->data_type, value);
505 int system_info_get_value_int(system_info_key_e key, int *value)
507 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_INT, (void **)value);
510 int system_info_get_value_bool(system_info_key_e key, bool *value)
512 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_BOOL, (void **)value);
515 int system_info_get_value_double(system_info_key_e key, double *value)
517 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_DOUBLE, (void **)value);
520 int system_info_get_value_string(system_info_key_e key, char **value)
522 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_STRING, (void **)value);