diff options
44 files changed, 11 insertions, 830 deletions
diff --git a/src/components/application_manager/include/application_manager/core_service.h b/src/components/application_manager/include/application_manager/core_service.h index 9a89bf51a1..2ff5a8ed79 100644 --- a/src/components/application_manager/include/application_manager/core_service.h +++ b/src/components/application_manager/include/application_manager/core_service.h @@ -118,22 +118,6 @@ class CoreService : public Service { uint32_t GetDeviceHandlerById(const std::string& device_id) FINAL; /** - * Sets device as primary device - * @param dev_id ID device - */ - void SetPrimaryDevice(const uint32_t dev_id) FINAL; - - /** - * Resets driver's device - */ - void ResetPrimaryDevice() FINAL; - - /** - * Return id of primary device - */ - uint32_t PrimaryDevice() const FINAL; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ 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 be7fe3e5f2..0b1445039a 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 @@ -188,22 +188,6 @@ class PolicyHandler : public PolicyHandlerInterface, void ResetAccess(const std::string& module) OVERRIDE; /** - * Sets device as primary device - * @param dev_id ID device - */ - void SetPrimaryDevice(const PTString& dev_id) OVERRIDE; - - /** - * Resets driver's device - */ - void ResetPrimaryDevice() OVERRIDE; - - /** - * Return id of primary device - */ - uint32_t PrimaryDevice() const OVERRIDE; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ diff --git a/src/components/application_manager/include/application_manager/service.h b/src/components/application_manager/include/application_manager/service.h index 9f59d58c26..c1666554be 100644 --- a/src/components/application_manager/include/application_manager/service.h +++ b/src/components/application_manager/include/application_manager/service.h @@ -118,22 +118,6 @@ class Service { virtual uint32_t GetDeviceHandlerById(const std::string& device_id) = 0; /** - * Sets device as primary device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const uint32_t dev_id) = 0; - - /** - * Resets driver's device - */ - virtual void ResetPrimaryDevice() = 0; - - /** - * Return id of primary device - */ - virtual uint32_t PrimaryDevice() const = 0; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ diff --git a/src/components/application_manager/src/core_service.cc b/src/components/application_manager/src/core_service.cc index f30115443f..dd37484591 100644 --- a/src/components/application_manager/src/core_service.cc +++ b/src/components/application_manager/src/core_service.cc @@ -147,27 +147,6 @@ uint32_t CoreService::GetDeviceHandlerById(const std::string& device_id) { return device_handle; } -void CoreService::SetPrimaryDevice(const uint32_t dev_id) { -#ifdef SDL_REMOTE_CONTROL - std::string device_handle = - MessageHelper::GetDeviceMacAddressForHandle(dev_id, application_manager_); - application_manager_.GetPolicyHandler().SetPrimaryDevice(device_handle); -#endif // SDL_REMOTE_CONTROL -} - -void CoreService::ResetPrimaryDevice() { -#ifdef SDL_REMOTE_CONTROL - application_manager_.GetPolicyHandler().ResetPrimaryDevice(); -#endif // SDL_REMOTE_CONTROL -} - -uint32_t CoreService::PrimaryDevice() const { -#ifdef SDL_REMOTE_CONTROL - return application_manager_.GetPolicyHandler().PrimaryDevice(); -#endif // SDL_REMOTE_CONTROL - return 0; -} - void CoreService::SetRemoteControl(bool enabled) { #ifdef SDL_REMOTE_CONTROL application_manager_.GetPolicyHandler().SetRemoteControl(enabled); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index ad1bb499da..bf5d19eed6 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -2025,86 +2025,6 @@ void PolicyHandler::ResetAccess(const std::string& module) { policy_manager_->ResetAccess(module); } -void PolicyHandler::SetPrimaryDevice(const PTString& dev_id) { - using namespace application_manager; - POLICY_LIB_CHECK_VOID(); - PTString old_dev_id = policy_manager_->PrimaryDevice(); - if (dev_id == old_dev_id) { - LOG4CXX_INFO(logger_, "Driver's device has not changed."); - return; - } - policy_manager_->SetPrimaryDevice(dev_id); - - connection_handler::DeviceHandle old_device_handle; - application_manager_.connection_handler().GetDeviceID(old_dev_id, - &old_device_handle); - - connection_handler::DeviceHandle device_handle; - application_manager_.connection_handler().GetDeviceID(dev_id, &device_handle); - - LOG4CXX_DEBUG(logger_, - "Old: " << old_dev_id << "(" << old_device_handle << ")" - << "New: " << dev_id << "(" << device_handle << ")"); - std::map<connection_handler::DeviceHandle, PTString> devices; - devices[device_handle] = dev_id; - devices[old_device_handle] = old_dev_id; - DataAccessor<ApplicationSet> accessor = application_manager_.applications(); - for (ApplicationSetConstIt i = accessor.GetData().begin(); - i != accessor.GetData().end(); - ++i) { - const ApplicationSharedPtr app = *i; - LOG4CXX_DEBUG(logger_, - "Item: " << app->device() << " - " << app->policy_app_id()); - if (devices.find(app->device()) != devices.end()) { - LOG4CXX_DEBUG(logger_, - "Send notify " << app->device() << " - " - << app->policy_app_id()); - policy_manager_->OnChangedPrimaryDevice(devices[app->device()], - app->policy_app_id()); - } - } -} - -void PolicyHandler::ResetPrimaryDevice() { - POLICY_LIB_CHECK_VOID(); - PTString old_dev_id = policy_manager_->PrimaryDevice(); - policy_manager_->ResetPrimaryDevice(); - - connection_handler::DeviceHandle old_device_handle; - application_manager_.connection_handler().GetDeviceID(old_dev_id, - &old_device_handle); - - LOG4CXX_DEBUG(logger_, - "Old: " << old_dev_id << "(" << old_device_handle << ")"); - - DataAccessor<ApplicationSet> accessor = application_manager_.applications(); - for (ApplicationSetConstIt i = accessor.GetData().begin(); - i != accessor.GetData().end(); - ++i) { - const ApplicationSharedPtr app = *i; - LOG4CXX_DEBUG(logger_, - "Item: " << app->device() << " - " << app->policy_app_id()); - if (app->device() == old_device_handle) { - LOG4CXX_DEBUG(logger_, - "Send notify " << app->device() << " - " - << app->policy_app_id()); - policy_manager_->OnChangedPrimaryDevice(old_dev_id, app->policy_app_id()); - } - } -} - -uint32_t PolicyHandler::PrimaryDevice() const { - POLICY_LIB_CHECK(0); - PTString device_id = policy_manager_->PrimaryDevice(); - connection_handler::DeviceHandle device_handle; - if (application_manager_.connection_handler().GetDeviceID(device_id, - &device_handle)) { - return device_handle; - } else { - return 0; - } -} - void PolicyHandler::SetRemoteControl(bool enabled) { POLICY_LIB_CHECK_VOID(); policy_manager_->SetRemoteControl(enabled); diff --git a/src/components/application_manager/test/rc_policy_handler_test.cc b/src/components/application_manager/test/rc_policy_handler_test.cc index 6e44e4a0d6..7c24b84acb 100644 --- a/src/components/application_manager/test/rc_policy_handler_test.cc +++ b/src/components/application_manager/test/rc_policy_handler_test.cc @@ -330,100 +330,10 @@ TEST_F(RCPolicyHandlerTest, CheckModule_SUCCESS) { EXPECT_TRUE(policy_handler_.CheckModule(kPolicyAppId_, module)); } -TEST_F(RCPolicyHandlerTest, SetPrimaryDevice_EqualDeviceId_UNSUCCESS) { - EnablePolicyAndPolicyManagerMock(); - - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(kDeviceId_)); - - policy_handler_.SetPrimaryDevice(kDeviceId_); -} - ACTION_P(SetDeviceHandle, handle) { *arg1 = handle; } -TEST_F(RCPolicyHandlerTest, SetPrimaryDevice_DifferentSUCCESS) { - EnablePolicyAndPolicyManagerMock(); - const PTString old_device_id("00:00:00:00:00:01"); - - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(old_device_id)); - EXPECT_CALL(*mock_policy_manager_, SetPrimaryDevice(kDeviceId_)); - - connection_handler::DeviceHandle old_device_handle(1u); - EXPECT_CALL(conn_handler, GetDeviceID(old_device_id, _)) - .WillOnce(DoAll(SetDeviceHandle(old_device_handle), Return(true))); - - connection_handler::DeviceHandle device_handle(2u); - EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId_, _)) - .WillOnce(DoAll(SetDeviceHandle(device_handle), Return(true))); - - test_app.insert(mock_app_); - EXPECT_CALL(app_manager_, applications()).WillOnce(Return(app_set)); - - EXPECT_CALL(*mock_app_, device()) - .WillOnce(Return(device_handle)) - .WillOnce(Return(device_handle)); - EXPECT_CALL(*mock_app_, policy_app_id()) - .WillRepeatedly(Return(kPolicyAppId_)); - - EXPECT_CALL(*mock_policy_manager_, - OnChangedPrimaryDevice(kDeviceId_, kPolicyAppId_)); - - policy_handler_.SetPrimaryDevice(kDeviceId_); -} - -TEST_F(RCPolicyHandlerTest, ResetPrimaryDevice_DifferenrDevIds_SUCCESS) { - EnablePolicyAndPolicyManagerMock(); - - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(kMacAddr_)); - EXPECT_CALL(*mock_policy_manager_, ResetPrimaryDevice()); - - connection_handler::DeviceHandle old_device_handle(1u); - EXPECT_CALL(conn_handler, GetDeviceID(kMacAddr_, _)) - .WillOnce(DoAll(SetDeviceHandle(old_device_handle), Return(true))); - - test_app.insert(mock_app_); - EXPECT_CALL(app_manager_, applications()).WillOnce(Return(app_set)); - - EXPECT_CALL(*mock_app_, device()).WillRepeatedly(Return(old_device_handle)); - EXPECT_CALL(*mock_app_, policy_app_id()) - .WillRepeatedly(Return(kPolicyAppId_)); - - EXPECT_CALL(*mock_policy_manager_, - OnChangedPrimaryDevice(kMacAddr_, kPolicyAppId_)); - - policy_handler_.ResetPrimaryDevice(); -} - -TEST_F(RCPolicyHandlerTest, PrimaryDevice_ValidDeviceHandle_SUCCESS) { - EnablePolicyAndPolicyManagerMock(); - - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(kDeviceId_)); - - connection_handler::DeviceHandle device_handle(1u); - EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId_, _)) - .WillOnce(DoAll(SetDeviceHandle(device_handle), Return(true))); - - EXPECT_EQ(device_handle, policy_handler_.PrimaryDevice()); -} - -TEST_F(RCPolicyHandlerTest, PrimaryDevice_GetDeviceIdFalse_UNSUCCESS) { - EnablePolicyAndPolicyManagerMock(); - - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(kDeviceId_)); - - connection_handler::DeviceHandle device_handle(1u); - EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId_, _)) - .WillOnce(DoAll(SetDeviceHandle(device_handle), Return(false))); - - EXPECT_EQ(0u, policy_handler_.PrimaryDevice()); -} - TEST_F(RCPolicyHandlerTest, GetRemoteControl_SUCCESS) { EnablePolicyAndPolicyManagerMock(); EXPECT_CALL(*mock_policy_manager_, GetRemoteControl()).WillOnce(Return(true)); @@ -436,9 +346,6 @@ TEST_F(RCPolicyHandlerTest, SetRemoteControl_SUCCESS) { const bool enabled(true); EXPECT_CALL(*mock_policy_manager_, SetRemoteControl(enabled)); - EXPECT_CALL(*mock_policy_manager_, PrimaryDevice()) - .WillOnce(Return(kDeviceId_)); - connection_handler::DeviceHandle device_handle(1u); EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId_, _)) .WillOnce(DoAll(SetDeviceHandle(device_handle), Return(true))); diff --git a/src/components/functional_module/include/functional_module/generic_module.h b/src/components/functional_module/include/functional_module/generic_module.h index 9d003f4e28..212ec32185 100644 --- a/src/components/functional_module/include/functional_module/generic_module.h +++ b/src/components/functional_module/include/functional_module/generic_module.h @@ -127,24 +127,6 @@ class GenericModule { mobile_apis::HMILevel::eType old_level) = 0; /** - * @brief Checks if plugin hasn't put restrictions on app's HMI Level - * @param app App with old HMILevel - * @param new_level HMILevel which is about to be set to app - */ - virtual bool CanAppChangeHMILevel( - application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level) { - return true; - } - - /** - * Handles removing (disconnecting) device - * @param device removed - */ - virtual void OnDeviceRemoved( - const connection_handler::DeviceHandle& device) = 0; - - /** * @brief OnUnregisterApplication handles application unregistering event * @param app_id application id which was unregistered */ diff --git a/src/components/functional_module/include/functional_module/plugin_manager.h b/src/components/functional_module/include/functional_module/plugin_manager.h index 76efc516fc..ebf0b033c4 100644 --- a/src/components/functional_module/include/functional_module/plugin_manager.h +++ b/src/components/functional_module/include/functional_module/plugin_manager.h @@ -90,21 +90,6 @@ class PluginManager : public ModuleObserver { mobile_apis::HMILevel::eType old_level); /** - * @brief Checks if plugin hasn't put restrictions on app's HMI Level - * @param app App with old HMILevel - * @param new_level HMILevel which is about to be set to app - * @return false if any of the plugins returns false. - */ - bool CanAppChangeHMILevel(application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level); - - /** - * Handles removing (disconnecting) device - * @param device removed - */ - void OnDeviceRemoved(const connection_handler::DeviceHandle& device); - - /** * @brief OnUnregisterApplication handles application unregistering event * @param app_id application id which was unregistered */ diff --git a/src/components/functional_module/src/plugin_manager.cc b/src/components/functional_module/src/plugin_manager.cc index b74a948f5b..7ebafc3d09 100644 --- a/src/components/functional_module/src/plugin_manager.cc +++ b/src/components/functional_module/src/plugin_manager.cc @@ -334,42 +334,7 @@ void PluginManager::OnAppHMILevelChanged( } } -bool PluginManager::CanAppChangeHMILevel( - application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level) { - DCHECK_OR_RETURN(app, false); - bool result = true; - for (PluginsIterator it = plugins_.begin(); plugins_.end() != it; ++it) { - if (it->second->IsAppForPlugin(app)) { - result = result && it->second->CanAppChangeHMILevel(app, new_level); - LOG4CXX_DEBUG(logger_, - "Application " << app->name().AsMBString() << " of plugin " - << it->second->GetModuleID() << " is " - << (result ? "allowed" : "not allowed") - << " to change level to " << new_level); - } - } - return result; -} - typedef std::map<ModuleID, ModulePtr>::value_type PluginsValueType; -struct HandleDeviceRemoved { - private: - const connection_handler::DeviceHandle& device_; - - public: - explicit HandleDeviceRemoved(const connection_handler::DeviceHandle& device) - : device_(device) {} - void operator()(PluginsValueType& x) { - x.second->OnDeviceRemoved(device_); - } -}; - -void PluginManager::OnDeviceRemoved( - const connection_handler::DeviceHandle& device) { - LOG4CXX_AUTO_TRACE(logger_); - std::for_each(plugins_.begin(), plugins_.end(), HandleDeviceRemoved(device)); -} struct HandleApplicationUnregistered { private: diff --git a/src/components/functional_module/test/include/driver_generic_module_test.h b/src/components/functional_module/test/include/driver_generic_module_test.h index f41a274055..3e607226c6 100644 --- a/src/components/functional_module/test/include/driver_generic_module_test.h +++ b/src/components/functional_module/test/include/driver_generic_module_test.h @@ -67,8 +67,6 @@ class DriverGenericModuleTest : public GenericModule { return observers_; } - void OnDeviceRemoved(const connection_handler::DeviceHandle&) {} - void OnUnregisterApplication(const uint32_t app_id) {} }; diff --git a/src/components/functional_module/test/include/mock_service.h b/src/components/functional_module/test/include/mock_service.h index b8e8c40d34..0297855246 100644 --- a/src/components/functional_module/test/include/mock_service.h +++ b/src/components/functional_module/test/include/mock_service.h @@ -68,9 +68,6 @@ class MockService : public Service { MOCK_METHOD1(ResetAccess, void(const ApplicationId& app_id)); MOCK_METHOD1(ResetAccess, void(const std::string& module)); MOCK_METHOD1(GetDeviceHandlerById, uint32_t(const std::string& device_id)); - MOCK_METHOD1(SetPrimaryDevice, void(const uint32_t dev_id)); - MOCK_METHOD0(ResetPrimaryDevice, void()); - MOCK_CONST_METHOD0(PrimaryDevice, uint32_t()); MOCK_METHOD1(SetRemoteControl, void(bool enabled)); MOCK_METHOD1(RemoveHMIFakeParameters, void(application_manager::MessagePtr& message)); diff --git a/src/components/functional_module/test/plugins/mock_generic_module.h b/src/components/functional_module/test/plugins/mock_generic_module.h index aef0a68f19..fd9ec7b3ef 100644 --- a/src/components/functional_module/test/plugins/mock_generic_module.h +++ b/src/components/functional_module/test/plugins/mock_generic_module.h @@ -60,12 +60,7 @@ class MockGenericModule : public GenericModule { MOCK_METHOD2(OnAppHMILevelChanged, void(application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType old_level)); - MOCK_METHOD1(OnDeviceRemoved, - void(const connection_handler::DeviceHandle& device)); MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id)); - MOCK_METHOD2(CanAppChangeHMILevel, - bool(application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level)); MOCK_METHOD0(RemoveAppExtensions, void()); }; diff --git a/src/components/functional_module/test/src/plugin_manager_test.cc b/src/components/functional_module/test/src/plugin_manager_test.cc index 0868c66323..1692e2f06c 100644 --- a/src/components/functional_module/test/src/plugin_manager_test.cc +++ b/src/components/functional_module/test/src/plugin_manager_test.cc @@ -150,57 +150,4 @@ TEST_F(PluginManagerTest, OnAppHMILevelChanged) { mobile_apis::HMILevel::eType::HMI_FULL); } -TEST_F(PluginManagerTest, CanAppChangeHMILevel) { - using test::components::application_manager_test::MockApplication; - NiceMock<MockApplication>* app = new NiceMock<MockApplication>(); - application_manager::ApplicationSharedPtr app_ptr(app); - - const application_manager::custom_str::CustomString name("name"); - ON_CALL(*app, name()).WillByDefault(ReturnRef(name)); - - Expectation is_for_plugin = - EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).WillOnce(Return(true)); - EXPECT_CALL(*module, CanAppChangeHMILevel(app_ptr, _)) - .Times(1) - .After(is_for_plugin) - .WillOnce(Return(true)); - ASSERT_TRUE(manager->CanAppChangeHMILevel( - app_ptr, mobile_apis::HMILevel::eType::HMI_FULL)); -} - -TEST_F(PluginManagerTest, CanAppChangeHMILevelNegative) { - using test::components::application_manager_test::MockApplication; - NiceMock<MockApplication>* app = new NiceMock<MockApplication>(); - application_manager::ApplicationSharedPtr app_ptr(app); - - const application_manager::custom_str::CustomString name("name"); - ON_CALL(*app, name()).WillByDefault(ReturnRef(name)); - - Expectation is_for_plugin = - EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).WillOnce(Return(true)); - EXPECT_CALL(*module, CanAppChangeHMILevel(app_ptr, _)) - .Times(1) - .After(is_for_plugin) - .WillOnce(Return(false)); - ASSERT_FALSE(manager->CanAppChangeHMILevel( - app_ptr, mobile_apis::HMILevel::eType::HMI_BACKGROUND)); -} - -TEST_F(PluginManagerTest, CanAppChangeHMILevelNotForPlugin) { - using test::components::application_manager_test::MockApplication; - NiceMock<MockApplication>* app = new NiceMock<MockApplication>(); - application_manager::ApplicationSharedPtr app_ptr(app); - - const application_manager::custom_str::CustomString name("name"); - ON_CALL(*app, name()).WillByDefault(ReturnRef(name)); - - Expectation is_for_plugin = - EXPECT_CALL(*module, IsAppForPlugin(app_ptr)).WillOnce(Return(false)); - EXPECT_CALL(*module, CanAppChangeHMILevel(app_ptr, _)) - .Times(0) - .After(is_for_plugin); - ASSERT_TRUE(manager->CanAppChangeHMILevel( - app_ptr, mobile_apis::HMILevel::eType::HMI_BACKGROUND)); -} - } // namespace functional_modules 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 cb49f23b48..e49d86290c 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -495,22 +495,6 @@ class PolicyHandlerInterface { virtual void ResetAccess(const std::string& module) = 0; /** - * Sets device as primary device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const PTString& dev_id) = 0; - - /** - * Resets driver's device - */ - virtual void ResetPrimaryDevice() = 0; - - /** - * Return id of primary device - */ - virtual uint32_t PrimaryDevice() const = 0; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ 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 6bdf707f46..f6d1396be8 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -566,23 +566,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void ResetAccess(const PTString& module) = 0; /** - * Sets driver as primary device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const PTString& dev_id) = 0; - - /** - * Resets driver's device - */ - virtual void ResetPrimaryDevice() = 0; - - /** - * Gets current primary device - * @return ID device - */ - virtual PTString PrimaryDevice() const = 0; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ @@ -594,14 +577,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual bool GetRemoteControl() const = 0; - /** - * Handles changed primary device event for a application - * @param device_id Device on which app is running - * @param application_id ID application - */ - virtual void OnChangedPrimaryDevice(const std::string& device_id, - const std::string& application_id) = 0; - /* * Send OnPermissionsChange notification to mobile app * when it's permissions are changed. 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 d1dc7c7bb2..da59af08d8 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -540,23 +540,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void ResetAccess(const PTString& module) = 0; /** - * Sets driver as primary device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const PTString& dev_id) = 0; - - /** - * Resets driver's device - */ - virtual void ResetPrimaryDevice() = 0; - - /** - * Gets current primary device - * @return ID device - */ - virtual PTString PrimaryDevice() const = 0; - - /** * Sets mode of remote control (on/off) * @param enabled true if remote control is turned on */ @@ -568,14 +551,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { */ virtual bool GetRemoteControl() const = 0; - /** - * Handles changed primary device event for a application - * @param device_id Device on which app is running - * @param application_id ID application - */ - virtual void OnChangedPrimaryDevice(const std::string& device_id, - const std::string& application_id) = 0; - /* * Send OnPermissionsChange notification to mobile app * when it's permissions are changed. 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 00682372f5..2acbb16032 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 @@ -258,12 +258,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_METHOD1(ResetAccess, void(const std::string& module)); - MOCK_METHOD1(SetPrimaryDevice, void(const policy::PTString& dev_id)); - - MOCK_METHOD0(ResetPrimaryDevice, void()); - - MOCK_CONST_METHOD0(PrimaryDevice, uint32_t()); - MOCK_METHOD1(SetRemoteControl, void(bool enabled)); MOCK_CONST_METHOD0(GetRemoteControl, bool()); 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 4718e22c1b..3739d96caf 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 @@ -169,15 +169,8 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(ResetAccess, void(const PTString& dev_id, const PTString& app_id)); MOCK_METHOD1(ResetAccess, void(const PTString& module)); - MOCK_METHOD1(SetPrimaryDevice, void(const PTString& dev_id)); - MOCK_METHOD0(ResetPrimaryDevice, void()); - MOCK_CONST_METHOD0(PrimaryDevice, PTString()); - MOCK_METHOD1(SetRemoteControl, void(bool enabled)); MOCK_CONST_METHOD0(GetRemoteControl, bool()); - MOCK_METHOD2(OnChangedPrimaryDevice, - void(const std::string& device_id, - const std::string& application_id)); MOCK_METHOD2(SendAppPermissionsChanged, void(const std::string& device_id, const std::string& application_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 dbbebef13b..551b711ea0 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 @@ -168,15 +168,8 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(ResetAccess, void(const PTString& dev_id, const PTString& app_id)); MOCK_METHOD1(ResetAccess, void(const PTString& module)); - MOCK_METHOD1(SetPrimaryDevice, void(const PTString& dev_id)); - MOCK_METHOD0(ResetPrimaryDevice, void()); - MOCK_CONST_METHOD0(PrimaryDevice, PTString()); - MOCK_METHOD1(SetRemoteControl, void(bool enabled)); MOCK_CONST_METHOD0(GetRemoteControl, bool()); - MOCK_METHOD2(OnChangedPrimaryDevice, - void(const std::string& device_id, - const std::string& application_id)); MOCK_METHOD2(SendAppPermissionsChanged, void(const std::string& device_id, const std::string& application_id)); diff --git a/src/components/policy/policy_external/include/policy/access_remote.h b/src/components/policy/policy_external/include/policy/access_remote.h index 4a98c61dbb..33524bf229 100644 --- a/src/components/policy/policy_external/include/policy/access_remote.h +++ b/src/components/policy/policy_external/include/policy/access_remote.h @@ -115,25 +115,6 @@ class AccessRemote { virtual bool IsEnabled() const = 0; /** - * Checks whether device is driver's device - * @param dev_id unique device id - * @return true if device is have driver - */ - virtual bool IsPrimaryDevice(const PTString& dev_id) const = 0; - - /** - * Sets device as driver's device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const PTString& dev_id) = 0; - - /** - * Gets current primary device - * @return ID device - */ - virtual PTString PrimaryDevice() const = 0; - - /** * Allows access subject to object * @param who subject is dev_id and app_id * @param what object is group_id diff --git a/src/components/policy/policy_external/include/policy/access_remote_impl.h b/src/components/policy/policy_external/include/policy/access_remote_impl.h index 72223dccab..749edd6ce2 100644 --- a/src/components/policy/policy_external/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_external/include/policy/access_remote_impl.h @@ -53,10 +53,6 @@ class AccessRemoteImpl : public AccessRemote { virtual void Disable(); virtual bool IsEnabled() const; - virtual bool IsPrimaryDevice(const PTString& dev_id) const; - virtual void SetPrimaryDevice(const PTString& dev_id); - virtual PTString PrimaryDevice() const; - virtual void Allow(const Subject& who, const Object& what); virtual void Deny(const Subject& who, const Object& what); virtual void Reset(const Subject& who); @@ -92,7 +88,6 @@ class AccessRemoteImpl : public AccessRemote { bool CompareParameters(const policy_table::Strings& parameters, RemoteControlParams* input) const; utils::SharedPtr<CacheManager> cache_; - PTString primary_device_; bool enabled_; AccessControlList acl_; HMIList hmi_types_; 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 95d654bc18..653dbf5281 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 @@ -394,13 +394,8 @@ class PolicyManagerImpl : public PolicyManager { bool allowed); virtual void ResetAccess(const PTString& dev_id, const PTString& app_id); virtual void ResetAccess(const PTString& module); - virtual void SetPrimaryDevice(const PTString& dev_id); - virtual void ResetPrimaryDevice(); - virtual PTString PrimaryDevice() const; virtual void SetRemoteControl(bool enabled); virtual bool GetRemoteControl() const; - virtual void OnChangedPrimaryDevice(const std::string& device_id, - const std::string& application_id); virtual void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id); virtual bool GetModuleTypes(const std::string& policy_app_id, 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 ab95659917..9ba1a1cfff 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -57,7 +57,6 @@ const std::string kDefaultDeviceConnectionType = "UNKNOWN"; const std::string kPreDataConsentId = "pre_DataConsent"; const std::string kDefaultId = "default"; const std::string kDeviceId = "device"; -const std::string kPrimary = "rc_primaryDevice"; /* *@brief Policy Services specifies Users of Updates diff --git a/src/components/policy/policy_external/src/access_remote_impl.cc b/src/components/policy/policy_external/src/access_remote_impl.cc index 4e6b49c2dd..cbed4aeb5c 100644 --- a/src/components/policy/policy_external/src/access_remote_impl.cc +++ b/src/components/policy/policy_external/src/access_remote_impl.cc @@ -111,10 +111,10 @@ struct ToModuleType { }; AccessRemoteImpl::AccessRemoteImpl() - : cache_(new CacheManager()), primary_device_(), enabled_(true), acl_() {} + : cache_(new CacheManager()), enabled_(true), acl_() {} AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache) - : cache_(cache), primary_device_(), enabled_(true), acl_() {} + : cache_(cache), enabled_(true), acl_() {} void AccessRemoteImpl::Init() { LOG4CXX_AUTO_TRACE(logger_); @@ -125,11 +125,6 @@ void AccessRemoteImpl::Init() { enabled_ = true; } -bool AccessRemoteImpl::IsPrimaryDevice(const PTString& dev_id) const { - LOG4CXX_AUTO_TRACE(logger_); - return primary_device_ == dev_id; -} - TypeAccess AccessRemoteImpl::Check(const Subject& who, const Object& what) const { LOG4CXX_AUTO_TRACE(logger_); @@ -236,15 +231,6 @@ void AccessRemoteImpl::Reset() { acl_.clear(); } -void AccessRemoteImpl::SetPrimaryDevice(const PTString& dev_id) { - LOG4CXX_AUTO_TRACE(logger_); - primary_device_ = dev_id; -} - -PTString AccessRemoteImpl::PrimaryDevice() const { - return primary_device_; -} - void AccessRemoteImpl::Enable() { LOG4CXX_AUTO_TRACE(logger_); set_enabled(true); @@ -290,10 +276,8 @@ const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes( const policy_table::Strings& AccessRemoteImpl::GetGroups(const Subject& who) { LOG4CXX_AUTO_TRACE(logger_); if (IsAppRemoteControl(who)) { - if (IsPrimaryDevice(who.dev_id)) { - return *cache_->pt_->policy_table.app_policies_section.apps[who.app_id] - .groups_primaryRC; - } + return *cache_->pt_->policy_table.app_policies_section.apps[who.app_id] + .groups_primaryRC; } return cache_->GetGroups(who.app_id); } 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 3e6cb62ecc..ec618859cd 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -2048,21 +2048,6 @@ void PolicyManagerImpl::ResetAccess(const PTString& module) { access_remote_->Reset(what); } -void PolicyManagerImpl::SetPrimaryDevice(const PTString& dev_id) { - LOG4CXX_AUTO_TRACE(logger_); - access_remote_->SetPrimaryDevice(dev_id); -} - -void PolicyManagerImpl::ResetPrimaryDevice() { - LOG4CXX_AUTO_TRACE(logger_); - access_remote_->SetPrimaryDevice(""); -} - -PTString PolicyManagerImpl::PrimaryDevice() const { - LOG4CXX_AUTO_TRACE(logger_); - return access_remote_->PrimaryDevice(); -} - void PolicyManagerImpl::SetRemoteControl(bool enabled) { LOG4CXX_AUTO_TRACE(logger_); if (enabled) { @@ -2076,18 +2061,6 @@ bool PolicyManagerImpl::GetRemoteControl() const { return access_remote_->IsEnabled(); } -void PolicyManagerImpl::OnChangedPrimaryDevice( - const std::string& device_id, const std::string& application_id) { - LOG4CXX_AUTO_TRACE(logger_); - Subject who = {device_id, application_id}; - if (!access_remote_->IsAppRemoteControl(who)) { - LOG4CXX_INFO(logger_, "Application " << who << " isn't remote"); - return; - } - - SendAppPermissionsChanged(who.dev_id, who.app_id); -} - void PolicyManagerImpl::SendHMILevelChanged(const Subject& who) { std::string default_hmi("NONE"); if (GetDefaultHmi(who.app_id, &default_hmi)) { @@ -2158,8 +2131,7 @@ void PolicyManagerImpl::OnPrimaryGroupsChanged( i != devices.end(); ++i) { const Subject who = {*i, application_id}; - if (access_remote_->IsAppRemoteControl(who) && - access_remote_->IsPrimaryDevice(who.dev_id)) { + if (access_remote_->IsAppRemoteControl(who)) { SendAppPermissionsChanged(who.dev_id, who.app_id); } } diff --git a/src/components/policy/policy_external/test/include/policy/mock_access_remote.h b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h index 01e48805b6..a0cb60fa9a 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_access_remote.h +++ b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h @@ -53,9 +53,6 @@ class MockAccessRemote : public policy::AccessRemote { MOCK_METHOD0(Enable, void()); MOCK_METHOD0(Disable, void()); MOCK_CONST_METHOD0(IsEnabled, bool()); - MOCK_CONST_METHOD1(IsPrimaryDevice, bool(const policy::PTString& dev_id)); - MOCK_METHOD1(SetPrimaryDevice, void(const policy::PTString& dev_id)); - MOCK_CONST_METHOD0(PrimaryDevice, policy::PTString()); MOCK_METHOD2(Allow, void(const policy::Subject& who, const policy::Object& what)); diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h index b9fd8862e9..e0d02f6f36 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote.h +++ b/src/components/policy/policy_regular/include/policy/access_remote.h @@ -118,25 +118,6 @@ class AccessRemote { virtual bool IsEnabled() const = 0; /** - * Checks whether device is driver's device - * @param dev_id unique device id - * @return true if device is have driver - */ - virtual bool IsPrimaryDevice(const PTString& dev_id) const = 0; - - /** - * Sets device as driver's device - * @param dev_id ID device - */ - virtual void SetPrimaryDevice(const PTString& dev_id) = 0; - - /** - * Gets current primary device - * @return ID device - */ - virtual PTString PrimaryDevice() const = 0; - - /** * Allows access subject to object * @param who subject is dev_id and app_id * @param what object is group_id diff --git a/src/components/policy/policy_regular/include/policy/access_remote_impl.h b/src/components/policy/policy_regular/include/policy/access_remote_impl.h index 2faf635f24..d15b707cca 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h @@ -57,10 +57,6 @@ class AccessRemoteImpl : public AccessRemote { virtual void Disable(); virtual bool IsEnabled() const; - virtual bool IsPrimaryDevice(const PTString& dev_id) const; - virtual void SetPrimaryDevice(const PTString& dev_id); - virtual PTString PrimaryDevice() const; - virtual void Allow(const Subject& who, const Object& what); virtual void Deny(const Subject& who, const Object& what); virtual void Reset(const Subject& who); @@ -92,7 +88,6 @@ class AccessRemoteImpl : public AccessRemote { bool CompareParameters(const policy_table::Strings& parameters, RemoteControlParams* input) const; utils::SharedPtr<CacheManager> cache_; - PTString primary_device_; bool enabled_; AccessControlList acl_; HMIList hmi_types_; 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 74dbeff3c9..73286414be 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 @@ -365,13 +365,8 @@ class PolicyManagerImpl : public PolicyManager { bool allowed); virtual void ResetAccess(const PTString& dev_id, const PTString& app_id); virtual void ResetAccess(const PTString& module); - virtual void SetPrimaryDevice(const PTString& dev_id); - virtual void ResetPrimaryDevice(); - virtual PTString PrimaryDevice() const; virtual void SetRemoteControl(bool enabled); virtual bool GetRemoteControl() const; - virtual void OnChangedPrimaryDevice(const std::string& device_id, - const std::string& application_id); virtual void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id); virtual bool GetModuleTypes(const std::string& policy_app_id, diff --git a/src/components/policy/policy_regular/src/access_remote_impl.cc b/src/components/policy/policy_regular/src/access_remote_impl.cc index a501cf05fa..8d076fbb5b 100644 --- a/src/components/policy/policy_regular/src/access_remote_impl.cc +++ b/src/components/policy/policy_regular/src/access_remote_impl.cc @@ -111,10 +111,10 @@ struct ToModuleType { }; AccessRemoteImpl::AccessRemoteImpl() - : cache_(new CacheManager()), primary_device_(), enabled_(true), acl_() {} + : cache_(new CacheManager()), enabled_(true), acl_() {} AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache) - : cache_(cache), primary_device_(), enabled_(true), acl_() {} + : cache_(cache), enabled_(true), acl_() {} void AccessRemoteImpl::Init() { LOG4CXX_AUTO_TRACE(logger_); @@ -125,11 +125,6 @@ void AccessRemoteImpl::Init() { enabled_ = true; } -bool AccessRemoteImpl::IsPrimaryDevice(const PTString& dev_id) const { - LOG4CXX_AUTO_TRACE(logger_); - return primary_device_ == dev_id; -} - TypeAccess AccessRemoteImpl::Check(const Subject& who, const Object& what) const { LOG4CXX_AUTO_TRACE(logger_); @@ -236,15 +231,6 @@ void AccessRemoteImpl::Reset() { acl_.clear(); } -void AccessRemoteImpl::SetPrimaryDevice(const PTString& dev_id) { - LOG4CXX_AUTO_TRACE(logger_); - primary_device_ = dev_id; -} - -PTString AccessRemoteImpl::PrimaryDevice() const { - return primary_device_; -} - void AccessRemoteImpl::Enable() { LOG4CXX_AUTO_TRACE(logger_); set_enabled(true); @@ -291,11 +277,9 @@ const policy_table::AppHMITypes& AccessRemoteImpl::HmiTypes( const policy_table::Strings& AccessRemoteImpl::GetGroups(const Subject& who) { LOG4CXX_AUTO_TRACE(logger_); if (IsAppRemoteControl(who)) { - if (IsPrimaryDevice(who.dev_id)) { - return *cache_->pt() - ->policy_table.app_policies_section.apps[who.app_id] - .groups_primaryRC; - } + return *cache_->pt() + ->policy_table.app_policies_section.apps[who.app_id] + .groups_primaryRC; } return cache_->GetGroups(who.app_id); } 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 f2ce3a0e5d..7ca4c5f3ac 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1278,21 +1278,6 @@ void PolicyManagerImpl::ResetAccess(const PTString& module) { access_remote_->Reset(what); } -void PolicyManagerImpl::SetPrimaryDevice(const PTString& dev_id) { - LOG4CXX_AUTO_TRACE(logger_); - access_remote_->SetPrimaryDevice(dev_id); -} - -void PolicyManagerImpl::ResetPrimaryDevice() { - LOG4CXX_AUTO_TRACE(logger_); - access_remote_->SetPrimaryDevice(""); -} - -PTString PolicyManagerImpl::PrimaryDevice() const { - LOG4CXX_AUTO_TRACE(logger_); - return access_remote_->PrimaryDevice(); -} - void PolicyManagerImpl::SetRemoteControl(bool enabled) { LOG4CXX_AUTO_TRACE(logger_); if (enabled) { @@ -1306,18 +1291,6 @@ bool PolicyManagerImpl::GetRemoteControl() const { return access_remote_->IsEnabled(); } -void PolicyManagerImpl::OnChangedPrimaryDevice( - const std::string& device_id, const std::string& application_id) { - LOG4CXX_AUTO_TRACE(logger_); - Subject who = {device_id, application_id}; - if (!access_remote_->IsAppRemoteControl(who)) { - LOG4CXX_INFO(logger_, "Application " << who << " isn't remote"); - return; - } - - SendAppPermissionsChanged(who.dev_id, who.app_id); -} - void PolicyManagerImpl::SendHMILevelChanged(const Subject& who) { std::string default_hmi("NONE"); if (GetDefaultHmi(who.app_id, &default_hmi)) { @@ -1388,8 +1361,7 @@ void PolicyManagerImpl::OnPrimaryGroupsChanged( i != devices.end(); ++i) { const Subject who = {*i, application_id}; - if (access_remote_->IsAppRemoteControl(who) && - access_remote_->IsPrimaryDevice(who.dev_id)) { + if (access_remote_->IsAppRemoteControl(who)) { SendAppPermissionsChanged(who.dev_id, who.app_id); } } diff --git a/src/components/policy/policy_regular/test/access_remote_impl_test.cc b/src/components/policy/policy_regular/test/access_remote_impl_test.cc index 58b2b28787..ef4151adfa 100644 --- a/src/components/policy/policy_regular/test/access_remote_impl_test.cc +++ b/src/components/policy/policy_regular/test/access_remote_impl_test.cc @@ -214,7 +214,6 @@ TEST(AccessRemoteImplTest, SetDefaultHmiTypes) { TEST(AccessRemoteImplTest, GetGroups) { AccessRemoteImpl access_remote; - access_remote.primary_device_ = "dev1"; access_remote.enabled_ = true; Subject who = {"dev1", "1234"}; access_remote.hmi_types_[who].push_back(policy_table::AHT_REMOTE_CONTROL); diff --git a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h index 8c5bf75ba5..ffd0c5eba0 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h @@ -53,10 +53,6 @@ class MockAccessRemote : public policy::AccessRemote { MOCK_METHOD0(Enable, void()); MOCK_METHOD0(Disable, void()); MOCK_CONST_METHOD0(IsEnabled, bool()); - MOCK_CONST_METHOD1(IsPrimaryDevice, bool(const policy::PTString& dev_id)); - MOCK_METHOD1(SetPrimaryDevice, void(const policy::PTString& dev_id)); - MOCK_CONST_METHOD0(PrimaryDevice, policy::PTString()); - MOCK_METHOD2(Allow, void(const policy::Subject& who, const policy::Object& what)); MOCK_METHOD2(Deny, diff --git a/src/components/remote_control/include/remote_control/commands/base_command_request.h b/src/components/remote_control/include/remote_control/commands/base_command_request.h index 2ef7f19cec..315acfd6c2 100644 --- a/src/components/remote_control/include/remote_control/commands/base_command_request.h +++ b/src/components/remote_control/include/remote_control/commands/base_command_request.h @@ -251,9 +251,6 @@ class BaseCommandRequest private: void CheckHMILevel(application_manager::TypeAccess access, bool hmi_consented = false); - void UpdateHMILevel( - const rc_event_engine::Event<application_manager::MessagePtr, - std::string>& event); /** * @brief CheckPolicyPermissions checks RPC permissions defined in policy diff --git a/src/components/remote_control/include/remote_control/policy_helper.h b/src/components/remote_control/include/remote_control/policy_helper.h index 1ca578c8aa..8d1fcc184b 100644 --- a/src/components/remote_control/include/remote_control/policy_helper.h +++ b/src/components/remote_control/include/remote_control/policy_helper.h @@ -43,17 +43,6 @@ class PolicyHelper { public: static void OnRSDLFunctionalityAllowing(bool allowed, RemotePluginInterface& rc_module); - static void SetIsAppOnPrimaryDevice( - application_manager::ApplicationSharedPtr app, - RemotePluginInterface& rc_module); - - private: - static void MarkApplications(const uint32_t device_handle, - RemotePluginInterface& rc_module); - static void MarkAppOnPrimaryDevice( - application_manager::ApplicationSharedPtr app, - const uint32_t device_handle, - RemotePluginInterface& rc_module); }; } // namespace remote_control diff --git a/src/components/remote_control/include/remote_control/rc_app_extension.h b/src/components/remote_control/include/remote_control/rc_app_extension.h index 07a8eecb67..f9d0cfa84d 100644 --- a/src/components/remote_control/include/remote_control/rc_app_extension.h +++ b/src/components/remote_control/include/remote_control/rc_app_extension.h @@ -59,14 +59,6 @@ class RCAppExtension : public application_manager::AppExtension { */ void GiveControl(bool is_control_given); - bool is_on_driver_device() const { - return is_on_driver_device_; - } - - void set_is_on_driver_device(bool is_driver_dev) { - is_on_driver_device_ = is_driver_dev; - } - /** * @brief Subscribe to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) diff --git a/src/components/remote_control/include/remote_control/remote_control_plugin.h b/src/components/remote_control/include/remote_control/remote_control_plugin.h index 9875723f43..85df1d51d1 100644 --- a/src/components/remote_control/include/remote_control/remote_control_plugin.h +++ b/src/components/remote_control/include/remote_control/remote_control_plugin.h @@ -92,21 +92,6 @@ class RemoteControlPlugin : public RemotePluginInterface { mobile_apis::HMILevel::eType old_level); /** - * @brief Checks if plugin hasn't put restrictions on app's HMI Level - * @param app App with old HMILevel - * @param new_level HMILevel which is about to be set to app - */ - virtual bool CanAppChangeHMILevel( - application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level); - - /** - * Handles removing (disconnecting) device - * @param device removed - */ - void OnDeviceRemoved(const connection_handler::DeviceHandle& device) OVERRIDE; - - /** * @brief OnUnregisterApplication handles application unregistering event * @param app_id application id which was unregistered */ diff --git a/src/components/remote_control/include/remote_control/remote_plugin_interface.h b/src/components/remote_control/include/remote_control/remote_plugin_interface.h index 670d8e1548..64aa7208a5 100644 --- a/src/components/remote_control/include/remote_control/remote_plugin_interface.h +++ b/src/components/remote_control/include/remote_control/remote_plugin_interface.h @@ -94,22 +94,6 @@ class RemotePluginInterface : public functional_modules::GenericModule { application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType old_level) = 0; - /** - * @brief Checks if plugin hasn't put restrictions on app's HMI Level - * @param app App with old HMILevel - * @param new_level HMILevel which is about to be set to app - */ - virtual bool CanAppChangeHMILevel( - application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level) = 0; - - /** - * Handles removing (disconnecting) device - * @param device removed - */ - virtual void OnDeviceRemoved( - const connection_handler::DeviceHandle& device) = 0; - virtual void SendHmiStatusNotification( application_manager::ApplicationSharedPtr app) = 0; diff --git a/src/components/remote_control/src/commands/base_command_request.cc b/src/components/remote_control/src/commands/base_command_request.cc index e3b0384e49..32a12ed8fd 100644 --- a/src/components/remote_control/src/commands/base_command_request.cc +++ b/src/components/remote_control/src/commands/base_command_request.cc @@ -487,31 +487,10 @@ void BaseCommandRequest::on_event( if (event.id() == functional_modules::hmi_api::get_user_consent) { ProcessAccessResponse(event); } else { - if (auto_allowed()) { - UpdateHMILevel(event); - } OnEvent(event); // run child's logic } } -void BaseCommandRequest::UpdateHMILevel( - const rc_event_engine::Event<application_manager::MessagePtr, std::string>& - event) { - LOG4CXX_AUTO_TRACE(logger_); - RCAppExtensionPtr extension = GetAppExtension(app_); - if (!extension) { - return; - } - if (!extension->is_on_driver_device()) { - Json::Value value = - MessageHelper::StringToValue(event.event_message()->json_message()); - std::string result_code; - std::string info; - bool success = ParseResultCode(value, result_code, info); - CheckHMILevel(application_manager::kAllowed, success); - } -} - void BaseCommandRequest::ProcessAccessResponse( const rc_event_engine::Event<application_manager::MessagePtr, std::string>& event) { diff --git a/src/components/remote_control/src/policy_helper.cc b/src/components/remote_control/src/policy_helper.cc index dadb84bd3e..e50233fe2b 100644 --- a/src/components/remote_control/src/policy_helper.cc +++ b/src/components/remote_control/src/policy_helper.cc @@ -44,34 +44,4 @@ void PolicyHelper::OnRSDLFunctionalityAllowing( rc_module.service()->SetRemoteControl(allowed); } -void PolicyHelper::SetIsAppOnPrimaryDevice( - application_manager::ApplicationSharedPtr app, - RemotePluginInterface& rc_module) { - MarkAppOnPrimaryDevice(app, rc_module.service()->PrimaryDevice(), rc_module); -} - -void PolicyHelper::MarkAppOnPrimaryDevice( - application_manager::ApplicationSharedPtr app, - const uint32_t device_handle, - RemotePluginInterface& rc_module) { - application_manager::AppExtensionUID module_id = rc_module.GetModuleID(); - RCAppExtensionPtr extension = - application_manager::AppExtensionPtr::static_pointer_cast<RCAppExtension>( - app->QueryInterface(module_id)); - DCHECK(extension); - bool is_driver = (app->device() == device_handle); - extension->set_is_on_driver_device(is_driver); -} - -void PolicyHelper::MarkApplications(const uint32_t device_handle, - RemotePluginInterface& rc_module) { - application_manager::AppExtensionUID module_id = rc_module.GetModuleID(); - std::vector<application_manager::ApplicationSharedPtr> applications = - rc_module.service()->GetApplications(module_id); - - for (size_t i = 0; i < applications.size(); ++i) { - MarkAppOnPrimaryDevice(applications[i], device_handle, rc_module); - } -} - } // namespace remote_control diff --git a/src/components/remote_control/src/remote_control_plugin.cc b/src/components/remote_control/src/remote_control_plugin.cc index 449379f4bc..5ecc587cfd 100644 --- a/src/components/remote_control/src/remote_control_plugin.cc +++ b/src/components/remote_control/src/remote_control_plugin.cc @@ -296,8 +296,6 @@ bool RemoteControlPlugin::IsAppForPlugin( RCAppExtensionPtr rc_app_extension = new RCAppExtension(GetModuleID()); app->AddExtension(rc_app_extension); service()->NotifyHMIAboutHMILevel(app, app->hmi_level()); - service()->SetPrimaryDevice(app->device()); - PolicyHelper::SetIsAppOnPrimaryDevice(app, *this); return true; } return false; @@ -313,33 +311,6 @@ void RemoteControlPlugin::OnAppHMILevelChanged( service()->NotifyHMIAboutHMILevel(app, app->hmi_level()); } -bool RemoteControlPlugin::CanAppChangeHMILevel( - application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level) { - application_manager::AppExtensionPtr app_extension = - app->QueryInterface(GetModuleID()); - if (!app_extension) { - return true; - } - RCAppExtensionPtr rc_app_extension = - application_manager::AppExtensionPtr::static_pointer_cast<RCAppExtension>( - app_extension); - if (new_level == mobile_apis::HMILevel::eType::HMI_FULL || - new_level == mobile_apis::HMILevel::eType::HMI_LIMITED) { - return rc_app_extension->is_on_driver_device(); - } - return true; -} - -void RemoteControlPlugin::OnDeviceRemoved( - const connection_handler::DeviceHandle& device) { - LOG4CXX_AUTO_TRACE(logger_); - bool is_driver = service()->PrimaryDevice() == device; - if (is_driver) { - service()->ResetPrimaryDevice(); - } -} - void RemoteControlPlugin::OnUnregisterApplication(const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); resource_allocation_manager_.OnUnregisterApplication(app_id); diff --git a/src/components/remote_control/test/include/mock_remote_control_plugin.h b/src/components/remote_control/test/include/mock_remote_control_plugin.h index fccaac2828..cae623af14 100644 --- a/src/components/remote_control/test/include/mock_remote_control_plugin.h +++ b/src/components/remote_control/test/include/mock_remote_control_plugin.h @@ -32,11 +32,6 @@ class MockRemotePluginInterface : public remote_control::RemotePluginInterface { MOCK_METHOD2(OnAppHMILevelChanged, void(application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType old_level)); - MOCK_METHOD2(CanAppChangeHMILevel, - bool(application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType new_level)); - MOCK_METHOD1(OnDeviceRemoved, - void(const connection_handler::DeviceHandle& device)); MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id)); MOCK_METHOD1(SendHmiStatusNotification, void(application_manager::ApplicationSharedPtr app)); diff --git a/src/components/remote_control/test/src/rc_app_extension_test.cc b/src/components/remote_control/test/src/rc_app_extension_test.cc index 5022853e30..163d09b9d0 100644 --- a/src/components/remote_control/test/src/rc_app_extension_test.cc +++ b/src/components/remote_control/test/src/rc_app_extension_test.cc @@ -48,12 +48,4 @@ TEST(CanAppExtensionTest, Control) { ASSERT_TRUE(extension.IsControlGiven()); } -TEST(CanAppExtensionTest, DriverDevice) { - RCAppExtension extension(5); - ASSERT_EQ(5, extension.uid()); - ASSERT_FALSE(extension.is_on_driver_device()); - extension.set_is_on_driver_device(true); - ASSERT_TRUE(extension.is_on_driver_device()); -} - } // namespace remote_control diff --git a/src/components/remote_control/test/src/rc_module_test.cc b/src/components/remote_control/test/src/rc_module_test.cc index 556bcd018c..59e9159f48 100644 --- a/src/components/remote_control/test/src/rc_module_test.cc +++ b/src/components/remote_control/test/src/rc_module_test.cc @@ -216,7 +216,6 @@ TEST_F(RCModuleTest, IsAppForPluginSuccess) { EXPECT_CALL(*app0_, hmi_level()).WillRepeatedly(Return(hmi)); ON_CALL(*app0_, device()).WillByDefault(Return(1)); EXPECT_CALL(*mock_service_, NotifyHMIAboutHMILevel(Eq(app0_), _)); - EXPECT_CALL(*mock_service_, PrimaryDevice()); EXPECT_CALL(*mock_service_, IsRemoteControlApplication(Eq(app0_))) .WillOnce(Return(true)); ASSERT_TRUE(module_.IsAppForPlugin(app0_)); @@ -250,62 +249,4 @@ TEST_F(RCModuleTest, OnAppHMILevelChanged) { module_.OnAppHMILevelChanged(app0_, mobile_apis::HMILevel::eType::HMI_FULL); } -TEST_F(RCModuleTest, SetDriverDeviceOnRegister) { - application_manager::AppExtensionPtr invalid_ext; - EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID())) - .Times(2) - .WillOnce(Return(invalid_ext)) - .WillRepeatedly(Return(rc_app_extention_)); - EXPECT_CALL(*app0_, AddExtension(_)).WillOnce(Return(true)); - ON_CALL(*app0_, device()).WillByDefault(Return(12)); - mobile_apis::HMILevel::eType hmi = mobile_apis::HMILevel::eType::HMI_NONE; - EXPECT_CALL(*app0_, hmi_level()).Times(1).WillRepeatedly(Return(hmi)); - EXPECT_CALL(*mock_service_, NotifyHMIAboutHMILevel(Eq(app0_), _)).Times(1); - EXPECT_CALL(*mock_service_, PrimaryDevice()).Times(1).WillOnce(Return(12)); - EXPECT_CALL(*mock_service_, IsRemoteControlApplication(Eq(app0_))) - .Times(1) - .WillOnce(Return(true)); - - ASSERT_TRUE(module_.IsAppForPlugin(app0_)); - ASSERT_TRUE(rc_app_extention_->is_on_driver_device()); -} - -TEST_F(RCModuleTest, SetDriverDeviceOnRegisterFail) { - application_manager::AppExtensionPtr invalid_ext; - EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID())) - .Times(2) - .WillOnce(Return(invalid_ext)) - .WillRepeatedly(Return(rc_app_extention_)); - EXPECT_CALL(*app0_, AddExtension(_)).WillOnce(Return(true)); - mobile_apis::HMILevel::eType hmi = mobile_apis::HMILevel::eType::HMI_FULL; - EXPECT_CALL(*app0_, hmi_level()).WillRepeatedly(Return(hmi)); - ON_CALL(*app0_, device()).WillByDefault(Return(12)); - EXPECT_CALL(*mock_service_, NotifyHMIAboutHMILevel(Eq(app0_), _)).Times(1); - EXPECT_CALL(*mock_service_, PrimaryDevice()).Times(1).WillOnce(Return(3)); - EXPECT_CALL(*mock_service_, IsRemoteControlApplication(Eq(app0_))) - .Times(1) - .WillOnce(Return(true)); - - ASSERT_TRUE(module_.IsAppForPlugin(app0_)); - ASSERT_FALSE(rc_app_extention_->is_on_driver_device()); -} - -TEST_F(RCModuleTest, CanAppChangeHMILevelPrimary) { - apps_.push_back(app0_); - - rc_app_extention_->set_is_on_driver_device(true); - - EXPECT_CALL(*app0_, QueryInterface(module_.GetModuleID())) - .WillRepeatedly(Return(rc_app_extention_)); - - ASSERT_TRUE(module_.CanAppChangeHMILevel( - app0_, mobile_apis::HMILevel::eType::HMI_FULL)); - ASSERT_TRUE(module_.CanAppChangeHMILevel( - app0_, mobile_apis::HMILevel::eType::HMI_LIMITED)); - ASSERT_TRUE(module_.CanAppChangeHMILevel( - app0_, mobile_apis::HMILevel::eType::HMI_BACKGROUND)); - ASSERT_TRUE(module_.CanAppChangeHMILevel( - app0_, mobile_apis::HMILevel::eType::HMI_NONE)); -} - } // namespace remote_control |