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
98 SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT,
99 SYSTEM_INFO_DATA_TYPE_INT,
100 system_info_get_multi_point_touch_count
104 /**< The supported network type */
105 SYSTEM_INFO_KEY_NETWORK_TYPE,
106 SYSTEM_INFO_DATA_TYPE_STRING,
107 system_info_get_network_type
111 /**< Indicates whether the device supports NFC */
112 SYSTEM_INFO_KEY_NFC_SUPPORTED,
113 SYSTEM_INFO_DATA_TYPE_BOOL,
114 system_info_get_nfc_supported
118 /**< The supported version of the OpenGL ES */
119 SYSTEM_INFO_KEY_OPENGLES_VERSION,
120 SYSTEM_INFO_DATA_TYPE_STRING,
121 system_info_get_opengles_version
125 /**< The number of bits per pixel */
126 SYSTEM_INFO_KEY_SCREEN_BITS_PER_PIXEL,
127 SYSTEM_INFO_DATA_TYPE_INT,
128 system_info_get_screen_bits_per_pixel
132 /**< The height of the screen in pixels */
133 SYSTEM_INFO_KEY_SCREEN_HEIGHT,
134 SYSTEM_INFO_DATA_TYPE_INT,
135 system_info_get_screen_height
139 /**< The width of the screen in pixels */
140 SYSTEM_INFO_KEY_SCREEN_WIDTH,
141 SYSTEM_INFO_DATA_TYPE_INT,
142 system_info_get_screen_width
146 /**< Indicates whether the device supports TV-out */
147 SYSTEM_INFO_KEY_TVOUT_SUPPORTED,
148 SYSTEM_INFO_DATA_TYPE_BOOL,
149 system_info_get_tvout_supported
153 /**< Indicates whether the device supports Wi-Fi */
154 SYSTEM_INFO_KEY_WIFI_SUPPORTED,
155 SYSTEM_INFO_DATA_TYPE_BOOL,
156 system_info_get_wifi_supported
160 /**< The unique ID to identify GSM, and UMTS mobile devices */
161 SYSTEM_INFO_KEY_MOBILE_DEVICE_ID,
162 SYSTEM_INFO_DATA_TYPE_STRING,
163 system_info_get_mobile_device_id
167 /**< The sales code of the CSC */
168 SYSTEM_INFO_KEY_CSC_SALES_CODE,
169 SYSTEM_INFO_DATA_TYPE_STRING,
170 system_info_get_csc_sales_code
174 /**< The Name of the Platform */
175 SYSTEM_INFO_KEY_PLATFORM_NAME,
176 SYSTEM_INFO_DATA_TYPE_STRING,
177 system_info_get_platform_name
181 /**< The Name of the Tizen version */
182 SYSTEM_INFO_KEY_TIZEN_VERSION_NAME,
183 SYSTEM_INFO_DATA_TYPE_STRING,
184 system_info_get_tizen_version_name
188 /**< Indicates whether the device supports HAPTIC */
189 SYSTEM_INFO_KEY_HAPTIC_SUPPORTED,
190 SYSTEM_INFO_DATA_TYPE_BOOL,
191 system_info_get_haptic_supproted
195 /**< Indicates whether the device supports HAPTIC */
196 SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED,
197 SYSTEM_INFO_DATA_TYPE_BOOL,
198 system_info_get_wifi_direct_supported
202 /**< The height of the screen DPI */
203 SYSTEM_INFO_KEY_SCREEN_DPI,
204 SYSTEM_INFO_DATA_TYPE_INT,
205 system_info_get_screen_DPI
209 /**< The Device unique ID to identify */
210 SYSTEM_INFO_KEY_DEVICE_UUID,
211 SYSTEM_INFO_DATA_TYPE_STRING,
212 system_info_get_device_uuid
216 /**< Indicates whether the device supports GPS */
217 SYSTEM_INFO_KEY_CPS_SUPPORTED,
218 SYSTEM_INFO_DATA_TYPE_BOOL,
219 system_info_get_cps_supported
223 /**< Indicates whether the device supports GPS */
224 SYSTEM_INFO_KEY_WPS_SUPPORTED,
225 SYSTEM_INFO_DATA_TYPE_BOOL,
226 system_info_get_wps_supported
230 /**< Indicates whether the device supports USB host */
231 SYSTEM_INFO_KEY_USB_HOST_SUPPORTED,
232 SYSTEM_INFO_DATA_TYPE_BOOL,
233 system_info_get_usb_host_supported
237 /**< Indicates whether the device supports USB accessory */
238 SYSTEM_INFO_KEY_USB_ACCESSORY_SUPPORTED,
239 SYSTEM_INFO_DATA_TYPE_BOOL,
240 system_info_get_usb_accessory_supported
244 /**< The CORE CPU architecture of model */
245 SYSTEM_INFO_KEY_CORE_CPU_ARCH,
246 SYSTEM_INFO_DATA_TYPE_STRING,
247 system_info_get_core_cpu_arch
251 /**< The CORE FPU architecture of model */
252 SYSTEM_INFO_KEY_CORE_FPU_ARCH,
253 SYSTEM_INFO_DATA_TYPE_STRING,
254 system_info_get_core_fpu_arch
258 /**< Indicates whether the device supports front camera */
259 SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED,
260 SYSTEM_INFO_DATA_TYPE_BOOL,
261 system_info_get_front_camera_supported
265 /**< Indicates whether the device supports front camera auto focus */
266 SYSTEM_INFO_KEY_FRONT_CAMERA_AF_SUPPORTED,
267 SYSTEM_INFO_DATA_TYPE_BOOL,
268 system_info_get_front_camera_af_supported
272 /**< Indicates whether the device supports front camera flash */
273 SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED,
274 SYSTEM_INFO_DATA_TYPE_BOOL,
275 system_info_get_front_camera_flash_supported
279 /**< Indicates whether the device supports back camera */
280 SYSTEM_INFO_KEY_BACK_CAMERA_SUPPORTED,
281 SYSTEM_INFO_DATA_TYPE_BOOL,
282 system_info_get_back_camera_supported
286 /**< Indicates whether the device supports back camera auto focus */
287 SYSTEM_INFO_KEY_BACK_CAMERA_AF_SUPPORTED,
288 SYSTEM_INFO_DATA_TYPE_BOOL,
289 system_info_get_back_camera_af_supported
293 /**< Indicates whether the device supports back camera flash */
294 SYSTEM_INFO_KEY_BACK_CAMERA_FLASH_SUPPORTED,
295 SYSTEM_INFO_DATA_TYPE_BOOL,
296 system_info_get_back_camera_flash_supported
300 /**< Indicates whether the device supports HDMI */
301 SYSTEM_INFO_KEY_HDMI_SUPPORTED,
302 SYSTEM_INFO_DATA_TYPE_BOOL,
303 system_info_get_hdmi_supported
307 /**< Indicates whether the device supports RCA */
308 SYSTEM_INFO_KEY_RCA_SUPPORTED,
309 SYSTEM_INFO_DATA_TYPE_BOOL,
310 system_info_get_rca_supported
314 /**< Indicates whether the device supports SIP VOIP */
315 SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED,
316 SYSTEM_INFO_DATA_TYPE_BOOL,
317 system_info_get_sip_voip_supported
321 /**< Indicates whether the device supports Microphone */
322 SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED,
323 SYSTEM_INFO_DATA_TYPE_BOOL,
324 system_info_get_microphone_supported
328 /**< Indicates whether the device supports stt */
329 SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED,
330 SYSTEM_INFO_DATA_TYPE_BOOL,
331 system_info_get_speech_recognition_supported
335 /**< Indicates whether the device supports barometer sensor */
336 SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED,
337 SYSTEM_INFO_DATA_TYPE_BOOL,
338 system_info_get_barometer_sensor_supported
342 /**< The supported texture format of the OpenGL ES */
343 SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT,
344 SYSTEM_INFO_DATA_TYPE_STRING,
345 system_info_get_opengles_texture_format
349 /**< The CORE CPU frequency of model */
350 SYSTEM_INFO_KEY_CORE_CPU_FREQ,
351 SYSTEM_INFO_DATA_TYPE_DOUBLE,
352 system_info_get_core_cpu_freq
356 /**< The height of the physical screen size in millimeters */
357 SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT,
358 SYSTEM_INFO_DATA_TYPE_INT,
359 system_info_get_physical_screen_height
363 /**< The width of the physical screen size in millimeters */
364 SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH,
365 SYSTEM_INFO_DATA_TYPE_INT,
366 system_info_get_physical_screen_width
370 /**< The build string of the platform binary */
371 SYSTEM_INFO_KEY_BUILD_STRING,
372 SYSTEM_INFO_DATA_TYPE_STRING,
373 system_info_get_build_string
377 /**< The build date of the platform binary */
378 SYSTEM_INFO_KEY_BUILD_DATE,
379 SYSTEM_INFO_DATA_TYPE_STRING,
380 system_info_get_build_date
384 /**< The build time of the platform binary */
385 SYSTEM_INFO_KEY_BUILD_TIME,
386 SYSTEM_INFO_DATA_TYPE_STRING,
387 system_info_get_build_time
391 SYSTEM_INFO_MAX, -1, NULL
396 static system_info_mode_type_e system_info_system_info_model_type;
397 static int system_info_initialized;
399 int system_info_get_system_info_initialized()
401 return system_info_initialized;
404 void system_info_set_system_info_initialized(int value)
406 system_info_initialized = value;
409 system_info_mode_type_e system_info_get_system_info_model_type()
411 return system_info_system_info_model_type;
414 int system_info_init(void)
417 char str[MAXBUFSIZE];
418 extern char *strcasestr(const char *s, const char *find);
420 fp = popen("uname -m", "r");
422 LOGE("[%s] cannot execute uname command!!!", __func__);
423 return SYSTEM_INFO_ERROR_IO_ERROR;
425 while (fgets(str, MAXBUFSIZE, fp)) {
426 if (strcasestr(str, "emulated")) {
427 system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_EMULATOR;
428 system_info_set_system_info_initialized(1);
430 return SYSTEM_INFO_ERROR_NONE;
435 system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_TARGET;
436 system_info_set_system_info_initialized(1);
438 return SYSTEM_INFO_ERROR_NONE;
442 static int system_info_get(system_info_key_e key, system_info_h *system_info)
447 if (0 == system_info_get_system_info_initialized()) {
448 ret_val = system_info_init();
450 LOGE("[%s] system information initialize fail!!!", __func__);
455 while (system_info_table[index].key != SYSTEM_INFO_MAX) {
456 if (system_info_table[index].key == key) {
457 *system_info = &system_info_table[index];
467 int system_info_get_value(system_info_key_e key, system_info_data_type_e data_type, void **value)
469 system_info_h system_info;
470 system_info_get_value_cb system_info_getter;
473 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid output param", __func__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
474 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
477 if (system_info_get(key, &system_info)) {
478 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __func__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
479 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
482 if (system_info->data_type != data_type) {
483 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __func__, SYSTEM_INFO_ERROR_INVALID_PARAMETER);
484 return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
487 system_info_getter = system_info->get_value_cb;
489 if (system_info_getter == NULL) {
490 LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system information", __func__, SYSTEM_INFO_ERROR_IO_ERROR);
491 return SYSTEM_INFO_ERROR_IO_ERROR;
494 return system_info_getter(key, system_info->data_type, value);
497 int system_info_get_value_int(system_info_key_e key, int *value)
499 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_INT, (void **)value);
502 int system_info_get_value_bool(system_info_key_e key, bool *value)
504 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_BOOL, (void **)value);
507 int system_info_get_value_double(system_info_key_e key, double *value)
509 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_DOUBLE, (void **)value);
512 int system_info_get_value_string(system_info_key_e key, char **value)
514 return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_STRING, (void **)value);