From d7f3cc3e8a847f16b0a70359842ae31d175aec5f Mon Sep 17 00:00:00 2001 From: Jack Byrne Date: Fri, 28 Aug 2015 16:09:52 -0400 Subject: Changed device_info id to string and mac_address --- .../include/application_manager/application_manager_impl.h | 2 +- .../application_manager/src/application_manager_impl.cc | 10 ++++++++-- .../src/commands/hmi/on_device_chosen_notification.cc | 2 +- .../src/commands/hmi/on_device_state_changed_notification.cc | 3 +-- src/components/application_manager/src/message_helper.cc | 8 ++++---- src/components/interfaces/HMI_API.xml | 2 +- src/components/interfaces/QT_HMI_API.xml | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 0046b4bf41..5c5e29e062 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -343,7 +343,7 @@ class ApplicationManagerImpl : public ApplicationManager, */ mobile_api::HMILevel::eType IsHmiLevelFullAllowed(ApplicationSharedPtr app); - void ConnectToDevice(uint32_t id); + void ConnectToDevice(const std::string& device_mac); void OnHMIStartedCooperation(); /* diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b8ba76541a..6ffa7e2335 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -542,14 +542,20 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed( return result; } -void ApplicationManagerImpl::ConnectToDevice(uint32_t id) { +void ApplicationManagerImpl::ConnectToDevice(const std::string& device_mac) { // TODO(VS): Call function from ConnectionHandler if (!connection_handler_) { LOG4CXX_WARN(logger_, "Connection handler is not set."); return; } - connection_handler_->ConnectToDevice(id); + connection_handler::DeviceHandle handle; + if (!connection_handler_->GetDeviceID(device_mac, &handle) ) { + LOG4CXX_ERROR(logger_, "Attempt to connect to invalid device with mac:" + << device_mac ); + return; + } + connection_handler_->ConnectToDevice(handle); } void ApplicationManagerImpl::OnHMIStartedCooperation() { diff --git a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc index 5d73c7b80e..441538bee2 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc @@ -50,7 +50,7 @@ void OnDeviceChosenNotification::Run() { if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { ApplicationManagerImpl::instance()->ConnectToDevice( (*message_)[strings::msg_params][strings::device_info][strings::id] - .asInt()); + .asString()); } } diff --git a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc index fbb2bcfe93..b41eb6b861 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc @@ -95,8 +95,7 @@ void OnDeviceStateChangedNotification::Run() { .asString(); if (device_id.empty()) { if ((*message_)[strings::msg_params].keyExists("deviceId")) { - device_id = MessageHelper::GetDeviceMacAddressForHandle( - (*message_)[strings::msg_params]["deviceId"]["id"].asInt()); + device_id = (*message_)[strings::msg_params]["deviceId"]["id"].asString(); } } else { // Policy uses hashed MAC address as device_id diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 2fd6d9f746..11bd6afda3 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -335,7 +335,7 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI( << application_impl.device()); } device_info[strings::name] = device_name; - device_info[strings::id] = application_impl.device(); + device_info[strings::id] = mac_address; const policy::DeviceConsent device_consent = policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_address); @@ -1320,7 +1320,7 @@ bool MessageHelper::CreateHMIApplicationStruct(ApplicationConstSharedPtr app, output[strings::device_info] = smart_objects::SmartObject(smart_objects::SmartType_Map); output[strings::device_info][strings::name] = device_name; - output[strings::device_info][strings::id] = app->device(); + output[strings::device_info][strings::id] = mac_address; const policy::DeviceConsent device_consent = policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_address); output[strings::device_info][strings::isSDLAllowed] = @@ -1537,7 +1537,7 @@ void MessageHelper::SendSDLActivateAppResponse(policy::AppPermissions& permissio (*message)[strings::msg_params]["device"]["name"] = permissions.deviceInfo .device_name; (*message)[strings::msg_params]["device"]["id"] = permissions.deviceInfo - .device_handle; + .device_mac_address; } (*message)[strings::msg_params]["isAppRevoked"] = permissions.appRevoked; @@ -1577,7 +1577,7 @@ void MessageHelper::SendOnSDLConsentNeeded( (*message)[strings::params][strings::message_type] = MessageType::kNotification; - (*message)[strings::msg_params]["device"]["id"] = device_info.device_handle; + (*message)[strings::msg_params]["device"]["id"] = device_info.device_mac_address; (*message)[strings::msg_params]["device"]["name"] = device_info.device_name; ApplicationManagerImpl::instance()->ManageHMICommand(message); diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 0aae26f30e..0f00117b1e 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1302,7 +1302,7 @@ The name of the device connected. - + The ID of the device connected diff --git a/src/components/interfaces/QT_HMI_API.xml b/src/components/interfaces/QT_HMI_API.xml index 6db4ec8383..eab9edb864 100644 --- a/src/components/interfaces/QT_HMI_API.xml +++ b/src/components/interfaces/QT_HMI_API.xml @@ -1114,7 +1114,7 @@ The name of the device connected. - + The ID of the device connected -- cgit v1.2.1