Skip to content

Commit

Permalink
fixup! Allocate resource after receiving successful response from HMI
Browse files Browse the repository at this point in the history
  • Loading branch information
LitvinenkoIra committed Aug 29, 2019
1 parent 16a263b commit a257b20
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,30 @@ void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) {

const rc_rpc_types::ModuleUid resource{module_type, module_id};
auto app = application_manager_.application(connection_key());

if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer.");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, "");
return;
}

const auto app_id = app->app_id();

bool is_resource_aquired = false;
bool is_resource_acquired = false;

if (result && !resource_allocation_manager_.IsResourceAlreadyAcquiredByApp(
resource, app_id)) {
resource_allocation_manager_.SetResourceAcquired(
module_type, module_id, app_id);

is_resource_aquired = true;
is_resource_acquired = true;
}

std::string response_info;
GetInfo(message, response_info);
SendResponse(result, result_code, response_info.c_str());

if (is_resource_aquired) {
if (is_resource_acquired) {
resource_allocation_manager_.SendOnRCStatusNotifications(
NotificationTrigger::MODULE_ALLOCATION,
std::shared_ptr<application_manager::Application>());
Expand Down

0 comments on commit a257b20

Please sign in to comment.