diff options
5 files changed, 46 insertions, 15 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 5fee7500ce..50703aec24 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -46,6 +46,10 @@ namespace application_manager { * table */ struct CommandParametersPermissions { + CommandParametersPermissions() + : permit_result(PermitResult::kRpcDisallowed) {} + + PermitResult permit_result; RPCParams allowed_params; RPCParams disallowed_params; RPCParams undefined_params; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 50f1152ec5..cb97b01e88 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -3362,6 +3362,7 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( GetPolicyHandler().CheckPermissions(app, function_id, rpc_params, result); if (NULL != params_permissions) { + params_permissions->permit_result = result.hmi_level_permitted; params_permissions->allowed_params = result.list_of_allowed_params; params_permissions->disallowed_params = result.list_of_disallowed_params; params_permissions->undefined_params = result.list_of_undefined_params; @@ -3387,8 +3388,10 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( switch (result.hmi_level_permitted) { case policy::kRpcDisallowed: + case policy::kRpcAllParamsDisallowed: return mobile_apis::Result::DISALLOWED; case policy::kRpcUserDisallowed: + case policy::kRpcAllParamsUserDisallowed: return mobile_apis::Result::USER_DISALLOWED; default: return mobile_apis::Result::INVALID_ENUM; diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index eca05da1ad..4c78231f94 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -105,6 +105,25 @@ const std::string CreateInfoForUnsupportedResult( } } +std::string CreateInfoForPolicyPermitResult(const PermitResult value) { + switch (value) { + case PermitResult::kRpcDisallowed: { + return "RPC is disallowed by Policies"; + } + case PermitResult::kRpcUserDisallowed: { + return "RPC is disallowed by the User"; + } + case PermitResult::kRpcAllParamsDisallowed: { + return "Requested parameters are disallowed by Policies"; + } + case PermitResult::kRpcAllParamsUserDisallowed: { + return "Requested parameters are disallowed by User"; + } + default: + return std::string(); + } +} + bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) { if (first.is_ok && second.is_unsupported_resource) { return true; @@ -627,7 +646,11 @@ bool CommandRequestImpl::CheckAllowedParameters() { check_result, correlation_id(), app->app_id()); - + std::string info = + CreateInfoForPolicyPermitResult(parameters_permissions_.permit_result); + if (!info.empty()) { + (*response)[strings::msg_params][strings::info] = info; + } application_manager_.SendMessageToMobile(response); return false; } @@ -766,7 +789,11 @@ void CommandRequestImpl::AddDisallowedParametersToInfo( } if (!info.empty()) { - info += " disallowed by policies."; + const uint32_t params_count = + removed_parameters_permissions_.disallowed_params.size() + + removed_parameters_permissions_.undefined_params.size(); + info += params_count > 1 ? " parameters are " : " parameter is "; + info += "disallowed by Policies"; if (!response[strings::msg_params][strings::info].asString().empty()) { // If we already have info add info about disallowed params to it diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index 6c34b4e6cb..6573806c02 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -77,29 +77,25 @@ void SendLocationRequest::Run() { return; } - smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - if (msg_params.keyExists(strings::delivery_mode)) { - const policy::RPCParams& allowed_params = - parameters_permissions().allowed_params; - - if (helpers::in_range(allowed_params, strings::delivery_mode)) { - msg_params.erase(strings::delivery_mode); - } - } - if (!AreMandatoryParamsAllowedByUser()) { LOG4CXX_ERROR(logger_, "All parameters are disallowed by user."); - SendResponse(false, mobile_api::Result::USER_DISALLOWED); + SendResponse(false, + mobile_api::Result::USER_DISALLOWED, + "Requested parameters are disallowed by User"); return; } if (!AreMandatoryParamsAllowedByPolicy()) { LOG4CXX_ERROR(logger_, "Mandatory parameters are disallowed by policy."); - SendResponse(false, mobile_api::Result::DISALLOWED); + SendResponse(false, + mobile_api::Result::DISALLOWED, + "Requested parameters are disallowed by Policies"); return; } std::vector<Common_TextFieldName::eType> fields_to_check; + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + if (msg_params.keyExists(strings::location_name)) { fields_to_check.push_back(Common_TextFieldName::locationName); } diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 96803e69a8..5cad0f7e3f 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -85,8 +85,9 @@ class EventDispatcher; class Application; class StateControllerImpl; -struct CommandParametersPermissions; using policy::RPCParams; +using policy::PermitResult; +struct CommandParametersPermissions; typedef std::vector<ApplicationSharedPtr> AppSharedPtrs; struct ApplicationsAppIdSorter { bool operator()(const ApplicationSharedPtr lhs, |