summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include/application_manager/policies/policy_handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/include/application_manager/policies/policy_handler.h')
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h69
1 files changed, 58 insertions, 11 deletions
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 4525433b8b..a0fef88b6d 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
@@ -86,8 +86,8 @@ class PolicyHandler : public PolicyHandlerInterface,
bool InitPolicyTable() OVERRIDE;
bool ResetPolicyTable() OVERRIDE;
bool ClearUserConsent() OVERRIDE;
- bool SendMessageToSDK(const BinaryMessage& pt_string,
- const std::string& url) OVERRIDE;
+ DEPRECATED bool SendMessageToSDK(const BinaryMessage& pt_string,
+ const std::string& url) OVERRIDE;
bool ReceiveMessageFromSDK(const std::string& file,
const BinaryMessage& pt_string) OVERRIDE;
bool UnloadPolicyLibrary() OVERRIDE;
@@ -110,6 +110,28 @@ class PolicyHandler : public PolicyHandlerInterface,
#else // EXTERNAL_PROPRIETARY_MODE
void OnSnapshotCreated(const BinaryMessage& pt_string,
const PTUIterationType iteration_type) OVERRIDE;
+
+ /**
+ * @brief Get the next available PTU URL and the associated application for
+ * performing the PTU
+ * @param iteration_type The iteration type of the PTU.
+ * If this is a retry and a retry URL was cached, that URL will be returned
+ * @param app_id Filled with the ID of application used to perform the PTU on
+ * success
+ * @return The next available PTU URL on success, empty string on failure
+ */
+ std::string GetNextUpdateUrl(const PTUIterationType iteration_type,
+ uint32_t& app_id) OVERRIDE;
+
+ /**
+ * @brief Update the cached URL and app ID used for policy retries
+ * @param app_id The ID of the application to be used for performing PTUs.
+ * If 0, the existing cached application will be cleared
+ * @param url The URL provided by the HMI to be used for performing PTU
+ * retries. If empty, the existing cached URL will be cleared and Core will
+ * choose which URLs to use on retry
+ */
+ void CacheRetryInfo(const uint32_t app_id, const std::string url) OVERRIDE;
#endif // EXTERNAL_PROPRIETARY_MODE
virtual bool GetPriority(const std::string& policy_app_id,
std::string* priority) const OVERRIDE;
@@ -412,11 +434,27 @@ class PolicyHandler : public PolicyHandlerInterface,
void OnSystemError(int code) OVERRIDE;
/**
- * @brief Chooses random application id to be used for snapshot sending
- * considering HMI level
+ * @brief Chooses and stores random application id to be used for snapshot
+ * sending considering HMI level
+ * @param iteration_type The iteration type of the request. If RetryIteration,
+ * the previously chosen app ID (via ChoosePTUApplication or CacheRetryInfo)
+ * will be returned if available
* @return Application id or 0, if there are no suitable applications
*/
- uint32_t GetAppIdForSending() const OVERRIDE;
+ uint32_t ChoosePTUApplication(
+ const PTUIterationType iteration_type =
+ PTUIterationType::DefaultIteration) OVERRIDE;
+
+ /**
+ * @brief Retrieve potential application id to be used for snapshot sending
+ * @param iteration_type The iteration type of the request. If RetryIteration,
+ * the previously chosen app ID (via ChoosePTUApplication or CacheRetryInfo)
+ * will be returned if available
+ * @return Application id or 0, if there are no suitable applications
+ */
+ uint32_t GetAppIdForSending(
+ const PTUIterationType iteration_type =
+ PTUIterationType::DefaultIteration) const OVERRIDE;
/**
* @brief Add application to PTU queue if no application with
@@ -877,6 +915,10 @@ class PolicyHandler : public PolicyHandlerInterface,
private:
static const std::string kLibrary;
+ bool SendMessageToSDK(const BinaryMessage& pt_string,
+ const std::string& url,
+ const uint32_t app_id);
+
/**
* @brief Collects currently registered applications ids linked to their
* device id
@@ -889,6 +931,10 @@ class PolicyHandler : public PolicyHandlerInterface,
std::shared_ptr<PolicyEventObserver> event_observer_;
uint32_t last_activated_app_id_;
+ // PTU retry information
+ uint32_t last_ptu_app_id_;
+ std::string retry_update_url_;
+
/**
* @brief Contains device handles, which were sent for user consent to HMI
*/
@@ -919,15 +965,16 @@ class PolicyHandler : public PolicyHandlerInterface,
friend class AppPermissionDelegate;
/**
- * @brief Checks if the application with the given policy
- * application id is registered or it is default id
- * @param app_idx Application idx from EndpointUrls vector
- * @param urls EndpointUrls vector
+ * @brief Checks if an application is able to perform a PTU using the
+ * specified URL list
+ * @param app_id ID of application used for PTU
+ * @param app_data EndpointData struct with list of URLs
* @return TRUE if the vector with URLs with given idx is not empty
- * and is related to a registered application or these are default URLs,
+ * and is related to the provided application or if these are default URLs,
* otherwise FALSE
*/
- bool IsUrlAppIdValid(const uint32_t app_idx, const EndpointUrls& urls) const;
+ bool IsUrlAppIdValid(const std::string app_id,
+ const EndpointData& app_data) const;
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);
};