-%bcond_with x
-%bcond_with wayland
Name: capi-system-info
Version: 0.2.0
Release: 0
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(glib-2.0)
-%if %{with wayland}
-BuildRequires: pkgconfig(ecore-wayland)
-%endif
-%if %{with x}
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(xi)
-BuildRequires: pkgconfig(xrandr)
-%endif
%description
%define tizen_id_path /opt/home/root/tizenid
%build
-%cmake . \
-%if !%{with x} && %{with wayland}
- -DENABLE_WAYLAND=TRUE \
-%endif
- -DCONFIG_FILE_PATH=%{config_file_path} \
- -DINFO_FILE_PATH=%{info_file_path} \
- -DOS_RELEASE_FILE_PATH=%{os_release_file_path} \
- -DSERIAL_PATH=%{serial_path} \
- -DTIZEN_ID_PATH=%{tizen_id_path}
+%cmake . -DCONFIG_FILE_PATH=%{config_file_path} \
+ -DINFO_FILE_PATH=%{info_file_path} \
+ -DOS_RELEASE_FILE_PATH=%{os_release_file_path} \
+ -DSERIAL_PATH=%{serial_path} \
+ -DTIZEN_ID_PATH=%{tizen_id_path}
%__make %{?_smp_mflags}
int system_info_get_manufacturer(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- char *manufacturer = NULL;
+ int ret;
+ char *manufacturer;
- manufacturer = strdup("samsung");
- if (manufacturer == NULL) {
- LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
- return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
- }
+ ret = system_info_get_platform_string(
+ "tizen.org/system/manufacturer",
+ &manufacturer);
+ if (ret == SYSTEM_INFO_ERROR_NONE)
+ *value = manufacturer;
- *value = manufacturer;
-
- return SYSTEM_INFO_ERROR_NONE;
+ return ret;
}
int system_info_get_tethering_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
bool *supported;
- char *string = NULL;
- char *model = "default";
+ bool tethering;
+ int ret;
supported = (bool *)value;
- if (access(TETHERING_INFO_FILE_PATH, R_OK)) {
- *supported = false;
- return SYSTEM_INFO_ERROR_NONE;
- }
-
- if (system_info_get_value_from_xml(TETHERING_INFO_FILE_PATH, model, "tethering-support", &string)) {
- LOGE("cannot get tethering-support info from %s!!!", TETHERING_INFO_FILE_PATH);
- return SYSTEM_INFO_ERROR_IO_ERROR;
- }
-
- if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
- *supported = true;
- else
- *supported = false;
-
- free(string);
+ ret = system_info_get_platform_bool(
+ "tizen.org/feature/network.tethering",
+ &tethering);
+ if (ret == SYSTEM_INFO_ERROR_NONE)
+ *supported = tethering;
- return SYSTEM_INFO_ERROR_NONE;
+ return ret;
}
int system_info_get_model(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- return system_info_ini_get_string(INFO_FILE_PATH, "version:model", (char **)value);
+ return system_info_get_platform_string("tizen.org/system/model_name", (char **)value);
}
int system_info_get_build_string(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- return system_info_ini_get_string(INFO_FILE_PATH, "version:build", (char **)value);
+ return system_info_get_platform_string("tizen.org/system/build.string", (char **)value);
}
int system_info_get_build_date(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- return system_info_ini_get_string(INFO_FILE_PATH, "build:date", (char **)value);
+ return system_info_get_platform_string("tizen.org/system/build.date", (char **)value);
}
int system_info_get_build_time(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- return system_info_ini_get_string(INFO_FILE_PATH, "build:time", (char **)value);
+ return system_info_get_platform_string("tizen.org/system/build.time", (char **)value);
}
int system_info_get_tizen_version(system_info_key_e key, system_info_data_type_e data_type, void **value)
#include <dlog.h>
-#ifndef WAYLAND_PLATFORM
-#include <X11/Xlib.h>
-#include <X11/extensions/Xrandr.h>
-#endif
-
#include <system_info.h>
#include <system_info_private.h>
#define LOG_TAG "CAPI_SYSTEM_INFO"
-typedef struct _progInfo ProgInfo;
-
-/* globals */
-ProgInfo g_pinfo;
-#ifdef WAYLAND_PLATFORM
-struct _progInfo {
- int *dpy;
- int root;
- int screen;
- int event_base, error_base;
- int major, minor;
- int *res;
-};
-#else
-struct _progInfo {
- Display *dpy;
- Window root;
- int screen;
- int event_base, error_base;
- int major, minor;
- XRRScreenResources *res;
-};
-#endif
-static int PHYSICAL_SCREEN_WIDTH;
-static int PHYSICAL_SCREEN_HEIGHT;
-int system_info_screen_initialized;
-
-int system_info_screen_init()
-{
-
- memset(&g_pinfo, 0x0, sizeof(ProgInfo));
- #ifdef WAYLAND_PLATFORM
- //In wayland environment, noting to do in this function, FIXME if necessary.
- LOGE("In wayland environment, system_info_screen_init Failed");
- system_info_screen_initialized = 1;
- return -1;
- #else
- int i;
- g_pinfo.dpy = XOpenDisplay(NULL);
- if (NULL == g_pinfo.dpy) {
- LOGE("XOpenDisplay Failed");
- return -1;
- }
-
- if (0 > g_pinfo.screen)
- g_pinfo.screen = DefaultScreen(g_pinfo.dpy);
- g_pinfo.root = RootWindow(g_pinfo.dpy, g_pinfo.screen);
-
- if (!XRRQueryExtension(g_pinfo.dpy, &g_pinfo.event_base, &g_pinfo.error_base) ||
- !XRRQueryVersion(g_pinfo.dpy, &g_pinfo.major, &g_pinfo.minor)) {
- LOGE("XRRQuery Failed");
- XCloseDisplay(g_pinfo.dpy);
- return -1;
- }
-
- g_pinfo.res = XRRGetScreenResources(g_pinfo.dpy, g_pinfo.root);
-
- if (!g_pinfo.res) {
- LOGE("XRRGetScreenResources Failed");
- XCloseDisplay(g_pinfo.dpy);
- return -1;
- }
-
- for (i = 0; i < g_pinfo.res->noutput; i++) {
- XRROutputInfo *output_info = XRRGetOutputInfo(g_pinfo.dpy, g_pinfo.res, g_pinfo.res->outputs[i]);
- if (!output_info) {
- LOGE("XRRGetOutputInfo Failed");
- XCloseDisplay(g_pinfo.dpy);
- return -1;
- }
-
- /* find target lcd */
- if (!strcmp(output_info->name, "LVDS1")) {
- /* XRRCrtcInfo information */
- XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(g_pinfo.dpy, g_pinfo.res, output_info->crtc);
- if (!crtc_info)
- break;
-
- PHYSICAL_SCREEN_WIDTH = output_info->mm_width;
- PHYSICAL_SCREEN_HEIGHT = output_info->mm_height;
-
- XRRFreeCrtcInfo(crtc_info);
- }
- XRRFreeOutputInfo(output_info);
- }
-
- XCloseDisplay(g_pinfo.dpy);
-
- system_info_screen_initialized = 1;
-
- return 0;
- #endif
-}
+#define MM_PER_INCH (25.4)
int system_info_get_screen_width(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
int system_info_get_physical_screen_height(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- int *height;
- int ret_val;
+ int ret;
+ int height, dpi;
+ int *physical;
+
+ physical = (int *)value;
- height = (int *)value;
+ ret = system_info_get_platform_int("tizen.org/feature/screen.dpi", &dpi);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ LOGE("Failed to get dpi information(%d)", ret);
+ return ret;
+ }
- if (0 == system_info_screen_initialized) {
- ret_val = system_info_screen_init();
- if (ret_val)
- return ret_val;
+ ret = system_info_get_platform_int("tizen.org/feature/screen.height", &height);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ LOGE("Failed to get height information(%d)", ret);
+ return ret;
}
- *height = PHYSICAL_SCREEN_HEIGHT;
+ *physical = (int)((height / dpi) * MM_PER_INCH);
return SYSTEM_INFO_ERROR_NONE;
}
int system_info_get_physical_screen_width(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
- int *width;
- int ret_val;
+ int ret;
+ int width, dpi;
+ int *physical;
- width = (int *)value;
+ physical = (int *)value;
+
+ ret = system_info_get_platform_int("tizen.org/feature/screen.dpi", &dpi);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ LOGE("Failed to get dpi information(%d)", ret);
+ return ret;
+ }
- if (0 == system_info_screen_initialized) {
- ret_val = system_info_screen_init();
- if (ret_val)
- return ret_val;
+ ret = system_info_get_platform_int("tizen.org/feature/screen.width", &width);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ LOGE("Failed to get height information(%d)", ret);
+ return ret;
}
- *width = PHYSICAL_SCREEN_WIDTH;
+ *physical = (int)((width / dpi) * MM_PER_INCH);
return SYSTEM_INFO_ERROR_NONE;
}