int* ids = nullptr;
char* compare_url = nullptr;
- if (bp_bookmark_adaptor_get_ids_p(&ids, // ids
- &ids_count, // count
- -1, //limit
- 0, // offset
- -1, //parent
- -1, //type
- -1, // is_operator
- -1, // is_editable
- BP_BOOKMARK_O_DATE_CREATED, // order_offset
- 0 // ordering ASC
- ) < 0) {
- LoggerE("Failed to obtain bookmarks");
- return PlatformResult{ErrorCode::UNKNOWN_ERR, "Failed to obtain bookmarks"};
+ int ntv_ret = bp_bookmark_adaptor_get_ids_p(
+ &ids, // ids
+ &ids_count, // count
+ -1, //limit
+ 0, // offset
+ -1, //parent
+ -1, //type
+ -1, // is_operator
+ -1, // is_editable
+ BP_BOOKMARK_O_DATE_CREATED, // order_offset
+ 0 // ordering ASC
+ );
+ if (ntv_ret < 0) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to obtain bookmarks",
+ ("bp_bookmark_adaptor_get_ids_p error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
PlatformResult result{ErrorCode::NO_ERROR};
bool url_found = false;
for (int i = 0; (i < ids_count) && result && !url_found; ++i) {
- if (bp_bookmark_adaptor_get_url(ids[i], &compare_url) < 0) {
- LoggerE("Failed to obtain URL");
- result = PlatformResult{ErrorCode::UNKNOWN_ERR, "Failed to obtain URL"};
+ ntv_ret = bp_bookmark_adaptor_get_url(ids[i], &compare_url);
+ if (ntv_ret < 0) {
+ result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to obtain URL",
+ ("bp_bookmark_adaptor_get_url error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
} else {
url_found = (0 == strcmp(url, compare_url));
free(compare_url);
int* ids = nullptr;
char* compare_title = nullptr;
- if (bp_bookmark_adaptor_get_ids_p(&ids, // ids
- &ids_count, // count
- -1, //limit
- 0, // offset
- -1, //parent
- -1, //type
- -1, // is_operator
- -1, // is_editable
- BP_BOOKMARK_O_DATE_CREATED, // order_offset
- 0 // ordering ASC
- ) < 0) {
- LoggerE("Failed to obtain bookmarks");
- return PlatformResult{ErrorCode::UNKNOWN_ERR, "Failed to obtain bookmarks"};
+ int ntv_ret = bp_bookmark_adaptor_get_ids_p(
+ &ids, // ids
+ &ids_count, // count
+ -1, //limit
+ 0, // offset
+ -1, //parent
+ -1, //type
+ -1, // is_operator
+ -1, // is_editable
+ BP_BOOKMARK_O_DATE_CREATED, // order_offset
+ 0 // ordering ASC
+ );
+ if (ntv_ret < 0) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to obtain bookmarks",
+ ("bp_bookmark_adaptor_get_ids_p error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
}
PlatformResult result{ErrorCode::NO_ERROR};
bool title_found = false;
for (int i = 0; (i < ids_count) && result && !title_found; ++i) {
- if (bp_bookmark_adaptor_get_parent_id(ids[i], &compare_parent) < 0) {
- LoggerE("Failed to obtain parent ID");
- result = PlatformResult{ErrorCode::UNKNOWN_ERR, "Failed to obtain parent ID"};
- } else if (bp_bookmark_adaptor_get_title(ids[i], &compare_title) < 0) {
- LoggerE("Failed to obtain title");
- result = PlatformResult{ErrorCode::UNKNOWN_ERR, "Failed to obtain title"};
+ if ((ntv_ret = bp_bookmark_adaptor_get_parent_id(ids[i], &compare_parent)) < 0) {
+ result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to obtain parent ID",
+ ("bp_bookmark_adaptor_get_parent_id error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
+ } else if ((ntv_ret = bp_bookmark_adaptor_get_title(ids[i], &compare_title)) < 0) {
+ result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to obtain title",
+ ("bp_bookmark_adaptor_get_title error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
} else {
title_found = (parent == compare_parent) && (0 == strcmp(title, compare_title));
free(compare_title);
ctx.id = arg.get(kId).get<double>();
if (!bookmark_foreach(ctx, info)) {
+ LoggerE("BookmarkGet error");
ReportError(o);
return;
}
bool exists = false;
auto result = BookmarkUrlExists(url.c_str(), &exists);
if (!result) {
- ReportError(result, &o);
+ LogAndReportError(result, &o);
return;
} else if (exists) {
- ReportError(PlatformResult{ErrorCode::UNKNOWN_ERR, "Bookmark already exists"}, &o);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Bookmark already exists"), &o);
return;
}
}
bool exists = false;
auto result = BookmarkTitleExistsInParent(title.c_str(), parent, &exists);
if (!result) {
- ReportError(result, &o);
+ LogAndReportError(result, &o);
return;
} else if (exists) {
- ReportError(PlatformResult{ErrorCode::UNKNOWN_ERR, "Bookmark already exists"}, &o);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Bookmark already exists"), &o);
return;
}
}
- if (bp_bookmark_adaptor_create(&saved_id) < 0) {
+ int ntv_ret;
+
+ ntv_ret = bp_bookmark_adaptor_create(&saved_id);
+ if (ntv_ret < 0) {
+ LoggerE("bp_bookmark_adaptor_create error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
- if (bp_bookmark_adaptor_set_title(saved_id, title.c_str()) < 0) {
+
+ ntv_ret = bp_bookmark_adaptor_set_title(saved_id, title.c_str());
+ if (ntv_ret < 0) {
bp_bookmark_adaptor_delete(saved_id);
+ LoggerE("bp_bookmark_adaptor_set_title error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
- if (bp_bookmark_adaptor_set_parent_id(saved_id, parent) < 0) {
+
+ ntv_ret = bp_bookmark_adaptor_set_parent_id(saved_id, parent);
+ if (ntv_ret < 0) {
bp_bookmark_adaptor_delete(saved_id);
+ LoggerE("bp_bookmark_adaptor_set_parent_id error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
- if (bp_bookmark_adaptor_set_type(saved_id, type) < 0) {
+
+ ntv_ret = bp_bookmark_adaptor_set_type(saved_id, type);
+ if (ntv_ret < 0) {
bp_bookmark_adaptor_delete(saved_id);
+ LoggerE("bp_bookmark_adaptor_set_type error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
- if (bp_bookmark_adaptor_set_url(saved_id, url.c_str()) < 0) {
+
+ ntv_ret = bp_bookmark_adaptor_set_url(saved_id, url.c_str());
+ if (ntv_ret < 0) {
bp_bookmark_adaptor_delete(saved_id);
+ LoggerE("bp_bookmark_adaptor_set_url error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
LoggerD("Enter");
int id = common::stol(
common::FromJson<std::string>(arg.get<picojson::object>(), kId));
- if (bp_bookmark_adaptor_delete(id) < 0) {
+
+ int ntv_ret = bp_bookmark_adaptor_delete(id);
+ if (ntv_ret < 0) {
+ LoggerE("bp_bookmark_adaptor_delete error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
const picojson::value& msg, picojson::object& o) {
LoggerD("Enter");
- if (bp_bookmark_adaptor_reset() < 0) {
+ int ntv_ret = bp_bookmark_adaptor_reset();
+ if (ntv_ret < 0) {
+ LoggerE("bp_bookmark_adaptor_reset error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
LoggerD("Enter");
int rootId(0);
- if (bp_bookmark_adaptor_get_root(&rootId) < 0) {
+ int ntv_ret = bp_bookmark_adaptor_get_root(&rootId);
+ if (ntv_ret < 0) {
+ LoggerE("bp_bookmark_adaptor_get_root error: %d (%s)", ntv_ret, get_error_message(ntv_ret));
ReportError(o);
return;
}
'includes':[
'../common/common.gypi',
],
+ 'variables': {
+ 'enable_common_debug_logs%': '0',
+ },
'targets': [
{
'target_name': 'tizen_common',
}],
],
}],
+ ['extension_build_type == "Debug"', {
+ 'conditions': [
+ ['enable_common_debug_logs == 0', {
+ # remove TIZEN_DEBUG_ENABLE flag
+ 'defines!': ['TIZEN_DEBUG_ENABLE'],
+ }],
+ ],
+ }],
],
'direct_dependent_settings': {
'libraries' : [
#define COMMON_LOGGER_H_
#include <dlog.h>
+
+// Tizen 3.0 uses different debug flag (DLOG_DEBUG_ENABLE) which is always
+// enabled, following code allows to disable logs with DLOG_DEBUG priority if
+// TIZEN_DEBUG_ENABLE is not set.
+// This code should be removed when DLOG_DEBUG_ENABLE flag is no longer set
+// by default in dlog.h file.
+#undef LOG_
+#ifdef TIZEN_DEBUG_ENABLE
+#define LOG_(id, prio, tag, fmt, arg...) \
+ ({ do { \
+ __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
+ } while (0); })
+#else // TIZEN_DEBUG_ENABLE
+#define LOG_(id, prio, tag, fmt, arg...) \
+ ({ do { \
+ if ((int)prio != DLOG_DEBUG) { \
+ __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
+ } \
+ } while (0); })
+#endif // TIZEN_DEBUG_ENABLE
+
+#undef SECURE_LOG_
+#ifdef TIZEN_DEBUG_ENABLE
+#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
+ ({ do { \
+ __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg); \
+ } while (0); })
+#else // TIZEN_DEBUG_ENABLE
+#define SECURE_LOG_(id, prio, tag, fmt, arg...) NOP(fmt, ##arg)
+#endif // TIZEN_DEBUG_ENABLE
+
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <string>
-#include <dlog.h>
#include <glib.h>
#include <memory>
#include <media_content.h>
exif_data = exif_data_new();
if (!exif_data) {
- LoggerE("Couldn't allocate new ExifData");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed",
+ ("Couldn't allocate new ExifData"));
}
exif_data_set_option(exif_data, EXIF_DATA_OPTION_FOLLOW_SPECIFICATION);
if (status)
ReportSuccess(result, response->get<picojson::object>());
else
- ReportError(status, &response->get<picojson::object>());
+ LogAndReportError(status, &response->get<picojson::object>());
};
auto get_response = [callback_id, this](const std::shared_ptr<JsonValue>& response)->void {
if (status)
ReportSuccess(result, response->get<picojson::object>());
else
- ReportError(status, &response->get<picojson::object>());
+ LogAndReportError(status, &response->get<picojson::object>());
};
auto get_response = [callback_id, this](const std::shared_ptr<JsonValue>& response) -> void {
}
if ("jpeg" != ext && "png" != ext && "gif" != ext) {
- LoggerE("extension: %s is not valid (jpeg/jpg/png/gif is supported)",
- ext.c_str());
status = PlatformResult(ErrorCode::INVALID_VALUES_ERR,
"getThumbnail support only jpeg/jpg/png/gif");
- ReportError(status, &response->get<picojson::object>());
+ LogAndReportError(status, &response->get<picojson::object>(),
+ ("extension: %s is not valid (jpeg/jpg/png/gif is supported)", ext.c_str()));
return;
}
LoggerD("Get thumbnail from Exif in file: [%s]", file_path.c_str());
ExifData *exif_data = exif_data_new_from_file(file_path.c_str());
if (!exif_data) {
- LoggerE("Error reading from file [%s]", file_path.c_str());
status = PlatformResult(ErrorCode::UNKNOWN_ERR,
"Error reading from file");
- ReportError(status, &response->get<picojson::object>());
+ LogAndReportError(status, &response->get<picojson::object>(),
+ ("Error reading from file [%s]", file_path.c_str()));
return;
}
if (!exif_data->data || !exif_data->size) {
exif_data_unref(exif_data);
- LoggerE("File [%s] doesn't contain thumbnail", file_path.c_str());
status = PlatformResult(ErrorCode::UNKNOWN_ERR,
"File doesn't contain thumbnail");
- ReportError(status, &response->get<picojson::object>());
+ LogAndReportError(status, &response->get<picojson::object>(),
+ ("File [%s] doesn't contain thumbnail", file_path.c_str()));
return;
}
ExifEntry* entry = prepareEntry(exif_data, tag);
if (!entry) {
- LoggerE("Exif entry is null");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
}
ExifByteOrder order = exif_data_get_byte_order(exif_data);
break;
}
default: {
- LoggerE("Error: wrong format: %d \n", entry->format);
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Wrong format");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Wrong format",
+ ("Error: wrong format: %d \n", entry->format));
}
}
return common::PlatformResult(common::ErrorCode::NO_ERROR);
LoggerD("Entered");
ExifEntry* entry = prepareEntry(exif_data, tag);
if (!entry) {
- LoggerE("Exif entry is null");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
}
if (!value.empty()) {
entry->data = static_cast<unsigned char*>(malloc(entry->size));
if (entry->data == nullptr) {
- LoggerE("Function malloc returned nullptr");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
}
memcpy(entry->data, value.c_str(), value.length());
LoggerD("Entered");
ExifEntry* entry = prepareEntry(exif_data, tag);
if (!entry) {
- LoggerE("Exif entry is null");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
}
entry->format = EXIF_FORMAT_RATIONAL;
entry->size = ExifTypeInfo::RationalSize;
entry->data = static_cast<unsigned char*>(malloc(entry->size));
if (entry->data == nullptr) {
- LoggerE("Function malloc returned nullptr");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
}
memset(entry->data, 0, entry->size);
}
LoggerD("Entered");
ExifEntry* entry = prepareEntry(exif_data, tag);
if (!entry) {
- LoggerE("Exif entry is null");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
}
ExifByteOrder order = exif_data_get_byte_order(exif_data);
entry->format = EXIF_FORMAT_RATIONAL;
entry->size = required_size;
entry->data = static_cast<unsigned char*>(malloc(entry->size));
if (entry->data == nullptr) {
- LoggerE("Function malloc returned nullptr");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
}
memset(entry->data, 0, entry->size);
}
LoggerD("Entered");
ExifEntry* entry = prepareEntry(exif_data, tag);
if (!entry) {
- LoggerE("Exif entry is null");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Exif entry is null");
}
const ExifByteOrder order = exif_data_get_byte_order(exif_data);
case EXIF_FORMAT_SLONG:
break;
default:
- LoggerE("output ExifFormat: %d is not supported!", store_as);
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "ExifFormat is not supported!");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "ExifFormat is not supported!",
+ ("output ExifFormat: %d is not supported!", store_as));
}
entry->format = store_as;
entry->size = required_size;
entry->data = static_cast<unsigned char*>(malloc(entry->size));
if (entry->data == nullptr) {
- LoggerE("Function malloc returned nullptr");
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Function malloc returned nullptr");
}
memset(entry->data, 0, entry->size);
}
LoggerE("output ExifFormat: %d is not supported!", store_as);
free(entry->data);
entry->data = nullptr;
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "ExifFormat is not supported!");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "ExifFormat is not supported!");
}
}
// Tags in other sections
default:
- LoggerE("Unsupported tag: %d", tag);
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Unsupported tag");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Unsupported tag",
+ ("Unsupported tag: %d", tag));
}
return common::PlatformResult(common::ErrorCode::NO_ERROR);
// Unsupported tags:
default:
- LoggerE("Unsupported tag: %d", tag);
- return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, "Unsupported tag");
+ return LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "Unsupported tag",
+ ("Unsupported tag: %d", tag));
}
return common::PlatformResult(common::ErrorCode::NO_ERROR);
pair = std::make_pair("isoSpeedRatings", JsonValue(array));
result_obj->insert(pair);
} else {
- LoggerE("iso speed ratings: format or components count is invalid!");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR,
"iso speed ratings: format or components count is invalid!");
}
break;
exp_time.toString().c_str());
}
} else {
- LoggerE("exposure time: format or components count is invalid!");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR,
"exposure time: format or components count is invalid!");
}
break;
const std::string& file_path = ExifUtil::convertUriToPath(uri);
ExifData* ed = exif_data_new_from_file(file_path.c_str());
if (!ed) {
- LoggerE("Error reading exif from file %s", file_path.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error reading exif from file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Error reading exif from file",
+ ("Error reading exif from file %s", file_path.c_str()));
}
LoggerD("loadFromURI_into_json exif_data_foreach_content START");
LoggerD("Entered");
JpegFile* new_jpg = new (std::nothrow) JpegFile();
if (!new_jpg) {
- LoggerE("Couldn't allocate Jpegfile!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed",
+ ("Couldn't allocate Jpegfile!"));
}
jpg_ptr->reset(new_jpg);
m_in_file = fopen(path.c_str(), "rb");
if (!m_in_file) {
- LoggerE("Couldn't open Jpeg file: [%s]", path.c_str());
- return PlatformResult(ErrorCode::NOT_FOUND_ERR, "Could not open JPEG file");
+ return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Could not open JPEG file",
+ ("Couldn't open Jpeg file: [%s]", path.c_str()));
}
fseek(m_in_file, 0, SEEK_END);
long ftell_val = ftell(m_in_file);
if (0 > ftell_val) {
- LoggerE("Input file [%s] access error! [%d]", path.c_str(), errno);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("Input file [%s] access error! [%d]", path.c_str(), errno));
}
const std::size_t in_file_size = static_cast<size_t>(ftell_val);
fseek(m_in_file, 0, SEEK_SET);
LoggerD("JPEG file: [%s] size:%d", path.c_str(), in_file_size);
if (0 == in_file_size) {
- LoggerE("Input file [%s] is empty!", path.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("Input file [%s] is empty!", path.c_str()));
}
m_in_data = new (std::nothrow) unsigned char[in_file_size];
if (!m_in_data) {
- LoggerE("Couldn't allocate buffer with size: %d", in_file_size);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed",
+ ("Couldn't allocate buffer with size: %d", in_file_size));
}
m_in_data_size = in_file_size;
const std::size_t read_bytes = fread(m_in_data, 1, m_in_data_size, m_in_file);
if (read_bytes != m_in_data_size) {
- LoggerE("Couldn't read all: %d bytes. Read only: %d bytes!", m_in_data_size,
- read_bytes);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not read JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not read JPEG file",
+ ("Couldn't read all: %d bytes. Read only: %d bytes!", m_in_data_size, read_bytes));
}
if (fclose(m_in_file) == EOF) {
const std::size_t num_bytes_before,
const std::size_t num_bytes_after) {
LoggerD("Entered");
- long long int start = static_cast<long long int>(offset) - num_bytes_before;
- if (start < 0) {
+ auto start = offset - num_bytes_before;
+ if (offset < num_bytes_before) {
start = 0;
}
- long long int end = static_cast<long long int>(offset) + num_bytes_after;
- if (end >= m_in_data_size) {
+ auto end = offset + num_bytes_after;
+ if (end >= m_in_data_size || end < start) {
end = m_in_data_size - 1;
}
std::stringstream ss;
ss << std::setfill('0') << std::setw(2) << std::hex;
- for (long long int i = start; i <= end; ++i) {
+ for (size_t i = start; i <= end; ++i) {
ss << static_cast<int>(m_in_data[i]);
}
return ss.str();
}
if (search_len == search_offset) {
- LoggerE("offset:%d | Couldn't find marker! RAW DATA:{%s}", offset,
- getPartOfFile(offset, 0, 10).c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("offset:%d | Couldn't find marker! RAW DATA:{%s}", offset, getPartOfFile(offset, 0, 10).c_str()));
}
const std::size_t section_offset = offset + search_offset - 1;
LoggerD("offset:%d | Moved to section begin", offset);
if (!isJpegMarker(section_begin[1])) {
- LoggerE("offset:%d | Is not valid marker: 0x%x RAW DATA:{%s}", offset,
- section_begin[1], getPartOfFile(section_offset, 0, 4).c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("offset:%d | Is not valid marker: 0x%x RAW DATA:{%s}", offset,
+ section_begin[1], getPartOfFile(section_offset, 0, 4).c_str()));
}
const JpegMarker cur_marker = castToJpegMarker(section_begin[1]);
{
JpegFileSection* sec = new (std::nothrow) JpegFileSection();
if (!sec) {
- LoggerE("Couldn't allocate JpegFileSection");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Memory allocation failed",
+ ("Couldn't allocate JpegFileSection"));
}
section = JpegFileSectionPtr(sec);
offset += 2; // Read data size - 2 bytes
if (total_section_len < 0) {
- LoggerE("offset:%d tag:0x%x | Error: total_section_len is: %d < 0",
- offset, cur_marker, total_section_len);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("offset:%d tag:0x%x | Error: total_section_len is: %d < 0",
+ offset, cur_marker, total_section_len));
}
if (section_offset + 2 + total_section_len > m_in_data_size) {
- LoggerE("offset:%d tag:0x%x | Error: current section offset:%d"
- " + 2 + total_section_len:%d = %d is greater then file size:%d",
- offset, cur_marker,
- section_offset, total_section_len,
- section_offset + total_section_len, m_in_data_size);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("offset:%d tag:0x%x | Error: current section offset:%d"
+ " + 2 + total_section_len:%d = %d is greater then file size:%d",
+ offset, cur_marker,
+ section_offset, total_section_len,
+ section_offset + total_section_len, m_in_data_size));
}
if (JPEG_MARKER_APP1 == cur_marker) {
{
JpegFileSection* new_sec = new (std::nothrow) JpegFileSection();
if (!new_sec) {
- LoggerE("Couldn't allocate JpegFileSection");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Memory allocation failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Memory allocation failed",
+ ("Couldn't allocate JpegFileSection"));
}
new_sec->type = JPEG_MARKER_APP1;
}
if (!soi_is_present) {
- LoggerW("SOI section is missing");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "JPEG file is invalid",
+ ("SOI section is missing"));
}
// Insert new Exif sections just after SOI
FILE* outf = fopen(out_path.c_str(), "wb");
if (!outf) {
- LoggerE("Couldn't open output file:"
- " [%s] - JPEG file will not be restored!", out_path.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Couldn't open output file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Couldn't open output file",
+ ("Couldn't open output file:"
+ " [%s] - JPEG file will not be restored!", out_path.c_str()));
}
std::size_t bytes_wrote = fwrite(m_in_data, 1, m_in_data_size, outf);
if (bytes_wrote != m_in_data_size) {
fclose(outf);
- LoggerE("Couldn't restore whole JPEG! "
- "Only %d of %d bytes have been wrote!",
- bytes_wrote, m_in_data_size);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Couldn't restore whole file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Couldn't restore whole file",
+ ("Couldn't restore whole JPEG! "
+ "Only %d of %d bytes have been wrote!",
+ bytes_wrote, m_in_data_size));
}
if (EOF == fclose(outf)) {
LoggerE("Couldn't close restore output file: [%s]", out_path.c_str());
m_out_file = fopen(out_path.c_str(), "wb");
if (!m_out_file) {
- LoggerE("Couldn't open output file: %s", out_path.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not write JPEG file",
+ ("Couldn't open output file: %s", out_path.c_str()));
}
unsigned char tmp_buf[128];
unsigned char* tmp = NULL;
exif_data_save_data(cur->exif_data, &tmp, &exif_output_size);
if (!tmp || 0 == exif_output_size) {
- LoggerE("Couldn't generate RAW Exif data!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
"Could not save Exif in JPEG file");
}
exif_output_data.reset(tmp);
if (exif_output_size > MAX_AVAILABLE_JPEG_SECTION_DATA_SIZE) {
- LoggerE("exif_output_size:%d is greater then maximum JPEG section"
- "data block size: %d", exif_output_size,
- MAX_AVAILABLE_JPEG_SECTION_DATA_SIZE);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Exif data is to big to be saved in JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Exif data is to big to be saved in JPEG file",
+ ("exif_output_size:%d is greater then maximum JPEG section"
+ "data block size: %d", exif_output_size,
+ MAX_AVAILABLE_JPEG_SECTION_DATA_SIZE));
}
section_size += exif_output_size;
write_exif_data = true;
offset += bytes_wrote;
if (bytes_wrote != bytes_to_write) {
- LoggerE("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
- bytes_wrote);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Could not write JPEG file",
+ ("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
+ bytes_wrote));
}
if (write_section_data && cur->size > 0) {
offset += bytes_wrote;
if (bytes_wrote != bytes_to_write) {
- LoggerE("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
- bytes_wrote);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Could not write JPEG file",
+ ("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
+ bytes_wrote));
}
}
offset += bytes_wrote;
if (bytes_wrote != bytes_to_write) {
- LoggerE("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
- bytes_wrote);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Could not write JPEG file",
+ ("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
+ bytes_wrote));
}
}
offset += bytes_wrote;
if (bytes_wrote != bytes_to_write) {
- LoggerE("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
- bytes_wrote);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Could not write JPEG file",
+ ("Couldn't wrote %d bytes! Only %d bytes wrote", bytes_to_write,
+ bytes_wrote));
}
}
}
m_out_file);
if (bytes_wrote != m_padding_data_size) {
- LoggerE("Couldn't wrote %d bytes! Only %d bytes wrote",
- m_padding_data_size, bytes_wrote);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Could not write JPEG file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Could not write JPEG file",
+ ("Couldn't wrote %d bytes! Only %d bytes wrote",
+ m_padding_data_size, bytes_wrote));
}
}
#define CHECK_EXIST(args, name, out) \
if (!args.contains(name)) { \
- ReportError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, \
+ LogAndReportError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, \
name" is required argument"), &out); \
return; \
}
PlatformResult result = Init();
if (!result) {
- LoggerE("Failed: Init()");
- ReportError(result, &out);
+ LogAndReportError(result, &out, ("Failed: Init()"));
return;
}
if (result) {
ReportSuccess(data, response_obj);
} else {
- LoggerE("Failed: manager_->GetHumanActivityData()");
- ReportError(result, &response_obj);
+ LogAndReportError(result, &response_obj, ("Failed: manager_->GetHumanActivityData()"));
}
Instance::PostMessage(this, response.serialize().c_str());
PlatformResult result = Init();
if (!result) {
- LoggerE("Failed: Init()");
- ReportError(result, &out);
+ LogAndReportError(result, &out, ("Failed: Init()"));
return;
}
if (result) {
ReportSuccess(out);
} else {
- LoggerE("Failed: manager_->SetListener()");
- ReportError(result, &out);
+ LogAndReportError(result, &out, ("Failed: manager_->SetListener()"));
}
}
PlatformResult result = Init();
if (!result) {
- LoggerE("Failed: Init()");
- ReportError(result, &out);
+ LogAndReportError(result, &out, ("Failed: Init()"));
return;
}
if (result) {
ReportSuccess(out);
} else {
- LoggerE("Failed: manager_->UnsetListener()");
- ReportError(result, &out);
+ LogAndReportError(result, &out, ("Failed: manager_->UnsetListener()"));
}
}
// check cache first
if (supported_.count(type)) {
- return PlatformResult(supported_[type]
+ return LogAndCreateResult(supported_[type]
? ErrorCode::NO_ERROR
: ErrorCode::NOT_SUPPORTED_ERR);
}
} else if (type == kActivityTypeWristUp) {
ret = gesture_is_supported(GESTURE_WRIST_UP, &supported);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "gesture_is_supported(GESTURE_WRIST_UP), error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "WRIST_UP gesture check failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "WRIST_UP gesture check failed",
+ ("gesture_is_supported(GESTURE_WRIST_UP), error: %d",ret));
}
} else if (type == kActivityTypeHrm) {
ret = sensor_is_supported(SENSOR_HRM, &supported);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "sensor_is_supported(HRM), error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "HRM sensor check failed");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "HRM sensor check failed",
+ ("sensor_is_supported(HRM), error: %d",ret));
}
} else if (type == kActivityTypeGps) {
supported = location_manager_is_supported_method(LOCATIONS_METHOD_GPS);
} else {
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR);
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR);
}
supported_[type] = supported;
- return PlatformResult(supported_[type]
+ return LogAndCreateResult(supported_[type]
? ErrorCode::NO_ERROR
: ErrorCode::NOT_SUPPORTED_ERR);
}
return SetGpsListener(callback);
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
}
PlatformResult HumanActivityMonitorManager::UnsetListener(
return UnsetGpsListener();
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
}
PlatformResult HumanActivityMonitorManager::GetHumanActivityData(
}
if (type == kActivityTypeWristUp) {
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR);
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR);
}
if (type == kActivityTypeHrm) {
return GetGpsData(data);
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Undefined activity type");
}
// WRIST_UP
ret = gesture_create(&gesture_handle_);
if (ret != GESTURE_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to create WRIST_UP handle, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to create WRIST_UP listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to create WRIST_UP listener",
+ ("Failed to create WRIST_UP handle, error: %d",ret));
}
ret = gesture_start_recognition(gesture_handle_,
OnWristUpEvent,
this);
if (ret != GESTURE_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to start WRIST_UP listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to start WRIST_UP listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to start WRIST_UP listener",
+ ("Failed to start WRIST_UP listener, error: %d",ret));
}
wrist_up_event_callback_ = callback;
ret = sensor_get_default_sensor(SENSOR_HRM, &hrm_sensor);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to get HRM sensor, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to get HRM sensor");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to get HRM sensor",
+ ("Failed to get HRM sensor, error: %d",ret));
}
ret = sensor_create_listener(hrm_sensor, &hrm_sensor_listener_);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to create HRM sensor listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to create HRM sensor listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to create HRM sensor listener",
+ ("Failed to create HRM sensor listener, error: %d",ret));
}
ret = sensor_listener_set_event_cb(hrm_sensor_listener_,
OnHrmSensorEvent,
this);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to set HRM sensor listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to set HRM sensor listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to set HRM sensor listener",
+ ("Failed to set HRM sensor listener, error: %d",ret));
}
ret = sensor_listener_start(hrm_sensor_listener_);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to start HRM sensor listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to start HRM sensor listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to start HRM sensor listener",
+ ("Failed to start HRM sensor listener, error: %d",ret));
}
hrm_event_callback_ = callback;
if (hrm_sensor_listener_) {
int ret = sensor_listener_stop(hrm_sensor_listener_);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to stop HRM sensor, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to stop HRM sensor");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to stop HRM sensor",
+ ("Failed to stop HRM sensor, error: "%d,ret));
}
ret = sensor_listener_unset_event_cb(hrm_sensor_listener_);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to unset HRM sensor listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to unset HRM sensor listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to unset HRM sensor listener",
+ ("Failed to unset HRM sensor listener, error: %d",ret));
}
ret = sensor_destroy_listener(hrm_sensor_listener_);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to destroy HRM sensor listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to destroy HRM sensor listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to destroy HRM sensor listener",
+ ("Failed to destroy HRM sensor listener, error: %d",ret));
}
}
LOGGER(DEBUG) << " |- value_count: " << event->value_count;
if (event->value_count < 2) {
- LOGGER(ERROR) << "To few values of HRM event";
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "To few values of HRM event");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "To few values of HRM event");
}
LOGGER(DEBUG) << " |- values[0]: " << event->values[0];
PlatformResult HumanActivityMonitorManager::GetHrmData(picojson::value* data) {
LoggerD("Enter");
if (!hrm_sensor_listener_) {
- return PlatformResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR);
+ return LogAndCreateResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR);
}
int ret;
sensor_event_s event;
ret = sensor_listener_read_data(hrm_sensor_listener_, &event);
if (ret != SENSOR_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to get HRM sensor data, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to get HRM sensor data");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to get HRM sensor data",
+ ("Failed to get HRM sensor data, error: %d",ret));
}
*data = picojson::value(picojson::object());
ret = location_manager_create(LOCATIONS_METHOD_GPS, &location_handle_);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to create location manager, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to create location manager");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to create location manager",
+ ("Failed to create location manager, error: %d",ret));
}
ret = location_manager_set_location_batch_cb(location_handle_,
120, // batch_period
this);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to set location listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to set location listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to set location listener",
+ ("Failed to set location listener, error: %d",ret));
}
ret = location_manager_start_batch(location_handle_);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to start location manager, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to start location manager");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to start location manager",
+ ("Failed to start location manager, error: %d",ret));
}
gps_event_callback_ = callback;
if (location_handle_) {
int ret = location_manager_stop_batch(location_handle_);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to stop location manager, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to stop location manager");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to stop location manager",
+ ("Failed to stop location manager, error: %d",ret));
}
ret = location_manager_unset_location_batch_cb(location_handle_);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to unset location listener, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to unset location listener");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to unset location listener",
+ ("Failed to unset location listener, error: %d",ret));
}
ret = location_manager_destroy(location_handle_);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to destroy location manager, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to destroy location manager");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Failed to destroy location manager",
+ ("Failed to destroy location manager, error: %d",ret));
}
}
PlatformResult HumanActivityMonitorManager::GetGpsData(picojson::value* data) {
LoggerD("Enter");
if (!location_handle_) {
- return PlatformResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR);
+ return LogAndCreateResult(ErrorCode::SERVICE_NOT_AVAILABLE_ERR);
}
int ret;
&level, &horizontal, &vertical,
×tamp);
if (ret != LOCATIONS_ERROR_NONE) {
- LOGGER(ERROR) << "Failed to get location, error: " << ret;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get location");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to get location",
+ ("Failed to get location, error: %d",ret));
}
*data = picojson::value(picojson::array());
double SoundManager::ConvertToSystemVolume(int max_volume, int volume) {
LoggerD("Enter");
- return round(static_cast<double>(volume) * 10 / max_volume) / 10;
+ return round(static_cast<double>(volume) * 100 / max_volume) / 100;
}
void SoundManager::VolumeChangeCallback(sound_type_e type, unsigned int value) {