#include "systeminfo-utils.h"
#include "systeminfo/systeminfo_instance.h"
+#include <fstream>
#include <sstream>
#include <memory>
#include <mutex>
#include <runtime_info.h>
#include <system_info.h>
-#include <system_info_internal.h>
#include <sys/statfs.h>
#include <vconf.h>
const std::string MEMORY_STATE_WARNING = "WARNING";
const int MEMORY_TO_BYTE = 1024;
const int BASE_GATHERING_INTERVAL = 100;
-const double DISPLAY_INCH_TO_MILLIMETER = 25.4;
+const double DISPLAY_INCH_TO_MILLIMETER = 2.54;
}
using namespace common;
return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
-static PlatformResult GetSystemValueString(system_info_key_e key, std::string& platform_string) {
- char* platform_c_string;
- if (SYSTEM_INFO_ERROR_NONE
- == system_info_get_value_string(key, &platform_c_string)) {
- if (platform_c_string) {
- LoggerD("Build platfrom string %s", platform_c_string);
- platform_string = platform_c_string;
- free(platform_c_string);
- return PlatformResult(ErrorCode::NO_ERROR);
- }
- }
-
- const char* error_msg = "Error when retrieving value from platform API";
- LoggerE("%s", error_msg);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
-}
-
PlatformResult GetVconfInt(const char *key, int &value) {
if (0 == vconf_get_int(key, &value)) {
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult SysteminfoUtils::ReportDisplay(picojson::object& out) {
int screenWidth = 0;
int screenHeight = 0;
- unsigned long dotsPerInchWidth = 0;
- unsigned long dotsPerInchHeight = 0;
+ int dotsPerInchWidth = 0;
+ int dotsPerInchHeight = 0;
double physicalWidth = 0;
double physicalHeight = 0;
double scaledBrightness;
// FETCH RESOLUTION
- if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int(
- SYSTEM_INFO_KEY_SCREEN_WIDTH, &screenWidth)) {
+ if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_int(
+ "tizen.org/feature/screen.width", &screenWidth)) {
LoggerE("Cannot get value of screen width");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get value of screen width");
}
- if (SYSTEM_INFO_ERROR_NONE != system_info_get_value_int(
- SYSTEM_INFO_KEY_SCREEN_HEIGHT, &screenHeight)) {
+ if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_int(
+ "tizen.org/feature/screen.height", &screenHeight)) {
LoggerE("Cannot get value of screen height");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get value of screen height");
}
//FETCH PHYSICAL WIDTH
if (dotsPerInchWidth != 0 && screenWidth != 0) {
- physicalWidth = DISPLAY_INCH_TO_MILLIMETER * screenWidth / dotsPerInchWidth;
+ physicalWidth = (screenWidth / dotsPerInchWidth) * DISPLAY_INCH_TO_MILLIMETER;
} else {
std::string log_msg = "Failed to get physical screen width value";
LoggerE("%s, screenWidth : %d, dotsPerInchWidth: %d", log_msg.c_str(),
//FETCH PHYSICAL HEIGHT
if (dotsPerInchHeight != 0 && screenHeight != 0) {
- physicalHeight = DISPLAY_INCH_TO_MILLIMETER * screenHeight / dotsPerInchHeight;
+ physicalHeight = (screenHeight / dotsPerInchHeight) * DISPLAY_INCH_TO_MILLIMETER;
} else {
std::string log_msg = "Failed to get physical screen height value";
LoggerE("%s, screenHeight : %d, dotsPerInchHeight: %d", log_msg.c_str(),
PlatformResult SysteminfoUtils::ReportBuild(picojson::object& out) {
std::string model = "";
- PlatformResult ret = SystemInfoDeviceCapability::GetValueString("tizen.org/system/model_name", &model);
+ PlatformResult ret = SystemInfoDeviceCapability::GetValueString(
+ "tizen.org/system/model_name", &model);
if (ret.IsError()) {
return ret;
}
std::string manufacturer = "";
- ret = GetSystemValueString(SYSTEM_INFO_KEY_MANUFACTURER, manufacturer);
+ ret = SystemInfoDeviceCapability::GetValueString(
+ "tizen.org/system/manufacturer", &manufacturer);
if (ret.IsError()) {
return ret;
}
std::string buildVersion = "";
- ret = GetSystemValueString(SYSTEM_INFO_KEY_BUILD_STRING, buildVersion);
+ ret = SystemInfoDeviceCapability::GetValueString(
+ "tizen.org/system/build.string", &buildVersion);
if (ret.IsError()) {
return ret;
}
PlatformResult SystemInfoDeviceCapability::GetPlatformCoreCpuFrequency(int* return_value)
{
LoggerD("Entered");
- double freq = 0;
- int ret = 0;
- ret = system_info_get_value_double(SYSTEM_INFO_KEY_CORE_CPU_FREQ, &freq);
- if (ret != SYSTEM_INFO_ERROR_NONE) {
- LoggerE("Failed to get cpu frequency: %d", ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get cpu frequency");
- } else {
- LoggerD("cpu frequency : %d", freq);
- *return_value = static_cast<int>(freq);
+ std::string freq;
+ std::ifstream cpuinfo_max_freq("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
+ if (!cpuinfo_max_freq.is_open()) {
+ LoggerE("Failed to get cpu frequency");
+ return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unable to open file");
}
+
+ getline(cpuinfo_max_freq, freq);
+ cpuinfo_max_freq.close();
+
+ LoggerD("cpu frequency : %s", freq.c_str());
+ *return_value = std::stoi(freq) / 1000; // unit: MHz
+
return PlatformResult(ErrorCode::NO_ERROR);
}