Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdl passenger mode without ut implementation #2792

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/appMain/sdl_preloaded_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"COMMUNICATION": 6,
"NORMAL": 4,
"NONE": 0
}
},
"lock_screen_dismissal_enabled": true
},
"functional_groupings": {
"Base-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class PolicyHandler : public PolicyHandlerInterface,
uint32_t TimeoutExchangeMSec() const OVERRIDE;
void OnExceededTimeout() OVERRIDE;
void OnSystemReady() OVERRIDE;
const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const OVERRIDE;
void PTUpdatedAt(Counters counter, int value) OVERRIDE;
void add_listener(PolicyHandlerObserver* listener) OVERRIDE;
void remove_listener(PolicyHandlerObserver* listener) OVERRIDE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace mobile_notification {
extern const char* state;
extern const char* syncp_timeout;
extern const char* syncp_url;
extern const char* lock_screen_dismissal_enabled;
} // namespace mobile_notification

namespace hmi_levels {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ void OnDriverDistractionNotification::Run() {
(*on_driver_distraction)[strings::msg_params][mobile_notification::state] =
state;

auto lock_screen_dismissal = application_manager_.GetPolicyHandler().LockScreenDismissalEnabledState();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan can be const


if ( lock_screen_dismissal &&
hmi_apis::Common_DriverDistractionState::DD_ON == state) {
(*on_driver_distraction)[strings::msg_params]
[mobile_notification::lock_screen_dismissal_enabled] = *lock_screen_dismissal;
}

const ApplicationSet applications =
application_manager_.applications().GetData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,8 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) {
CreateCommand<hmi::OnDriverDistractionNotification>(message);

EXPECT_CALL(app_mngr_, set_driver_distraction_state(state));
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillOnce(ReturnRef(mock_policy_handler_));
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_));
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0);
EXPECT_CALL(*app_ptr_, app_id()).Times(0);
Expand All @@ -1811,6 +1813,8 @@ TEST_F(HMICommandsNotificationsTest,

ApplicationSharedPtr invalid_app;
application_set_.insert(invalid_app);
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillOnce(ReturnRef(mock_policy_handler_));
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_));
EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0);
EXPECT_CALL(*app_ptr_, app_id()).Times(0);
Expand All @@ -1826,6 +1830,8 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) {
CreateCommand<hmi::OnDriverDistractionNotification>(message);

application_set_.insert(app_);
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillOnce(ReturnRef(mock_policy_handler_));
EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_));
policy::CheckPermissionResult result;
result.hmi_level_permitted = policy::kRpcAllowed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3387,6 +3387,14 @@ void ApplicationManagerImpl::SendDriverDistractionState(
mobile_api::FunctionID::OnDriverDistractionID;
(*on_driver_distraction)[strings::msg_params][mobile_notification::state] =
driver_distraction_state();
auto lock_screen_dismissal = policy_handler_->LockScreenDismissalEnabledState();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan can be const


if ( lock_screen_dismissal &&
hmi_apis::Common_DriverDistractionState::DD_ON == driver_distraction_state()) {
(*on_driver_distraction)[strings::msg_params]
[mobile_notification::lock_screen_dismissal_enabled] = *lock_screen_dismissal;
}

(*on_driver_distraction)[strings::params][strings::connection_key] =
application->app_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,11 @@ void PolicyHandler::OnSystemReady() {
policy_manager_->OnSystemReady();
}

const utils::OptionalVal<bool> PolicyHandler::LockScreenDismissalEnabledState() const {
POLICY_LIB_CHECK(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan probably return empty Value if policy library not available

return policy_manager_->LockScreenDismissalEnabledState();
}

void PolicyHandler::PTUpdatedAt(Counters counter, int value) {
POLICY_LIB_CHECK_VOID();
policy_manager_->PTUpdatedAt(counter, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ namespace mobile_notification {
const char* state = "state";
const char* syncp_timeout = "Timeout";
const char* syncp_url = "URL";
const char* lock_screen_dismissal_enabled = "lockScreenDismissalEnabled";
} // namespace mobile_notification

namespace hmi_levels {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "policy/usage_statistics/statistics_manager.h"
#include "utils/custom_string.h"
#include "utils/callable.h"
#include "utils/optional.h"
#include "policy/policy_settings.h"
#include "smart_objects/smart_object.h"
#include "policy/policy_types.h"
Expand Down Expand Up @@ -120,6 +121,7 @@ class PolicyHandlerInterface {
virtual uint32_t TimeoutExchangeMSec() const = 0;
virtual void OnExceededTimeout() = 0;
virtual void OnSystemReady() = 0;
virtual const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const = 0;
virtual void PTUpdatedAt(Counters counter, int value) = 0;
virtual void add_listener(PolicyHandlerObserver* listener) = 0;
virtual void remove_listener(PolicyHandlerObserver* listener) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <vector>

#include "utils/callable.h"
#include "utils/optional.h"

#include "policy/policy_types.h"
#include "policy/policy_table/types.h"
Expand Down Expand Up @@ -155,6 +156,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
*/
virtual void KmsChanged(int kilometers) = 0;

/**
* @brief Returns state of the lock screen that could be able to be dismissed
* while connected to SDL, allowing users the ability to interact with the
* app.
* @return bool True if lock screen is able to be dismissed.
*/
virtual const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const = 0;

/**
* @brief Increments counter of ignition cycles
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <cstdint>

#include "utils/callable.h"
#include "utils/optional.h"

#include "policy/policy_types.h"
#include "policy/policy_table/types.h"
#include "policy/policy_listener.h"
Expand Down Expand Up @@ -155,6 +157,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
*/
virtual void KmsChanged(int kilometers) = 0;

/**
* @brief Returns state of the lock screen that could be able to be dismissed
* while connected to SDL, allowing users the ability to interact with the
* app.
* @return bool True if lock screen is able to be dismissed.
*/
virtual const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const = 0;

/**
* @brief Increments counter of ignition cycles
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
MOCK_CONST_METHOD0(TimeoutExchangeMSec, uint32_t());
MOCK_METHOD0(OnExceededTimeout, void());
MOCK_METHOD0(OnSystemReady, void());
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const utils::OptionalVal<bool>());
MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value));
MOCK_METHOD1(add_listener, void(policy::PolicyHandlerObserver* listener));
MOCK_METHOD1(remove_listener, void(policy::PolicyHandlerObserver* listener));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id));
MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const utils::OptionalVal<bool>());
MOCK_CONST_METHOD1(GetDeviceConsent,
DeviceConsent(const std::string& device_id));
MOCK_METHOD2(SetDeviceConsent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD0(ResetUserConsent, bool());
MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string());
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const utils::OptionalVal<bool>());
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MockCacheManagerInterface : public CacheManagerInterface {
MOCK_METHOD0(TimeoutResponse, int());
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const utils::OptionalVal<bool>());
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
MOCK_METHOD2(GetUserFriendlyMsg,
std::vector<UserFriendlyMessage>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD0(ResetUserConsent, bool());
MOCK_CONST_METHOD0(GetPolicyTableStatus, std::string());
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const utils::OptionalVal<bool>());
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
Expand Down
7 changes: 7 additions & 0 deletions src/components/interfaces/MOBILE_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6775,6 +6775,13 @@
<param name="state" type="DriverDistractionState" mandatory="true">
<description>Current State of Driver Distraction</description>
</param>
<param name="lockScreenDismissalEnabled" type="Boolean" mandatory="false">
<description>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan formating of xml should be fixed

If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users
the ability to interact with the app. Dismissals should include a warning to the user and ensure
that they are not the driver.
</description>
</param>
</function>

<function name="OnPermissionsChange" functionID="OnPermissionsChangeID" messagetype="notification" since="2.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ class CacheManager : public CacheManagerInterface {
*/
virtual const VehicleInfo GetVehicleInfo() const;

/**
* @brief Returns state of the lock screen that could be able to be dismissed
* while connected to SDL, allowing users the ability to interact with the
* app.
* @return bool True if lock screen is able to be dismissed.
*/
const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const OVERRIDE;

/**
* @brief Allows to update 'vin' field in module_meta table.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <string>
#include <vector>
#include "utils/optional.h"

#include "policy/policy_table/types.h"
#include "policy/pt_representation.h"
Expand Down Expand Up @@ -165,6 +166,14 @@ class CacheManagerInterface {
*/
virtual const VehicleInfo GetVehicleInfo() const = 0;

/**
* @brief Returns state of the lock screen that could be able to be dismissed
* while connected to SDL, allowing users the ability to interact with the
* app.
* @return bool True if lock screen is able to be dismissed.
*/
virtual const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const = 0;

/**
* @brief Allows to update 'vin' field in module_meta table.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ class PolicyManagerImpl : public PolicyManager {
*/
void KmsChanged(int kilometers) OVERRIDE;

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan avoid description in overridings of the functions

* @brief Returns state of the lock screen that could be able to be dismissed
* while connected to SDL, allowing users the ability to interact with the
* app.
* @return bool True if lock screen is able to be dismissed.
*/
const utils::OptionalVal<bool> LockScreenDismissalEnabledState() const OVERRIDE;

/**
* @brief Increments counter of ignition cycles
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ struct ModuleConfig : CompositeType {
Optional<String<0, 65535> > certificate;
Optional<Boolean> preloaded_pt;
Optional<Boolean> full_app_id_supported;
Optional<Boolean> lock_screen_dismissal_enabled;

public:
ModuleConfig();
Expand Down
11 changes: 11 additions & 0 deletions src/components/policy/policy_external/src/cache_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "utils/file_system.h"
#include "utils/helpers.h"

#include "json/reader.h"
#include "json/features.h"
#include "json/writer.h"
Expand Down Expand Up @@ -1389,6 +1390,16 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
return vehicle_info;
}

const utils::OptionalVal<bool> CacheManager::LockScreenDismissalEnabledState() const {
CACHE_MANAGER_CHECK(utils::OptionalVal<bool>(utils::OptionalVal<bool>::EMPTY));
sync_primitives::AutoLock auto_lock(cache_lock_);
policy_table::ModuleConfig& module_config = pt_->policy_table.module_config;
if (module_config.lock_screen_dismissal_enabled.is_initialized()) {
return utils::OptionalVal<bool>(*module_config.lock_screen_dismissal_enabled);
}
return utils::OptionalVal<bool>(utils::OptionalVal<bool>::EMPTY);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan would be better to create initial empty variable and return it in CACHE_MANAGER_CHECK and outside the if. If it is possible to use this variable inside of, wold be wonderful

}

std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,11 @@ void PolicyManagerImpl::KmsChanged(int kilometers) {
}
}

const utils::OptionalVal<bool> PolicyManagerImpl::LockScreenDismissalEnabledState() const {
LOG4CXX_AUTO_TRACE(logger_);
return cache_->LockScreenDismissalEnabledState();
}

void PolicyManagerImpl::IncrementIgnitionCycles() {
cache_->IncrementIgnitionCycles();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,9 @@ ModuleConfig::ModuleConfig(const Json::Value* value__)
, preloaded_date(impl::ValueMember(value__, "preloaded_date"))
, certificate(impl::ValueMember(value__, "certificate"))
, preloaded_pt(impl::ValueMember(value__, "preloaded_pt"))
, full_app_id_supported(
impl::ValueMember(value__, "full_app_id_supported")) {}
, full_app_id_supported(impl::ValueMember(value__, "full_app_id_supported"))
, lock_screen_dismissal_enabled(
impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {}

void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
exchange_after_x_days = from.exchange_after_x_days;
Expand All @@ -583,6 +584,7 @@ void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) {
endpoints = from.endpoints;
notifications_per_minute_by_priority =
from.notifications_per_minute_by_priority;
lock_screen_dismissal_enabled = from.lock_screen_dismissal_enabled;

certificate.assign_if_valid(from.certificate);
vehicle_make.assign_if_valid(from.vehicle_make);
Expand Down Expand Up @@ -665,6 +667,9 @@ bool ModuleConfig::is_valid() const {
if (!preloaded_date.is_valid()) {
return false;
}
if (!lock_screen_dismissal_enabled.is_valid()) {
return false;
}
return Validate();
}

Expand Down
10 changes: 6 additions & 4 deletions src/components/policy/policy_external/src/sql_pt_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const std::string kCreateSchema =
" `vehicle_model` VARCHAR(45), "
" `vehicle_year` VARCHAR(4), "
" `preloaded_date` VARCHAR (10), "
" `certificate` VARCHAR (45) "
" `certificate` VARCHAR (45), "
" `lock_screen_dismissal_enabled` BOOL"
"); "
"CREATE TABLE IF NOT EXISTS `functional_group`( "
" `id` INTEGER PRIMARY KEY NOT NULL, "
Expand Down Expand Up @@ -418,7 +419,7 @@ const std::string kInsertInitData =
" VALUES (0, 0, 0, 0); "
"INSERT OR IGNORE INTO `module_config` (`preloaded_pt`, `is_first_run`,"
" `exchange_after_x_ignition_cycles`, `exchange_after_x_kilometers`, "
" `exchange_after_x_days`, `timeout_after_x_seconds`) "
" `exchange_after_x_days`, `timeout_after_x_seconds`)"
" VALUES(1, 0, 0, 0, 0, 0); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('EMERGENCY'); "
"INSERT OR IGNORE INTO `priority`(`value`) VALUES ('NAVIGATION'); "
Expand Down Expand Up @@ -668,7 +669,7 @@ const std::string kUpdateModuleConfig =
" `exchange_after_x_kilometers` = ?, `exchange_after_x_days` = ?, "
" `timeout_after_x_seconds` = ?, `vehicle_make` = ?, "
" `vehicle_model` = ?, `vehicle_year` = ?, `preloaded_date` = ?, "
" `certificate` = ? ";
" `certificate` = ?, lock_screen_dismissal_enabled = ?";

const std::string kInsertEndpoint =
"INSERT INTO `endpoint` (`service`, `url`, `application_id`) "
Expand Down Expand Up @@ -719,7 +720,8 @@ const std::string kSelectModuleConfig =
"SELECT `preloaded_pt`, `exchange_after_x_ignition_cycles`, "
" `exchange_after_x_kilometers`, `exchange_after_x_days`, "
" `timeout_after_x_seconds`, `vehicle_make`,"
" `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate` "
" `vehicle_model`, `vehicle_year`, `preloaded_date`, `certificate`, "
" `lock_screen_dismissal_enabled` "
" FROM `module_config`";

const std::string kSelectEndpoints =
Expand Down
Loading