return PlatformResult(ErrorCode::NO_ERROR);
}
const std::string error_msg = "Could not get " + std::string(key);
- LoggerD("%s",error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
PlatformResult SysteminfoUtils::GetRuntimeInfoString(system_settings_key_e key, std::string* platform_string) {
}
const std::string error_msg = "Error when retrieving system setting information: "
+ std::to_string(err);
- LoggerE("%s", error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
PlatformResult SysteminfoUtils::CheckTelephonySupport() {
return ret;
}
if (!supported) {
- LoggerD("Telephony is not supported on this device");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR,
- "Telephony is not supported on this device");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "Telephony is not supported on this device");
}
return PlatformResult(ErrorCode::NO_ERROR);
}
return ret;
}
if (!supported) {
- LoggerD("Back-facing camera with a flash is not supported on this device");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR,
- "Back-facing camera with a flash is not supported on this device");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR,
+ "Back-facing camera with a flash is not supported on this device");
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int error = connection_create(&connection_handle);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot create connection: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_create error: %d (%s)", error, get_error_message(error)));
}
std::unique_ptr<std::remove_pointer<connection_h>::type, int (*)(connection_h)> connection_handle_ptr(
connection_handle, &connection_destroy); // automatically release the memory
error = connection_get_ethernet_state(connection_handle, &connection_state);
if (CONNECTION_ERROR_NOT_SUPPORTED == error) {
std::string log_msg = "Cannot get ethernet connection state: Not supported";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, log_msg,
+ ("connection_get_ethernet_state error: %d (%s)", error, get_error_message(error)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int ret = device_memory_get_total(&value);
if (ret != DEVICE_ERROR_NONE) {
std::string log_msg = "Failed to get total memory: " + std::to_string(ret);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("device_memory_get_total error: %d (%s)", ret, get_error_message(ret)));
}
*result = static_cast<long long>(value*MEMORY_TO_BYTE);
int ret = device_memory_get_available(&value);
if (ret != DEVICE_ERROR_NONE) {
std::string log_msg = "Failed to get total memory: " + std::to_string(ret);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("device_memory_get_available error: %d (%s)", ret, get_error_message(ret)));
}
*result = static_cast<long long>(value*MEMORY_TO_BYTE);
PlatformResult SysteminfoUtils::RegisterVconfCallback(const char *in_key, vconf_callback_fn cb,
void* event_ptr) {
if (0 != vconf_notify_key_changed(in_key, cb, event_ptr)) {
- LoggerE("Failed to register vconf callback: %s", in_key);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register vconf callback");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to register vconf callback",
+ ("Failed to register vconf callback: %s", in_key));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult SysteminfoUtils::UnregisterVconfCallback(const char *in_key, vconf_callback_fn cb) {
if (0 != vconf_ignore_key_changed(in_key, cb)) {
- LoggerE("Failed to unregister vconf callback: %s", in_key);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister vconf callback");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to unregister vconf callback",
+ ("Failed to unregister vconf callback: %s", in_key));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
const char *noti_id,
tapi_notification_cb callback,
void *user_data) {
- if (TAPI_API_SUCCESS != tel_register_noti_event(handle, noti_id, callback, user_data)) {
- LoggerE("Failed to register tapi callback with key: %s", noti_id);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to register tapi callback");
+ int ntv_ret = tel_register_noti_event(handle, noti_id, callback, user_data);
+ if (TAPI_API_SUCCESS != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to register tapi callback",
+ ("Failed to register tapi callback with key: %s - %d (%s)",
+ noti_id, ntv_ret, get_error_message(ntv_ret)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult SysteminfoUtils::UnregisterTapiChangeCallback(TapiHandle *handle,
const char *noti_id) {
- if (TAPI_API_SUCCESS != tel_deregister_noti_event(handle, noti_id)) {
- LoggerE("Failed to unregister tapi callback with key: %s", noti_id);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister tapi callback");
+ int ntv_ret = tel_deregister_noti_event(handle, noti_id);
+ if (TAPI_API_SUCCESS != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to unregister tapi callback",
+ ("Failed to unregister tapi callback with key: %s - %d (%s)",
+ noti_id, ntv_ret, get_error_message(ntv_ret)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
if (SYSTEM_INFO_ERROR_NONE != ret) {
std::string log_msg = "Platform error while getting bool value: ";
log_msg += std::string(key) + " " + std::to_string(ret);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("system_info_get_custom_bool error: %d (%s)", ret, get_error_message(ret)));
}
}
if (SYSTEM_INFO_ERROR_NONE != ret) {
std::string log_msg = "Platform error while getting int value: ";
log_msg += std::string(key) + " " + std::to_string(ret);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("system_info_get_custom_int error: %d (%s)", ret, get_error_message(ret)));
}
}
if (SYSTEM_INFO_ERROR_NONE != ret) {
std::string log_msg = "Platform error while getting string value: ";
log_msg += std::string(key) + " " + std::to_string(ret);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("system_info_get_custom_string error: %d (%s)", ret, get_error_message(ret)));
}
}
} else {
size_t prefix_len = strlen("http://");
if (key.length() <= prefix_len) {
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
}
PlatformResult ret = SystemInfoDeviceCapability::GetValueString(key.substr(prefix_len).c_str(), value);
if (ret.IsError()){
} else {
size_t prefix_len = strlen("http://");
if (key.length() <= prefix_len) {
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
}
PlatformResult ret = SystemInfoDeviceCapability::GetValueBool(
key.substr(prefix_len).c_str(), bool_value);
} else {
size_t prefix_len = strlen("http://");
if (key.length() <= prefix_len) {
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
}
PlatformResult ret = SystemInfoDeviceCapability::GetValueInt(
key.substr(prefix_len).c_str(), &result);
} else if (type == "string" || type == "int") {
result_obj.insert(std::make_pair("value", picojson::value(value)));
} else {
- LoggerD("Value for given key was not found");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Value for given key was not found");
}
result_obj.insert(std::make_pair("type", picojson::value(type)));
if (!bool_result) {
// this exception is converted to "Undefined" value in JS layer
std::string log_msg = "OpenGL-ES is not supported";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, log_msg);
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, log_msg);
}
std::string texture_format = "";
if (texture_format.empty()) {
// this exception is converted to "Undefined" value in JS layer
std::string log_msg = "Platform error while getting OpenGL-ES texture format";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, log_msg);
}
*result = texture_format;
return PlatformResult(ErrorCode::NO_ERROR);
}
if (result.empty()) {
- LoggerE("Platform error while retrieving platformCoreCpuArch: result is empty");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "platformCoreCpuArch result is empty");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "platformCoreCpuArch result is empty");
}
*return_value = result;
return PlatformResult(ErrorCode::NO_ERROR);
result += kPlatformCoreVfpv3;
}
if (result.empty()) {
- LoggerE("Platform error while retrieving platformCoreFpuArch: result is empty");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "platformCoreFpuArch result is empty");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "platformCoreFpuArch result is empty");
}
*return_value = result;
return PlatformResult(ErrorCode::NO_ERROR);
std::ifstream cpuinfo_freq(file_name);
if (!cpuinfo_freq.is_open()) {
- LoggerE("Failed to get cpu frequency");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unable to open file");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Unable to open file",
+ ("Failed to get cpu frequency"));
}
#ifdef TIZEN_IS_EMULATOR
#define CHECK_EXIST(args, name, out) \
if (!args.contains(name)) {\
- ReportError(TypeMismatchException(name" is required argument"), out);\
+ LogAndReportError(TypeMismatchException(name" is required argument"), out);\
return;\
}
}
const double brightness = args.get("brightness").get<double>();
int result = device_flash_set_brightness(brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
if (DEVICE_ERROR_INVALID_PARAMETER == result) {
- ReportError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Error occured"), &out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Error occured"), &out,
+ ("device_flash_set_brightness error: %d (%s)", result, get_error_message(result)));
} else {
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), &out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), &out,
+ ("device_flash_set_brightness error: %d (%s)", result, get_error_message(result)));
}
return;
}
int brightness = 0;
int result = device_flash_get_brightness(&brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), &out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), &out,
+ ("device_flash_get_brightness error: %d (%s)", result, get_error_message(result)));
return;
}
int brightness = 0;
int result = device_flash_get_max_brightness(&brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Not supported property"), &out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Not supported property"), &out,
+ ("device_flash_get_max_brightness error: %d (%s)", result, get_error_message(result)));
return;
}
ReportSuccess(picojson::value(std::to_string(brightness)), out);
#define CHECK_EXIST(args, name, out) \
if (!args.contains(name)) {\
- ReportError(TypeMismatchException(name" is required argument"), *out);\
+ LogAndReportError(TypeMismatchException(name" is required argument"), *out);\
return;\
}
#define DEFAULT_REPORT_BOOL_CAPABILITY(str_name, feature_name) \
ret = SystemInfoDeviceCapability::GetValueBool(feature_name, &bool_value); \
if (ret.IsError()) { \
- ReportError(ret, out); \
+ LogAndReportError(ret, out); \
return; \
} \
result_obj.insert(std::make_pair(str_name, picojson::value(bool_value)));
#define REPORT_BOOL_CAPABILITY(str_name, method) \
ret = method(&bool_value); \
if (ret.IsError()) { \
- ReportError(ret, out); \
+ LogAndReportError(ret, out); \
return; \
} \
result_obj.insert(std::make_pair(str_name, picojson::value(bool_value)));
#define DEFAULT_REPORT_INT_CAPABILITY(str_name, feature_name) \
ret = SystemInfoDeviceCapability::GetValueInt(feature_name, &int_value); \
if (ret.IsError()) { \
- ReportError(ret, out); \
+ LogAndReportError(ret, out); \
return; \
} \
result_obj.insert(std::make_pair(str_name, picojson::value(std::to_string(int_value))));
#define DEFAULT_REPORT_STRING_CAPABILITY(str_name, feature_name) \
ret = SystemInfoDeviceCapability::GetValueString(feature_name, &str_value); \
if (ret.IsError()) { \
- ReportError(ret, out); \
+ LogAndReportError(ret, out); \
return; \
} \
result_obj.insert(std::make_pair(str_name, picojson::value(str_value)));
#define REPORT_STRING_CAPABILITY(str_name, method) \
ret = method(&str_value); \
if (ret.IsError()) { \
- ReportError(ret, out); \
+ LogAndReportError(ret, out); \
return; \
} \
result_obj.insert(std::make_pair(str_name, picojson::value(str_value)));
ReportSuccess(result, *out);
LoggerD("Success");
} else {
- ReportError(ret, out);
+ LogAndReportError(ret, out);
}
}
picojson::value result = picojson::value(picojson::object());
PlatformResult ret = prop_manager_.GetPropertyValue(prop_id, false, &result);
if (ret.IsError()) {
- ReportError(ret,&(response->get<picojson::object>()));
+ LogAndReportError(ret,&(response->get<picojson::object>()));
return;
}
ReportSuccess(result, response->get<picojson::object>());
PlatformResult ret = prop_manager_.GetPropertyValue(prop_id, true, &result);
if (ret.IsError()) {
- LoggerE("Failed: GetPropertyValue()");
- ReportError(ret,&(response->get<picojson::object>()));
+ LogAndReportError(
+ ret, &(response->get<picojson::object>()),
+ ("Failed: GetPropertyValue()"));
return;
}
ReportSuccess(result, response->get<picojson::object>());
long long return_value = 0;
PlatformResult ret = SysteminfoUtils::GetTotalMemory(&return_value);
if (ret.IsError()) {
- LoggerD("Error");
- ReportError(ret, out);
+ LogAndReportError(ret, out);
return;
}
result_obj.insert(std::make_pair("totalMemory",
long long return_value = 0;
PlatformResult ret = SysteminfoUtils::GetAvailableMemory(&return_value);
if (ret.IsError()) {
- LoggerD("Error");
- ReportError(ret, out);
+ LogAndReportError(ret, out);
return;
}
result_obj.insert(std::make_pair("availableMemory",
unsigned long count = 0;
PlatformResult ret = GetPropertyCount(property, &count);
if (ret.IsError()) {
- LoggerE("Failed: GetCount()");
- ReportError(ret, out);
+ LogAndReportError(ret, out,
+ ("Failed: GetPropertyCount()"));
return;
}
result_obj.insert(std::make_pair("count", picojson::value(static_cast<double>(count))));
} else if (property_name == kPropertyIdDeviceOrientation) {
ret = RegisterDeviceOrientationListener();
} else if (property_name == kPropertyIdBuild) {
- LoggerW("BUILD property's value is a fixed value");
//should be accepted, but no registration is needed
- ret = PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
+ ret = LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "BUILD property's value is a fixed value");
} else if (property_name == kPropertyIdLocale) {
ret = RegisterLocaleListener();
} else if (property_name == kPropertyIdNetwork) {
} else if (property_name == kPropertyIdCameraFlash) {
ret = RegisterCameraFlashListener();
} else {
- LoggerE("Not supported property");
- ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
+ ret = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
}
if (ret.IsSuccess()) {
registered_listeners_.insert(property_name);
LoggerD("Success");
return;
}
- LoggerD("Error");
- ReportError(ret, out);
+ LogAndReportError(ret, out);
}
void SysteminfoManager::RemovePropertyValueChangeListener(const picojson::value& args,
} else if (property_name == kPropertyIdCameraFlash) {
ret = UnregisterCameraFlashListener();
} else {
- LoggerE("Not supported property");
- ret = PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
+ ret = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Not supported property");
}
} else {
LoggerD("Removing listener for property with id: %s is not needed, not registered",
LoggerD("Success");
return;
}
- LoggerD("Error");
- ReportError(ret, out);
+ LogAndReportError(ret, out);
}
#define CHECK_LISTENER_ERROR(method) \
OnNetworkValueChangedCb,
static_cast<void*>(this));
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to register ip change callback: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot register ip change callback");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot register ip change callback",
+ ("connection_set_ip_address_changed_cb error: %d (%s)",
+ error, get_error_message(error)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
int error = connection_unset_ip_address_changed_cb(handle);
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to unregister ip change callback: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot unregister ip change callback");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot unregister ip change callback",
+ ("connection_unset_ip_address_changed_cb error: %d (%s)",
+ error, get_error_message(error)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
BASE_GATHERING_INTERVAL, 0,
OnDeviceOrientationChangedCb, this);
if (!sensor_ret) {
- LoggerE("Failed to register orientation change event listener");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to register orientation change event listener");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to register orientation change event listener",
+ ("sensord_register_event error: %d (%s)", sensor_ret, get_error_message(sensor_ret)));
}
LoggerD("Added callback for DEVICE_ORIENTATION");
OnDeviceAutoRotationChangedCb))
bool sensor_ret = sensord_unregister_event(GetSensorHandle(), AUTO_ROTATION_EVENT_CHANGE_STATE);
if (!sensor_ret) {
- LoggerE("Failed to unregister orientation change event listener");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to unregister"
- " orientation change event listener");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to unregister orientation change event listener",
+ ("sensord_unregister_event error: %d (%s)", sensor_ret, get_error_message(sensor_ret)));
}
LoggerD("Removed callback for DEVICE_ORIENTATION");
PlatformResult SysteminfoManager::RegisterLocaleListener() {
LoggerD("Entered");
- if (SYSTEM_SETTINGS_ERROR_NONE !=
- system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
- OnLocaleChangedCb, static_cast<void*>(this)) ) {
- LoggerE("Country change callback registration failed");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Country change callback registration failed");
+ int ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
+ OnLocaleChangedCb, static_cast<void*>(this));
+ if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Country change callback registration failed",
+ ("system_settings_set_changed_cb error: %d (%s)", ret, get_error_message(ret)));
}
- if (SYSTEM_SETTINGS_ERROR_NONE !=
- system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
- OnLocaleChangedCb, static_cast<void*>(this)) ) {
- LoggerE("Language change callback registration failed");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Language change callback registration failed");
+
+ ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
+ OnLocaleChangedCb, static_cast<void*>(this));
+ if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Language change callback registration failed",
+ ("system_settings_set_changed_cb error: %d (%s)", ret, get_error_message(ret)));
}
LoggerD("Added callback for LOCALE");
return PlatformResult(ErrorCode::NO_ERROR);
connection_h handle;
PlatformResult ret(ErrorCode::NO_ERROR);
CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
- if (CONNECTION_ERROR_NONE !=
- connection_set_type_changed_cb(handle, OnNetworkChangedCb, static_cast<void*>(this))) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Registration of listener failed");
+ int ntv_ret = connection_set_type_changed_cb(handle, OnNetworkChangedCb, static_cast<void*>(this));
+ if (CONNECTION_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Registration of listener failed",
+ ("connection_set_type_changed_cb error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
LoggerD("Added callback for NETWORK");
return PlatformResult(ErrorCode::NO_ERROR);
connection_h handle;
PlatformResult ret(ErrorCode::NO_ERROR);
CHECK_LISTENER_ERROR(GetConnectionHandle(handle))
- if (CONNECTION_ERROR_NONE != connection_unset_type_changed_cb(handle)) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unregistration of listener failed");
+ int ntv_ret = connection_unset_type_changed_cb(handle);
+ if (CONNECTION_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Unregistration of listener failed",
+ ("connection_unset_type_changed_cb error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
LoggerD("Removed callback for NETWORK");
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult SysteminfoManager::RegisterCameraFlashListener() {
LoggerD("Entered");
- if (DEVICE_ERROR_NONE != device_add_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
- OnBrightnessChangedCb, this)) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR);
+ int ret = device_add_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
+ OnBrightnessChangedCb, this);
+ if (DEVICE_ERROR_NONE != ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error occured",
+ ("device_add_callback error: %d (%s)", ret, get_error_message(ret)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult SysteminfoManager::UnregisterCameraFlashListener() {
LoggerD("Entered");
PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
- if (DEVICE_ERROR_NONE != device_remove_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
- OnBrightnessChangedCb)) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR);
+ int ntv_ret = device_remove_callback(DEVICE_CALLBACK_FLASH_BRIGHTNESS,
+ OnBrightnessChangedCb);
+ if (DEVICE_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error occured",
+ ("device_remove_callback error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
LoggerD("Removed callback for camera_flash");
return PlatformResult(ErrorCode::NO_ERROR);
const double brightness = args.get("brightness").get<double>();
int result = device_flash_set_brightness(brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), out,
+ ("device_flash_set_brightness error: %d (%s)", result, get_error_message(result)));
return;
}
ReportSuccess(*out);
int brightness = 0;
int result = device_flash_get_brightness(&brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Error occured"), out,
+ ("device_flash_get_brightness error: %d (%s)", result, get_error_message(result)));
return;
}
ReportSuccess(picojson::value(std::to_string(brightness)), *out);
int brightness = 0;
int result = device_flash_get_max_brightness(&brightness);
if (result != DEVICE_ERROR_NONE) {
- LoggerE("Error occured");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Not supported property"), out);
+ LogAndReportError(
+ PlatformResult(ErrorCode::UNKNOWN_ERR, "Not supported property"), out,
+ ("device_flash_get_max_brightness error: %d (%s)",
+ result, get_error_message(result)));
return;
}
ReportSuccess(picojson::value(std::to_string(brightness)), *out);
*count = kDefaultPropertyCount;
}
} else {
- LoggerD("Property with given id is not supported");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported",
+ ("Property %s with given id is not supported", property.c_str()));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int handle_orientation = sensord_connect(sensor);
if (handle_orientation < 0) {
std::string log_msg = "Failed to connect auto rotation sensor";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, log_msg);
}
bool ret = sensord_start(handle_orientation, 0);
if(!ret) {
sensord_disconnect(handle_orientation);
std::string log_msg = "Failed to start auto rotation sensor";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, log_msg);
}
LoggerD("Sensor starts successfully = %d", handle_orientation);
*result = handle_orientation;
if (nullptr == connection_handle_) {
int error = connection_create(&connection_handle_);
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to create connection: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot create connection");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot create connection",
+ ("connection_create error: %d (%s)", error, get_error_message(error)));
}
}
handle = connection_handle_;
array.push_back(result);
}
if (property_count == 0) {
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported");
}
}
} else if ("CAMERA_FLASH" == property) {
return ReportCameraFlash(res_obj, index);
}
- LoggerD("Property with given id is not supported");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Property with given id is not supported");
}
/// BATTERY
int ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &value);
if (kVconfErrorNone != ret) {
std::string log_msg = "Platform error while getting battery detail: ";
- LoggerE("%s%d", log_msg.c_str(), ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, (log_msg + std::to_string(ret)));
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, (log_msg + std::to_string(ret)),
+ ("vconf_get_int error: %d (%s)", ret, get_error_message(ret)));
}
out->insert(std::make_pair("level", picojson::value(static_cast<double>(value)/kRemainingBatteryChargeMax)));
ret = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value);
if (kVconfErrorNone != ret) {
std::string log_msg = "Platform error while getting battery charging: ";
- LoggerE("%s%d",log_msg.c_str(), ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, (log_msg + std::to_string(ret)));
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, (log_msg + std::to_string(ret)),
+ ("vconf_get_int error: %d (%s)", ret, get_error_message(ret)));
}
out->insert(std::make_pair("isCharging", picojson::value(0 != value)));
return PlatformResult(ErrorCode::NO_ERROR);
fp = fopen("/proc/stat", "r");
if (nullptr == fp) {
std::string error_msg("Can not open /proc/stat for reading");
- LoggerE( "%s", error_msg.c_str() );
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
long long usr = 0;
}
} else {
std::string error_msg( "Could not read /proc/stat" );
- LoggerE( "%s", error_msg.c_str() );
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
manager_.SetCpuInfoLoad(cpu_info.load);
double scaledBrightness;
// FETCH RESOLUTION
- 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");
+ int ntv_ret = system_info_get_platform_int("tizen.org/feature/screen.width",
+ &screenWidth);
+ if (SYSTEM_INFO_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get value of screen width",
+ ("system_info_get_platform_int error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
}
- 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");
+ ntv_ret = system_info_get_platform_int("tizen.org/feature/screen.height",
+ &screenHeight);
+ if (SYSTEM_INFO_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get value of screen height",
+ ("system_info_get_platform_int error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
}
//FETCH DOTS PER INCH
int dots_per_inch=0;
- if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_int(
- "tizen.org/feature/screen.dpi", &dots_per_inch)) {
+ ntv_ret = system_info_get_platform_int("tizen.org/feature/screen.dpi",
+ &dots_per_inch);
+ if (SYSTEM_INFO_ERROR_NONE == ntv_ret) {
dotsPerInchWidth = dots_per_inch;
dotsPerInchHeight = dots_per_inch;
} else {
- LoggerE("Cannot get 'tizen.org/feature/screen.dpi' value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Cannot get 'tizen.org/feature/screen.dpi' value");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get 'tizen.org/feature/screen.dpi' value",
+ ("system_info_get_platform_int error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
}
//FETCH PHYSICAL WIDTH
//FETCH BRIGHTNESS
int brightness;
- if (kVconfErrorNone == vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness)) {
+ ntv_ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ if (kVconfErrorNone == ntv_ret) {
scaledBrightness = static_cast<double>(brightness)/kDisplayBrightnessDivideValue;
} else {
- LoggerE("Cannot get brightness value of display");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get brightness value of display");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get brightness value of display",
+ ("vconf_get_int error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
out->insert(std::make_pair("resolutionWidth", picojson::value(std::to_string(screenWidth))));
return PlatformResult(ErrorCode::NO_ERROR);
}
else {
- LoggerE("VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL check failed");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL check failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL check failed");
}
}
status = kOrientationLandscapeSecondary;
break;
default:
- LoggerE("Received unexpected data: %u", rotation);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Received unexpected data");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Received unexpected data",
+ ("Received unexpected data: %u", rotation));
}
*result = status;
return PlatformResult(ErrorCode::NO_ERROR);
type_string = kNetworkTypeUnknown;
break;
default:
- LoggerE("Incorrect type: %d", type);
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Incorrect type");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Incorrect type",
+ ("Incorrect type: %d", type));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int error = connection_create(&connection_handle);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot create connection: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_create error: %d (%s)", error, get_error_message(error)));
}
std::unique_ptr<std::remove_pointer<connection_h>::type, int(*)(connection_h)>
connection_handle_ptr(connection_handle, &connection_destroy);
error = connection_get_type(connection_handle, &connection_type);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot get connection type: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_type error: %d (%s)", error, get_error_message(error)));
}
switch (connection_type) {
type = kEthernet;
break;
default:
- LoggerE("Incorrect type: %d", connection_type);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Incorrect type");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Incorrect type",
+ ("Incorrect type: %d", connection_type));
}
std::string type_str = "";
PlatformResult ret = GetNetworkTypeString(type, type_str);
WIFI_ADDRESS_FAMILY_IPV4,
&ip_addr);
if (WIFI_ERROR_NONE != error) {
- LoggerE("Failed to get ip address: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get ip address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get ip address",
+ ("wifi_ap_get_ip_address error: %d (%s)", error, get_error_message(error)));
}
*ip_addr_str = ip_addr;
free(ip_addr);
WIFI_ADDRESS_FAMILY_IPV6,
&ip_addr);
if (WIFI_ERROR_NONE != error) {
- LoggerE("Failed to get ipv6 address: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get ipv6 address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get ipv6 address",
+ ("Failed to get ipv6 address: %d (%s)", error, get_error_message(error)));
}
*ipv6_addr_str = ip_addr;
free(ip_addr);
CONNECTION_ADDRESS_FAMILY_IPV4,
&ip_addr);
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to get ip address: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get ip address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get ip address",
+ ("Failed to get ip address: %d (%s)", error, get_error_message(error)));
}
*ip_addr_str = ip_addr;
free(ip_addr);
} else if (CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED != error) {
//core api returns error -97 = CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED
//it will be supported in the future. For now let's ignore this error
- LoggerE("Failed to get ipv6 address: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get ipv6 address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get ipv6 address",
+ ("Failed to get ipv6 address: %d (%s)", error, get_error_message(error)));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int error = wifi_initialize();
if (WIFI_ERROR_NONE != error) {
std::string log_msg = "Initialize failed: " + std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_initialize error: %d (%s)", error, get_error_message(error)));
} else {
LoggerD("WIFI initialization succeed");
}
if (WIFI_ERROR_NONE != error) {
std::string log_msg = "Checking if wifi is activated failed: " +
std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_is_activated error: %d (%s)", error, get_error_message(error)));
} else {
LoggerD("WIFI activated check succeed");
}
if (WIFI_ERROR_NO_CONNECTION != error) {
std::string log_msg = "Cannot get connected access point handle: " +
std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_get_connected_ap error: %d (%s)", error, get_error_message(error)));
}
} else {
//if getting connected AP succeed, set status on true
free(mac);
} else {
std::string log_msg = "Failed to get mac address: " + std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_get_mac_address error: %d (%s)", error, get_error_message(error)));
}
//refreshing access point information
if (WIFI_ERROR_NONE != error) {
std::string log_msg = "Failed to refresh access point information: " +
std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_ap_refresh error: %d (%s)", error, get_error_message(error)));
}
//gathering ssid
free(essid);
} else {
std::string log_msg = "Failed to get network ssid: " + std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_ap_get_essid error: %d (%s)", error, get_error_message(error)));
}
//gathering ips
} else {
std::string log_msg = "Failed to get signal strength: " +
std::string(get_error_message(error));
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("wifi_ap_get_rssi error: %d (%s)", error, get_error_message(error)));
}
} else {
result_signal_strength = ((double) rssi_level)/WIFI_RSSI_LEVEL_4;
int error = connection_create(&connection_handle);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot create connection: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_create error: %d (%s)", error, get_error_message(error)));
}
std::unique_ptr<std::remove_pointer<connection_h>::type, int (*)(connection_h)> connection_handle_ptr(
connection_handle, &connection_destroy); // automatically release the memory
if (CONNECTION_ERROR_NONE != error) {
if (CONNECTION_ERROR_NOT_SUPPORTED == error) {
std::string log_msg = "Cannot get ethernet connection state: Not supported";
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, log_msg,
+ ("connection_get_ethernet_state error: %d (%s)", error, get_error_message(error)));
}
std::string log_msg = "Cannot get ethernet connection state: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_ethernet_state error: %d (%s)", error, get_error_message(error)));
}
switch (connection_state) {
error = connection_get_ethernet_cable_state(connection_handle, &cable_state);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot get ethernet cable state: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_ethernet_cable_state error: %d (%s)",
+ error, get_error_message(error)));
}
switch (cable_state) {
free(mac);
} else {
std::string log_msg = "Failed to get mac address: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_mac_address error: %d (%s)", error, get_error_message(error)));
}
error = connection_get_type(connection_handle, &connection_type);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot get connection type: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_type error: %d (%s)", error, get_error_message(error)));
}
if (CONNECTION_TYPE_ETHERNET == connection_type) {
error = connection_get_current_profile(connection_handle, &profile_handle);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot get connection profile: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_get_current_profile %d (%s)", error, get_error_message(error)));
}
std::unique_ptr<std::remove_pointer<connection_profile_h>::type,
int (*)(connection_profile_h)> profile_handle_ptr(
tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PLMN, &result_value);
if (TAPI_API_SUCCESS != tapi_res) {
std::string error_msg = "Cannot get mcc value, error: " + std::to_string(tapi_res);
- LoggerE("%s", error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
*result_mcc = static_cast<unsigned short>(result_value) / kMccDivider;
*result_mnc = static_cast<unsigned short>(result_value) % kMccDivider;
tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_CELLID, &result_value);
if (TAPI_API_SUCCESS != tapi_res) {
std::string error_msg = "Cannot get cell_id value, error: " + std::to_string(tapi_res);
- LoggerE("%s", error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
*result_cell_id = static_cast<unsigned short>(result_value);
tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_LAC, &result_value);
if (TAPI_API_SUCCESS != tapi_res) {
std::string error_msg = "Cannot get lac value, error: " + std::to_string(tapi_res);
- LoggerE("%s", error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
*result_lac = static_cast<unsigned short>(result_value);
tapi_res = tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_ROAMING_STATUS, &result_value);
if (TAPI_API_SUCCESS != tapi_res) {
std::string error_msg = "Cannot get is_roaming value, error: " + std::to_string(tapi_res);
- LoggerE("%s", error_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error_msg);
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, error_msg);
}
*result_is_roaming = (0 != result_value) ? true : false;
if (0 != vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &result_value)) {
- LoggerE("Cannot get is_flight_mode value");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get is_flight_mode value");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot get is_flight_mode value");
}
*result_is_flight_mode = (0 != result_value) ? true : false;
return PlatformResult(ErrorCode::NO_ERROR);
int error = connection_create(&connection_handle);
if (CONNECTION_ERROR_NONE != error) {
std::string log_msg = "Cannot create connection: " + std::to_string(error);
- LoggerE("%s", log_msg.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, log_msg);
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, log_msg,
+ ("connection_create error: %d (%s)", error, get_error_message(error)));
}
std::unique_ptr<std::remove_pointer<connection_h>::type, int(*)(connection_h)>
connection_handle_ptr(connection_handle, &connection_destroy);
error = connection_get_type(connection_handle, &connection_type);
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to get connection type: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get connection type");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get connection type",
+ ("Failed to get connection type: %d (%s)", error, get_error_message(error)));
}
char* apn = nullptr;
profile_handle_ptr(profile_handle, &connection_profile_destroy);
// automatically release the memory
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to get profile: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get profile");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get profile",
+ ("Failed to get profile: %d (%s)", error, get_error_message(error)));
}
error = connection_profile_get_cellular_apn(profile_handle, &apn);
if (CONNECTION_ERROR_NONE != error) {
- LoggerE("Failed to get apn name: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get apn name");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get apn name",
+ ("Failed to get apn name: %d (%s)", error, get_error_message(error)));
}
*result_apn = apn;
free(apn);
if (statfs(kStorageInternalPath.c_str(), &fs) < 0) {
- LoggerE("There are no storage units detected");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "There are no storage units detected");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "There are no storage units detected");
}
CreateStorageInfo(kTypeInternal, fs, &internal_obj);
manager_.SetAvailableCapacityInternal(fs.f_bavail);
if (0 == vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState)) {
if (VCONFKEY_SYSMAN_MMC_MOUNTED == sdcardState){
if (statfs(kStorageSdcardPath.c_str(), &fs) < 0) {
- LoggerE("MMC mounted, but not accessible");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "MMC mounted, but not accessible");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "MMC mounted, but not accessible");
}
array.push_back(picojson::value(picojson::object()));
picojson::object& external_obj = array.back().get<picojson::object>();
std::string camera = manager_.GetCameraTypes(index);
out->insert(std::make_pair("camera", picojson::value(camera)));
} else {
- return PlatformResult(
- ErrorCode::NOT_SUPPORTED_ERR,
- "Camera is not supported on this device");
+ return LogAndCreateResult(
+ ErrorCode::NOT_SUPPORTED_ERR, "Camera is not supported on this device");
}
return PlatformResult(ErrorCode::NO_ERROR);
msin_ = imsi.szMsin;
}
else {
- LoggerE("Failed to get sim imsi: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get sim imsi");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to get sim imsi",
+ ("Failed to get sim imsi: %d (%s)", error, get_error_message(error)));
}
return PlatformResult(ErrorCode::NO_ERROR);