summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external
diff options
context:
space:
mode:
authorAndrey Oleynik (GitHub) <aoleynik@luxoft.com>2017-11-29 18:33:59 +0200
committerAndriy Byzhynar <AByzhynar@luxoft.com>2018-01-18 12:03:51 +0200
commitee1d2d7677a7d94da43cc8b1e047bdd816e5fd83 (patch)
treee1b956cd3c472f792117735a20935587e75cfb79 /src/components/policy/policy_external
parent11bef60123b62bbe0f8f624bb24a5f0cf74980aa (diff)
downloadsdl_core-ee1d2d7677a7d94da43cc8b1e047bdd816e5fd83.tar.gz
Changes iAP2 Bluetooth to USB switching flow
These changes update switching flow so now instead of automatic switching start in case of same UUID is detected SDL will wait for external signal from the system to start this flow. Also due to UUID is reliable only while device remains connected (at least on certain systems) SDL now uses Bluetooth MAC and USB serial to manage devices and UUID is used only for detection of devices able to switch their transports. Currently only iAP2 Bluetooth to USB support is implemented.
Diffstat (limited to 'src/components/policy/policy_external')
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h9
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h3
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc25
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc6
5 files changed, 52 insertions, 0 deletions
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 aa5360d2b7..ef93ec72ab 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -701,6 +701,15 @@ class CacheManager : public CacheManagerInterface {
const PolicySettings& get_settings() const;
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
private:
std::string currentDateTime();
struct AppHMITypeToString {
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 ae1f8922ba..b9e9f73646 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
@@ -778,6 +778,15 @@ class CacheManagerInterface {
virtual void SetExternalConsentForApp(
const PermissionConsent& permissions) = 0;
+ /**
+ * @brief OnDeviceSwitching Processes existing policy permissions for devices
+ * switching transport
+ * @param device_id_from Device ID original
+ * @param device_id_to Device ID new
+ */
+ virtual void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) = 0;
+
#ifdef BUILD_TESTS
/**
* @brief GetPT allows to obtain SharedPtr to PT.
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 80ceb06e7e..97a2e60055 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
@@ -559,6 +559,9 @@ class PolicyManagerImpl : public PolicyManager {
*/
void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE;
+ void OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) OVERRIDE;
+
/**
* @brief Gets meta information
* @return meta information
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index b5e44014dd..70739c9159 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -2629,6 +2629,31 @@ const PolicySettings& CacheManager::get_settings() const {
return *settings_;
}
+void CacheManager::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+ auto device_data = *(pt_->policy_table.device_data);
+
+ auto from = pt_->policy_table.device_data->find(device_id_from);
+ DCHECK_OR_RETURN_VOID(from != device_data.end());
+
+ auto to = pt_->policy_table.device_data->find(device_id_to);
+ DCHECK_OR_RETURN_VOID(to != device_data.end());
+
+ auto& consents_from = *(from->second.user_consent_records);
+ auto& consents_to = *(to->second.user_consent_records);
+
+ LOG4CXX_DEBUG(logger_,
+ "Merging user consents from device: " << device_id_from <<
+ " to device: " << device_id_to);
+ for (auto f = consents_from.begin(); f != consents_from.end(); ++f) {
+ const auto app_id = f->first;
+ LOG4CXX_DEBUG(logger_, "Updating permissions for key: " << app_id);
+ consents_to[app_id] = f->second;
+ }
+}
+
CacheManager::BackgroundBackuper::BackgroundBackuper(
CacheManager* cache_manager)
: cache_manager_(cache_manager)
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 d50779383a..24bfd3a4d1 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1681,6 +1681,12 @@ void PolicyManagerImpl::OnAppRegisteredOnMobile(
SendNotificationOnPermissionsUpdated(application_id);
}
+void PolicyManagerImpl::OnDeviceSwitching(
+ const std::string& device_id_from, const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ cache_->OnDeviceSwitching(device_id_from, device_id_to);
+}
+
const MetaInfo PolicyManagerImpl::GetMetaInfo() const {
LOG4CXX_AUTO_TRACE(logger_);
return cache_->GetMetaInfo();