summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan <akutsan@luxoft.com>2020-01-28 00:10:37 +0300
committerAndriy Byzhynar (GitHub) <AByzhynar@luxoft.com>2020-02-05 22:44:27 +0200
commit210e0eb230057d4cde9afab637a1304e06fd606a (patch)
treeb3b68b4465130dd7d52b7ddd7a489680b75cda71
parent20b121130939ad6f00fe3535ef60e60b132cb54e (diff)
downloadsdl_core-210e0eb230057d4cde9afab637a1304e06fd606a.tar.gz
Policy changes for Web Engine support
Issue : #3197
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h49
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc239
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc416
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h92
-rw-r--r--src/components/include/policy/policy_external/policy/policy_listener.h8
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h61
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_listener.h7
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h63
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h22
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h10
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_listener.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h14
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h10
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h14
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h34
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h36
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h4
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h46
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h70
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc60
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc78
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc59
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc17
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test_base.cc4
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h31
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h36
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h4
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h50
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h72
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc60
-rw-r--r--src/components/policy/policy_regular/src/policy_helper.cc78
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc60
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc6
34 files changed, 1371 insertions, 443 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index a03288f9a9..b517a7d82c 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -427,6 +427,8 @@ class PolicyHandler : public PolicyHandlerInterface,
custom_str::CustomString GetAppName(
const std::string& policy_app_id) OVERRIDE;
+ std::vector<std::string> GetApplicationPolicyIDs() const OVERRIDE;
+
/**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
@@ -436,6 +438,13 @@ class PolicyHandler : public PolicyHandlerInterface,
std::vector<std::string>& enabled_apps) const OVERRIDE;
/**
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ /**
* @brief Checks if a given application is an enabled cloud application
* @param policy_app_id Unique application id
* @return true, if the application is an enabled cloud application,
@@ -444,33 +453,24 @@ class PolicyHandler : public PolicyHandlerInterface,
const bool CheckCloudAppEnabled(
const std::string& policy_app_id) const OVERRIDE;
- /**
- * @brief Get cloud app policy information, all fields that aren't set for a
- * given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- bool GetCloudAppParameters(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ bool GetAppProperties(
+ const std::string& policy_app_id,
+ policy::AppProperties& out_app_properties) const OVERRIDE;
void OnAuthTokenUpdated(const std::string& policy_app_id,
const std::string& auth_token) OVERRIDE;
+ void OnSetAppProperties(
+ const smart_objects::SmartObject& properties) OVERRIDE;
+
+ AppPropertiesState GetAppPropertiesStatus(
+ const smart_objects::SmartObject& properties,
+ const std::string& app_id) const OVERRIDE;
+
+ bool IsNewApplication(const std::string& policy_app_id) const OVERRIDE;
+
+ void OnLocalAppAdded() OVERRIDE;
+
/**
* @brief Callback for when a SetCloudAppProperties message is received
* from a mobile app
@@ -533,6 +533,9 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::string& device_id,
const std::string& policy_app_id) const OVERRIDE;
+ void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const OVERRIDE;
+
virtual void OnPTExchangeNeeded() OVERRIDE;
virtual void GetAvailableApps(std::queue<std::string>& apps) OVERRIDE;
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 64e15d7134..bad26698c6 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -548,6 +548,15 @@ void PolicyHandler::SendOnAppPermissionsChanged(
app->app_id(), permissions, application_manager_);
}
+void PolicyHandler::SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto notification =
+ MessageHelper::CreateOnAppPropertiesChangeNotification(
+ policy_app_id, application_manager_);
+ application_manager_.GetRPCService().ManageHMICommand(notification);
+}
+
void PolicyHandler::OnPTExchangeNeeded() {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
@@ -1984,47 +1993,205 @@ bool PolicyHandler::CheckSystemAction(
return false;
}
+std::vector<std::string> PolicyHandler::GetApplicationPolicyIDs() const {
+ POLICY_LIB_CHECK(std::vector<std::string>());
+ const auto all_policy_ids = policy_manager_->GetApplicationPolicyIDs();
+ std::vector<std::string> policy_app_ids;
+
+ std::copy_if(
+ all_policy_ids.begin(),
+ all_policy_ids.end(),
+ std::back_inserter(policy_app_ids),
+ [](std::string id) {
+ return helpers::Compare<std::string, helpers::NEQ, helpers::ALL>(
+ id, kDefaultId, kPreDataConsentId, kDeviceId);
+ });
+
+ return policy_app_ids;
+}
+
void PolicyHandler::GetEnabledCloudApps(
std::vector<std::string>& enabled_apps) const {
POLICY_LIB_CHECK_VOID();
policy_manager_->GetEnabledCloudApps(enabled_apps);
}
-bool PolicyHandler::GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const {
+bool PolicyHandler::GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const {
POLICY_LIB_CHECK(false);
- return policy_manager_->GetCloudAppParameters(policy_app_id,
- enabled,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+ return policy_manager_->GetAppProperties(policy_app_id, out_app_properties);
+}
+
+std::vector<std::string> PolicyHandler::GetEnabledLocalApps() const {
+ POLICY_LIB_CHECK(std::vector<std::string>());
+ return policy_manager_->GetEnabledLocalApps();
}
const bool PolicyHandler::CheckCloudAppEnabled(
const std::string& policy_app_id) const {
POLICY_LIB_CHECK(false);
- bool enabled = false;
- std::string endpoint;
- std::string auth_token;
- std::string certificate;
- std::string cloud_transport_type;
- std::string hybrid_app_preference;
- policy_manager_->GetCloudAppParameters(policy_app_id,
- enabled,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
- return enabled;
+ AppProperties out_app_properties;
+ policy_manager_->GetAppProperties(policy_app_id, out_app_properties);
+ return out_app_properties.enabled;
+}
+
+PolicyHandler::AppPropertiesState PolicyHandler::GetAppPropertiesStatus(
+ const smart_objects::SmartObject& properties,
+ const std::string& app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ AppProperties app_properties;
+ policy_manager_->GetAppProperties(app_id, app_properties);
+
+ policy::StringArray nicknames;
+ policy::StringArray app_hmi_types;
+ policy_manager_->GetInitialAppData(app_id, &nicknames, &app_hmi_types);
+
+ if (properties.keyExists(strings::enabled) &&
+ app_properties.enabled != properties[strings::enabled].asBool()) {
+ LOG4CXX_DEBUG(logger_,
+ "\"enabled\" was changed from: "
+ << app_properties.enabled
+ << " to: " << properties[strings::enabled].asBool());
+ return AppPropertiesState::ENABLED_FLAG_SWITCH;
+ }
+ if (properties.keyExists(strings::auth_token) &&
+ app_properties.auth_token != properties[strings::auth_token].asString()) {
+ LOG4CXX_DEBUG(logger_,
+ "\"auth_token\" was changed from: "
+ << app_properties.auth_token
+ << " to: " << properties[strings::auth_token].asString());
+ return AppPropertiesState::AUTH_TOKEN_CHANGED;
+ }
+ if (properties.keyExists(strings::transport_type) &&
+ app_properties.transport_type !=
+ properties[strings::transport_type].asString()) {
+ LOG4CXX_DEBUG(logger_,
+ "\"transport_type\" was changed from: "
+ << app_properties.transport_type << " to: "
+ << properties[strings::transport_type].asString());
+ return AppPropertiesState::TRANSPORT_TYPE_CHANGED;
+ }
+
+ if (properties.keyExists(strings::cloud_transport_type) &&
+ app_properties.transport_type !=
+ properties[strings::cloud_transport_type].asString()) {
+ LOG4CXX_DEBUG(logger_,
+ "\"transport_type\" was changed from: "
+ << app_properties.transport_type << " to: "
+ << properties[strings::cloud_transport_type].asString());
+ return AppPropertiesState::TRANSPORT_TYPE_CHANGED;
+ }
+
+ if (properties.keyExists(strings::endpoint) &&
+ app_properties.endpoint != properties[strings::endpoint].asString()) {
+ LOG4CXX_DEBUG(logger_,
+ "\"endpoint\" was changed from: "
+ << app_properties.endpoint
+ << " to: " << properties[strings::endpoint].asString());
+ return AppPropertiesState::ENDPOINT_CHANGED;
+ }
+ if (properties.keyExists(strings::nicknames)) {
+ const smart_objects::SmartArray* nicknames_array =
+ properties[strings::nicknames].asArray();
+
+ if (nicknames_array->empty() && !nicknames.empty()) {
+ return AppPropertiesState::NICKNAMES_CHANGED;
+ }
+
+ smart_objects::SmartArray::const_iterator it_begin =
+ nicknames_array->begin();
+ smart_objects::SmartArray::const_iterator it_end = nicknames_array->end();
+ for (; it_begin != it_end; ++it_begin) {
+ const auto result =
+ std::find(nicknames.begin(), nicknames.end(), (*it_begin).asString());
+ if (nicknames.end() == result) {
+ LOG4CXX_DEBUG(logger_,
+ "\"nicknames\" were changed, new value: "
+ << (*it_begin).asString());
+ return AppPropertiesState::NICKNAMES_CHANGED;
+ }
+ }
+ }
+ if (properties.keyExists(strings::hybrid_app_preference)) {
+ auto value = static_cast<mobile_apis::HybridAppPreference::eType>(
+ properties[strings::hybrid_app_preference].asUInt());
+ std::string hybrid_app_preference_str;
+ smart_objects::EnumConversionHelper<
+ mobile_apis::HybridAppPreference::eType>::
+ EnumToString(value, &hybrid_app_preference_str);
+ if (app_properties.hybrid_app_preference != hybrid_app_preference_str) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "\"hybrid_app_preference\" was changed from: "
+ << app_properties.hybrid_app_preference << " to: "
+ << properties[strings::hybrid_app_preference].asString());
+ return AppPropertiesState::HYBRYD_APP_PROPERTIES_CHANGED;
+ }
+ }
+ return AppPropertiesState::NO_CHANGES;
+}
+
+bool PolicyHandler::IsNewApplication(const std::string& policy_app_id) const {
+ return policy_manager_->IsNewApplication(policy_app_id);
+}
+
+void PolicyHandler::OnSetAppProperties(
+ const smart_objects::SmartObject& properties) {
+ POLICY_LIB_CHECK_VOID();
+
+ const auto policy_app_id(properties[strings::policy_app_id].asString());
+ policy_manager_->InitCloudApp(policy_app_id);
+
+ bool auth_token_update = false;
+ if (properties.keyExists(strings::enabled)) {
+ const bool enabled = properties[strings::enabled].asBool();
+ policy_manager_->SetCloudAppEnabled(policy_app_id, enabled);
+ }
+ if (properties.keyExists(strings::auth_token)) {
+ const std::string auth_token = properties[strings::auth_token].asString();
+ policy_manager_->SetAppAuthToken(policy_app_id, auth_token);
+ auth_token_update = true;
+ }
+ if (properties.keyExists(strings::transport_type)) {
+ policy_manager_->SetAppCloudTransportType(
+ policy_app_id, properties[strings::transport_type].asString());
+ }
+ if (properties.keyExists(strings::endpoint)) {
+ policy_manager_->SetAppEndpoint(policy_app_id,
+ properties[strings::endpoint].asString());
+ }
+ if (properties.keyExists(strings::nicknames)) {
+ StringArray nicknames;
+ const smart_objects::SmartObject& nicknames_array =
+ properties[strings::nicknames];
+ for (size_t i = 0; i < nicknames_array.length(); ++i) {
+ nicknames.push_back(nicknames_array[i].asString());
+ }
+ policy_manager_->SetAppNicknames(policy_app_id, nicknames);
+ }
+ if (properties.keyExists(strings::hybrid_app_preference)) {
+ std::string hybrid_app_preference;
+
+ auto value = static_cast<mobile_apis::HybridAppPreference::eType>(
+ properties[strings::hybrid_app_preference].asUInt());
+ smart_objects::EnumConversionHelper<
+ mobile_apis::HybridAppPreference::eType>::
+ EnumToString(value, &hybrid_app_preference);
+ policy_manager_->SetHybridAppPreference(policy_app_id,
+ hybrid_app_preference);
+ }
+
+ if (auth_token_update) {
+ AppProperties app_properties;
+ if (policy_manager_->GetAppProperties(policy_app_id, app_properties)) {
+ OnAuthTokenUpdated(policy_app_id, app_properties.auth_token);
+ }
+ }
+}
+
+void PolicyHandler::OnLocalAppAdded() {
+ policy_manager_->OnLocalAppAdded();
}
void PolicyHandler::OnSetCloudAppProperties(
@@ -2087,9 +2254,8 @@ void PolicyHandler::OnSetCloudAppProperties(
if (properties.keyExists(strings::hybrid_app_preference)) {
std::string hybrid_app_preference;
- mobile_apis::HybridAppPreference::eType value =
- static_cast<mobile_apis::HybridAppPreference::eType>(
- properties[strings::hybrid_app_preference].asUInt());
+ auto value = static_cast<mobile_apis::HybridAppPreference::eType>(
+ properties[strings::hybrid_app_preference].asUInt());
smart_objects::EnumConversionHelper<
mobile_apis::HybridAppPreference::eType>::
EnumToString(value, &hybrid_app_preference);
@@ -2098,13 +2264,10 @@ void PolicyHandler::OnSetCloudAppProperties(
}
if (auth_token_update) {
- bool enabled;
- std::string end, cert, ctt, hap;
- std::string auth_token;
+ AppProperties app_properties;
- policy_manager_->GetCloudAppParameters(
- policy_app_id, enabled, end, cert, auth_token, ctt, hap);
- OnAuthTokenUpdated(policy_app_id, auth_token);
+ policy_manager_->GetAppProperties(policy_app_id, app_properties);
+ OnAuthTokenUpdated(policy_app_id, app_properties.auth_token);
}
}
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index 961f338ca4..3f37cec657 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -72,6 +72,8 @@
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol_handler/mock_session_observer.h"
+#include "smart_objects/enum_schema_item.h"
+
namespace test {
namespace components {
namespace policy_handler_test {
@@ -272,6 +274,19 @@ class PolicyHandlerTest : public ::testing::Test {
hmi_types.push_back(hmi_type);
return hmi_types;
}
+
+ void SetExpectationsAndCheckCloudAppPropertiesStatus(
+ const policy::AppProperties& app_properties,
+ const smart_objects::SmartObject& properties,
+ const policy::PolicyHandlerInterface::AppPropertiesState&
+ app_properties_state) {
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(DoAll(SetArgReferee<1>(app_properties), Return(true)));
+ EXPECT_CALL(*mock_policy_manager_, GetInitialAppData(kPolicyAppId_, _, _));
+ EXPECT_EQ(
+ app_properties_state,
+ policy_handler_.GetAppPropertiesStatus(properties, kPolicyAppId_));
+ }
};
namespace {
@@ -2687,6 +2702,12 @@ TEST_F(PolicyHandlerTest, OnSetCloudAppProperties_AllProperties_SUCCESS) {
mobile_apis::HybridAppPreference::CLOUD;
std::string hybrid_app_preference_str = "CLOUD";
std::string endpoint = "anEndpoint";
+ const policy::AppProperties app_properties(endpoint,
+ " ",
+ enabled,
+ auth_token,
+ cloud_transport_type,
+ hybrid_app_preference_str);
StringArray nicknames_vec;
nicknames_vec.push_back(app_name);
@@ -2720,9 +2741,8 @@ TEST_F(PolicyHandlerTest, OnSetCloudAppProperties_AllProperties_SUCCESS) {
EXPECT_CALL(*mock_policy_manager_,
SetHybridAppPreference(kPolicyAppId_, hybrid_app_preference_str));
EXPECT_CALL(*mock_policy_manager_, SetAppEndpoint(kPolicyAppId_, endpoint));
- EXPECT_CALL(*mock_policy_manager_,
- GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgReferee<4>(auth_token), Return(true)));
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(DoAll(SetArgReferee<1>(app_properties), Return(true)));
EXPECT_CALL(app_manager_, RefreshCloudAppInformation());
EXPECT_CALL(policy_handler_observer,
OnAuthTokenUpdated(kPolicyAppId_, auth_token));
@@ -2740,38 +2760,370 @@ TEST_F(PolicyHandlerTest, GetCloudAppParameters_AllProperties_SUCCESS) {
std::string hybrid_app_preference_str = "CLOUD";
std::string endpoint = "anEndpoint";
+ const policy::AppProperties app_properties(endpoint,
+ certificate,
+ enabled,
+ auth_token,
+ cloud_transport_type,
+ hybrid_app_preference_str);
+
application_manager_test::MockPolicyHandlerObserver policy_handler_observer;
policy_handler_.add_listener(&policy_handler_observer);
- EXPECT_CALL(*mock_policy_manager_,
- GetCloudAppParameters(kPolicyAppId_, _, _, _, _, _, _))
- .WillOnce(DoAll(SetArgReferee<1>(enabled),
- SetArgReferee<2>(endpoint),
- SetArgReferee<3>(certificate),
- SetArgReferee<4>(auth_token),
- SetArgReferee<5>(cloud_transport_type),
- SetArgReferee<6>(hybrid_app_preference_str),
- Return(true)));
-
- bool enabled_out;
- std::string endpoint_out;
- std::string cert_out;
- std::string auth_token_out;
- std::string ctt_out;
- std::string hap_out;
- EXPECT_TRUE(policy_handler_.GetCloudAppParameters(kPolicyAppId_,
- enabled_out,
- endpoint_out,
- cert_out,
- auth_token_out,
- ctt_out,
- hap_out));
- EXPECT_EQ(enabled, enabled_out);
- EXPECT_EQ(endpoint, endpoint_out);
- EXPECT_EQ(certificate, cert_out);
- EXPECT_EQ(auth_token, auth_token_out);
- EXPECT_EQ(cloud_transport_type, ctt_out);
- EXPECT_EQ(hybrid_app_preference_str, hap_out);
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(DoAll(SetArgReferee<1>(app_properties), Return(true)));
+
+ policy::AppProperties out_app_properties;
+ EXPECT_TRUE(
+ policy_handler_.GetAppProperties(kPolicyAppId_, out_app_properties));
+ EXPECT_EQ(app_properties.enabled, out_app_properties.enabled);
+ EXPECT_EQ(app_properties.endpoint, out_app_properties.endpoint);
+ EXPECT_EQ(app_properties.certificate, out_app_properties.certificate);
+ EXPECT_EQ(app_properties.auth_token, out_app_properties.auth_token);
+ EXPECT_EQ(app_properties.transport_type, out_app_properties.transport_type);
+ EXPECT_EQ(app_properties.hybrid_app_preference,
+ out_app_properties.hybrid_app_preference);
+}
+
+TEST_F(PolicyHandlerTest, SendOnAppPropertiesChangeNotification_SUCCESS) {
+ using namespace smart_objects;
+ auto notification = std::make_shared<SmartObject>(SmartType_Null);
+
+ ON_CALL(app_manager_, GetRPCService())
+ .WillByDefault(ReturnRef(mock_rpc_service_));
+
+ EXPECT_CALL(mock_message_helper_,
+ CreateOnAppPropertiesChangeNotification(kPolicyAppId_, _))
+ .WillOnce(Return(notification));
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(notification, commands::Command::SOURCE_HMI));
+
+ policy_handler_.SendOnAppPropertiesChangeNotification(kPolicyAppId_);
+}
+
+TEST_F(PolicyHandlerTest, GetApplicationPolicyIDs_GetEmptyIDsVector_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ std::vector<std::string> app_ids_vector;
+ ON_CALL(*mock_policy_manager_, GetApplicationPolicyIDs())
+ .WillByDefault(Return(app_ids_vector));
+
+ EXPECT_CALL(*mock_policy_manager_, GetApplicationPolicyIDs());
+ EXPECT_EQ(app_ids_vector, policy_handler_.GetApplicationPolicyIDs());
+}
+
+TEST_F(PolicyHandlerTest,
+ GetApplicationPolicyIDs_GetIDFromAppIDsVectorWithWrongIDs_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ std::vector<std::string> app_ids_vector = {policy::kDefaultId,
+ policy::kPreDataConsentId,
+ policy::kDeviceId,
+ kPolicyAppId_};
+ ON_CALL(*mock_policy_manager_, GetApplicationPolicyIDs())
+ .WillByDefault(Return(app_ids_vector));
+
+ EXPECT_CALL(*mock_policy_manager_, GetApplicationPolicyIDs());
+
+ auto policy_ids = policy_handler_.GetApplicationPolicyIDs();
+ EXPECT_NE(app_ids_vector, policy_ids);
+ EXPECT_EQ(1u, policy_ids.size());
+ EXPECT_EQ(kPolicyAppId_, policy_ids[0]);
+}
+
+TEST_F(PolicyHandlerTest, CheckCloudAppEnabled_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ policy::AppProperties out_app_properties;
+ out_app_properties.enabled = true;
+
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(DoAll(SetArgReferee<1>(out_app_properties), Return(true)));
+ EXPECT_TRUE(policy_handler_.CheckCloudAppEnabled(kPolicyAppId_));
+}
+
+TEST_F(PolicyHandlerTest, CheckCloudAppNotEnabled_SUCCESS) {
+ ChangePolicyManagerToMock();
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _));
+ EXPECT_FALSE(policy_handler_.CheckCloudAppEnabled(kPolicyAppId_));
+}
+
+TEST_F(PolicyHandlerTest, OnLocalAppAdded_SUCCESS) {
+ ChangePolicyManagerToMock();
+ EXPECT_CALL(*mock_policy_manager_, OnLocalAppAdded());
+ policy_handler_.OnLocalAppAdded();
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_NoPropertiesChanged) {
+ ChangePolicyManagerToMock();
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(Return(false));
+ EXPECT_CALL(*mock_policy_manager_, GetInitialAppData(kPolicyAppId_, _, _))
+ .WillOnce(Return(false));
+ EXPECT_EQ(policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES,
+ policy_handler_.GetAppPropertiesStatus(properties, kPolicyAppId_));
+}
+
+TEST_F(PolicyHandlerTest,
+ GetAppPropertiesStatus_EnableFlagSwitchChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ policy::AppProperties app_properties;
+ app_properties.enabled = false;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::enabled] = !app_properties.enabled;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::ENABLED_FLAG_SWITCH);
+}
+
+TEST_F(PolicyHandlerTest,
+ GetAppPropertiesStatus_EnableFlagSwitchNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ policy::AppProperties app_properties;
+ app_properties.enabled = false;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::enabled] = app_properties.enabled;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_AuthTokenChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentToken = "kCurrentToken";
+ const std::string kNewToken = "kNewToken";
+
+ policy::AppProperties app_properties;
+ app_properties.auth_token = kCurrentToken;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::auth_token] = kNewToken;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::AUTH_TOKEN_CHANGED);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_AuthTokenNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentToken = "kCurrentToken";
+
+ policy::AppProperties app_properties;
+ app_properties.auth_token = kCurrentToken;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::auth_token] = app_properties.auth_token;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_TransportTypeChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentTransportType = "kCurrentTransportType";
+ const std::string kNewTransportType = "kNewTransportType";
+
+ policy::AppProperties app_properties;
+ app_properties.transport_type = kCurrentTransportType;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::cloud_transport_type] = kNewTransportType;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::
+ TRANSPORT_TYPE_CHANGED);
+}
+
+TEST_F(PolicyHandlerTest,
+ GetAppPropertiesStatus_TransportTypeNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentTransportType = "kCurrentTransportType";
+
+ policy::AppProperties app_properties;
+ app_properties.transport_type = kCurrentTransportType;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::cloud_transport_type] = app_properties.transport_type;
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_EndPointChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentEndPoint = "kCurrentEndPoint";
+ const std::string kNewEndPoint = "kNewEndPoint";
+
+ policy::AppProperties app_properties;
+ app_properties.endpoint = kCurrentEndPoint;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::endpoint] = kNewEndPoint;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::ENDPOINT_CHANGED);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_EndPointNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kCurrentEndPoint = "kCurrentEndPoint";
+
+ policy::AppProperties app_properties;
+ app_properties.endpoint = kCurrentEndPoint;
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::endpoint] = app_properties.endpoint;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_NicknameChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kFakeNickname = "fake_nickname";
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::nicknames] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ properties[strings::nicknames].asArray()->push_back(
+ smart_objects::SmartObject(kFakeNickname));
+
+ std::shared_ptr<policy::StringArray> nicknames =
+ std::make_shared<policy::StringArray>();
+
+ const auto expected_app_properties_state =
+ policy::PolicyHandlerInterface::AppPropertiesState::NICKNAMES_CHANGED;
+
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(Return(true));
+ EXPECT_CALL(*mock_policy_manager_, GetInitialAppData(kPolicyAppId_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(*nicknames), Return(true)));
+ EXPECT_EQ(expected_app_properties_state,
+ policy_handler_.GetAppPropertiesStatus(properties, kPolicyAppId_));
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_NicknameNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const std::string kFakeNickname = "fake_nickname";
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::nicknames] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ properties[strings::nicknames].asArray()->push_back(
+ smart_objects::SmartObject(kFakeNickname));
+
+ std::shared_ptr<policy::StringArray> nicknames =
+ std::make_shared<policy::StringArray>();
+ nicknames->push_back(kFakeNickname);
+
+ const auto expected_app_properties_state =
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES;
+
+ EXPECT_CALL(*mock_policy_manager_, GetAppProperties(kPolicyAppId_, _))
+ .WillOnce(Return(true));
+ EXPECT_CALL(*mock_policy_manager_, GetInitialAppData(kPolicyAppId_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(*nicknames), Return(true)));
+ EXPECT_EQ(expected_app_properties_state,
+ policy_handler_.GetAppPropertiesStatus(properties, kPolicyAppId_));
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_HybridAppChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const auto kCurrentHybridAppProperties =
+ mobile_apis::HybridAppPreference::eType::CLOUD;
+ const auto kNewHybridAppProperties =
+ mobile_apis::HybridAppPreference::eType::MOBILE;
+
+ policy::AppProperties app_properties;
+ smart_objects::EnumConversionHelper<mobile_apis::HybridAppPreference::eType>::
+ EnumToString(kCurrentHybridAppProperties,
+ &app_properties.hybrid_app_preference);
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::hybrid_app_preference] = kNewHybridAppProperties;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::
+ HYBRYD_APP_PROPERTIES_CHANGED);
+}
+
+TEST_F(PolicyHandlerTest, GetAppPropertiesStatus_HybridAppNotChanged_SUCCESS) {
+ ChangePolicyManagerToMock();
+
+ const auto kCurrentHybridAppProperties =
+ mobile_apis::HybridAppPreference::eType::CLOUD;
+
+ policy::AppProperties app_properties;
+ smart_objects::EnumConversionHelper<mobile_apis::HybridAppPreference::eType>::
+ EnumToString(kCurrentHybridAppProperties,
+ &app_properties.hybrid_app_preference);
+
+ smart_objects::SmartObject properties;
+ properties[strings::app_id] = kPolicyAppId_;
+ properties[strings::hybrid_app_preference] = kCurrentHybridAppProperties;
+
+ SetExpectationsAndCheckCloudAppPropertiesStatus(
+ app_properties,
+ properties,
+ policy::PolicyHandlerInterface::AppPropertiesState::NO_CHANGES);
+}
+
+TEST_F(PolicyHandlerTest, GetEnabledLocalApps_SUCCESS) {
+ ChangePolicyManagerToMock();
+ std::vector<std::string> enabled_local_apps;
+
+ EXPECT_CALL(*mock_policy_manager_, GetEnabledLocalApps())
+ .WillOnce(Return(enabled_local_apps));
+ EXPECT_EQ(enabled_local_apps, policy_handler_.GetEnabledLocalApps());
+
+ enabled_local_apps.push_back("local_app");
+ EXPECT_CALL(*mock_policy_manager_, GetEnabledLocalApps())
+ .WillOnce(Return(enabled_local_apps));
+ EXPECT_EQ(enabled_local_apps, policy_handler_.GetEnabledLocalApps());
}
} // namespace policy_handler_test
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index 3af3b770aa..1e9f4d51b3 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -159,6 +159,13 @@ class PolicyHandlerInterface : public VehicleDataItemProvider {
const std::string& policy_app_id) const = 0;
/**
+ * @brief Send OnAppPropertiesChangeNotification to the HMI
+ * @param policy_app_id policy app id
+ */
+ virtual void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief CheckSystemAction allows to check whether certain system
* action is enabled.
*
@@ -478,6 +485,13 @@ class PolicyHandlerInterface : public VehicleDataItemProvider {
const std::string& policy_app_id) const = 0;
/**
+ * @brief Get a list of policy app ids
+ * @return apps list filled with the policy app ids of each
+ * application
+ */
+ virtual std::vector<std::string> GetApplicationPolicyIDs() const = 0;
+
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
@@ -495,29 +509,63 @@ class PolicyHandlerInterface : public VehicleDataItemProvider {
const std::string& policy_app_id) const = 0;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
+
+ /**
+ * @brief Get app policy information, all fields that aren't set for a
* given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const = 0;
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
+
+ /**
+ * @brief Callback for when a BC.SetAppProperties message is
+ * received from the HMI
+ * @param message The BC.SetAppProperties message
+ */
+ virtual void OnSetAppProperties(
+ const smart_objects::SmartObject& properties) = 0;
+
+ enum class AppPropertiesState {
+ NO_CHANGES,
+ ENABLED_FLAG_SWITCH,
+ AUTH_TOKEN_CHANGED,
+ TRANSPORT_TYPE_CHANGED,
+ ENDPOINT_CHANGED,
+ NICKNAMES_CHANGED,
+ HYBRYD_APP_PROPERTIES_CHANGED
+ };
+
+ /**
+ * @brief Checks if the application properties were changed. Compares the
+ * properties received from the HMI with the stored properties in the database
+ * @param properties new app properties
+ * @param app_id application id
+ * @return AppPropertiesState enum value that indicates which property has
+ * been changed
+ */
+ virtual AppPropertiesState GetAppPropertiesStatus(
+ const smart_objects::SmartObject& properties,
+ const std::string& app_id) const = 0;
+
+ /**
+ * @brief Check if certain application already in policy db.
+ * @param policy application id.
+ * @return true if application presents false otherwise.
+ */
+ virtual bool IsNewApplication(const std::string& application_id) const = 0;
+
+ /**
+ * @brief OnLocalAppAdded triggers PTU
+ */
+ virtual void OnLocalAppAdded() = 0;
/**
* @brief Callback for when a SetCloudAppProperties message is received from a
diff --git a/src/components/include/policy/policy_external/policy/policy_listener.h b/src/components/include/policy/policy_external/policy/policy_listener.h
index 8220d05584..c613fdd091 100644
--- a/src/components/include/policy/policy_external/policy/policy_listener.h
+++ b/src/components/include/policy/policy_external/policy/policy_listener.h
@@ -110,6 +110,14 @@ class PolicyListener {
const std::string& policy_app_id) const = 0;
/**
+ * @brief Send OnAppPropertiesChangeNotification to the HMI
+ * @param policy_app_id policy app id
+ */
+
+ virtual void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief GetAvailableApps allows to obtain list of registered applications.
*/
virtual void GetAvailableApps(std::queue<std::string>&) = 0;
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 22721841aa..935233e92d 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -602,6 +602,13 @@ class PolicyManager : public usage_statistics::StatisticsManager,
virtual Json::Value GetPolicyTableData() const = 0;
/**
+ * @brief Get a list of policy app ids
+ * @return apps list filled with the policy app ids of each
+ * application
+ */
+ virtual const std::vector<std::string> GetApplicationPolicyIDs() const = 0;
+
+ /**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
@@ -610,29 +617,21 @@ class PolicyManager : public usage_statistics::StatisticsManager,
std::vector<std::string>& enabled_apps) const = 0;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
+ * @brief Get app policy information, all fields that aren't set for a
* given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const = 0;
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
+
+ /**
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
/**
* @ brief Initialize new cloud app in the policy table
@@ -778,6 +777,12 @@ class PolicyManager : public usage_statistics::StatisticsManager,
*/
virtual void SendAppPermissionsChanged(const std::string& device_id,
const std::string& application_id) = 0;
+ /**
+ * @brief Send OnAppPropertiesChangeNotification to the HMI
+ * @param policy_app_id policy app id
+ */
+ virtual void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const = 0;
/**
* @brief Gets all allowed module types
@@ -831,6 +836,18 @@ class PolicyManager : public usage_statistics::StatisticsManager,
virtual ExternalConsentStatus GetExternalConsentStatus() = 0;
/**
+ * @brief OnLocalAppAdded triggers PTU
+ */
+ virtual void OnLocalAppAdded() = 0;
+
+ /**
+ * @brief Check if certain application already in policy db.
+ * @param policy application id.
+ * @return true if application presents false otherwise.
+ */
+ virtual bool IsNewApplication(const std::string& application_id) const = 0;
+
+ /**
* @brief Restart PTU timeout if PTU in UPDATING state
*/
virtual void ResetTimeout() = 0;
diff --git a/src/components/include/policy/policy_regular/policy/policy_listener.h b/src/components/include/policy/policy_regular/policy/policy_listener.h
index bbe220060e..5b8245f6a4 100644
--- a/src/components/include/policy/policy_regular/policy/policy_listener.h
+++ b/src/components/include/policy/policy_regular/policy/policy_listener.h
@@ -108,6 +108,13 @@ class PolicyListener {
const std::string& policy_app_id) const = 0;
/**
+ * @brief Send OnAppPropertiesChangeNotification to the HMI
+ * @param policy_app_id policy app id
+ */
+ virtual void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief GetAvailableApps allows to obtain list of registered applications.
*/
virtual void GetAvailableApps(std::queue<std::string>&) = 0;
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index c9143d6bbb..52923a53e2 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -575,6 +575,14 @@ class PolicyManager : public usage_statistics::StatisticsManager,
* @return policy_table as json object
*/
virtual Json::Value GetPolicyTableData() const = 0;
+
+ /**
+ * @brief Get a list of policy app ids
+ * @return apps list filled with the policy app ids of each
+ * application
+ */
+ virtual const std::vector<std::string> GetApplicationPolicyIDs() const = 0;
+
/**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
@@ -584,29 +592,21 @@ class PolicyManager : public usage_statistics::StatisticsManager,
std::vector<std::string>& enabled_apps) const = 0;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
+
+ /**
+ * @brief Get app policy information, all fields that aren't set for a
* given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const = 0;
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
/**
* @ brief Initialize new cloud app in the policy table
@@ -758,6 +758,13 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& application_id) = 0;
/**
+ * @brief Send OnAppPropertiesChangeNotification to the HMI
+ * @param policy_app_id policy app id
+ */
+ virtual void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief Gets all allowed module types
* @param policy_app_id unique identifier of application
* @param modules list of allowed module types
@@ -786,6 +793,18 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const EndpointUrls& urls) const = 0;
/**
+ * @brief OnLocalAppAdded triggers PTU
+ */
+ virtual void OnLocalAppAdded() = 0;
+
+ /**
+ * @brief Check if certain application already in policy db.
+ * @param policy application id.
+ * @return true if application presents false otherwise.
+ */
+ virtual bool IsNewApplication(const std::string& application_id) const = 0;
+
+ /**
* @brief Restart PTU timeout if PTU in UPDATING state
*/
virtual void ResetTimeout() = 0;
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index f6e0b3cb0f..a9cb70354a 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -206,6 +206,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
void(const policy::AppPermissions& permissions,
const std::string& device_id,
const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(SendOnAppPropertiesChangeNotification,
+ void(const std::string& policy_app_id));
MOCK_METHOD0(OnPTExchangeNeeded, void());
MOCK_METHOD1(GetAvailableApps, void(std::queue<std::string>& apps));
MOCK_METHOD3(
@@ -242,18 +244,24 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
const std::vector<std::string>(
const transport_manager::DeviceHandle& device_handle,
const std::string& policy_app_id));
+ MOCK_CONST_METHOD0(GetApplicationPolicyIDs, std::vector<std::string>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
MOCK_CONST_METHOD1(CheckCloudAppEnabled,
const bool(const std::string& policy_app_id));
- MOCK_CONST_METHOD7(GetCloudAppParameters,
+ MOCK_CONST_METHOD0(GetEnabledLocalApps, std::vector<std::string>());
+ MOCK_CONST_METHOD2(GetAppProperties,
bool(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ policy::AppProperties& out_app_properties));
+
+ MOCK_METHOD1(OnSetAppProperties,
+ void(const smart_objects::SmartObject& message));
+ MOCK_CONST_METHOD2(
+ GetAppPropertiesStatus,
+ AppPropertiesState(const smart_objects::SmartObject& properties,
+ const std::string& app_id));
+ MOCK_CONST_METHOD1(IsNewApplication, bool(const std::string& application_id));
+ MOCK_METHOD0(OnLocalAppAdded, void());
MOCK_METHOD1(OnSetCloudAppProperties,
void(const smart_objects::SmartObject& message));
MOCK_CONST_METHOD2(
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index b74ddbd13c..c6eb3416da 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -61,6 +61,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_METHOD0(IsPTPreloaded, bool());
MOCK_METHOD0(IgnitionCyclesBeforeExchange, int());
MOCK_METHOD1(KilometersBeforeExchange, int(int current));
+ MOCK_CONST_METHOD0(GetEnabledLocalApps, std::vector<std::string>());
MOCK_CONST_METHOD1(GetPermissionsList, bool(StringArray& perm_list));
MOCK_METHOD2(SetCountersPassedForSuccessfulUpdate,
bool(Counters counter, int value));
@@ -83,14 +84,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD7(GetCloudAppParameters,
+ MOCK_CONST_METHOD2(GetAppProperties,
bool(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ AppProperties& out_app_properties));
MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
index 2eb5b3300b..0060d2299f 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h
@@ -94,6 +94,8 @@ class MockPolicyListener : public ::policy::PolicyListener {
void(const policy::AppPermissions& permissions,
const std::string& device_id,
const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(SendOnAppPropertiesChangeNotification,
+ void(const std::string& policy_app_id));
MOCK_CONST_METHOD1(
GetDevicesIds,
std::vector<std::string>(const std::string& policy_app_id));
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index d2023fd3d4..5adb982410 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -194,6 +194,8 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD2(SendAppPermissionsChanged,
void(const std::string& device_id,
const std::string& application_id));
+ MOCK_CONST_METHOD1(SendOnAppPropertiesChangeNotification,
+ void(const std::string& application_id));
MOCK_CONST_METHOD2(GetModuleTypes,
bool(const std::string& policy_app_id,
std::vector<std::string>* modules));
@@ -228,14 +230,12 @@ class MockPolicyManager : public PolicyManager {
std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD7(GetCloudAppParameters,
+ MOCK_CONST_METHOD2(GetAppProperties,
bool(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ AppProperties& out_app_properties));
+ MOCK_CONST_METHOD0(GetEnabledLocalApps, std::vector<std::string>());
+ MOCK_CONST_METHOD1(IsNewApplication, bool(const std::string& application_id));
+ MOCK_METHOD0(OnLocalAppAdded, void());
MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index e592caf3bc..7c78eadfc8 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -55,6 +55,7 @@ class MockCacheManagerInterface : public CacheManagerInterface {
MOCK_METHOD0(IsPTPreloaded, bool());
MOCK_METHOD0(IgnitionCyclesBeforeExchange, int());
MOCK_METHOD1(KilometersBeforeExchange, int(int current));
+ MOCK_CONST_METHOD0(GetEnabledLocalApps, std::vector<std::string>());
MOCK_METHOD2(SetCountersPassedForSuccessfulUpdate,
bool(Counters counter, int value));
MOCK_METHOD1(DaysBeforeExchange, int(int current));
@@ -69,14 +70,9 @@ class MockCacheManagerInterface : public CacheManagerInterface {
std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD7(GetCloudAppParameters,
+ MOCK_CONST_METHOD2(GetAppProperties,
bool(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ AppProperties& out_app_properties));
MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h
index 48c549e91b..e5f2321217 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h
@@ -89,6 +89,8 @@ class MockPolicyListener : public ::policy::PolicyListener {
void(const policy::AppPermissions& permissions,
const std::string& device_id,
const std::string& policy_app_id));
+ MOCK_CONST_METHOD1(SendOnAppPropertiesChangeNotification,
+ void(const std::string& policy_app_id));
MOCK_METHOD3(OnUpdateHMILevel,
void(const std::string& device_id,
const std::string& policy_app_id,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index da9edb9fe5..a76d61dfe4 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -193,6 +193,8 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD2(SendAppPermissionsChanged,
void(const std::string& device_id,
const std::string& application_id));
+ MOCK_CONST_METHOD1(SendOnAppPropertiesChangeNotification,
+ void(const std::string& application_id));
MOCK_CONST_METHOD2(GetModuleTypes,
bool(const std::string& policy_app_id,
std::vector<std::string>* modules));
@@ -223,14 +225,12 @@ class MockPolicyManager : public PolicyManager {
std::vector<policy_table::VehicleDataItem>());
MOCK_CONST_METHOD1(GetEnabledCloudApps,
void(std::vector<std::string>& enabled_apps));
- MOCK_CONST_METHOD7(GetCloudAppParameters,
+ MOCK_CONST_METHOD2(GetAppProperties,
bool(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference));
+ AppProperties& out_app_properties));
+ MOCK_CONST_METHOD0(GetEnabledLocalApps, std::vector<std::string>());
+ MOCK_CONST_METHOD1(IsNewApplication, bool(const std::string& application_id));
+ MOCK_METHOD0(OnLocalAppAdded, void());
MOCK_METHOD1(InitCloudApp, void(const std::string& policy_app_id));
MOCK_METHOD2(SetCloudAppEnabled,
void(const std::string& policy_app_id, const bool enabled));
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index 5e3cf3dde7..b24e05fb6d 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -181,32 +181,18 @@ class CacheManager : public CacheManagerInterface {
* @param enabled_apps List filled with the policy app id of each enabled
* cloud application
*/
- virtual void GetEnabledCloudApps(
- std::vector<std::string>& enabled_apps) const;
+ void GetEnabledCloudApps(
+ std::vector<std::string>& enabled_apps) const OVERRIDE;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
- * given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const;
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id
+ * of each enabled local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
/**
* Initializes a new cloud application with default policies
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 2cb5f8fe33..8e3f90b64f 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -190,29 +190,21 @@ class CacheManagerInterface {
std::vector<std::string>& enabled_apps) const = 0;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
+
+ /**
+ * @brief Get app policy information, all fields that aren't set for a
* given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const = 0;
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
/**
* Initializes a new cloud application with default policies
diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h
index 2054485ef5..69ba8806d4 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -231,6 +231,10 @@ struct CheckAppPolicy {
void InsertPermission(const std::string& app_id,
const AppPermissions& permissions_diff);
+ bool IsAppPropertiesChanged(const AppPoliciesValueType& app_policy) const;
+
+ bool IsAppPropertiesProvided(const AppPoliciesValueType& app_policy) const;
+
private:
PolicyManagerImpl* pm_;
const std::shared_ptr<policy_table::Table> update_;
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index ce344d576a..57499131f9 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -667,28 +667,14 @@ class PolicyManagerImpl : public PolicyManager {
std::vector<std::string>& enabled_apps) const OVERRIDE;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
- * given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- bool GetCloudAppParameters(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
/**
* @ brief Initialize new cloud app in the policy table
@@ -921,6 +907,10 @@ class PolicyManagerImpl : public PolicyManager {
*/
void OnSystemRequestReceived() OVERRIDE;
+ void OnLocalAppAdded() OVERRIDE;
+
+ bool IsNewApplication(const std::string& application_id) const OVERRIDE;
+
protected:
/**
* @brief Parse policy table content and convert to PT object
@@ -1037,13 +1027,6 @@ class PolicyManagerImpl : public PolicyManager {
DeviceConsent device_consent);
/**
- * @brief Check if certain application already in policy db.
- * @param policy application id.
- * @return true if application presents false otherwise.
- */
- bool IsNewApplication(const std::string& application_id) const;
-
- /**
* Checks existing and permissions of AppStorageFolder
* @return true if AppStorageFolder exists and has permissions read/write
*/
@@ -1124,6 +1107,9 @@ class PolicyManagerImpl : public PolicyManager {
void SendAppPermissionsChanged(const std::string& device_id,
const std::string& application_id) OVERRIDE;
+ void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const OVERRIDE;
+
/**
* @brief notify listener of updated auth token for a given policy id
* @param policy_app_id the app id that has an updated auth token
@@ -1341,6 +1327,8 @@ class PolicyManagerImpl : public PolicyManager {
*/
bool send_on_update_sent_out_;
+ std::vector<std::string> app_properties_changed_list_;
+
/**
* @brief Flag for notifying that invalid PTU should be triggered
*/
diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h
index ee2d806ba5..2ede46d6c5 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -231,8 +231,11 @@ struct DeviceInfo {
using namespace helpers;
static const std::string bluetooth("BLUETOOTH");
static const std::string wifi("WIFI");
+ static const std::string webengine("WEBENGINE_WEBSOCKET");
if (Compare<std::string, EQ, ONE>(deviceType, bluetooth, wifi)) {
connection_type.assign("BTMAC");
+ } else if (Compare<std::string, EQ, ONE>(deviceType, webengine)) {
+ connection_type.assign("");
}
}
};
@@ -451,11 +454,13 @@ struct ApplicationPolicyActions {
ApplicationPolicyActions()
: is_notify_system(false)
, is_send_permissions_to_app(false)
- , is_consent_needed(false) {}
+ , is_consent_needed(false)
+ , app_properties_changed(false) {}
bool is_notify_system;
bool is_send_permissions_to_app;
bool is_consent_needed;
+ bool app_properties_changed;
};
/**
@@ -516,6 +521,7 @@ enum PermissionsCheckResult {
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED,
+ RESULT_APP_PROPERTIES_CHANGED
};
/**
@@ -538,6 +544,68 @@ enum ConsentPriorityType { kUserConsentPrio, kExternalConsentPrio };
*/
enum ConsentProcessingPolicy { kTimestampBased, kExternalConsentBased };
+/**
+ * @brief The AppProperties struct contains application properties
+ */
+struct AppProperties {
+ AppProperties()
+ : endpoint()
+ , certificate()
+ , enabled(false)
+ , auth_token()
+ , transport_type()
+ , hybrid_app_preference() {}
+
+ AppProperties(std::string endpoint,
+ std::string certificate,
+ bool enabled,
+ std::string auth_token,
+ std::string transport_type,
+ std::string hybrid_app_preference)
+ : endpoint(endpoint)
+ , certificate(certificate)
+ , enabled(enabled)
+ , auth_token(auth_token)
+ , transport_type(transport_type)
+ , hybrid_app_preference(hybrid_app_preference) {}
+
+ /**
+ * @brief endpoint Filled with the endpoint used to connect to the cloud
+ * application.
+ * @note should be absent for local applications
+ */
+ std::string endpoint;
+
+ /**
+ * @brief certificate Filled with the certificate used for creation
+ * of a secure connection to the cloud application
+ */
+ std::string certificate;
+
+ /**
+ * @brief enabled Whether or not the app is enabled
+ */
+ bool enabled;
+
+ /**
+ * @brief auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ */
+ std::string auth_token;
+
+ /**
+ * @brief transport_type Filled with the transport type used by the
+ * cloud/local application (ex. "WSS")
+ */
+ std::string transport_type;
+
+ /**
+ * @brief hybrid_app_preference Filled with the hybrid app preference for the
+ * application set by the user
+ */
+ std::string hybrid_app_preference;
+};
+
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 5bf4bfd658..a49d450a9e 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1471,40 +1471,60 @@ void CacheManager::GetEnabledCloudApps(
#endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT
}
-bool CacheManager::GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const {
+bool CacheManager::GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const {
const policy_table::ApplicationPolicies& policies =
pt_->policy_table.app_policies_section.apps;
policy_table::ApplicationPolicies::const_iterator policy_iter =
policies.find(policy_app_id);
if (policies.end() != policy_iter) {
auto app_policy = (*policy_iter).second;
- endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint
- : std::string();
- auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token
- : std::string();
- cloud_transport_type = app_policy.cloud_transport_type.is_initialized()
- ? *app_policy.cloud_transport_type
- : std::string();
- certificate = app_policy.certificate.is_initialized()
- ? *app_policy.certificate
- : std::string();
- hybrid_app_preference =
+ out_app_properties.endpoint = app_policy.endpoint.is_initialized()
+ ? *app_policy.endpoint
+ : std::string();
+ out_app_properties.auth_token = app_policy.auth_token.is_initialized()
+ ? *app_policy.auth_token
+ : std::string();
+ out_app_properties.transport_type =
+ app_policy.cloud_transport_type.is_initialized()
+ ? *app_policy.cloud_transport_type
+ : std::string();
+ out_app_properties.certificate = app_policy.certificate.is_initialized()
+ ? *app_policy.certificate
+ : std::string();
+ out_app_properties.hybrid_app_preference =
app_policy.hybrid_app_preference.is_initialized()
? EnumToJsonString(*app_policy.hybrid_app_preference)
: std::string();
- enabled = app_policy.enabled.is_initialized() && *app_policy.enabled;
+ out_app_properties.enabled =
+ app_policy.enabled.is_initialized() && *app_policy.enabled;
return true;
}
return false;
}
+std::vector<std::string> CacheManager::GetEnabledLocalApps() const {
+#if !defined(WEBSOCKET_SERVER_TRANSPORT_SUPPORT)
+ return std::vector<std::string>();
+#else
+ std::vector<std::string> enabled_apps;
+ const policy_table::ApplicationPolicies& app_policies =
+ pt_->policy_table.app_policies_section.apps;
+ for (const auto& app_policies_item : app_policies) {
+ const auto app_policy = app_policies_item.second;
+ // Local (WebEngine) applications
+ // should not have "endpoint" field
+ if (app_policy.endpoint.is_initialized()) {
+ continue;
+ }
+ if (app_policy.enabled.is_initialized() && *app_policy.enabled) {
+ enabled_apps.push_back(app_policies_item.first);
+ }
+ }
+ return enabled_apps;
+#endif // WEBSOCKET_SERVER_TRANSPORT_SUPPORT
+}
+
void CacheManager::InitCloudApp(const std::string& policy_app_id) {
CACHE_MANAGER_CHECK_VOID();
sync_primitives::AutoLock auto_lock(cache_lock_);
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index 98e5b5b3c1..b8bbb1682c 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -434,6 +434,13 @@ void CheckAppPolicy::InsertPermission(const std::string& app_id,
bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
const std::string app_id = app_policy.first;
+
+ const bool app_properties_changed = IsAppPropertiesChanged(app_policy);
+ const bool is_predefined_app = IsPredefinedApp(app_policy);
+ if (!is_predefined_app && app_properties_changed) {
+ AddResult(app_id, RESULT_APP_PROPERTIES_CHANGED);
+ }
+
AppPermissions permissions_diff(app_id);
if (!IsKnownAppication(app_id)) {
LOG4CXX_WARN(logger_,
@@ -668,6 +675,74 @@ bool CheckAppPolicy::IsRequestSubTypeChanged(
return diff.size();
}
+bool CheckAppPolicy::IsAppPropertiesProvided(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (app_policy.second.hybrid_app_preference.is_initialized() ||
+ app_policy.second.endpoint.is_initialized() ||
+ app_policy.second.enabled.is_initialized() ||
+ app_policy.second.auth_token.is_initialized() ||
+ app_policy.second.cloud_transport_type.is_initialized() ||
+ app_policy.second.nicknames.is_initialized()) {
+ return true;
+ }
+ return false;
+}
+
+bool CheckAppPolicy::IsAppPropertiesChanged(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!IsAppPropertiesProvided(app_policy)) {
+ return false;
+ }
+
+ if (!IsKnownAppication(app_policy.first)) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "AppProperties provided for new application: " << app_policy.first);
+ return true;
+ }
+
+ policy::AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+ const auto snapshot_properties = *it;
+
+ if (app_policy.second.enabled.is_initialized() &&
+ app_policy.second.enabled != snapshot_properties.second.enabled) {
+ LOG4CXX_DEBUG(logger_, "\"enabled\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.endpoint.is_initialized() &&
+ app_policy.second.endpoint != snapshot_properties.second.endpoint) {
+ LOG4CXX_DEBUG(logger_, "\"endpoint\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.hybrid_app_preference.is_initialized() &&
+ app_policy.second.hybrid_app_preference !=
+ snapshot_properties.second.hybrid_app_preference) {
+ LOG4CXX_DEBUG(logger_, "\"hybrid_app_preference\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.auth_token.is_initialized() &&
+ app_policy.second.auth_token != snapshot_properties.second.auth_token) {
+ LOG4CXX_DEBUG(logger_, "\"auth_token\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.cloud_transport_type.is_initialized() &&
+ app_policy.second.cloud_transport_type !=
+ snapshot_properties.second.cloud_transport_type) {
+ LOG4CXX_DEBUG(logger_, "\"cloud_transport_type\" was changed");
+ return true;
+ }
+
+ return false;
+}
+
bool CheckAppPolicy::IsEncryptionRequiredFlagChanged(
const AppPoliciesValueType& app_policy) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -778,6 +853,9 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
+ case RESULT_APP_PROPERTIES_CHANGED:
+ actions_[app_id].app_properties_changed = true;
+ break;
case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
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 787e65f43a..cd2bd4c2d4 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -622,6 +622,10 @@ void PolicyManagerImpl::ProcessActionsForAppPolicies(
continue;
}
+ if (action.second.app_properties_changed) {
+ app_properties_changed_list_.push_back(app_policy->first);
+ }
+
const auto devices_ids = listener()->GetDevicesIds(app_policy->first);
for (const auto& device_id : devices_ids) {
if (action.second.is_consent_needed) {
@@ -820,21 +824,13 @@ void PolicyManagerImpl::GetEnabledCloudApps(
cache_->GetEnabledCloudApps(enabled_apps);
}
-bool PolicyManagerImpl::GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const {
- return cache_->GetCloudAppParameters(policy_app_id,
- enabled,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+std::vector<std::string> PolicyManagerImpl::GetEnabledLocalApps() const {
+ return cache_->GetEnabledLocalApps();
+}
+
+bool PolicyManagerImpl::GetAppProperties(
+ const std::string& policy_app_id, AppProperties& out_app_properties) const {
+ return cache_->GetAppProperties(policy_app_id, out_app_properties);
}
void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) {
@@ -1201,6 +1197,12 @@ void PolicyManagerImpl::AddDevice(const std::string& device_id,
}
}
+void PolicyManagerImpl::OnLocalAppAdded() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ update_status_manager_.ScheduleUpdate();
+ StartPTExchange();
+}
+
void PolicyManagerImpl::SetDeviceInfo(const std::string& device_id,
const DeviceInfo& device_info) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1702,6 +1704,12 @@ void PolicyManagerImpl::UpdateAppConsentWithExternalConsent(
cache_->SetExternalConsentForApp(updated_external_consent_permissions);
}
+void PolicyManagerImpl::SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ listener_->SendOnAppPropertiesChangeNotification(policy_app_id);
+}
+
void PolicyManagerImpl::ResumePendingAppPolicyActions() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1714,6 +1722,10 @@ void PolicyManagerImpl::ResumePendingAppPolicyActions() {
SendPermissionsToApp(send_permissions_params.first,
send_permissions_params.second);
}
+
+ for (auto& app : app_properties_changed_list_) {
+ SendOnAppPropertiesChangeNotification(app);
+ }
send_permissions_list_.clear();
}
@@ -2318,10 +2330,10 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name,
const bool ret = cache_->Init(file_name, settings);
if (ret) {
RefreshRetrySequence();
- std::vector<std::string> enabled_apps;
- cache_->GetEnabledCloudApps(enabled_apps);
- for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) {
- SendAuthTokenUpdated(*it);
+ std::vector<std::string> enabled_cloud_apps;
+ cache_->GetEnabledCloudApps(enabled_cloud_apps);
+ for (auto app : enabled_cloud_apps) {
+ SendAuthTokenUpdated(app);
}
}
return ret;
@@ -2440,12 +2452,9 @@ void PolicyManagerImpl::SendAppPermissionsChanged(
}
void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) {
- bool enabled = false;
- std::string end, cert, ctt, hap;
- std::string auth_token;
- cache_->GetCloudAppParameters(
- policy_app_id, enabled, end, cert, auth_token, ctt, hap);
- listener_->OnAuthTokenUpdated(policy_app_id, auth_token);
+ AppProperties app_properties;
+ cache_->GetAppProperties(policy_app_id, app_properties);
+ listener_->OnAuthTokenUpdated(policy_app_id, app_properties.auth_token);
}
void PolicyManagerImpl::OnPrimaryGroupsChanged(
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
index 4fbbeaa6aa..920d2e1272 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
@@ -146,9 +146,6 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
// Arrange
CreateLocalPT(preloaded_pt_filename_);
- EXPECT_CALL(listener_, GetDevicesIds(app_id_1_))
- .WillRepeatedly(Return(transport_manager::DeviceList()));
-
policy_manager_->AddApplication(
device_id_1_, app_id_1_, HmiTypes(policy_table::AHT_DEFAULT));
@@ -224,8 +221,10 @@ TEST_F(PolicyManagerImplTest2,
EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, app_id_1_))
.Times(0);
- EXPECT_CALL(listener_, GetDevicesIds(app_id_1_))
- .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_)));
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
+ ON_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillByDefault(Return(transport_manager::DeviceList(1, device_id_1_)));
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
// Add app from consented device. App will be assigned with default policies
@@ -289,8 +288,12 @@ TEST_F(PolicyManagerImplTest2,
"Bluetooth"));
EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_, application_id_))
.Times(0);
- EXPECT_CALL(listener_, GetDevicesIds(application_id_))
- .WillRepeatedly(Return(transport_manager::DeviceList(1, device_id_1_)));
+
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
+ ON_CALL(listener_, GetDevicesIds(app_id_1_))
+ .WillByDefault(Return(transport_manager::DeviceList(1, device_id_1_)));
+
policy_manager_->SetUserConsentForDevice(device_id_1_, true);
// Add app from consented device. App will be assigned with default policies
policy_manager_->AddApplication(
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
index 9f363a223a..dc1d7a06ef 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc
@@ -257,6 +257,8 @@ void PolicyManagerImplTest2::SetUp() {
ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return());
ON_CALL(listener_, ptu_retry_handler())
.WillByDefault(ReturnRef(ptu_retry_handler_));
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
file_system::CreateDirectory(app_storage_folder_);
@@ -675,6 +677,8 @@ PolicyManagerImplTest_RequestTypes::PolicyManagerImplTest_RequestTypes()
void PolicyManagerImplTest_RequestTypes::SetUp() {
ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return());
+ ON_CALL(listener_, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
file_system::CreateDirectory(app_storage_folder_);
const bool in_memory = true;
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index 6bd2c4840b..0ad7634382 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -161,6 +161,7 @@ class CacheManager : public CacheManagerInterface {
const boost::optional<std::string> LockScreenDismissalWarningMessage(
const std::string& language) const OVERRIDE;
+
/**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
@@ -170,28 +171,14 @@ class CacheManager : public CacheManagerInterface {
std::vector<std::string>& enabled_apps) const;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
- * given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const;
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
/**
* Initializes a new cloud application with default policies
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index a1b4af0f39..35a61f6597 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -177,29 +177,21 @@ class CacheManagerInterface {
std::vector<std::string>& enabled_apps) const = 0;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ virtual std::vector<std::string> GetEnabledLocalApps() const = 0;
+
+ /**
+ * @brief Get app policy information, all fields that aren't set for a
* given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- virtual bool GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const = 0;
+ * @param policy_app_id policy app id
+ * @param out_app_properties application properties
+ * @return true if application presents in database, otherwise - false
+ */
+ virtual bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const = 0;
/**
* Initializes a new cloud application with default policies
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index a8cec41715..d5155cf91b 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -131,6 +131,10 @@ struct CheckAppPolicy {
bool IsEncryptionRequiredFlagChanged(
const AppPoliciesValueType& app_policy) const;
+ bool IsAppPropertiesChanged(const AppPoliciesValueType& app_policy) const;
+
+ bool IsAppPropertiesProvided(const AppPoliciesValueType& app_policy) const;
+
private:
PolicyManagerImpl* pm_;
const std::shared_ptr<policy_table::Table> update_;
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 192de6cd34..a1a39ff80b 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -671,6 +671,7 @@ class PolicyManagerImpl : public PolicyManager {
* @return policy_table as json object
*/
Json::Value GetPolicyTableData() const OVERRIDE;
+
/**
* @brief Get a list of enabled cloud applications
* @param enabled_apps List filled with the policy app id of each enabled
@@ -680,28 +681,14 @@ class PolicyManagerImpl : public PolicyManager {
std::vector<std::string>& enabled_apps) const OVERRIDE;
/**
- * @brief Get cloud app policy information, all fields that aren't set for a
- * given app will be filled with empty strings
- * @param policy_app_id Unique application id
- * @param enabled Whether or not the app is enabled
- * @param endpoint Filled with the endpoint used to connect to the cloud
- * application
- * @param certificate Filled with the certificate used to for creating a
- * secure connection to the cloud application
- * @param auth_token Filled with the token used for authentication when
- * reconnecting to the cloud app
- * @param cloud_transport_type Filled with the transport type used by the
- * cloud application (ex. "WSS")
- * @param hybrid_app_preference Filled with the hybrid app preference for the
- * cloud application set by the user
- */
- bool GetCloudAppParameters(const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const OVERRIDE;
+ * @brief Get a list of enabled local applications
+ * @return enabled_apps List filled with the policy app id of each enabled
+ * local application
+ */
+ std::vector<std::string> GetEnabledLocalApps() const OVERRIDE;
+
+ bool GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const OVERRIDE;
/**
* @ brief Initialize new cloud app in the policy table
@@ -876,6 +863,10 @@ class PolicyManagerImpl : public PolicyManager {
int32_t timespan_seconds) OVERRIDE;
// Interface StatisticsManager (end)
+ void OnLocalAppAdded() OVERRIDE;
+
+ bool IsNewApplication(const std::string& application_id) const OVERRIDE;
+
void ResetTimeout() OVERRIDE;
protected:
@@ -984,13 +975,6 @@ class PolicyManagerImpl : public PolicyManager {
DeviceConsent device_consent);
/**
- * @brief Check if certain application already in policy db.
- * @param policy application id.
- * @return true if application presents false otherwise.
- */
- bool IsNewApplication(const std::string& application_id) const;
-
- /**
* Checks existing and permissions of AppStorageFolder
* @return true if AppStorageFolder exists and has permissions read/write
*/
@@ -1077,6 +1061,9 @@ class PolicyManagerImpl : public PolicyManager {
void SendAppPermissionsChanged(const std::string& device_id,
const std::string& application_id) OVERRIDE;
+ void SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const OVERRIDE;
+
/**
* @brief notify listener of updated auth token for a given policy id
* @param policy_app_id the app id that has an updated auth token
@@ -1185,6 +1172,11 @@ class PolicyManagerImpl : public PolicyManager {
bool send_on_update_sent_out_;
/**
+ * @brief List of chnaged application properties
+ */
+ std::vector<std::string> app_properties_changed_list_;
+
+ /**
* @brief Flag for notifying that invalid PTU should be triggered
*/
bool trigger_ptu_;
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index 9fddb9761b..a72837418f 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -233,8 +233,11 @@ struct DeviceInfo {
using namespace helpers;
static const std::string bluetooth("BLUETOOTH");
static const std::string wifi("WIFI");
+ static const std::string webengine("WEBENGINE_WEBSOCKET");
if (Compare<std::string, EQ, ONE>(deviceType, bluetooth, wifi)) {
connection_type.assign("BTMAC");
+ } else if (Compare<std::string, EQ, ONE>(deviceType, webengine)) {
+ connection_type.assign("");
}
}
};
@@ -443,11 +446,13 @@ struct ApplicationPolicyActions {
ApplicationPolicyActions()
: is_notify_system(false)
, is_send_permissions_to_app(false)
- , is_consent_needed(false) {}
+ , is_consent_needed(false)
+ , app_properties_changed(false) {}
bool is_notify_system;
bool is_send_permissions_to_app;
bool is_consent_needed;
+ bool app_properties_changed;
};
/**
@@ -507,7 +512,8 @@ enum PermissionsCheckResult {
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
RESULT_REQUEST_SUBTYPE_CHANGED,
- RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED
+ RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED,
+ RESULT_APP_PROPERTIES_CHANGED
};
/**
@@ -523,6 +529,68 @@ typedef std::set<std::pair<std::string, PermissionsCheckResult> >
*/
typedef std::pair<uint32_t, uint32_t> AppIdURL;
+/**
+ * @brief The AppProperties struct contains application properties
+ */
+struct AppProperties {
+ AppProperties()
+ : endpoint()
+ , certificate()
+ , enabled(false)
+ , auth_token()
+ , transport_type()
+ , hybrid_app_preference() {}
+
+ AppProperties(std::string endpoint,
+ std::string certificate,
+ bool enabled,
+ std::string auth_token,
+ std::string transport_type,
+ std::string hybrid_app_preference)
+ : endpoint(endpoint)
+ , certificate(certificate)
+ , enabled(enabled)
+ , auth_token(auth_token)
+ , transport_type(transport_type)
+ , hybrid_app_preference(hybrid_app_preference) {}
+
+ /**
+ * @brief endpoint Filled with the endpoint used to connect to the cloud
+ * application.
+ * @note should be absent for local applications
+ */
+ std::string endpoint;
+
+ /**
+ * @brief certificate Filled with the certificate used for creation
+ * of a secure connection to the cloud application
+ */
+ std::string certificate;
+
+ /**
+ * @brief enabled Whether or not the app is enabled
+ */
+ bool enabled;
+
+ /**
+ * @brief auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ */
+ std::string auth_token;
+
+ /**
+ * @brief transport_type Filled with the transport type used by the
+ * cloud/local application (ex. "WSS")
+ */
+ std::string transport_type;
+
+ /**
+ * @brief hybrid_app_preference Filled with the hybrid app preference for the
+ * application set by the user
+ */
+ std::string hybrid_app_preference;
+};
+
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_POLICY_TYPES_H_
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 743b9eff6c..7a6f98f536 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -766,35 +766,55 @@ void CacheManager::GetEnabledCloudApps(
#endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT
}
-bool CacheManager::GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const {
+std::vector<std::string> CacheManager::GetEnabledLocalApps() const {
+#if !defined(WEBSOCKET_SERVER_TRANSPORT_SUPPORT)
+ return std::vector<std::string>();
+#else
+ std::vector<std::string> enabled_apps;
+ const policy_table::ApplicationPolicies& app_policies =
+ pt_->policy_table.app_policies_section.apps;
+ for (const auto& app_policies_item : app_policies) {
+ const auto app_policy = app_policies_item.second;
+ // Local (WebEngine) applications
+ // should not have "endpoint" field
+ if (app_policy.endpoint.is_initialized()) {
+ continue;
+ }
+ if (app_policy.enabled.is_initialized() && *app_policy.enabled) {
+ enabled_apps.push_back(app_policies_item.first);
+ }
+ }
+ return enabled_apps;
+#endif // WEBSOCKET_SERVER_TRANSPORT_SUPPORT
+}
+
+bool CacheManager::GetAppProperties(const std::string& policy_app_id,
+ AppProperties& out_app_properties) const {
const policy_table::ApplicationPolicies& policies =
pt_->policy_table.app_policies_section.apps;
policy_table::ApplicationPolicies::const_iterator policy_iter =
policies.find(policy_app_id);
if (policies.end() != policy_iter) {
auto app_policy = (*policy_iter).second;
- endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint
- : std::string();
- auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token
- : std::string();
- cloud_transport_type = app_policy.cloud_transport_type.is_initialized()
- ? *app_policy.cloud_transport_type
- : std::string();
- certificate = app_policy.certificate.is_initialized()
- ? *app_policy.certificate
- : std::string();
- hybrid_app_preference =
+ out_app_properties.endpoint = app_policy.endpoint.is_initialized()
+ ? *app_policy.endpoint
+ : std::string();
+ out_app_properties.auth_token = app_policy.auth_token.is_initialized()
+ ? *app_policy.auth_token
+ : std::string();
+ out_app_properties.transport_type =
+ app_policy.cloud_transport_type.is_initialized()
+ ? *app_policy.cloud_transport_type
+ : std::string();
+ out_app_properties.certificate = app_policy.certificate.is_initialized()
+ ? *app_policy.certificate
+ : std::string();
+ out_app_properties.hybrid_app_preference =
app_policy.hybrid_app_preference.is_initialized()
? EnumToJsonString(*app_policy.hybrid_app_preference)
: std::string();
- enabled = app_policy.enabled.is_initialized() && *app_policy.enabled;
+ out_app_properties.enabled =
+ app_policy.enabled.is_initialized() && *app_policy.enabled;
return true;
}
return false;
diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc
index b689ed81ba..08f1fbb177 100644
--- a/src/components/policy/policy_regular/src/policy_helper.cc
+++ b/src/components/policy/policy_regular/src/policy_helper.cc
@@ -388,6 +388,12 @@ void CheckAppPolicy::AddResult(const std::string& app_id,
bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
const std::string app_id = app_policy.first;
+ const bool app_properties_changed = IsAppPropertiesChanged(app_policy);
+ const bool is_predefined_app = IsPredefinedApp(app_policy);
+ if (!is_predefined_app && app_properties_changed) {
+ AddResult(app_id, RESULT_APP_PROPERTIES_CHANGED);
+ }
+
if (!IsKnownAppication(app_id)) {
LOG4CXX_WARN(logger_,
"Application:" << app_id << " is not present in snapshot.");
@@ -608,6 +614,74 @@ bool CheckAppPolicy::IsRequestSubTypeChanged(
return diff.size();
}
+bool CheckAppPolicy::IsAppPropertiesProvided(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (app_policy.second.hybrid_app_preference.is_initialized() ||
+ app_policy.second.endpoint.is_initialized() ||
+ app_policy.second.enabled.is_initialized() ||
+ app_policy.second.auth_token.is_initialized() ||
+ app_policy.second.cloud_transport_type.is_initialized() ||
+ app_policy.second.nicknames.is_initialized()) {
+ return true;
+ }
+ return false;
+}
+
+bool CheckAppPolicy::IsAppPropertiesChanged(
+ const AppPoliciesValueType& app_policy) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!IsAppPropertiesProvided(app_policy)) {
+ return false;
+ }
+
+ if (!IsKnownAppication(app_policy.first)) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "AppProperties provided for new application: " << app_policy.first);
+ return true;
+ }
+
+ policy::AppPoliciesConstItr it =
+ snapshot_->policy_table.app_policies_section.apps.find(app_policy.first);
+ const auto snapshot_properties = *it;
+
+ if (app_policy.second.enabled.is_initialized() &&
+ app_policy.second.enabled != snapshot_properties.second.enabled) {
+ LOG4CXX_DEBUG(logger_, "\"enabled\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.endpoint.is_initialized() &&
+ app_policy.second.endpoint != snapshot_properties.second.endpoint) {
+ LOG4CXX_DEBUG(logger_, "\"endpoint\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.hybrid_app_preference.is_initialized() &&
+ app_policy.second.hybrid_app_preference !=
+ snapshot_properties.second.hybrid_app_preference) {
+ LOG4CXX_DEBUG(logger_, "\"hybrid_app_preference\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.auth_token.is_initialized() &&
+ app_policy.second.auth_token != snapshot_properties.second.auth_token) {
+ LOG4CXX_DEBUG(logger_, "\"auth_token\" was changed");
+ return true;
+ }
+
+ if (app_policy.second.cloud_transport_type.is_initialized() &&
+ app_policy.second.cloud_transport_type !=
+ snapshot_properties.second.cloud_transport_type) {
+ LOG4CXX_DEBUG(logger_, "\"cloud_transport_type\" was changed");
+ return true;
+ }
+
+ return false;
+}
+
bool CheckAppPolicy::IsEncryptionRequiredFlagChanged(
const AppPoliciesValueType& app_policy) const {
auto get_app_encryption_needed =
@@ -699,7 +773,6 @@ void FillActionsForAppPolicies::operator()(
const policy::CheckAppPolicyResults::value_type& value) {
const std::string app_id = value.first;
const auto app_policy = app_policies_.find(app_id);
-
if (app_policies_.end() == app_policy) {
return;
}
@@ -717,6 +790,9 @@ void FillActionsForAppPolicies::operator()(
case RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED:
actions_[app_id].is_consent_needed = true;
break;
+ case RESULT_APP_PROPERTIES_CHANGED:
+ actions_[app_id].app_properties_changed = true;
+ break;
case RESULT_CONSENT_NOT_REQUIRED:
case RESULT_PERMISSIONS_REVOKED:
case RESULT_REQUEST_TYPE_CHANGED:
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 22205763a9..ff1ed5d5a9 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -466,6 +466,10 @@ void PolicyManagerImpl::ProcessActionsForAppPolicies(
continue;
}
+ if (it_actions->second.app_properties_changed) {
+ app_properties_changed_list_.push_back(app_policy->first);
+ }
+
const auto devices_ids = listener()->GetDevicesIds(app_policy->first);
for (const auto& device_id : devices_ids) {
if (it_actions->second.is_consent_needed) {
@@ -493,6 +497,12 @@ void PolicyManagerImpl::ProcessActionsForAppPolicies(
}
}
+void PolicyManagerImpl::SendOnAppPropertiesChangeNotification(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ listener_->SendOnAppPropertiesChangeNotification(policy_app_id);
+}
+
void PolicyManagerImpl::ResumePendingAppPolicyActions() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -505,6 +515,11 @@ void PolicyManagerImpl::ResumePendingAppPolicyActions() {
SendPermissionsToApp(send_permissions_params.first,
send_permissions_params.second);
}
+
+ for (auto& app : app_properties_changed_list_) {
+ SendOnAppPropertiesChangeNotification(app);
+ }
+
send_permissions_list_.clear();
}
@@ -681,6 +696,12 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) {
}
}
+void PolicyManagerImpl::OnLocalAppAdded() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ update_status_manager_.ScheduleUpdate();
+ StartPTExchange();
+}
+
void PolicyManagerImpl::OnAppRegisteredOnMobile(
const std::string& device_id, const std::string& application_id) {
StartPTExchange();
@@ -737,21 +758,13 @@ void PolicyManagerImpl::GetEnabledCloudApps(
cache_->GetEnabledCloudApps(enabled_apps);
}
-bool PolicyManagerImpl::GetCloudAppParameters(
- const std::string& policy_app_id,
- bool& enabled,
- std::string& endpoint,
- std::string& certificate,
- std::string& auth_token,
- std::string& cloud_transport_type,
- std::string& hybrid_app_preference) const {
- return cache_->GetCloudAppParameters(policy_app_id,
- enabled,
- endpoint,
- certificate,
- auth_token,
- cloud_transport_type,
- hybrid_app_preference);
+std::vector<std::string> PolicyManagerImpl::GetEnabledLocalApps() const {
+ return cache_->GetEnabledLocalApps();
+}
+
+bool PolicyManagerImpl::GetAppProperties(
+ const std::string& policy_app_id, AppProperties& out_app_properties) const {
+ return cache_->GetAppProperties(policy_app_id, out_app_properties);
}
void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) {
@@ -1580,10 +1593,10 @@ bool PolicyManagerImpl::InitPT(const std::string& file_name,
if (!certificate_data.empty()) {
listener_->OnCertificateUpdated(certificate_data);
}
- std::vector<std::string> enabled_apps;
- cache_->GetEnabledCloudApps(enabled_apps);
- for (auto it = enabled_apps.begin(); it != enabled_apps.end(); ++it) {
- SendAuthTokenUpdated(*it);
+ std::vector<std::string> enabled_cloud_apps;
+ cache_->GetEnabledCloudApps(enabled_cloud_apps);
+ for (auto app : enabled_cloud_apps) {
+ SendAuthTokenUpdated(app);
}
}
return ret;
@@ -1734,12 +1747,9 @@ void PolicyManagerImpl::SendAppPermissionsChanged(
}
void PolicyManagerImpl::SendAuthTokenUpdated(const std::string policy_app_id) {
- bool enabled = false;
- std::string end, cert, ctt, hap;
- std::string auth_token;
- cache_->GetCloudAppParameters(
- policy_app_id, enabled, end, cert, auth_token, ctt, hap);
- listener_->OnAuthTokenUpdated(policy_app_id, auth_token);
+ AppProperties app_properties;
+ cache_->GetAppProperties(policy_app_id, app_properties);
+ listener_->OnAuthTokenUpdated(policy_app_id, app_properties.auth_token);
}
void PolicyManagerImpl::OnPrimaryGroupsChanged(
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index abb5901690..08e8dd4023 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -1328,6 +1328,8 @@ TEST_F(
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+ ON_CALL(listener, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
GetPTU("valid_sdl_pt_update.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
// Try to add existing app
@@ -1342,6 +1344,8 @@ TEST_F(PolicyManagerImplTest2, UpdateApplication_AppServices) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+ ON_CALL(listener, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
GetPTU("valid_sdl_pt_update.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
// Try to add existing app
@@ -1376,6 +1380,8 @@ TEST_F(PolicyManagerImplTest2,
const int kSecondsInDay = 60 * 60 * 24;
int days = date_time::getSecs(current_time) / kSecondsInDay;
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
+ ON_CALL(listener, GetDevicesIds(_))
+ .WillByDefault(Return(transport_manager::DeviceList()));
GetPTU("valid_sdl_pt_update.json");
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());