summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/resumption/resumption_data_db.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/resumption/resumption_data_db.cc')
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc79
1 files changed, 33 insertions, 46 deletions
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index b493001c45..063cb332f1 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -49,9 +49,10 @@ const std::string kDatabaseName = "resumption";
namespace resumption {
CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption")
-ResumptionDataDB::ResumptionDataDB(const application_manager::ApplicationManager& application_manager)
- : ResumptionData(application_manager),
- db_(new utils::dbms::SQLDatabase(kDatabaseName)) {
+ResumptionDataDB::ResumptionDataDB(
+ const application_manager::ApplicationManager& application_manager)
+ : ResumptionData(application_manager)
+ , db_(new utils::dbms::SQLDatabase(kDatabaseName)) {
#ifndef __QNX__
std::string path = application_manager_.get_settings().app_storage_folder();
if (!path.empty()) {
@@ -71,10 +72,13 @@ bool ResumptionDataDB::Init() {
if (!db_->Open()) {
LOG4CXX_ERROR(logger_, "Failed opening database.");
LOG4CXX_INFO(logger_, "Starting opening retries.");
- const uint16_t attempts = application_manager_.get_settings().attempts_to_open_resumption_db();
+ const uint16_t attempts =
+ application_manager_.get_settings().attempts_to_open_resumption_db();
LOG4CXX_DEBUG(logger_, "Total attempts number is: " << attempts);
bool is_opened = false;
- const uint16_t open_attempt_timeout_ms = application_manager_.get_settings().open_attempt_timeout_ms_resumption_db();
+ const uint16_t open_attempt_timeout_ms =
+ application_manager_.get_settings()
+ .open_attempt_timeout_ms_resumption_db();
const useconds_t sleep_interval_mcsec = open_attempt_timeout_ms * 1000;
LOG4CXX_DEBUG(logger_,
"Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
@@ -90,8 +94,7 @@ bool ResumptionDataDB::Init() {
if (!is_opened) {
LOG4CXX_ERROR(logger_,
"Open retry sequence failed. Tried "
- << attempts
- << " attempts with "
+ << attempts << " attempts with "
<< open_attempt_timeout_ms
<< " open timeout(ms) for each.");
return false;
@@ -143,11 +146,10 @@ void ResumptionDataDB::SaveApplication(
const std::string& device_mac = application->mac_address();
LOG4CXX_INFO(logger_,
"app_id : " << application->app_id() << " policy_app_id : "
- << policy_app_id
- << " device_id : "
- << device_mac);
+ << policy_app_id << " device_id : " << device_mac);
- if (!CheckExistenceApplication(policy_app_id, device_mac, application_exist)) {
+ if (!CheckExistenceApplication(
+ policy_app_id, device_mac, application_exist)) {
LOG4CXX_ERROR(logger_, "Problem with access to DB");
return;
}
@@ -193,13 +195,10 @@ int32_t ResumptionDataDB::GetStoredHMILevel(
int hmi_level;
if (SelectHMILevel(policy_app_id, device_id, hmi_level)) {
- LOG4CXX_INFO(
- logger_,
- "Application with policy application id = " << policy_app_id
- << " and device id = "
- << device_id
- << "has hmi level = "
- << hmi_level);
+ LOG4CXX_INFO(logger_,
+ "Application with policy application id = "
+ << policy_app_id << " and device id = " << device_id
+ << "has hmi level = " << hmi_level);
return hmi_level;
}
LOG4CXX_FATAL(logger_, "HMI level doesn't exists in saved data");
@@ -223,10 +222,9 @@ bool ResumptionDataDB::CheckSavedApplication(const std::string& policy_app_id,
return false;
}
LOG4CXX_INFO(logger_,
- "Application with policy_app_id = " << policy_app_id
- << " and device_id = "
- << device_id
- << " does exist");
+ "Application with policy_app_id = "
+ << policy_app_id << " and device_id = " << device_id
+ << " does exist");
return true;
}
@@ -491,9 +489,7 @@ void ResumptionDataDB::SelectHMIId(const std::string& policy_app_id,
LOG4CXX_FATAL(logger_,
"Saved data doesn't have application with "
"device id = "
- << device_id
- << " and policy appID = "
- << policy_app_id);
+ << device_id << " and policy appID = " << policy_app_id);
}
bool ResumptionDataDB::SelectHashId(const std::string& policy_app_id,
@@ -525,9 +521,7 @@ bool ResumptionDataDB::SelectHashId(const std::string& policy_app_id,
LOG4CXX_WARN(logger_,
"Saved data doesn't have application with "
"device id = "
- << device_id
- << " and policy appID = "
- << policy_app_id
+ << device_id << " and policy appID = " << policy_app_id
<< "or hashID");
return false;
}
@@ -566,11 +560,9 @@ bool ResumptionDataDB::CheckExistenceApplication(
/* Position of data in "query" :
amount of application = 0 */
if (result && query.GetInteger(0)) {
- LOG4CXX_INFO(
- logger_,
- "Saved data has application with policy appID = " << policy_app_id
- << " and deviceID = "
- << device_id);
+ LOG4CXX_INFO(logger_,
+ "Saved data has application with policy appID = "
+ << policy_app_id << " and deviceID = " << device_id);
application_exist = true;
} else if (result) {
LOG4CXX_INFO(logger_, "Saved data does not contain application");
@@ -640,18 +632,15 @@ void ResumptionDataDB::UpdateHmiLevel(const std::string& policy_app_id,
if (query.Exec()) {
LOG4CXX_INFO(logger_,
"Saved data has application with policy appID = "
- << policy_app_id
- << " and deviceID = "
- << device_id
- << " has new HMI level = "
- << hmi_level);
+ << policy_app_id << " and deviceID = " << device_id
+ << " has new HMI level = " << hmi_level);
WriteDb();
}
}
}
void ResumptionDataDB::Persist() {
- WriteDb();
+ WriteDb();
}
bool ResumptionDataDB::RefreshDB() const {
@@ -761,9 +750,8 @@ bool ResumptionDataDB::DropAppDataResumption(const std::string& device_id,
const std::string& app_id) {
LOG4CXX_AUTO_TRACE(logger_);
- utils::ScopeGuard guard = utils::MakeObjGuard(
- *db_,
- &utils::dbms::SQLDatabase::RollbackTransaction);
+ utils::ScopeGuard guard =
+ utils::MakeObjGuard(*db_, &utils::dbms::SQLDatabase::RollbackTransaction);
db_->BeginTransaction();
if (!DeleteSavedFiles(app_id, device_id)) {
@@ -784,7 +772,7 @@ bool ResumptionDataDB::DropAppDataResumption(const std::string& device_id,
if (!DeleteSavedGlobalProperties(app_id, device_id)) {
return false;
}
- if(!UpdateGrammarID(app_id, device_id, 0)) {
+ if (!UpdateGrammarID(app_id, device_id, 0)) {
return false;
}
db_->CommitTransaction();
@@ -1468,9 +1456,8 @@ bool ResumptionDataDB::DeleteSavedApplication(const std::string& policy_app_id,
const std::string& device_id) {
LOG4CXX_AUTO_TRACE(logger_);
- utils::ScopeGuard guard = utils::MakeObjGuard(
- *db_,
- &utils::dbms::SQLDatabase::RollbackTransaction);
+ utils::ScopeGuard guard =
+ utils::MakeObjGuard(*db_, &utils::dbms::SQLDatabase::RollbackTransaction);
db_->BeginTransaction();
if (!DeleteSavedFiles(policy_app_id, device_id)) {