Skip to content

Commit ba71a83

Browse files
committed
Answer PR comments
1 parent fd9582e commit ba71a83

File tree

9 files changed

+51
-37
lines changed

9 files changed

+51
-37
lines changed

src/components/application_manager/include/application_manager/message_helper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ class MessageHelper {
9393
* OnSystemRequestNotification
9494
* @param policy_data pt snapshot data
9595
* @param connection_key connection key of application
96+
* @param request_type OnSystemRequest request type
9697
* @return OnSystemRequest notification smart object
9798
*/
9899
static smart_objects::SmartObjectSPtr
99100
CreateOnSystemRequestNotificationToMobile(
100-
const std::vector<uint8_t>& policy_data, const uint32_t connection_key);
101+
const std::vector<uint8_t>& policy_data,
102+
const uint32_t connection_key,
103+
const mobile_apis::RequestType::eType request_type);
101104

102105
/**
103106
* @brief ServiceStatusUpdateNotificationBuilder small utility class used for

src/components/application_manager/src/message_helper/message_helper.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,20 +2332,16 @@ bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) {
23322332

23332333
smart_objects::SmartObjectSPtr
23342334
MessageHelper::CreateOnSystemRequestNotificationToMobile(
2335-
const std::vector<uint8_t>& policy_data, const uint32_t app_id) {
2335+
const std::vector<uint8_t>& policy_data,
2336+
const uint32_t app_id,
2337+
const mobile_apis::RequestType::eType request_type) {
23362338
auto notification =
23372339
CreateNotification(mobile_apis::FunctionID::OnSystemRequestID, app_id);
23382340

23392341
(*notification)[strings::params][strings::binary_data] =
23402342
smart_objects::SmartObject(policy_data);
23412343

2342-
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2343-
(*notification)[strings::msg_params][strings::request_type] =
2344-
mobile_apis::RequestType::PROPRIETARY;
2345-
#else
2346-
(*notification)[strings::msg_params][strings::request_type] =
2347-
mobile_apis::RequestType::HTTP;
2348-
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
2344+
(*notification)[strings::msg_params][strings::request_type] = request_type;
23492345

23502346
return notification;
23512347
}
@@ -2355,8 +2351,14 @@ void MessageHelper::SendPolicySnapshotNotification(
23552351
const std::vector<uint8_t>& policy_data,
23562352
const std::string& url,
23572353
ApplicationManager& app_mngr) {
2358-
auto notification =
2359-
CreateOnSystemRequestNotificationToMobile(policy_data, connection_key);
2354+
const auto request_type =
2355+
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2356+
mobile_apis::RequestType::PROPRIETARY;
2357+
#else
2358+
mobile_apis::RequestType::HTTP;
2359+
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
2360+
auto notification = CreateOnSystemRequestNotificationToMobile(
2361+
policy_data, connection_key, request_type);
23602362

23612363
if (!url.empty()) {
23622364
(*notification)[strings::msg_params][strings::url] =
@@ -2367,13 +2369,6 @@ void MessageHelper::SendPolicySnapshotNotification(
23672369

23682370
(*notification)[strings::params][strings::binary_data] =
23692371
smart_objects::SmartObject(policy_data);
2370-
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2371-
(*notification)[strings::msg_params][strings::request_type] =
2372-
mobile_apis::RequestType::PROPRIETARY;
2373-
#else
2374-
(*notification)[strings::msg_params][strings::request_type] =
2375-
mobile_apis::RequestType::HTTP;
2376-
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
23772372

23782373
PrintSmartObject(*notification);
23792374
app_mngr.GetRPCService().ManageMobileCommand(notification,

src/components/application_manager/src/policies/policy_handler.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,9 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string,
14901490
if (PTUIterationType::RetryIteration == iteration_type) {
14911491
auto on_system_request_notification =
14921492
MessageHelper::CreateOnSystemRequestNotificationToMobile(
1493-
pt_string, GetAppIdForSending());
1493+
pt_string,
1494+
GetAppIdForSending(),
1495+
mobile_apis::RequestType::PROPRIETARY);
14941496
application_manager_.GetRPCService().ManageMobileCommand(
14951497
on_system_request_notification, commands::Command::SOURCE_SDL);
14961498
} else {

src/components/application_manager/test/include/application_manager/mock_message_helper.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ class MockMessageHelper {
139139
MOCK_METHOD2(SendDecryptCertificateToHMI,
140140
void(const std::string& file_name,
141141
ApplicationManager& app_mngr));
142-
MOCK_METHOD2(
143-
CreateOnSystemRequestNotificationToMobile,
144-
smart_objects::SmartObjectSPtr(const std::vector<uint8_t>& policy_data,
145-
const uint32_t connection_key));
142+
MOCK_METHOD3(CreateOnSystemRequestNotificationToMobile,
143+
smart_objects::SmartObjectSPtr(
144+
const std::vector<uint8_t>& policy_data,
145+
const uint32_t connection_key,
146+
const mobile_apis::RequestType::eType request_type));
146147
#ifdef EXTERNAL_PROPRIETARY_MODE
147148
MOCK_METHOD4(
148149
SendGetListOfPermissionsResponse,

src/components/application_manager/test/mock_message_helper.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,12 @@ MessageHelper::ServiceStatusUpdateNotificationBuilder::notification() const {
614614

615615
smart_objects::SmartObjectSPtr
616616
MessageHelper::CreateOnSystemRequestNotificationToMobile(
617-
const std::vector<uint8_t>& policy_data, const uint32_t connection_key) {
617+
const std::vector<uint8_t>& policy_data,
618+
const uint32_t connection_key,
619+
const mobile_apis::RequestType::eType request_type) {
618620
return MockMessageHelper::message_helper_mock()
619-
->CreateOnSystemRequestNotificationToMobile(policy_data, connection_key);
621+
->CreateOnSystemRequestNotificationToMobile(
622+
policy_data, connection_key, request_type);
620623
}
621624

622625
smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities(

src/components/policy/policy_external/include/policy/policy_manager_impl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,10 @@ class PolicyManagerImpl : public PolicyManager {
838838
void RetrySequenceFailed() OVERRIDE;
839839

840840
/**
841-
* @brief Begins new retry sequence
841+
* @brief In EXTERNAL_PROPRIETARY_MODE PTU sequence is driven by HMI and
842+
* begins with OnSystemRequest from HMI. Following function is called when
843+
* this notification is received to track number of PTU retries and react
844+
* accordingly once allowed retry count is exceeded
842845
*/
843846
void OnSystemRequestReceived() OVERRIDE;
844847

@@ -1197,7 +1200,7 @@ class PolicyManagerImpl : public PolicyManager {
11971200
/**
11981201
* @brief Lock for guarding retry sequence
11991202
*/
1200-
sync_primitives::Lock retry_sequence_lock_;
1203+
mutable sync_primitives::Lock retry_sequence_lock_;
12011204

12021205
/**
12031206
* @brief Device id, which is used during PTU handling for specific

src/components/policy/policy_external/src/policy_manager_impl.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,11 +1268,21 @@ void PolicyManagerImpl::SetUserConsentForApp(
12681268

12691269
bool PolicyManagerImpl::IsAllowedRetryCountExceeded() const {
12701270
LOG4CXX_AUTO_TRACE(logger_);
1271+
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
1272+
12711273
return retry_sequence_index_ > retry_sequence_seconds_.size();
12721274
}
12731275

12741276
void PolicyManagerImpl::IncrementRetryIndex() {
12751277
LOG4CXX_AUTO_TRACE(logger_);
1278+
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
1279+
1280+
if (!is_ptu_in_progress_) {
1281+
LOG4CXX_TRACE(logger_,
1282+
"First PTU iteration, skipping incrementing retry index");
1283+
is_ptu_in_progress_ = true;
1284+
return;
1285+
}
12761286

12771287
++retry_sequence_index_;
12781288
LOG4CXX_DEBUG(logger_,
@@ -1289,11 +1299,7 @@ void PolicyManagerImpl::RetrySequenceFailed() {
12891299
void PolicyManagerImpl::OnSystemRequestReceived() {
12901300
LOG4CXX_AUTO_TRACE(logger_);
12911301

1292-
if (is_ptu_in_progress_) {
1293-
IncrementRetryIndex();
1294-
} else {
1295-
is_ptu_in_progress_ = true;
1296-
}
1302+
IncrementRetryIndex();
12971303
}
12981304

12991305
bool PolicyManagerImpl::GetDefaultHmi(const std::string& policy_app_id,

src/components/policy/policy_regular/include/policy/policy_manager_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ class PolicyManagerImpl : public PolicyManager {
922922
/**
923923
* @brief Starts new retry sequence
924924
*/
925-
void StartRetrySequence();
925+
void OnPTUIterationTimeout();
926926

927927
private:
928928
/**

src/components/policy/policy_regular/src/policy_manager_impl.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ PolicyManagerImpl::PolicyManagerImpl()
7777
new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_)))
7878
, retry_sequence_timeout_(kDefaultRetryTimeoutInMSec)
7979
, retry_sequence_index_(0)
80-
, timer_retry_sequence_("Retry sequence timer",
81-
new timer::TimerTaskImpl<PolicyManagerImpl>(
82-
this, &PolicyManagerImpl::StartRetrySequence))
80+
, timer_retry_sequence_(
81+
"Retry sequence timer",
82+
new timer::TimerTaskImpl<PolicyManagerImpl>(
83+
this, &PolicyManagerImpl::OnPTUIterationTimeout))
8384
, ignition_check(true)
8485
, retry_sequence_url_(0, 0, "")
8586
, wrong_ptu_update_received_(false)
@@ -1410,7 +1411,7 @@ void PolicyManagerImpl::set_cache_manager(
14101411
cache_ = std::shared_ptr<CacheManagerInterface>(cache_manager);
14111412
}
14121413

1413-
void PolicyManagerImpl::StartRetrySequence() {
1414+
void PolicyManagerImpl::OnPTUIterationTimeout() {
14141415
LOG4CXX_DEBUG(logger_, "Start new retry sequence");
14151416

14161417
const bool is_exceeded_retries_count =

0 commit comments

Comments
 (0)