summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtrunov <dtrunov@luxoft.com>2015-04-29 14:14:24 +0300
committerdtrunov <dtrunov@luxoft.com>2015-06-23 15:41:26 +0300
commit9342f0edfbde61daa3ce6d7beba1486e2b95006a (patch)
tree59063207eee4df1bb866adb3daa1c548362b66c4
parent7dc0110c46505f881db44bc132231eb3aff9cca4 (diff)
downloadsdl_core-9342f0edfbde61daa3ce6d7beba1486e2b95006a.tar.gz
Fixed resume of HMI level after expected disconnect
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_db.h31
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h3
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc84
-rw-r--r--src/components/application_manager/src/resumption/resumption_sql_queries.cc16
4 files changed, 48 insertions, 86 deletions
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
index 50c621fdd7..5e85e85376 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
@@ -323,6 +323,15 @@ class ResumptionDataDB : public ResumptionData {
*/
bool DeleteSavedGlobalProperties(const std::string& mobile_app_id,
const std::string& device_id);
+ /**
+ * @brief Deletes data from application table
+ * @param policy_app_id - mobile application id
+ * @param device_id - contains id of device on which is running application
+ * @return true if data was deleted otherwise returns
+ * false
+ */
+ bool DeleteDataFromApplicationTable(const std::string& policy_app_id,
+ const std::string& device_id);
/**
* @brief Saves files data to DB
@@ -389,15 +398,12 @@ class ResumptionDataDB : public ResumptionData {
* @param application contains data for saving
* @param mobile_app_id - mobile application id
* @param device_id - contains id of device on which is running application
- * @param application_exist = true if application exists
- * in DB otherwise = false
* @return true if application data was saved successfully
* otherwise returns false
*/
bool SaveApplicationToDB(app_mngr::ApplicationConstSharedPtr application,
const std::string& policy_app_id,
- const std::string& device_id,
- bool application_exist);
+ const std::string& device_id);
/**
* @brief Updates ignition of count on saved applications after onAwake
@@ -430,18 +436,6 @@ class ResumptionDataDB : public ResumptionData {
const std::string& text_query);
/**
- * @brief Execute query in order to receive application primary key
- * @param mobile_app_id - mobile application id
- * @param device_id - contains id of device on which is running application
- * @param primary_key - will contain primary key from DB
- * @return true if query was run successfully otherwise returns
- * false
- */
- bool ExecSelectPrimaryKeyFromApplication(
- const std::string& policy_app_id, const std::string& device_id,
- int64_t& primary_key) const;
-
- /**
* @brief Execute query in order to insert image to DB
* @param image_primary_key - will contain primary key from image table
* @param image contains data for saving to DB
@@ -545,8 +539,6 @@ class ResumptionDataDB : public ResumptionData {
* @param device_id contains id of device on which is running application
* @param application_primary_key will contain primary key from application table
* @param global_properties_key contains primary key from globalproperties table
- * @param application_exist contains TRUE if application exists on DB
- * otherwise contains FALSE.
* @return true if query was run successfully otherwise returns
* false
*/
@@ -554,8 +546,7 @@ class ResumptionDataDB : public ResumptionData {
const std::string& mobile_app_id,
const std::string& device_id,
int64_t& application_primary_key,
- int64_t global_properties_key,
- bool application_exist);
+ int64_t global_properties_key);
/**
* @brief Delete application data where ign_off_count >= application_lifes
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
index 8f8d5d5f6f..7fe78f64e0 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
@@ -78,9 +78,9 @@ extern const std::string kDeletevrHelpItemArray;
extern const std::string kDeleteTableLimitedCharacterList;
extern const std::string kDeleteCharacterArray;
extern const std::string kDeleteTTSChunk;
+extern const std::string kDeleteFromApplicationTable;
extern const std::string kDeleteHelpTimeoutPromptArray;
extern const std::string kDeleteGlobalProperties;
-extern const std::string kSelectPrimaryKeyFromApplication;
extern const std::string kSelectCountImage;
extern const std::string kSelectPrimaryKeyImage;
extern const std::string kInsertImage;
@@ -105,7 +105,6 @@ extern const std::string kInsertVRHelpItemArray;
extern const std::string kInsertHelpTimeoutPromptArray;
extern const std::string kInsertTTSChunk;
extern const std::string kInsertApplication;
-extern const std::string kUpdateApplication;
extern const std::string kSelectCountFiles;
extern const std::string kSelectFiles;
extern const std::string kSelectCountSubMenu;
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 81a2760b44..e2586fedf0 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -152,7 +152,7 @@ void ResumptionDataDB::SaveApplication(
}
}
- if (!SaveApplicationToDB(application, m_app_id, device_id, application_exist)) {
+ if (!SaveApplicationToDB(application, policy_app_id, device_id)) {
LOG4CXX_ERROR(logger_, "Saving of application data is not finished");
return;
}
@@ -1216,6 +1216,10 @@ bool ResumptionDataDB::DeleteSavedApplication(const std::string& mobile_app_id,
db_->RollbackTransaction();
return false;
}
+ if (!DeleteDataFromApplicationTable(policy_app_id, device_id)) {
+ db_->RollbackTransaction();
+ return false;
+ }
db_->CommitTransaction();
return true;
}
@@ -1406,7 +1410,21 @@ bool ResumptionDataDB::DeleteSavedGlobalProperties(const std::string& mobile_app
return true;
}
-bool ResumptionDataDB::ExecQueryToDeleteData(const std::string& mobile_app_id,
+bool ResumptionDataDB::DeleteDataFromApplicationTable(const std::string& policy_app_id,
+ const std::string& device_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!ExecQueryToDeleteData(
+ policy_app_id, device_id, kDeleteFromApplicationTable)) {
+ LOG4CXX_WARN(logger_,
+ "Incorrect delete data from application table");
+ return false;
+ }
+
+ return true;
+}
+
+bool ResumptionDataDB::ExecQueryToDeleteData(const std::string& policy_app_id,
const std::string& device_id,
const std::string& text_query) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1436,23 +1454,6 @@ bool ResumptionDataDB::ExecUnionQueryToDeleteData(const std::string& mobile_app_
return result;
}
-bool ResumptionDataDB::ExecSelectPrimaryKeyFromApplication(
- const std::string& policy_app_id, const std::string& device_id,
- int64_t& primary_key) const {
- LOG4CXX_AUTO_TRACE(logger_);
- utils::dbms::SQLQuery query(db());
- bool result = query.Prepare(kSelectPrimaryKeyFromApplication);
- if (result) {
- query.Bind(0, mobile_app_id);
- query.Bind(1, device_id);
- result = query.Exec();
- if (result) {
- primary_key = query.GetUInteger(0);
- }
- }
- return result;
-}
-
bool ResumptionDataDB::ExecInsertImage(int64_t& image_primary_key,
const smart_objects::SmartObject& image) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1626,10 +1627,8 @@ bool ResumptionDataDB::ExecInsertDataToArray(
bool ResumptionDataDB::SaveApplicationToDB(
app_mngr::ApplicationConstSharedPtr application,
- const std::string& mobile_app_id,
- const std::string& device_id,
- bool application_exist) {
-
+ const std::string& policy_app_id,
+ const std::string& device_id) {
LOG4CXX_AUTO_TRACE(logger_);
int64_t application_primary_key = 0;
int64_t global_properties_key = 0;
@@ -1639,9 +1638,8 @@ bool ResumptionDataDB::SaveApplicationToDB(
db_->RollbackTransaction();
return false;
}
- if (!InsertApplicationData(application, mobile_app_id, device_id,
- application_primary_key, global_properties_key,
- application_exist)) {
+ if (!InsertApplicationData(application, policy_app_id, device_id,
+ application_primary_key, global_properties_key)) {
LOG4CXX_WARN(logger_, "Incorrect insert application data to DB.");
db_->RollbackTransaction();
return false;
@@ -2230,8 +2228,7 @@ bool ResumptionDataDB::InsertApplicationData(app_mngr::ApplicationConstSharedPtr
const std::string& mobile_app_id,
const std::string& device_id,
int64_t& application_primary_key,
- int64_t global_properties_key,
- bool application_exist) {
+ int64_t global_properties_key) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace app_mngr;
utils::dbms::SQLQuery query(db());
@@ -2244,19 +2241,12 @@ bool ResumptionDataDB::InsertApplicationData(app_mngr::ApplicationConstSharedPtr
const mobile_apis::HMILevel::eType hmi_level = application->hmi_level();
bool is_media_application = application->IsAudioApplication();
- if (application_exist) {
- if (!query.Prepare(kUpdateApplication)){
- LOG4CXX_WARN(logger_, "Problem with verification query "
- "for update table application");
- return false;
- }
- } else {
- if (!query.Prepare(kInsertApplication)){
- LOG4CXX_WARN(logger_, "Problem with verification query "
- "for insert to table application");
- return false;
- }
+ if (!query.Prepare(kInsertApplication)) {
+ LOG4CXX_WARN(logger_, "Problem with verification query "
+ "for insert to table application");
+ return false;
}
+
/* Positions of binding data for "query":
field "connection_key" from table "application" = 0
field "grammarID" from table "application" = 1
@@ -2287,18 +2277,8 @@ bool ResumptionDataDB::InsertApplicationData(app_mngr::ApplicationConstSharedPtr
LOG4CXX_WARN(logger_, "Problem with execution query");
return false;
}
-
- if (application_exist) {
- if (!ExecSelectPrimaryKeyFromApplication(policy_app_id, device_id,
- application_primary_key)) {
- LOG4CXX_INFO(logger_, "Problem with receiving application primary key");
- return false;
- }
- } else {
- application_primary_key = query.LastInsertId();
- }
-
- LOG4CXX_INFO(logger_, "Application data were saved successfully");
+ application_primary_key = query.LastInsertId();
+ LOG4CXX_INFO(logger_, "Data were saved successfully to application table");
return true;
}
diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc
index 41df6403c2..b4400f9cc1 100644
--- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc
+++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc
@@ -574,6 +574,10 @@ const std::string kDeleteTTSChunk =
"FROM `application` "
"WHERE `appID` = ? AND `deviceID` = ?))";
+const std::string kDeleteFromApplicationTable =
+ "DELETE FROM `application` "
+ "WHERE `appID` = ? AND `deviceID` = ?";
+
const std::string kDeleteHelpTimeoutPromptArray =
"DELETE FROM `helpTimeoutPromptArray` "
"WHERE `idglobalProperties` = (SELECT `idglobalProperties` "
@@ -586,11 +590,6 @@ const std::string kDeleteGlobalProperties =
"FROM `application` "
"WHERE `appID` = ? AND `deviceID` = ?)";
-const std::string kSelectPrimaryKeyFromApplication =
- "SELECT `idApplication` "
- "FROM `application` "
- "WHERE `appID` = ? AND `deviceID` = ?";
-
const std::string kSelectCountImage =
"SELECT COUNT (`value`) "
"FROM `image` "
@@ -738,13 +737,6 @@ const std::string kInsertApplication =
"VALUES "
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
-const std::string kUpdateApplication =
- "UPDATE `application` "
- "SET `connection_key` = ?, `grammarID` = ?, `hashID` = ?, "
- "`hmiAppID` = ?, `hmiLevel` = ?, `ign_off_count` = ?, `suspend_count` = ?, "
- "`timeStamp` = ?, `idglobalProperties` = ?, `isMediaApplication` = ? "
- "WHERE `appID` = ? AND `deviceID` = ?;";
-
const std::string kSelectCountFiles =
"SELECT COUNT (`idfile`) "
"FROM `applicationFilesArray` "