summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2021-01-11 09:14:18 -0500
committerGitHub <noreply@github.com>2021-01-11 09:14:18 -0500
commit8be4f3273203c353ada484c57d654c12cd19d2e4 (patch)
treee5faf1d8bea0587ded658eb65e0ca9da2a005c6d
parent218aee15ea7d37dbca773e09cb391d0d229886d6 (diff)
downloadsdl_core-8be4f3273203c353ada484c57d654c12cd19d2e4.tar.gz
Fix/Revoked App Consent Activation (#3592)
* Add permissions check in OnAllowSDLFunctionalityNotification for application revoked case * Fix unit tests * Fix unit tests * Use IsApplicationRevoked instead of GetAppPermissionChanges * Fix IsApplicationRevoked check * Add check to prevent setting last_activated_app_id_ for revoked app
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc15
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc4
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc2
3 files changed, 15 insertions, 6 deletions
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index cb9b7df3e1..890dd5b57a 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1380,7 +1380,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
}
#ifdef EXTERNAL_PROPRIETARY_MODE
-
ApplicationSet applications;
{
DataAccessor<ApplicationSet> accessor =
@@ -1426,7 +1425,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
}
#ifdef EXTERNAL_PROPRIETARY_MODE
-
if (last_activated_app_id_) {
ApplicationSharedPtr app =
application_manager_.application(last_activated_app_id_);
@@ -1437,7 +1435,14 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
<< "' not found among registered applications.");
return;
}
- if (is_allowed) {
+
+ bool is_allowed_by_policies = true;
+ if (PolicyEnabled()) {
+ is_allowed_by_policies =
+ !policy_manager->IsApplicationRevoked(app->policy_app_id());
+ }
+
+ if (is_allowed && is_allowed_by_policies) {
// Send HMI status notification to mobile
// Put application in full
AudioStreamingState::eType audio_state =
@@ -1510,7 +1515,9 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
// is not allowed.
if (!permissions.isSDLAllowed) {
permissions.priority.clear();
- last_activated_app_id_ = connection_key;
+ if (!permissions.appRevoked) {
+ last_activated_app_id_ = connection_key;
+ }
}
if (permissions.appRevoked) {
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index a66cff1727..f566bed934 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -926,8 +926,8 @@ void PolicyHandlerTest::TestActivateApp(const uint32_t connection_key,
_,
_));
#endif // EXTERNAL_PROPRIETARY_MODE
-
- EXPECT_CALL(*application1, policy_app_id()).WillOnce(Return(kPolicyAppId_));
+ EXPECT_CALL(*application1, policy_app_id())
+ .WillRepeatedly(Return(kPolicyAppId_));
EXPECT_CALL(*mock_policy_manager_,
GetAppPermissionsChanges(kMacAddr_, kPolicyAppId_))
.WillOnce(Return(permissions));
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
index 4d39e699b5..95fc783b2d 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
@@ -66,6 +66,7 @@ const int kServiceTypeInt = 0;
const std::string kDeviceNumber = "XXX123456789ZZZ";
const std::string kAppStorageFolder = "app_storage_folder";
const std::string kValidAppId = "1234";
+const std::vector<std::string> kDevices{kDeviceNumber};
} // namespace
class PolicyManagerImplTest : public ::testing::Test {
@@ -88,6 +89,7 @@ class PolicyManagerImplTest : public ::testing::Test {
ON_CALL(policy_settings_, app_storage_folder())
.WillByDefault(ReturnRef(kAppStorageFolder));
+ ON_CALL(listener_, GetDevicesIds(_)).WillByDefault(Return(kDevices));
}
::testing::AssertionResult IsValid(const policy_table::Table& table) {