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 "CAPI_SYSTEM_INFO"
34 int system_info_get_model(system_info_key_e key, system_info_data_type_e data_type, void **value)
36 return system_info_ini_get_string(INFO_FILE_PATH, "version:model", (char **)value);
39 int system_info_get_build_string(system_info_key_e key, system_info_data_type_e data_type, void **value)
41 return system_info_ini_get_string(INFO_FILE_PATH, "version:build", (char **)value);
44 int system_info_get_build_date(system_info_key_e key, system_info_data_type_e data_type, void **value)
46 return system_info_ini_get_string(INFO_FILE_PATH, "build:date", (char **)value);
49 int system_info_get_build_time(system_info_key_e key, system_info_data_type_e data_type, void **value)
51 return system_info_ini_get_string(INFO_FILE_PATH, "build:time", (char **)value);
54 int system_info_get_tizen_version(system_info_key_e key, system_info_data_type_e data_type, void **value)
56 return system_info_get_platform_string("tizen.org/feature/platform.version", (char**)value);
59 int system_info_get_core_cpu_arch(system_info_key_e key, system_info_data_type_e data_type, void **value)
62 char *CORE_CPU_ARCH = NULL;
64 if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv6", &cpu_arch) == SYSTEM_INFO_ERROR_NONE
66 CORE_CPU_ARCH = strdup("armv6");
67 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv7", &cpu_arch) == SYSTEM_INFO_ERROR_NONE
69 CORE_CPU_ARCH = strdup("armv7");
70 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.x86", &cpu_arch) == SYSTEM_INFO_ERROR_NONE
72 CORE_CPU_ARCH = strdup("x86");
74 if (CORE_CPU_ARCH == NULL) {
76 return SYSTEM_INFO_ERROR_IO_ERROR;
79 *value = CORE_CPU_ARCH;
81 return SYSTEM_INFO_ERROR_NONE;
84 int system_info_get_core_fpu_arch(system_info_key_e key, system_info_data_type_e data_type, void **value)
87 char *CORE_FPU_ARCH = NULL;
89 if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse2", &fpu_arch) == SYSTEM_INFO_ERROR_NONE
91 CORE_FPU_ARCH = strdup("sse2");
92 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse3", &fpu_arch) == SYSTEM_INFO_ERROR_NONE
94 CORE_FPU_ARCH = strdup("sse3");
95 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.ssse3", &fpu_arch) == SYSTEM_INFO_ERROR_NONE
97 CORE_FPU_ARCH = strdup("ssse3");
98 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv2", &fpu_arch) == SYSTEM_INFO_ERROR_NONE
100 CORE_FPU_ARCH = strdup("vfpv2");
101 else if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv3", &fpu_arch) == SYSTEM_INFO_ERROR_NONE
103 CORE_FPU_ARCH = strdup("vfpv3");
105 if (CORE_FPU_ARCH == NULL) {
107 return SYSTEM_INFO_ERROR_IO_ERROR;
110 *value = CORE_FPU_ARCH;
112 return SYSTEM_INFO_ERROR_NONE;
115 int system_info_get_core_cpu_freq(system_info_key_e key, system_info_data_type_e data_type, void **value)
118 FILE *cpuinfo, *cpuinfo_max_freq;
119 double max_freq = 0.0;
121 char str[MAXBUFSIZE];
123 if (system_info_get_system_info_model_type() != SYSTEM_INFO_MODEL_TYPE_EMULATOR) {
124 cpuinfo_max_freq = fopen(CPU_INFO_MAX_FREQ_PATH, "r");
125 if (NULL == cpuinfo_max_freq) {
126 LOGE("cannot file open %s file!!!", CPU_INFO_MAX_FREQ_PATH);
127 return SYSTEM_INFO_ERROR_IO_ERROR;
129 if (fscanf(cpuinfo_max_freq, "%lf", &max_freq) < 1) {
130 fclose(cpuinfo_max_freq);
131 return SYSTEM_INFO_ERROR_IO_ERROR;
133 max_freq = max_freq / 1024;
135 fclose(cpuinfo_max_freq);
138 cpuinfo = fopen(CPU_INFO_FILE_PATH, "r");
139 if (NULL == cpuinfo) {
140 LOGE("cannot file open %s file!!!", CPU_INFO_FILE_PATH);
141 return SYSTEM_INFO_ERROR_IO_ERROR;
143 while (fgets(str, MAXBUFSIZE, cpuinfo)) {
144 if (!strncmp("cpu MHz", str, strlen("cpu MHz"))) {
145 name = strchr(str, ':');
146 max_freq = atof(name+2);
154 count = (double *)value;
158 return SYSTEM_INFO_ERROR_NONE;
161 int system_info_get_platform_name(system_info_key_e key, system_info_data_type_e data_type, void **value)
163 return system_info_get_platform_string("tizen.org/system/platform.name", (char**)value);
166 int system_info_get_tizen_version_name(system_info_key_e key, system_info_data_type_e data_type, void **value)
168 char *TIZEN_VERSION_NAME = NULL;
170 char str[MAXBUFSIZE];
171 char tmpStr[MAXBUFSIZE];
174 extern char *strcasestr(const char *s, const char *find);
176 info = fopen(OS_RELEASE_FILE_PATH, "r");
178 LOGE("cannot file open %s file!!!", OS_RELEASE_FILE_PATH);
179 return SYSTEM_INFO_ERROR_IO_ERROR;
182 while (fgets(str, MAXBUFSIZE, info)) {
183 if (strcasestr(str, "VERSION")) {
184 name = strchr(str, ',');
186 tmpStrlen = strlen(name);
188 strncpy(tmpStr, name, tmpStrlen-2);
189 tmpStr[tmpStrlen-2] = '\0';
191 TIZEN_VERSION_NAME = strdup(tmpStr);
192 if (TIZEN_VERSION_NAME == NULL) {
193 LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
195 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
201 *value = TIZEN_VERSION_NAME;
203 return SYSTEM_INFO_ERROR_NONE;
206 int system_info_get_opengles_version(system_info_key_e key, system_info_data_type_e data_type, void **value)
210 char *OPENGLES_VERSION = NULL;
211 int version_supported = 0;
213 if (system_info_get_platform_bool("tizen.org/feature/opengles.version.1_1", &glversion) == SYSTEM_INFO_ERROR_NONE
214 && glversion == true)
215 version_supported += 1;
217 if (system_info_get_platform_bool("tizen.org/feature/opengles.version.2_0", &glversion) == SYSTEM_INFO_ERROR_NONE
218 && glversion == true)
219 version_supported += 2;
221 switch (version_supported) {
238 if (version != NULL) {
239 OPENGLES_VERSION = strdup(version);
241 if (OPENGLES_VERSION == NULL) {
242 LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
243 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
247 *value = OPENGLES_VERSION;
249 return SYSTEM_INFO_ERROR_NONE;
252 int system_info_get_opengles_texture_format(system_info_key_e key, system_info_data_type_e data_type, void **value)
255 char *OPENGLES_TEXTURE_FORMAT;
256 char textureformat[MAXBUFSIZE];
258 textureformat[0] = '\0';
260 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.utc", &texture) == SYSTEM_INFO_ERROR_NONE
262 strcat(textureformat, "utc ");
263 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.ptc", &texture) == SYSTEM_INFO_ERROR_NONE
265 strcat(textureformat, "| ptc ");
266 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.etc", &texture) == SYSTEM_INFO_ERROR_NONE
268 strcat(textureformat, "| etc ");
269 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.3dc", &texture) == SYSTEM_INFO_ERROR_NONE
271 strcat(textureformat, "| 3dc ");
272 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.atc", &texture) == SYSTEM_INFO_ERROR_NONE
274 strcat(textureformat, "| atc ");
275 if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.pvrtc", &texture) == SYSTEM_INFO_ERROR_NONE
277 strcat(textureformat, "| pvrtc");
279 OPENGLES_TEXTURE_FORMAT = strdup(textureformat);
281 if (OPENGLES_TEXTURE_FORMAT == NULL) {
282 LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
283 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
286 *value = OPENGLES_TEXTURE_FORMAT;
288 return SYSTEM_INFO_ERROR_NONE;
291 int system_info_get_mms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
293 return system_info_get_platform_bool("tizen.org/feature/network.telephony.mms", (bool *)value);
296 int system_info_get_sms_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
298 return system_info_get_platform_bool("tizen.org/feature/network.telephony.sms", (bool *)value);
301 int system_info_get_cbs_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
303 return system_info_get_platform_bool("tizen.org/feature/network.telephony.cbs", (bool *)value);
306 int system_info_get_graphics_hwaccel_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
308 return system_info_get_platform_bool("tizen.org/feature/graphics.acceleration", (bool *)value);
311 int system_info_get_feature_pinch_zoom_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
313 return system_info_get_platform_bool("tizen.org/feature/multi_point_touch.pinch_zoom", (bool *)value);
316 int system_info_get_feature_auto_rotation_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
318 return system_info_get_platform_bool("tizen.org/feature/screen.auto_rotation", (bool *)value);