Skip to content

Commit e161a9b

Browse files
committed
Answer PR comments
1 parent 6f752bd commit e161a9b

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
@@ -2340,20 +2340,16 @@ bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) {
23402340

23412341
smart_objects::SmartObjectSPtr
23422342
MessageHelper::CreateOnSystemRequestNotificationToMobile(
2343-
const std::vector<uint8_t>& policy_data, const uint32_t app_id) {
2343+
const std::vector<uint8_t>& policy_data,
2344+
const uint32_t app_id,
2345+
const mobile_apis::RequestType::eType request_type) {
23442346
auto notification =
23452347
CreateNotification(mobile_apis::FunctionID::OnSystemRequestID, app_id);
23462348

23472349
(*notification)[strings::params][strings::binary_data] =
23482350
smart_objects::SmartObject(policy_data);
23492351

2350-
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2351-
(*notification)[strings::msg_params][strings::request_type] =
2352-
mobile_apis::RequestType::PROPRIETARY;
2353-
#else
2354-
(*notification)[strings::msg_params][strings::request_type] =
2355-
mobile_apis::RequestType::HTTP;
2356-
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
2352+
(*notification)[strings::msg_params][strings::request_type] = request_type;
23572353

23582354
return notification;
23592355
}
@@ -2363,8 +2359,14 @@ void MessageHelper::SendPolicySnapshotNotification(
23632359
const std::vector<uint8_t>& policy_data,
23642360
const std::string& url,
23652361
ApplicationManager& app_mngr) {
2366-
auto notification =
2367-
CreateOnSystemRequestNotificationToMobile(policy_data, connection_key);
2362+
const auto request_type =
2363+
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2364+
mobile_apis::RequestType::PROPRIETARY;
2365+
#else
2366+
mobile_apis::RequestType::HTTP;
2367+
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
2368+
auto notification = CreateOnSystemRequestNotificationToMobile(
2369+
policy_data, connection_key, request_type);
23682370

23692371
if (!url.empty()) {
23702372
(*notification)[strings::msg_params][strings::url] =
@@ -2375,13 +2377,6 @@ void MessageHelper::SendPolicySnapshotNotification(
23752377

23762378
(*notification)[strings::params][strings::binary_data] =
23772379
smart_objects::SmartObject(policy_data);
2378-
#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
2379-
(*notification)[strings::msg_params][strings::request_type] =
2380-
mobile_apis::RequestType::PROPRIETARY;
2381-
#else
2382-
(*notification)[strings::msg_params][strings::request_type] =
2383-
mobile_apis::RequestType::HTTP;
2384-
#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
23852380

23862381
PrintSmartObject(*notification);
23872382
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
@@ -1492,7 +1492,9 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string,
14921492
if (PTUIterationType::RetryIteration == iteration_type) {
14931493
auto on_system_request_notification =
14941494
MessageHelper::CreateOnSystemRequestNotificationToMobile(
1495-
pt_string, GetAppIdForSending());
1495+
pt_string,
1496+
GetAppIdForSending(),
1497+
mobile_apis::RequestType::PROPRIETARY);
14961498
application_manager_.GetRPCService().ManageMobileCommand(
14971499
on_system_request_notification, commands::Command::SOURCE_SDL);
14981500
} 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
@@ -1270,11 +1270,21 @@ void PolicyManagerImpl::SetUserConsentForApp(
12701270

12711271
bool PolicyManagerImpl::IsAllowedRetryCountExceeded() const {
12721272
LOG4CXX_AUTO_TRACE(logger_);
1273+
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
1274+
12731275
return retry_sequence_index_ > retry_sequence_seconds_.size();
12741276
}
12751277

12761278
void PolicyManagerImpl::IncrementRetryIndex() {
12771279
LOG4CXX_AUTO_TRACE(logger_);
1280+
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
1281+
1282+
if (!is_ptu_in_progress_) {
1283+
LOG4CXX_TRACE(logger_,
1284+
"First PTU iteration, skipping incrementing retry index");
1285+
is_ptu_in_progress_ = true;
1286+
return;
1287+
}
12781288

12791289
++retry_sequence_index_;
12801290
LOG4CXX_DEBUG(logger_,
@@ -1291,11 +1301,7 @@ void PolicyManagerImpl::RetrySequenceFailed() {
12911301
void PolicyManagerImpl::OnSystemRequestReceived() {
12921302
LOG4CXX_AUTO_TRACE(logger_);
12931303

1294-
if (is_ptu_in_progress_) {
1295-
IncrementRetryIndex();
1296-
} else {
1297-
is_ptu_in_progress_ = true;
1298-
}
1304+
IncrementRetryIndex();
12991305
}
13001306

13011307
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)
@@ -1411,7 +1412,7 @@ void PolicyManagerImpl::set_cache_manager(
14111412
cache_ = std::shared_ptr<CacheManagerInterface>(cache_manager);
14121413
}
14131414

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

14171418
const bool is_exceeded_retries_count =

0 commit comments

Comments
 (0)