summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Byzhynar (GitHub) <AByzhynar@luxoft.com>2018-10-02 18:14:50 +0300
committerJackLivio <jack@livio.io>2018-10-02 11:14:50 -0400
commitb77a003833a8d917cd51578d397e6965fd7e1258 (patch)
tree336c3fb42e34d848bd59d1a961a6e9385f9e308c
parent905fdedf805154f03ab5fd568471665112ac62bf (diff)
downloadsdl_core-b77a003833a8d917cd51578d397e6965fd7e1258.tar.gz
Fix/sdl_does_not_send SDL.OnStatusUpdate(UPDATE_NEEDED) (#2494)
* Add missed RequestSubTypes gathering Added missed request subtypes gathering during app policies section collecting * Fix sending SDL.OnStatusUpdate if existed app registered Added logic of handling case when existed app registered but PTU was unsuccessful from previous IGN cycle NOTE: Fix for EXTERNAL_PROPRIETARY flow * Fix sending SDL.OnStatusUpdate when existed app registered Added logic of handling case when existed app registered but PTU was unsuccessful from previous IGN cycle NOTE: Fix for PROPRIETARY flow * Update update status manager mock classes Updated MockUpdateStatusManager classes for both policy flows: EXTERNAL_PROPRIETARY and PROPRIETARY
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc2
-rw-r--r--src/components/policy/policy_external/include/policy/update_status_manager.h6
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc9
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc3
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc11
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager.h6
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager_interface.h6
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc5
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc8
-rw-r--r--src/components/policy/policy_regular/src/update_status_manager.cc9
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h1
12 files changed, 58 insertions, 10 deletions
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index a52cb52fbe..e99db3bece 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -2521,6 +2521,7 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result,
void MessageHelper::SendOnStatusUpdate(const std::string& status,
ApplicationManager& app_mngr) {
+ LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObjectSPtr message =
std::make_shared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
@@ -2533,6 +2534,7 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status,
(*message)[strings::params][strings::message_type] =
MessageType::kNotification;
+ LOG4CXX_DEBUG(logger_, "Sending new status:" << status);
(*message)[strings::msg_params]["status"] = status;
app_mngr.GetRPCService().ManageHMICommand(message);
diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h
index b4a373d1cf..29adeec084 100644
--- a/src/components/policy/policy_external/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_external/include/policy/update_status_manager.h
@@ -114,6 +114,12 @@ class UpdateStatusManager {
void OnResetRetrySequence();
/**
+ * @brief Update status handler on existed application registering
+ * @param is_update_required Update necessity flag
+ */
+ void OnExistedApplicationAdded(const bool is_update_required);
+
+ /**
* @brief Update status handler on new application registering
*/
void OnNewApplicationAdded(const DeviceConsent consent);
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index e93eea3969..95304f45a6 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1922,13 +1922,15 @@ StatusNotifier PolicyManagerImpl::AddApplication(
DeviceConsent device_consent = GetUserConsentForDevice(device_id);
sync_primitives::AutoLock lock(apps_registration_lock_);
if (IsNewApplication(application_id)) {
+ LOG4CXX_DEBUG(logger_, "Adding new application");
AddNewApplication(application_id, device_consent);
return std::make_shared<CallStatusChange>(update_status_manager_,
device_consent);
- } else {
- PromoteExistedApplication(application_id, device_consent);
- return std::make_shared<utils::CallNothing>();
}
+ LOG4CXX_DEBUG(logger_, "Promote existed application");
+ PromoteExistedApplication(application_id, device_consent);
+ update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired());
+ return std::make_shared<utils::CallNothing>();
}
void PolicyManagerImpl::RemoveAppConsentForGroup(
@@ -2042,7 +2044,6 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name,
const bool ret = cache_->Init(file_name, settings);
if (ret) {
RefreshRetrySequence();
- update_status_manager_.OnPolicyInit(cache_->UpdateRequired());
}
return ret;
}
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index f26264ddf9..248372beff 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -897,6 +897,9 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
if (!GatherRequestType(app_id, &*params.RequestType)) {
return false;
}
+ if (!GatherRequestSubType(app_id, &*params.RequestSubType)) {
+ return false;
+ }
GatherPreconsentedGroup(app_id, &*params.preconsented_groups);
(*policies).apps[app_id] = params;
}
diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc
index e738554799..579ad8cb56 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -118,12 +118,23 @@ void UpdateStatusManager::OnResetRetrySequence() {
ProcessEvent(kOnResetRetrySequence);
}
+void UpdateStatusManager::OnExistedApplicationAdded(
+ const bool is_update_required) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (is_update_required) {
+ current_status_.reset(new UpToDateStatus());
+ ProcessEvent(kScheduleUpdate);
+ }
+}
+
void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) {
LOG4CXX_AUTO_TRACE(logger_);
if (kDeviceAllowed != consent) {
+ LOG4CXX_DEBUG(logger_, "Application registered from non-consented device");
app_registered_from_non_consented_device_ = true;
return;
}
+ LOG4CXX_DEBUG(logger_, "Application registered from consented device");
app_registered_from_non_consented_device_ = false;
ProcessEvent(kOnNewAppRegistered);
}
diff --git a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
index a1c808d23a..104b37e379 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_update_status_manager.h
@@ -33,7 +33,6 @@
#define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_TEST_INCLUDE_POLICY_MOCK_UPDATE_STATUS_MANAGER_H_
#include "gmock/gmock.h"
-
#include "policy/update_status_manager.h"
namespace test {
@@ -49,6 +48,7 @@ class MockUpdateStatusManager : public ::policy::UpdateStatusManager {
MOCK_METHOD0(OnWrongUpdateReceived, void());
MOCK_METHOD1(OnResetDefaultPT, void(bool is_update_required));
MOCK_METHOD0(OnResetRetrySequence, void());
+ MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required));
MOCK_METHOD1(OnNewApplicationAdded, void(const DeviceConsent));
MOCK_METHOD1(OnPolicyInit, void(bool is_update_required));
MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus());
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h
index 52d5b92b8a..5cd20e57e3 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h
@@ -118,6 +118,12 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
void OnNewApplicationAdded(const DeviceConsent consent);
/**
+ * @brief Update status handler on existed application registering
+ * @param is_update_required Update necessity flag
+ */
+ void OnExistedApplicationAdded(const bool is_update_required);
+
+ /**
* @brief Update status handler for policy initialization
* @param is_update_required Update necessity flag
*/
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
index b9da90f929..b4999b569c 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h
@@ -105,6 +105,12 @@ class UpdateStatusManagerInterface {
virtual void OnNewApplicationAdded(DeviceConsent device_consent) = 0;
/**
+ * @brief Update status handler on existed application registering
+ * @param is_update_required Update necessity flag
+ */
+ virtual void OnExistedApplicationAdded(const bool is_update_required) = 0;
+
+ /**
* @brief Update status handler for policy initialization
* @param is_update_required Update necessity flag
*/
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 9accabf59b..2f47853a2d 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -1453,10 +1453,13 @@ bool CacheManager::Init(const std::string& file_name,
void CacheManager::FillDeviceSpecificData() {}
bool CacheManager::LoadFromBackup() {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(cache_lock_);
pt_ = backup_->GenerateSnapshot();
update_required = backup_->UpdateRequired();
-
+ LOG4CXX_DEBUG(logger_,
+ "Update required flag from backup: " << std::boolalpha
+ << update_required);
FillDeviceSpecificData();
return true;
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index 084ddd2701..4985035629 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -1211,10 +1211,10 @@ StatusNotifier PolicyManagerImpl::AddApplication(
AddNewApplication(application_id, device_consent);
return std::make_shared<CallStatusChange>(update_status_manager_,
device_consent);
- } else {
- PromoteExistedApplication(application_id, device_consent);
- return std::make_shared<utils::CallNothing>();
}
+ PromoteExistedApplication(application_id, device_consent);
+ update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired());
+ return std::make_shared<utils::CallNothing>();
}
void PolicyManagerImpl::RemoveAppConsentForGroup(
@@ -1237,6 +1237,7 @@ void PolicyManagerImpl::AddNewApplication(const std::string& application_id,
void PolicyManagerImpl::PromoteExistedApplication(
const std::string& application_id, DeviceConsent device_consent) {
+ LOG4CXX_AUTO_TRACE(logger_);
// If device consent changed to allowed during application being
// disconnected, app permissions should be changed also
if (kDeviceAllowed == device_consent &&
@@ -1289,7 +1290,6 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name,
const bool ret = cache_->Init(file_name, settings);
if (ret) {
RefreshRetrySequence();
- update_status_manager_.OnPolicyInit(cache_->UpdateRequired());
const std::string certificate_data = cache_->GetCertificate();
if (!certificate_data.empty()) {
listener_->OnCertificateUpdated(certificate_data);
diff --git a/src/components/policy/policy_regular/src/update_status_manager.cc b/src/components/policy/policy_regular/src/update_status_manager.cc
index 66d21dea54..97a1573176 100644
--- a/src/components/policy/policy_regular/src/update_status_manager.cc
+++ b/src/components/policy/policy_regular/src/update_status_manager.cc
@@ -100,6 +100,15 @@ void UpdateStatusManager::OnResetRetrySequence() {
ProcessEvent(kOnResetRetrySequence);
}
+void UpdateStatusManager::OnExistedApplicationAdded(
+ const bool is_update_required) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (is_update_required) {
+ current_status_.reset(new UpToDateStatus());
+ ProcessEvent(kScheduleUpdate);
+ }
+}
+
void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) {
LOG4CXX_AUTO_TRACE(logger_);
if (kDeviceAllowed != consent) {
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
index 924284c8cc..8dcaabd3cb 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
+++ b/src/components/policy/policy_regular/test/include/policy/mock_update_status_manager.h
@@ -47,6 +47,7 @@ class MockUpdateStatusManager : public UpdateStatusManager {
MOCK_METHOD0(OnWrongUpdateReceived, void());
MOCK_METHOD1(OnResetDefaultPT, void(bool is_update_required));
MOCK_METHOD0(OnResetRetrySequence, void());
+ MOCK_METHOD1(OnExistedApplicationAdded, void(const bool is_update_required));
MOCK_METHOD0(OnNewApplicationAdded, void());
MOCK_METHOD1(OnPolicyInit, void(bool is_update_required));
MOCK_METHOD0(GetUpdateStatus, PolicyTableStatus());