summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc116
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_db.cc396
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_impl.cc83
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_json.cc282
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_sql_queries.cc78
-rw-r--r--src/components/application_manager/src/app_launch/apps_launcher.cc139
-rw-r--r--src/components/application_manager/src/app_launch/device_apps_launcher.cc208
-rw-r--r--src/components/application_manager/src/application_impl.cc21
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc196
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc382
-rw-r--r--src/components/application_manager/src/commands/hmi/close_popup_request.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc53
-rw-r--r--src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc59
-rw-r--r--src/components/application_manager/src/commands/hmi/get_urls.cc166
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc26
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc30
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc13
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc28
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc103
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc17
-rw-r--r--src/components/application_manager/src/commands/hmi/on_received_policy_update.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/on_system_request_notification.cc16
-rw-r--r--src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc7
-rw-r--r--src/components/application_manager/src/commands/hmi/request_from_hmi.cc54
-rw-r--r--src/components/application_manager/src/commands/hmi/request_to_hmi.cc24
-rw-r--r--src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc70
-rw-r--r--src/components/application_manager/src/commands/hmi/sdl_policy_update.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc5
-rw-r--r--src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc54
-rw-r--r--src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc14
-rw-r--r--src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc57
-rw-r--r--src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc120
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc118
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_request.cc117
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_request.cc171
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc123
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc93
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_file_request.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc19
-rw-r--r--src/components/application_manager/src/commands/mobile/get_dtcs_request.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc30
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_event_notification.cc14
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_press_notification.cc25
-rw-r--r--src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc28
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc161
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_request.cc200
-rw-r--r--src/components/application_manager/src/commands/mobile/read_did_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc318
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_response.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc91
-rw-r--r--src/components/application_manager/src/commands/mobile/scrollable_message_request.cc26
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc34
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc21
-rw-r--r--src/components/application_manager/src/commands/mobile/set_display_layout_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_request.cc91
-rw-r--r--src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc29
-rw-r--r--src/components/application_manager/src/commands/mobile/show_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_request.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/speak_request.cc14
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc255
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc48
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_request.cc21
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc (renamed from src/components/application_manager/src/hmi_capabilities.cc)788
-rw-r--r--src/components/application_manager/src/hmi_command_factory.cc17
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc268
-rw-r--r--src/components/application_manager/src/hmi_language_handler.cc15
-rw-r--r--src/components/application_manager/src/hmi_state.cc2
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc390
-rw-r--r--src/components/application_manager/src/mobile_message_handler.cc97
-rw-r--r--src/components/application_manager/src/policies/delegates/app_permission_delegate.cc18
-rw-r--r--src/components/application_manager/src/policies/policy_event_observer.cc1
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc887
-rw-r--r--src/components/application_manager/src/policies/policy_retry_sequence.cc3
-rw-r--r--src/components/application_manager/src/policies/pt_exchange_handler_ext.cc88
-rw-r--r--src/components/application_manager/src/policies/pt_exchange_handler_impl.cc79
-rw-r--r--src/components/application_manager/src/request_controller.cc163
-rw-r--r--src/components/application_manager/src/request_info.cc65
-rw-r--r--src/components/application_manager/src/request_tracker.cc133
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc (renamed from src/components/application_manager/src/resumption/resume_ctrl.cc)186
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc9
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc29
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc4
-rw-r--r--src/components/application_manager/src/usage_statistics.cc14
104 files changed, 5964 insertions, 2581 deletions
diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
new file mode 100644
index 0000000000..481635d8e6
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <iterator>
+#include <algorithm>
+#include <utility>
+#include <vector>
+#include "application_manager/app_launch/app_launch_ctrl_impl.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "connection_handler/connection_handler.h"
+#include "application_manager/application.h"
+#include "utils/timer_task_impl.h"
+#include "utils/make_shared.h"
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchCtrlImpl::AppLaunchCtrlImpl(
+ AppLaunchData& data,
+ application_manager::ApplicationManager& app_mngr,
+ const AppLaunchSettings& settings)
+ : settings_(settings)
+ , app_launch_data_(data)
+ , resume_ctrl_(app_mngr.resume_controller())
+ , apps_launcher_(app_mngr.connection_handler(),
+ settings.max_number_of_ios_device(),
+ settings.app_launch_max_retry_attempt(),
+ settings.app_launch_retry_wait_time())
+ , device_apps_launcher_(app_mngr, apps_launcher_, settings) {}
+
+void AppLaunchCtrlImpl::OnAppRegistered(
+ const application_manager::Application& app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ // TODO (AKutsan) : get device mac
+ ApplicationDataPtr app_data = utils::MakeShared<ApplicationData>(
+ app.policy_app_id(), app.bundle_id(), app.mac_address());
+ apps_launcher_.OnLaunched(app_data);
+ app_launch_data_.AddApplicationData(*app_data);
+}
+
+ApplicationDataPtr GetAppFromHmiLevelPair(
+ const std::pair<int32_t, ApplicationDataPtr>& pair) {
+ return pair.second;
+}
+
+bool HmiLevelSorter(const std::pair<int32_t, ApplicationDataPtr>& lval,
+ const std::pair<int32_t, ApplicationDataPtr>& rval) {
+ if (lval.first == -1) {
+ return false;
+ }
+ if (rval.first == -1) {
+ return true;
+ }
+ return lval.first < rval.first;
+}
+
+void AppLaunchCtrlImpl::OnDeviceConnected(const std::string& device_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> apps_on_device =
+ app_launch_data_.GetApplicationDataByDevice(device_mac);
+ std::vector<std::pair<int32_t, ApplicationDataPtr> > apps_hmi_levels;
+ std::vector<ApplicationDataPtr>::iterator it = apps_on_device.begin();
+ for (; it != apps_on_device.end(); ++it) {
+ const ApplicationDataPtr& app_data = *it;
+ const int32_t hmi_level = resume_ctrl_.GetSavedAppHmiLevel(
+ app_data->mobile_app_id_, app_data->device_mac_);
+ const std::pair<int32_t, ApplicationDataPtr> hmi_level_app(hmi_level,
+ app_data);
+ apps_hmi_levels.push_back(hmi_level_app);
+ }
+ std::sort(apps_hmi_levels.begin(), apps_hmi_levels.end(), HmiLevelSorter);
+ apps_on_device.clear();
+ std::transform(apps_hmi_levels.begin(),
+ apps_hmi_levels.end(),
+ std::back_inserter(apps_on_device),
+ GetAppFromHmiLevelPair);
+ if (apps_on_device.size() > 0) {
+ device_apps_launcher_.LaunchAppsOnDevice(device_mac, apps_on_device);
+ } else {
+ LOG4CXX_DEBUG(logger_, "No apps in saved for device " << device_mac);
+ }
+}
+
+void AppLaunchCtrlImpl::OnMasterReset() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ app_launch_data_.Clear();
+}
+} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
new file mode 100644
index 0000000000..f3adfc749b
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string>
+#include <unistd.h>
+
+#include "application_manager/app_launch/app_launch_data_db.h"
+#include "application_manager/application_manager_impl.h"
+#include "application_manager/app_launch/app_launch_sql_queries.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/message_helper.h"
+#include "utils/make_shared.h"
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataDB::AppLaunchDataDB(const AppLaunchSettings& settings,
+ DbStorage db_storage)
+ : AppLaunchDataImpl(settings) {
+ if (db_storage == In_File_Storage) {
+ db_.reset(new utils::dbms::SQLDatabase(kDatabaseName));
+#ifndef __QNX__
+ std::string path = settings_.app_storage_folder();
+ if (!path.empty()) {
+ db()->set_path(path + "/");
+ }
+ } else if (db_storage == In_Memory_Storage) {
+ db_.reset(new utils::dbms::SQLDatabase());
+#endif // __QNX__
+ DCHECK(db_.get());
+ } else {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_ERROR(logger_, "Get not existed type of database storage");
+ }
+
+ // Connect to resumption DB
+ init_successeful_ = Init();
+}
+
+AppLaunchDataDB::~AppLaunchDataDB() {
+ db()->Close();
+}
+
+bool AppLaunchDataDB::Init() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!db()->Open()) {
+ LOG4CXX_ERROR(logger_, "Failed opening database.");
+ LOG4CXX_INFO(logger_, "Starting opening retries.");
+ const uint16_t attempts = settings_.app_launch_max_retry_attempt();
+ LOG4CXX_DEBUG(logger_, "Total attempts number is: " << attempts);
+ bool is_opened = false;
+ const uint16_t open_attempt_timeout_ms =
+ settings_.app_launch_retry_wait_time();
+ const useconds_t sleep_interval_mcsec = open_attempt_timeout_ms * 1000u;
+ LOG4CXX_DEBUG(logger_,
+ "Open attempt timeout(ms) is: " << open_attempt_timeout_ms);
+ for (size_t i = 0u; i < attempts; ++i) {
+ usleep(sleep_interval_mcsec);
+ LOG4CXX_INFO(logger_, "Attempt: " << i + 1);
+ if (db()->Open()) {
+ LOG4CXX_INFO(logger_, "Database opened.");
+ is_opened = true;
+ break;
+ }
+ }
+ if (!is_opened) {
+ LOG4CXX_ERROR(logger_,
+ "Open retry sequence failed. Tried "
+ << attempts << " attempts with "
+ << open_attempt_timeout_ms
+ << " open timeout(ms) for each.");
+ return false;
+ }
+ }
+#ifndef __QNX__
+ if (!db()->IsReadWrite()) {
+ LOG4CXX_ERROR(logger_, "There are no read/write permissions for database");
+ return false;
+ }
+#endif // __QNX__
+
+ utils::dbms::SQLQuery query(db());
+ if (!query.Exec(kCreateSchema)) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed creating schema of database: " << query.LastError().text());
+ return false;
+ }
+
+ return true;
+}
+
+bool AppLaunchDataDB::Persist() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ if ((retVal = WriteDb())) {
+ LOG4CXX_DEBUG(logger_, "App_lauch had been successfully saved.");
+ } else {
+ LOG4CXX_WARN(logger_, "Fail to save app_launch data.");
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::IsAppDataAlreadyExisted(
+ const ApplicationData& app_data) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kFindApplicationData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kFindApplicationData'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ if (query.Exec()) {
+ retVal = query.GetBoolean(result_query);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::RefreshAppSessionTime(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kRefreshApplicationDataSessionTime)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries "
+ "'kRefreshApplicationDataSessionTime'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ if (query.Exec()) {
+ LOG4CXX_DEBUG(logger_, "Dare&time last session were updated successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::AddNewAppData(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kAddApplicationData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kAddApplicationData'");
+ return retVal;
+ }
+
+ query.Bind(device_mac_index, app_data.device_mac_);
+ query.Bind(application_id_index, app_data.mobile_app_id_);
+ query.Bind(bundle_id_index, app_data.bundle_id_);
+
+ retVal = query.Exec();
+ if (retVal) {
+ LOG4CXX_DEBUG(logger_, "New application data was added successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac(
+ const std::string& dev_mac) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> dev_apps;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return dev_apps;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kGetApplicationDataByDevID)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification queries 'kGetApplicationDataByDevID'");
+ return dev_apps;
+ }
+
+ query.Bind(device_mac_index, dev_mac);
+ const bool retVal = query.Exec();
+ if (retVal) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+ do {
+ const std::string device_mac = query.GetString(device_mac_index);
+ const std::string mobile_app_id = query.GetString(application_id_index);
+ const std::string bundle_id = query.GetString(bundle_id_index);
+ dev_apps.push_back(utils::MakeShared<ApplicationData>(
+ mobile_app_id, bundle_id, device_mac));
+ } while (query.Next());
+ LOG4CXX_DEBUG(logger_, "All application data has been successfully loaded");
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return dev_apps;
+}
+
+bool AppLaunchDataDB::Clear() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ utils::dbms::SQLQuery query(db());
+ retVal = query.Exec(kDropSchema);
+
+ if (retVal) {
+ LOG4CXX_INFO(logger_, "App_Launch table had been cleared successfully");
+ retVal = WriteDb();
+ init_successeful_ = false;
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed dropping database: " << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+uint32_t AppLaunchDataDB::GetCurentNumberOfAppData() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ uint32_t number_of_app_data = 0u;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return number_of_app_data;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kGetNumberOfApplicationData)) {
+ LOG4CXX_WARN(
+ logger_,
+ "Problem with verification queries 'kGetNumberOfApplicationData'");
+ return number_of_app_data;
+ }
+
+ if (query.Exec()) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+
+ number_of_app_data = query.GetInteger(result_query);
+ LOG4CXX_DEBUG(logger_,
+ "Total cout saved mobile applications is "
+ << number_of_app_data);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return number_of_app_data;
+}
+
+bool AppLaunchDataDB::DeleteOldestAppData() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ if (!init_successeful_) {
+ LOG4CXX_ERROR(logger_,
+ "AppLaunch data base was not successfully "
+ "initialize, AppLaunch won't work!");
+ return retVal;
+ }
+
+ utils::dbms::SQLQuery query(db());
+
+ if (!query.Prepare(kDeleteOldestAppData)) {
+ LOG4CXX_WARN(logger_,
+ "Problem with verification queries 'kDeleteOldestAppData'");
+ return retVal;
+ }
+
+ if ((retVal = query.Exec())) {
+ LOG4CXX_INFO(logger_,
+ "Values of ignition off counts were updated successfully");
+ retVal = WriteDb();
+ } else {
+ LOG4CXX_WARN(logger_,
+ "Failed execute query 'kGetNumberOfApplicationData'. Reson: "
+ << query.LastError().text());
+ }
+
+ return retVal;
+}
+
+bool AppLaunchDataDB::WriteDb() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return db_->Backup();
+}
+
+utils::dbms::SQLDatabase* AppLaunchDataDB::db() const {
+#ifdef __QNX__
+ std::auto_ptr<utils::dbms::SQLDatabase> db_qnx(
+ new utils::dbms::SQLDatabase(kDatabaseName));
+ db_qnx.get()->Open();
+ return db_qnx.get();
+#else
+ return db_.get();
+#endif // __QNX__
+}
+
+} // namespace resumption
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_impl.cc b/src/components/application_manager/src/app_launch/app_launch_data_impl.cc
new file mode 100644
index 0000000000..c095cc9d94
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_impl.cc
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "application_manager/app_launch/app_launch_data_impl.h"
+#include "utils/logger.h"
+
+namespace app_launch {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataImpl::AppLaunchDataImpl(const AppLaunchSettings& settings)
+ : settings_(settings)
+ , kMaxNumberOfiOSdevice(settings.max_number_of_ios_device()) {}
+
+AppLaunchDataImpl::~AppLaunchDataImpl() {}
+
+bool AppLaunchDataImpl::AddApplicationData(const ApplicationData& app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = true;
+
+ if (app_data.device_mac_.empty() == false &&
+ app_data.mobile_app_id_.empty() == false &&
+ app_data.bundle_id_.empty() == false) {
+ if (IsAppDataAlreadyExisted(app_data)) {
+ LOG4CXX_INFO(logger_, "This application data already existed");
+ retVal &= RefreshAppSessionTime(app_data);
+ } else {
+ if (GetCurentNumberOfAppData() >= get_max_number_iOS_devs()) {
+ LOG4CXX_INFO(logger_,
+ "Max number of application data have. It will be deleted "
+ "the oldest one");
+ retVal &= DeleteOldestAppData();
+ }
+ retVal &= AddNewAppData(app_data);
+ LOG4CXX_INFO(logger_, "Added new application data to DB");
+ }
+ } else {
+ retVal = false;
+ }
+ return retVal;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataImpl::GetApplicationDataByDevice(
+ const std::string& dev_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<ApplicationDataPtr> apps = GetAppDataByDevMac(dev_mac);
+
+ if (apps.empty()) {
+ LOG4CXX_DEBUG(logger_, "No application founded by mac" << dev_mac);
+ }
+
+ return apps;
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_json.cc b/src/components/application_manager/src/app_launch/app_launch_data_json.cc
new file mode 100644
index 0000000000..7599dcccb3
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_data_json.cc
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <algorithm>
+#include "application_manager/app_launch/app_launch_data_json.h"
+#include "application_manager/smart_object_keys.h"
+#include "smart_objects/smart_object.h"
+#include "utils/make_shared.h"
+#include "utils/date_time.h"
+#include "json/json.h"
+
+namespace app_launch {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+AppLaunchDataJson::AppLaunchDataJson(const AppLaunchSettings& settings,
+ resumption::LastState& last_state)
+ : AppLaunchDataImpl(settings)
+ , app_launch_json_lock_(true)
+ , last_state_(last_state) {}
+
+AppLaunchDataJson::~AppLaunchDataJson() {}
+
+Json::Value& AppLaunchDataJson::GetSavedApplicationDataList() const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ Json::Value& app_launch = GetApplicationData();
+ if (!app_launch.isMember(strings::app_launch_list)) {
+ app_launch[strings::app_launch_list] = Json::Value(Json::arrayValue);
+ LOG4CXX_WARN(logger_, "app_list section is missed");
+ }
+ Json::Value& app_launch_list = app_launch[strings::app_launch_list];
+ if (!app_launch_list.isArray()) {
+ LOG4CXX_ERROR(logger_, "app_launch_list type INVALID rewrite");
+ app_launch_list = Json::Value(Json::arrayValue);
+ }
+ return app_launch_list;
+}
+
+Json::Value& AppLaunchDataJson::GetApplicationData() const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ Json::Value& dictionary = last_state().get_dictionary();
+ if (!dictionary.isMember(strings::app_launch)) {
+ dictionary[strings::app_launch] = Json::Value(Json::objectValue);
+ LOG4CXX_WARN(logger_, "app_launch section is missed");
+ }
+ Json::Value& app_launch = dictionary[strings::app_launch];
+ if (!app_launch.isObject()) {
+ LOG4CXX_ERROR(logger_, "resumption type INVALID rewrite");
+ app_launch = Json::Value(Json::objectValue);
+ }
+ return app_launch;
+}
+
+Json::Value& AppLaunchDataJson::GetApplicationListAndIndex(
+ const ApplicationData& app_data, int32_t& founded_index) const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+
+ Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ const std::string deviceID =
+ apps_list[idx][strings::device_id].asString();
+ const std::string bundleID =
+ apps_list[idx][strings::bundle_id].asString();
+ const std::string appID = apps_list[idx][strings::app_id].asString();
+
+ if (deviceID == app_data.device_mac_ && bundleID == app_data.bundle_id_ &&
+ appID == app_data.mobile_app_id_) {
+ founded_index = idx;
+ }
+ }
+ }
+
+ return apps_list;
+}
+
+bool AppLaunchDataJson::IsAppDataAlreadyExisted(
+ const ApplicationData& app_data) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ int32_t index = NotFound;
+ GetApplicationListAndIndex(app_data, index);
+ return index == NotFound ? false : true;
+}
+
+bool AppLaunchDataJson::RefreshAppSessionTime(const ApplicationData& app_data) {
+ using namespace application_manager;
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool retVal = false;
+
+ int32_t index = NotFound;
+ Json::Value& json_data_list = GetApplicationListAndIndex(app_data, index);
+ if (index != NotFound) {
+ if (json_data_list.empty() == false) {
+ json_data_list[index][strings::app_launch_last_session] =
+ static_cast<Json::Value::UInt64>(DateTime::getCurrentTime().tv_sec);
+ retVal = true;
+ }
+ }
+ return retVal;
+}
+
+bool AppLaunchDataJson::AddNewAppData(const ApplicationData& app_data) {
+ using namespace application_manager;
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+
+ Json::Value& json_app_data =
+ GetSavedApplicationDataList().append(Json::Value());
+ json_app_data[strings::device_id] = app_data.device_mac_;
+ json_app_data[strings::app_id] = app_data.mobile_app_id_;
+ json_app_data[strings::bundle_id] = app_data.bundle_id_;
+ json_app_data[strings::app_launch_last_session] =
+ static_cast<Json::Value::UInt64>(DateTime::getCurrentTime().tv_sec);
+
+ LOG4CXX_DEBUG(logger_,
+ "New application data saved. Detatils device_id: "
+ << app_data.device_mac_
+ << ", app_id: " << app_data.mobile_app_id_
+ << ", bundle_id: " << app_data.bundle_id_ << ".");
+
+ return true;
+}
+
+std::vector<ApplicationDataPtr> AppLaunchDataJson::GetAppDataByDevMac(
+ const std::string& dev_mac) const {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ std::vector<ApplicationDataPtr> dev_apps;
+ const Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ const std::string deviceMac =
+ apps_list[idx][strings::device_id].asString();
+ const std::string bundleID =
+ apps_list[idx][strings::bundle_id].asString();
+ const std::string appID = apps_list[idx][strings::app_id].asString();
+
+ if (deviceMac == dev_mac) {
+ dev_apps.push_back(
+ utils::MakeShared<ApplicationData>(appID, bundleID, deviceMac));
+ }
+ }
+ }
+
+ return dev_apps;
+}
+
+bool AppLaunchDataJson::Clear() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ GetSavedApplicationDataList().clear();
+
+ LOG4CXX_DEBUG(logger_,
+ "Application launch JSON section successfully cleared.");
+
+ return true;
+}
+
+uint32_t AppLaunchDataJson::GetCurentNumberOfAppData() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ uint32_t list_size = GetSavedApplicationDataList().size();
+
+ LOG4CXX_DEBUG(logger_,
+ "Successfully was gotten app_launch list. Size: " << list_size);
+
+ return list_size;
+}
+
+bool AppLaunchDataJson::DeleteOldestAppData() {
+ using namespace application_manager;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ std::vector<uint64_t> temp_array;
+ std::vector<Json::Value> temp_json_list;
+ Json::Value& apps_list = GetSavedApplicationDataList();
+ const Json::ArrayIndex size = apps_list.size();
+
+ // Search oldest record in Json
+ // for it collect all timestaps in vector
+ for (Json::ArrayIndex idx = 0; idx != size; ++idx) {
+ if (apps_list[idx].isMember(strings::device_id) &&
+ apps_list[idx].isMember(strings::bundle_id) &&
+ apps_list[idx].isMember(strings::app_id) &&
+ apps_list[idx].isMember(strings::app_launch_last_session)) {
+ temp_array.push_back(
+ apps_list[idx][strings::app_launch_last_session].asUInt64());
+ }
+ }
+
+ // Calc oldest one and found index of it in Json
+ const int32_t oldest_index =
+ (std::min_element(temp_array.begin(), temp_array.end()) -
+ temp_array.begin());
+
+ // Copy in temporary vector Json list without oldest record
+ int32_t i = 0;
+ for (Json::Value::iterator it = GetSavedApplicationDataList().begin();
+ it != GetSavedApplicationDataList().end();
+ ++it, i++) {
+ if ((*it).isMember(strings::device_id) &&
+ (*it).isMember(strings::bundle_id) && (*it).isMember(strings::app_id) &&
+ (*it).isMember(strings::app_launch_last_session)) {
+ if (i == oldest_index) {
+ continue;
+ }
+ temp_json_list.push_back((*it));
+ }
+ }
+
+ // Clear Json list
+ GetSavedApplicationDataList().clear();
+
+ // Copy to Json new list without oldest one
+ for (std::vector<Json::Value>::iterator it = temp_json_list.begin();
+ it != temp_json_list.end();
+ ++it) {
+ GetSavedApplicationDataList().append((*it));
+ }
+
+ LOG4CXX_DEBUG(
+ logger_, "Oldest application launch data had been successfully deleted.");
+
+ return true;
+}
+
+bool AppLaunchDataJson::Persist() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(app_launch_json_lock_);
+ last_state().SaveStateToFileSystem();
+ return true;
+}
+
+} // app_launch
diff --git a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc
new file mode 100644
index 0000000000..950bcd44fa
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "application_manager/app_launch/app_launch_sql_queries.h"
+
+namespace app_launch {
+
+const std::string kCreateSchema =
+ "CREATE TABLE IF NOT EXISTS `app_launch`( "
+ " `deviceMac` TEXT, "
+ " `appID` TEXT,"
+ " `bundleID` TEXT,"
+ " `last_session` DATETIME, "
+ " PRIMARY KEY(`deviceMac`, `appID`, `bundleID`)"
+ " ); ";
+
+const std::string kDropSchema = "DROP TABLE IF EXISTS `app_launch`; ";
+
+const std::string kAddApplicationData =
+ "INSERT INTO `app_launch`"
+ "(`deviceMac`, `appID`, `bundleID`, `last_session`)"
+ "VALUES "
+ "(?, ?, ?, STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW'));";
+
+const std::string kFindApplicationData =
+ " SELECT COUNT(*)"
+ "FROM `app_launch`"
+ "WHERE `deviceMac` = ? AND `appID` = ? AND `bundleID` = ?;";
+
+const std::string kDeleteOldestAppData =
+ "DELETE FROM `app_launch`"
+ "WHERE `last_session` IN ("
+ "SELECT MIN(`last_session`)"
+ "FROM `app_launch`);";
+
+const std::string kGetNumberOfApplicationData =
+ "SELECT COUNT (*)"
+ "FROM `app_launch` ;";
+
+const std::string kGetApplicationDataByDevID =
+ "SELECT *"
+ "FROM `app_launch`"
+ "WHERE `deviceMac` = ?;";
+
+const std::string kRefreshApplicationDataSessionTime =
+ "UPDATE `app_launch`"
+ "SET `last_session` = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')"
+ "WHERE `deviceMac` = ? AND appID = ? AND bundleID = ?;";
+
+} // namespace resumption
diff --git a/src/components/application_manager/src/app_launch/apps_launcher.cc b/src/components/application_manager/src/app_launch/apps_launcher.cc
new file mode 100644
index 0000000000..41465ae985
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/apps_launcher.cc
@@ -0,0 +1,139 @@
+#include <algorithm>
+#include "application_manager/app_launch/apps_launcher.h"
+#include "utils/make_shared.h"
+#include "utils/timer_task_impl.h"
+#include <iostream>
+
+namespace app_launch {
+struct LauncherGenerator {
+ LauncherGenerator(AppsLauncher& apps_laucnher,
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time)
+ : apps_laucnher_(apps_laucnher)
+ , connection_handler_(connection_handler)
+ , app_launch_max_retry_attempt_(app_launch_max_retry_attempt)
+ , app_launch_retry_wait_time_(app_launch_retry_wait_time) {}
+ AppsLauncher::LauncherPtr operator()() {
+ return utils::MakeShared<AppsLauncher::Launcher>(
+ apps_laucnher_,
+ connection_handler_,
+ app_launch_max_retry_attempt_,
+ app_launch_retry_wait_time_);
+ }
+
+ AppsLauncher& apps_laucnher_;
+ connection_handler::ConnectionHandler& connection_handler_;
+ const uint16_t app_launch_max_retry_attempt_;
+ const uint16_t app_launch_retry_wait_time_;
+};
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+AppsLauncher::AppsLauncher(
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t max_number_of_ios_device,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ free_launchers_.resize(max_number_of_ios_device);
+ std::generate(free_launchers_.begin(),
+ free_launchers_.end(),
+ LauncherGenerator(*this,
+ connection_handler,
+ app_launch_max_retry_attempt,
+ app_launch_retry_wait_time));
+}
+
+void AppsLauncher::StartLaunching(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ DCHECK_OR_RETURN_VOID(!free_launchers_.empty())
+ const AppLaunchers::iterator it = free_launchers_.begin();
+ LauncherPtr app_launcher = *it;
+ works_launchers_.push_back(app_launcher);
+ free_launchers_.erase(it);
+ app_launcher->PosponedLaunch(app_data);
+}
+
+struct AppLauncherFinder {
+ AppLauncherFinder(const ApplicationDataPtr& app_data) : app_data_(app_data) {}
+ bool operator()(const AppsLauncher::LauncherPtr& launcher) const {
+ DCHECK_OR_RETURN(launcher->app_data_ && app_data_, false)
+ return *launcher->app_data_ == *app_data_;
+ }
+ const ApplicationDataPtr& app_data_;
+};
+
+void AppsLauncher::StopLaunching(ApplicationDataPtr app_data) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ const AppLaunchers::iterator it = std::find_if(works_launchers_.begin(),
+ works_launchers_.end(),
+ AppLauncherFinder(app_data));
+ if (it != works_launchers_.end()) {
+ LauncherPtr launcher = *it;
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+ works_launchers_.erase(it);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Unable to StopLaunching" << app_data->mobile_app_id_);
+ }
+}
+
+void AppsLauncher::OnLaunched(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopLaunching(app_data);
+}
+
+void AppsLauncher::OnRetryAttemptsExhausted(ApplicationDataPtr app_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopLaunching(app_data);
+}
+
+AppsLauncher::Launcher::Launcher(
+ AppsLauncher& parent,
+ connection_handler::ConnectionHandler& connection_handler,
+ const uint16_t app_launch_max_retry_attempt,
+ const uint16_t app_launch_retry_wait_time)
+ : retry_timer_(
+ "AppsLauncherTimer",
+ new timer::TimerTaskImpl<Launcher>(this, &Launcher::LaunchNow))
+ , app_launch_max_retry_attempt_(app_launch_max_retry_attempt)
+ , app_launch_retry_wait_time_(app_launch_retry_wait_time)
+ , connection_handler_(connection_handler)
+ , parent_(parent) {}
+
+void AppsLauncher::Launcher::PosponedLaunch(
+ const app_launch::ApplicationDataPtr& app_data) {
+ DCHECK(!app_data_);
+ app_data_ = app_data;
+ retry_index_ = 0;
+ retry_timer_.Start(app_launch_retry_wait_time_, timer::kPeriodic);
+ LOG4CXX_DEBUG(logger_,
+ "Applicaiton " << app_data->mobile_app_id_ << " on device "
+ << app_data->device_mac_
+ << " will be launched in "
+ << app_launch_retry_wait_time_ << " ms");
+}
+
+void AppsLauncher::Launcher::Clear() {
+ retry_timer_.Stop();
+ app_data_.reset();
+ retry_index_ = 0;
+}
+
+void AppsLauncher::Launcher::LaunchNow() {
+ if (retry_index_++ < app_launch_max_retry_attempt_) {
+ LOG4CXX_DEBUG(logger_,
+ "Run App " << app_data_->mobile_app_id_ << "with bundle "
+ << app_data_->bundle_id_ << " On Device "
+ << app_data_->device_mac_);
+
+ connection_handler_.RunAppOnDevice(app_data_->device_mac_,
+ app_data_->bundle_id_);
+ } else {
+ parent_.OnRetryAttemptsExhausted(app_data_);
+ }
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
new file mode 100644
index 0000000000..0eb9245cf8
--- /dev/null
+++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
@@ -0,0 +1,208 @@
+#include <string>
+#include <vector>
+#include <algorithm>
+
+#include "application_manager/app_launch/device_apps_launcher.h"
+#include "application_manager/app_launch/app_launch_data.h"
+#include "application_manager/app_launch/apps_launcher.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+#include "utils/timer.h"
+#include "utils/timer_task_impl.h"
+#include <iostream>
+
+namespace app_launch {
+CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
+
+typedef std::pair<std::string, std::vector<ApplicationDataPtr> > AppsOnDevice;
+typedef utils::SharedPtr<AppsOnDevice> AppsOnDevicePtr;
+
+class Launcher {
+ public:
+ Launcher(const resumption::ResumeCtrl& resume_ctrl,
+ DeviceAppsLauncher& device_launcher,
+ AppsLauncher& apps_launcher)
+ : device_launcher_(device_launcher)
+ , apps_launcher_(apps_launcher)
+ , resume_ctrl_(resume_ctrl)
+ , gap_between_app_timer_("GapBetweenLaunchTimer",
+ new timer::TimerTaskImpl<Launcher>(
+ this, &Launcher::OnGapBetweenLaunchExpired))
+ , wait_before_launch_timer_(
+ "WaitBeforeLainchTimer",
+ new timer::TimerTaskImpl<Launcher>(this, &Launcher::LaunchNext)) {}
+
+ void Start(const AppsOnDevicePtr& apps_on_device) {
+ DCHECK(!apps_on_device_);
+ apps_on_device_ = apps_on_device;
+ const time_t curr_time = time(NULL);
+ const time_t sdl_launch_time = resume_ctrl_.LaunchTime();
+ const double seconds_from_sdl_start = difftime(curr_time, sdl_launch_time);
+ const uint32_t wait_time =
+ device_launcher_.settings().resumption_delay_after_ign();
+ const uint32_t wait_before_launch_timeout =
+ seconds_from_sdl_start < wait_time
+ ? wait_time - seconds_from_sdl_start
+ : device_launcher_.settings().app_launch_wait_time();
+ wait_before_launch_timer_.Start(wait_before_launch_timeout,
+ timer::kSingleShot);
+ }
+
+ void LaunchNext() {
+ std::vector<ApplicationDataPtr>& apps = apps_on_device_->second;
+ std::vector<ApplicationDataPtr>::iterator it = apps.begin();
+ if (it != apps.end()) {
+ apps_launcher_.StartLaunching(*it);
+ apps.erase(it);
+ gap_between_app_timer_.Start(
+ device_launcher_.settings().wait_time_between_apps(),
+ timer::kSingleShot);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "All Apps on " << apps_on_device_->first
+ << " posponed launched");
+ device_launcher_.StopLaunchingAppsOnDevice(apps_on_device_->first);
+ }
+ }
+
+ void OnGapBetweenLaunchExpired() {
+ LaunchNext();
+ }
+
+ void OnAppRegistered(const ApplicationDataPtr& app_data) {
+ std::vector<ApplicationDataPtr>& apps = apps_on_device_->second;
+ std::vector<ApplicationDataPtr>::iterator it =
+ std::find(apps.begin(), apps.end(), app_data);
+ if (it != apps.end()) {
+ apps.erase(it);
+ }
+ }
+
+ void Clear() {
+ gap_between_app_timer_.Stop();
+ wait_before_launch_timer_.Stop();
+ apps_on_device_.reset();
+ }
+
+ DeviceAppsLauncher& device_launcher_;
+ AppsLauncher& apps_launcher_;
+ const resumption::ResumeCtrl& resume_ctrl_;
+
+ timer::Timer gap_between_app_timer_;
+ timer::Timer wait_before_launch_timer_;
+
+ AppsOnDevicePtr apps_on_device_;
+};
+
+typedef utils::SharedPtr<Launcher> LauncherPtr;
+typedef std::vector<LauncherPtr> Launchers;
+
+struct LauncherGenerator {
+ LauncherGenerator(resumption::ResumeCtrl& resume_ctrl,
+ DeviceAppsLauncher& interface,
+ AppsLauncher& apps_launcher)
+ : resume_ctrl_(resume_ctrl)
+ , interface_(interface)
+ , apps_launcher_(apps_launcher) {}
+
+ LauncherPtr operator()() const {
+ return utils::MakeShared<Launcher>(
+ resume_ctrl_, interface_, apps_launcher_);
+ }
+
+ resumption::ResumeCtrl& resume_ctrl_;
+ DeviceAppsLauncher& interface_;
+ AppsLauncher& apps_launcher_;
+};
+
+class DeviceAppsLauncherImpl {
+ public:
+ DeviceAppsLauncherImpl(DeviceAppsLauncher& interface,
+ AppsLauncher& apps_launcher)
+ : interface_(interface) {
+ sync_primitives::AutoLock lock(launchers_lock_);
+ LauncherGenerator generate(
+ interface.app_mngr_.resume_controller(), interface, apps_launcher);
+ free_launchers_.reserve(interface.settings_.max_number_of_ios_device());
+ std::generate_n(std::back_inserter(free_launchers_),
+ interface.settings_.max_number_of_ios_device(),
+ generate);
+ }
+
+ bool LaunchAppsOnDevice(
+ const std::string& device_mac,
+ const std::vector<ApplicationDataPtr>& applications_to_launch) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_,
+ "On Device " << device_mac << " will be launched "
+ << applications_to_launch.size() << " apps");
+ AppsOnDevicePtr apps_on_device =
+ utils::MakeShared<AppsOnDevice>(device_mac, applications_to_launch);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ DCHECK_OR_RETURN(!free_launchers_.empty(), false)
+ const Launchers::iterator it = free_launchers_.begin();
+ LauncherPtr launcher = *it;
+ works_launchers_.push_back(launcher);
+ free_launchers_.erase(it);
+ launcher->Start(apps_on_device);
+ return true;
+ }
+
+ struct LauncherFinder {
+ LauncherFinder(const std::string& device_mac) : device_mac_(device_mac) {}
+
+ bool operator()(const LauncherPtr& launcher) const {
+ return device_mac_ == launcher->apps_on_device_->first;
+ }
+
+ std::string device_mac_;
+ };
+
+ bool StopLaunchingAppsOnDevice(const std::string& device_mac) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launchers_lock_);
+ const Launchers::iterator it = std::find_if(works_launchers_.begin(),
+ works_launchers_.end(),
+ LauncherFinder(device_mac));
+ if (it == works_launchers_.end()) {
+ return false;
+ }
+ LauncherPtr launcher = *it;
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+ works_launchers_.erase(it);
+ return true;
+ }
+
+ private:
+ sync_primitives::Lock launchers_lock_;
+ Launchers free_launchers_;
+ Launchers works_launchers_;
+ DeviceAppsLauncher& interface_;
+};
+
+bool DeviceAppsLauncher::LaunchAppsOnDevice(
+ const std::string& device_mac,
+ const std::vector<ApplicationDataPtr>& applications_to_launch) {
+ return impl_->LaunchAppsOnDevice(device_mac, applications_to_launch);
+}
+
+DeviceAppsLauncher::DeviceAppsLauncher(
+ application_manager::ApplicationManager& app_mngr,
+ app_launch::AppsLauncher& apps_launcher,
+ const AppLaunchSettings& settings)
+ : app_mngr_(app_mngr)
+ , settings_(settings)
+ , impl_(new DeviceAppsLauncherImpl(*this, apps_launcher)) {}
+
+bool DeviceAppsLauncher::StopLaunchingAppsOnDevice(
+ const std::string& device_mac) {
+ return impl_->StopLaunchingAppsOnDevice(device_mac);
+}
+
+const AppLaunchSettings& DeviceAppsLauncher::settings() const {
+ return settings_;
+}
+
+} // namespace app_launch
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 61451e3602..5f9c4386f5 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -171,6 +171,11 @@ bool ApplicationImpl::IsFullscreen() const {
return mobile_api::HMILevel::HMI_FULL == hmi_level();
}
+bool ApplicationImpl::is_audio() const {
+ return is_media_application() || is_voice_communication_supported() ||
+ is_navi();
+}
+
void ApplicationImpl::ChangeSupportingAppHMIType() {
is_navi_ = false;
is_voice_communication_application_ = false;
@@ -318,6 +323,10 @@ const std::string& ApplicationImpl::app_icon_path() const {
return app_icon_path_;
}
+const std::string& ApplicationImpl::bundle_id() const {
+ return bundle_id_;
+}
+
connection_handler::DeviceHandle ApplicationImpl::device() const {
return device_;
}
@@ -489,7 +498,8 @@ void ApplicationImpl::WakeUpStreaming(
ServiceType::kMobileNav, true, application_manager_);
video_streaming_suspended_ = false;
}
- video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, false);
+ video_stream_suspend_timer_.Start(video_stream_suspend_timeout_,
+ timer::kPeriodic);
} else if (ServiceType::kAudio == service_type) {
sync_primitives::AutoLock lock(audio_streaming_suspended_lock_);
if (audio_streaming_suspended_) {
@@ -498,7 +508,8 @@ void ApplicationImpl::WakeUpStreaming(
ServiceType::kAudio, true, application_manager_);
audio_streaming_suspended_ = false;
}
- audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, false);
+ audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_,
+ timer::kPeriodic);
}
}
@@ -570,6 +581,10 @@ void ApplicationImpl::set_grammar_id(uint32_t value) {
grammar_id_ = value;
}
+void ApplicationImpl::set_bundle_id(const std::string& bundle_id) {
+ bundle_id_ = bundle_id;
+}
+
void ApplicationImpl::ResetDataInNone() {
put_file_in_none_count_ = 0;
delete_file_in_none_count_ = 0;
@@ -688,7 +703,7 @@ UsageStatistics& ApplicationImpl::usage_report() {
return usage_report_;
}
-bool ApplicationImpl::IsCommandLimitsExceeded(
+bool ApplicationImpl::AreCommandLimitsExceeded(
mobile_apis::FunctionID::eType cmd_id, TLimitSource source) {
TimevalStruct current = date_time::DateTime::getCurrentTime();
switch (source) {
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8cf09412f3..097abc4645 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -44,6 +44,11 @@
#include "application_manager/message_helper.h"
#include "application_manager/mobile_message_handler.h"
#include "application_manager/policies/policy_handler.h"
+#include "application_manager/hmi_capabilities_impl.h"
+#include "application_manager/resumption/resume_ctrl_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl_impl.h"
+#include "application_manager/app_launch/app_launch_data_db.h"
+#include "application_manager/app_launch/app_launch_data_json.h"
#include "protocol_handler/protocol_handler.h"
#include "hmi_message_handler/hmi_message_handler.h"
#include "connection_handler/connection_handler_impl.h"
@@ -104,7 +109,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, media_manager_(NULL)
, hmi_handler_(NULL)
, connection_handler_(NULL)
- , policy_handler_(policy_settings, *this)
+ , policy_handler_(new policy::PolicyHandler(policy_settings, *this))
, protocol_handler_(NULL)
, request_ctrl_(am_settings)
, hmi_so_factory_(NULL)
@@ -114,10 +119,10 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, messages_from_hmi_("AM FromHMI", this)
, messages_to_hmi_("AM ToHMI", this)
, audio_pass_thru_messages_("AudioPassThru", this)
- , hmi_capabilities_(*this)
+ , hmi_capabilities_(new HMICapabilitiesImpl(*this))
, unregister_reason_(
mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM)
- , resume_ctrl_(*this)
+ , resume_ctrl_(new resumption::ResumeCtrlImpl(*this))
, navi_close_app_timeout_(am_settings.stop_streaming_timeout())
, navi_end_stream_timeout_(am_settings.stop_streaming_timeout())
, stopping_application_mng_lock_(true)
@@ -134,6 +139,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties))
, is_low_voltage_(false)
+ , apps_size_(0)
, is_stopping_(false) {
std::srand(std::time(0));
AddPolicyObserver(this);
@@ -148,7 +154,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::ClearTimerPool)));
const uint32_t timeout_ms = 10000u;
- clearing_timer->Start(timeout_ms, false);
+ clearing_timer->Start(timeout_ms, timer::kSingleShot);
timer_pool_.push_back(clearing_timer);
}
@@ -427,7 +433,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
LOG4CXX_DEBUG(logger_, "Restarting application list update timer");
GetPolicyHandler().OnAppsSearchStarted();
uint32_t timeout = get_settings().application_list_update_timeout();
- application_list_update_timer_.Start(timeout, true);
+ application_list_update_timer_.Start(timeout, timer::kSingleShot);
if (!is_all_apps_allowed_) {
LOG4CXX_WARN(logger_,
@@ -462,12 +468,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
GetPolicyHandler().GetStatisticManager(),
*this));
if (!application) {
- usage_statistics::AppCounter count_of_rejections_sync_out_of_memory(
- GetPolicyHandler().GetStatisticManager(),
- policy_app_id,
- usage_statistics::REJECTIONS_SYNC_OUT_OF_MEMORY);
- ++count_of_rejections_sync_out_of_memory;
-
utils::SharedPtr<smart_objects::SmartObject> response(
MessageHelper::CreateNegativeResponse(
connection_key,
@@ -534,26 +534,32 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
if (!application->hmi_app_id()) {
const bool is_saved =
- resume_ctrl_.IsApplicationSaved(policy_app_id, device_mac);
+ resume_controller().IsApplicationSaved(policy_app_id, device_mac);
application->set_hmi_application_id(
- is_saved ? resume_ctrl_.GetHMIApplicationID(policy_app_id, device_mac)
- : GenerateNewHMIAppID());
+ is_saved
+ ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac)
+ : GenerateNewHMIAppID());
}
+ if (params.keyExists(strings::app_info)) {
+ const smart_objects::SmartObject& app_info = params[strings::app_info];
+ const std::string& bundle_id = app_info[strings::bundle_id].asString();
+ application->set_bundle_id(bundle_id);
+ }
// Stops timer of saving data to resumption in order to
// doesn't erase data from resumption storage.
// Timer will be started after hmi level resumption.
- resume_ctrl_.OnAppRegistrationStart(policy_app_id, device_mac);
+ resume_controller().OnAppRegistrationStart(policy_app_id, device_mac);
+
// Add application to registered app list and set appropriate mark.
// Lock has to be released before adding app to policy DB to avoid possible
// deadlock with simultaneous PTU processing
applications_list_lock_.Acquire();
application->MarkRegistered();
applications_.insert(application);
+ apps_size_ = applications_.size();
applications_list_lock_.Release();
- GetPolicyHandler().AddApplication(application->policy_app_id());
-
return application;
}
@@ -913,6 +919,7 @@ void ApplicationManagerImpl::OnDeviceListUpdated(
GetPolicyHandler().AddDevice(dev_params.device_mac_address,
device_info.connection_type);
+ app_launch_ctrl().OnDeviceConnected(dev_params.device_mac_address);
}
smart_objects::SmartObjectSPtr msg_params =
@@ -939,7 +946,7 @@ void ApplicationManagerImpl::OnFindNewApplicationsRequest() {
connection_handler().ConnectToAllDevices();
LOG4CXX_DEBUG(logger_, "Starting application list update timer");
uint32_t timeout = get_settings().application_list_update_timeout();
- application_list_update_timer_.Start(timeout, true);
+ application_list_update_timer_.Start(timeout, timer::kSingleShot);
GetPolicyHandler().OnAppsSearchStarted();
}
@@ -975,10 +982,10 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel(
LOG4CXX_AUTO_TRACE(logger_);
HMILevel::eType default_hmi = HMILevel::HMI_NONE;
- if (policy_handler_.PolicyEnabled()) {
+ if (GetPolicyHandler().PolicyEnabled()) {
const std::string policy_app_id = application->policy_app_id();
std::string default_hmi_string = "";
- if (policy_handler_.GetDefaultHmi(policy_app_id, &default_hmi_string)) {
+ if (GetPolicyHandler().GetDefaultHmi(policy_app_id, &default_hmi_string)) {
if ("BACKGROUND" == default_hmi_string) {
default_hmi = HMILevel::HMI_BACKGROUND;
} else if ("FULL" == default_hmi_string) {
@@ -1009,7 +1016,7 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() {
uint32_t hmi_app_id = get_rand_from_range(1);
LOG4CXX_DEBUG(logger_, "GenerateNewHMIAppID value is: " << hmi_app_id);
- while (resume_ctrl_.IsHMIApplicationIdExist(hmi_app_id)) {
+ while (resume_controller().IsHMIApplicationIdExist(hmi_app_id)) {
LOG4CXX_DEBUG(logger_, "HMI appID " << hmi_app_id << " is exists.");
hmi_app_id = get_rand_from_range(1);
LOG4CXX_DEBUG(logger_, "Trying new value: " << hmi_app_id);
@@ -1340,9 +1347,12 @@ void ApplicationManagerImpl::SendMessageToMobile(
ApplicationSharedPtr app = application(
(*message)[strings::params][strings::connection_key].asUInt());
+ const bool is_result_code_exists =
+ (*message)[strings::msg_params].keyExists(strings::result_code);
+
if (!app) {
LOG4CXX_ERROR(logger_, "No application associated with connection key");
- if ((*message)[strings::msg_params].keyExists(strings::result_code) &&
+ if (is_result_code_exists &&
((*message)[strings::msg_params][strings::result_code] ==
NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) {
(*message)[strings::params][strings::protocol_version] =
@@ -1356,6 +1366,12 @@ void ApplicationManagerImpl::SendMessageToMobile(
app->protocol_version();
}
+ if (app && is_result_code_exists &&
+ (*message)[strings::msg_params][strings::result_code] ==
+ mobile_apis::Result::OUT_OF_MEMORY) {
+ app->usage_report().RecordRejectionsSyncOutOfMemory();
+ }
+
mobile_so_factory().attachSchema(*message, false);
LOG4CXX_DEBUG(
logger_,
@@ -1374,8 +1390,9 @@ void ApplicationManagerImpl::SendMessageToMobile(
// checked against policy permissions
if (msg_to_mobile[strings::params].keyExists(strings::correlation_id)) {
request_ctrl_.OnMobileResponse(
- msg_to_mobile[strings::params][strings::correlation_id].asInt(),
- msg_to_mobile[strings::params][strings::connection_key].asInt());
+ msg_to_mobile[strings::params][strings::correlation_id].asUInt(),
+ msg_to_mobile[strings::params][strings::connection_key].asUInt(),
+ msg_to_mobile[strings::params][strings::function_id].asInt());
} else if (app) {
mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
@@ -1390,21 +1407,22 @@ void ApplicationManagerImpl::SendMessageToMobile(
for (; iter != iter_end; ++iter) {
if (true == iter->second.asBool()) {
LOG4CXX_INFO(logger_, "Request's param: " << iter->first);
- params.push_back(iter->first);
+ params.insert(iter->first);
}
}
}
- const mobile_apis::Result::eType check_result = CheckPolicyPermissions(
- app->policy_app_id(), app->hmi_level(), function_id, params);
+ const std::string string_functionID =
+ MessageHelper::StringifiedFunctionID(function_id);
+ const mobile_apis::Result::eType check_result =
+ CheckPolicyPermissions(app, string_functionID, params);
if (mobile_apis::Result::SUCCESS != check_result) {
- const std::string string_functionID =
- MessageHelper::StringifiedFunctionID(function_id);
LOG4CXX_WARN(logger_,
"Function \"" << string_functionID << "\" (#" << function_id
<< ") not allowed by policy");
return;
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
if (function_id == mobile_apis::FunctionID::OnSystemRequestID) {
mobile_apis::RequestType::eType request_type =
static_cast<mobile_apis::RequestType::eType>(
@@ -1414,6 +1432,7 @@ void ApplicationManagerImpl::SendMessageToMobile(
GetPolicyHandler().OnUpdateRequestSentToMobile();
}
}
+#endif // EXTERNAL_PROPRIETARY_MODE
}
if (message_to_send->binary_data()) {
@@ -1425,9 +1444,10 @@ void ApplicationManagerImpl::SendMessageToMobile(
impl::MessageToMobile(message_to_send, final_message));
}
-void ApplicationManagerImpl::TerminateRequest(uint32_t connection_key,
- uint32_t corr_id) {
- request_ctrl_.terminateRequest(corr_id, connection_key, true);
+void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key,
+ const uint32_t corr_id,
+ const int32_t function_id) {
+ request_ctrl_.TerminateRequest(corr_id, connection_key, function_id, true);
}
bool ApplicationManagerImpl::ManageMobileCommand(
@@ -1680,8 +1700,10 @@ bool ApplicationManagerImpl::ManageHMICommand(
command->Run();
if (kResponse == message_type) {
const uint32_t correlation_id =
- (*(message.get()))[strings::params][strings::correlation_id].asInt();
- request_ctrl_.OnHMIResponse(correlation_id);
+ (*(message.get()))[strings::params][strings::correlation_id].asUInt();
+ const int32_t function_id =
+ (*(message.get()))[strings::params][strings::function_id].asInt();
+ request_ctrl_.OnHMIResponse(correlation_id, function_id);
}
return true;
}
@@ -1696,11 +1718,11 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
!IsReadWriteAllowed(app_storage_folder, TYPE_STORAGE)) {
return false;
}
- if (!resume_ctrl_.Init(last_state)) {
+ if (!resume_controller().Init(last_state)) {
LOG4CXX_ERROR(logger_, "Problem with initialization of resume controller");
return false;
}
- hmi_capabilities_.Init(&last_state);
+ hmi_capabilities_->Init(&last_state);
if (!(file_system::IsWritingAllowed(app_storage_folder) &&
file_system::IsReadingAllowed(app_storage_folder))) {
@@ -1737,6 +1759,16 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
"System is configured to work without policy functionality.");
}
media_manager_ = media_manager;
+
+ if (settings_.use_db_for_resumption()) {
+ app_launch_dto_.reset(new app_launch::AppLaunchDataDB(settings_));
+ } else {
+ app_launch_dto_.reset(
+ new app_launch::AppLaunchDataJson(settings_, last_state));
+ }
+ app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl(
+ *app_launch_dto_.get(), *this, settings_));
+
return true;
}
@@ -2122,11 +2154,11 @@ mobile_apis::MOBILE_API& ApplicationManagerImpl::mobile_so_factory() {
}
HMICapabilities& ApplicationManagerImpl::hmi_capabilities() {
- return hmi_capabilities_;
+ return *hmi_capabilities_;
}
const HMICapabilities& ApplicationManagerImpl::hmi_capabilities() const {
- return hmi_capabilities_;
+ return *hmi_capabilities_;
}
void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data,
@@ -2257,8 +2289,8 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
device_id, NULL, NULL, &device_mac, NULL);
const uint32_t hmi_app_id =
- resume_ctrl_.IsApplicationSaved(policy_app_id, device_mac)
- ? resume_ctrl_.GetHMIApplicationID(policy_app_id, device_mac)
+ resume_controller().IsApplicationSaved(policy_app_id, device_mac)
+ ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac)
: GenerateNewHMIAppID();
// AppId = 0 because this is query_app(provided by hmi for download, but not
@@ -2603,12 +2635,12 @@ void ApplicationManagerImpl::UnregisterApplication(
return;
}
if (is_resuming) {
- resume_ctrl_.SaveApplication(app_to_remove);
+ resume_controller().SaveApplication(app_to_remove);
} else {
- resume_ctrl_.RemoveApplicationFromSaved(app_to_remove);
+ resume_controller().RemoveApplicationFromSaved(app_to_remove);
}
applications_.erase(app_to_remove);
- (hmi_capabilities_.get_hmi_language_handler())
+ (hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
AppV4DevicePredicate finder(handle);
ApplicationSharedPtr app = FindApp(accessor, finder);
@@ -2750,32 +2782,20 @@ void ApplicationManagerImpl::Handle(const impl::AudioData message) {
}
mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
- const std::string& policy_app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::FunctionID::eType function_id,
+ const ApplicationSharedPtr app,
+ const std::string& function_id,
const RPCParams& rpc_params,
CommandParametersPermissions* params_permissions) {
- LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_INFO(logger_, "CheckPolicyPermissions");
// TODO(AOleynik): Remove check of policy_enable, when this flag will be
// unused in config file
if (!GetPolicyHandler().PolicyEnabled()) {
return mobile_apis::Result::SUCCESS;
}
- const std::string stringified_functionID =
- MessageHelper::StringifiedFunctionID(function_id);
- const std::string stringified_hmi_level =
- MessageHelper::StringifiedHMILevel(hmi_level);
- LOG4CXX_DEBUG(logger_,
- "Checking permissions for " << policy_app_id << " in "
- << stringified_hmi_level << " rpc "
- << stringified_functionID);
+ DCHECK(app);
policy::CheckPermissionResult result;
- GetPolicyHandler().CheckPermissions(policy_app_id,
- stringified_hmi_level,
- stringified_functionID,
- rpc_params,
- result);
+ GetPolicyHandler().CheckPermissions(app, function_id, rpc_params, result);
if (NULL != params_permissions) {
params_permissions->allowed_params = result.list_of_allowed_params;
@@ -2783,30 +2803,22 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
params_permissions->undefined_params = result.list_of_undefined_params;
}
- if (hmi_level == mobile_apis::HMILevel::HMI_NONE &&
- function_id != mobile_apis::FunctionID::UnregisterAppInterfaceID) {
- ApplicationSharedPtr app = application_by_policy_id(policy_app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "No application for policy id " << policy_app_id);
- return mobile_apis::Result::GENERIC_ERROR;
- }
+ if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE &&
+ function_id != MessageHelper::StringifiedFunctionID(
+ mobile_apis::FunctionID::UnregisterAppInterfaceID)) {
if (result.hmi_level_permitted != policy::kRpcAllowed) {
app->usage_report().RecordRpcSentInHMINone();
}
}
- const std::string log_msg = "Application: " + policy_app_id + ", RPC: " +
- stringified_functionID + ", HMI status: " +
- stringified_hmi_level;
-
+#ifdef ENABLE_LOG
+ const std::string log_msg =
+ "Application: " + app->policy_app_id() + ", RPC: " + function_id +
+ ", HMI status: " + MessageHelper::StringifiedHMILevel(app->hmi_level());
+#endif // ENABLE_LOG
if (result.hmi_level_permitted != policy::kRpcAllowed) {
LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg);
- ApplicationSharedPtr app = application_by_policy_id(policy_app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "No application for policy id " << policy_app_id);
- return mobile_apis::Result::GENERIC_ERROR;
- }
app->usage_report().RecordPolicyRejectedRpcCall();
switch (result.hmi_level_permitted) {
@@ -2972,7 +2984,7 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
"CloseNaviAppTimer",
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::CloseNaviApp)));
- close_timer->Start(navi_close_app_timeout_, true);
+ close_timer->Start(navi_close_app_timeout_, timer::kSingleShot);
sync_primitives::AutoLock lock(timer_pool_lock_);
timer_pool_.push_back(close_timer);
@@ -3013,7 +3025,7 @@ void ApplicationManagerImpl::OnHMILevelChanged(
"AppShouldFinishStreaming",
new TimerTaskImpl<ApplicationManagerImpl>(
this, &ApplicationManagerImpl::EndNaviStreaming)));
- end_stream_timer->Start(navi_end_stream_timeout_, true);
+ end_stream_timer->Start(navi_end_stream_timeout_, timer::kPeriodic);
sync_primitives::AutoLock lock(timer_pool_lock_);
timer_pool_.push_back(end_stream_timer);
@@ -3077,7 +3089,7 @@ void ApplicationManagerImpl::CloseNaviApp() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis::AppInterfaceUnregisteredReason;
using namespace mobile_apis::Result;
-
+ DCHECK_OR_RETURN_VOID(!navi_app_to_stop_.empty());
uint32_t app_id = navi_app_to_stop_.front();
navi_app_to_stop_.pop_front();
@@ -3100,12 +3112,14 @@ void ApplicationManagerImpl::EndNaviStreaming() {
using namespace mobile_apis::AppInterfaceUnregisteredReason;
using namespace mobile_apis::Result;
- uint32_t app_id = navi_app_to_end_stream_.front();
- navi_app_to_end_stream_.pop_front();
+ if (!navi_app_to_end_stream_.empty()) {
+ const uint32_t app_id = navi_app_to_end_stream_.front();
+ navi_app_to_end_stream_.pop_front();
- if (navi_app_to_stop_.end() ==
- std::find(navi_app_to_stop_.begin(), navi_app_to_stop_.end(), app_id)) {
- DisallowStreaming(app_id);
+ if (navi_app_to_stop_.end() ==
+ std::find(navi_app_to_stop_.begin(), navi_app_to_stop_.end(), app_id)) {
+ DisallowStreaming(app_id);
+ }
}
}
@@ -3159,7 +3173,7 @@ bool ApplicationManagerImpl::IsApplicationForbidden(
policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice(
const std::string& device_id) const {
- return policy_handler_.GetUserConsentForDevice(device_id);
+ return GetPolicyHandler().GetUserConsentForDevice(device_id);
}
void ApplicationManagerImpl::OnWakeUp() {
@@ -3250,8 +3264,12 @@ bool ApplicationManagerImpl::IsHMICooperating() const {
void ApplicationManagerImpl::OnApplicationListUpdateTimer() {
LOG4CXX_DEBUG(logger_, "Application list update timer finished");
+
+ apps_to_register_list_lock_.Acquire();
+ const bool trigger_ptu = apps_size_ != applications_.size();
+ apps_to_register_list_lock_.Release();
SendUpdateAppList();
- GetPolicyHandler().OnAppsSearchCompleted();
+ GetPolicyHandler().OnAppsSearchCompleted(trigger_ptu);
}
void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() {
@@ -3299,7 +3317,7 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList(
LOG4CXX_INFO(logger_, "Start tts_global_properties_timer_");
tts_global_properties_app_list_lock_.Release();
const uint32_t timeout_ms = 1000;
- tts_global_properties_timer_.Start(timeout_ms, false);
+ tts_global_properties_timer_.Start(timeout_ms, timer::kSingleShot);
return;
}
tts_global_properties_app_list_lock_.Release();
@@ -3460,6 +3478,10 @@ event_engine::EventDispatcher& ApplicationManagerImpl::event_dispatcher() {
return event_dispatcher_;
}
+app_launch::AppLaunchCtrl& ApplicationManagerImpl::app_launch_ctrl() {
+ return *app_launch_ctrl_;
+}
+
const std::string ApplicationManagerImpl::DirectoryTypeToString(
ApplicationManagerImpl::DirectoryType type) const {
DirectoryTypeMap::const_iterator it = dir_type_to_string_map_.find(type);
diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc
index b3b463328f..cea5412587 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,15 +32,92 @@
#include <algorithm>
#include <string>
+#include "utils/macro.h"
#include "application_manager/commands/command_request_impl.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
#include "smart_objects/smart_object.h"
-
namespace application_manager {
namespace commands {
+std::string MergeInfos(const ResponseInfo& first_info,
+ const std::string& first_str,
+ const ResponseInfo& second_info,
+ const std::string& second_str) {
+ if ((first_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !second_str.empty()) {
+ return second_str;
+ }
+
+ if ((second_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !first_str.empty()) {
+ return first_str;
+ }
+
+ return MergeInfos(first_str, second_str);
+}
+
+std::string MergeInfos(const std::string& first, const std::string& second) {
+ return first + ((!first.empty() && !second.empty()) ? ", " : "") + second;
+}
+
+std::string MergeInfos(const std::string& first,
+ const std::string& second,
+ const std::string& third) {
+ std::string result = MergeInfos(first, second);
+ return MergeInfos(result, third);
+}
+
+const std::string CreateInfoForUnsupportedResult(
+ HmiInterfaces::InterfaceID interface) {
+ switch (interface) {
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VR): {
+ return "VR is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS): {
+ return "TTS is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_UI): {
+ return "UI is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_Navigation): {
+ return "Navi is not supported by system";
+ }
+ case (HmiInterfaces::InterfaceID::HMI_INTERFACE_VehicleInfo): {
+ return "VehicleInfo is not supported by system";
+ }
+ default:
+#ifdef ENABLE_LOG
+ CREATE_LOGGERPTR_LOCAL(logger, "Commands");
+ LOG4CXX_WARN(logger,
+ "Could not create info because"
+ " interface isn't valid. Interface is:"
+ << static_cast<int32_t>(interface));
+#endif // ENABLE_LOG
+ return "";
+ }
+}
+
+bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) {
+ if (first.is_ok && second.is_unsupported_resource &&
+ second.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) {
+ return true;
+ }
+ return false;
+}
+
+bool IsResultCodeUnsupported(const ResponseInfo& first,
+ const ResponseInfo& second) {
+ return ((first.is_ok || first.is_invalid_enum) &&
+ second.is_unsupported_resource) ||
+ ((second.is_ok || second.is_invalid_enum) &&
+ first.is_unsupported_resource) ||
+ (first.is_unsupported_resource && second.is_unsupported_resource);
+}
+
struct DisallowedParamsInserter {
DisallowedParamsInserter(smart_objects::SmartObject& response,
mobile_apis::VehicleDataResultCode::eType code)
@@ -194,6 +271,43 @@ bool CommandRequestImpl::CheckSyntax(const std::string& str,
return true;
}
+smart_objects::SmartObject CreateUnsupportedResourceResponse(
+ const hmi_apis::FunctionID::eType function_id,
+ const uint32_t hmi_correlation_id,
+ HmiInterfaces::InterfaceID interface) {
+ smart_objects::SmartObject response(smart_objects::SmartType_Map);
+ smart_objects::SmartObject& params = response[strings::params];
+ params[strings::message_type] = MessageType::kResponse;
+ params[strings::correlation_id] = hmi_correlation_id;
+ params[strings::protocol_type] = CommandImpl::hmi_protocol_type_;
+ params[strings::protocol_version] = CommandImpl::protocol_version_;
+ params[strings::function_id] = function_id;
+ params[hmi_response::code] = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ smart_objects::SmartObject& msg_params = response[strings::msg_params];
+ msg_params[strings::info] = CreateInfoForUnsupportedResult(interface);
+ return response;
+}
+
+bool CommandRequestImpl::ProcessHMIInterfacesAvailability(
+ const uint32_t hmi_correlation_id,
+ const hmi_apis::FunctionID::eType& function_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ HmiInterfaces::InterfaceID interface =
+ hmi_interfaces.GetInterfaceFromFunction(function_id);
+ DCHECK(interface != HmiInterfaces::HMI_INTERFACE_INVALID_ENUM);
+ const HmiInterfaces::InterfaceState state =
+ hmi_interfaces.GetInterfaceState(interface);
+ if (HmiInterfaces::STATE_NOT_AVAILABLE == state) {
+ event_engine::Event event(function_id);
+ event.set_smart_object(CreateUnsupportedResourceResponse(
+ function_id, hmi_correlation_id, interface));
+ event.raise(application_manager_.event_dispatcher());
+ return false;
+ }
+ return true;
+}
+
uint32_t CommandRequestImpl::SendHMIRequest(
const hmi_apis::FunctionID::eType& function_id,
const smart_objects::SmartObject* msg_params,
@@ -202,12 +316,6 @@ uint32_t CommandRequestImpl::SendHMIRequest(
const uint32_t hmi_correlation_id =
application_manager_.GetNextHMICorrelationID();
- if (use_events) {
- LOG4CXX_DEBUG(logger_,
- "subscribe_on_event " << function_id << " "
- << hmi_correlation_id);
- subscribe_on_event(function_id, hmi_correlation_id);
- }
smart_objects::SmartObject& request = *result;
request[strings::params][strings::message_type] = MessageType::kRequest;
@@ -222,9 +330,19 @@ uint32_t CommandRequestImpl::SendHMIRequest(
request[strings::msg_params] = *msg_params;
}
- if (!application_manager_.ManageHMICommand(result)) {
- LOG4CXX_ERROR(logger_, "Unable to send request");
- SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY);
+ if (use_events) {
+ LOG4CXX_DEBUG(logger_,
+ "subscribe_on_event " << function_id << " "
+ << hmi_correlation_id);
+ subscribe_on_event(function_id, hmi_correlation_id);
+ }
+ if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) {
+ if (!application_manager_.ManageHMICommand(result)) {
+ LOG4CXX_ERROR(logger_, "Unable to send request");
+ SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY);
+ }
+ } else {
+ LOG4CXX_DEBUG(logger_, "Interface is not available");
}
return hmi_correlation_id;
}
@@ -375,60 +493,60 @@ bool CommandRequestImpl::CheckAllowedParameters() {
return true;
}
- const ApplicationSet& accessor =
- application_manager_.applications().GetData();
- ApplicationSetConstIt it_app_list = accessor.begin();
- ApplicationSetConstIt it_app_list_end = accessor.end();
- for (; it_app_list != it_app_list_end; ++it_app_list) {
- if (connection_key() == (*it_app_list).get()->app_id()) {
- RPCParams params;
-
- const smart_objects::SmartObject& s_map =
- (*message_)[strings::msg_params];
- if (smart_objects::SmartType_Map == s_map.getType()) {
- smart_objects::SmartMap::iterator iter = s_map.map_begin();
- smart_objects::SmartMap::iterator iter_end = s_map.map_end();
-
- for (; iter != iter_end; ++iter) {
- if (true == iter->second.asBool()) {
- LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first);
- params.push_back(iter->first);
- }
- }
- }
-
- mobile_apis::Result::eType check_result =
- application_manager_.CheckPolicyPermissions(
- (*it_app_list).get()->policy_app_id(),
- (*it_app_list).get()->hmi_level(),
- static_cast<mobile_api::FunctionID::eType>(function_id()),
- params,
- &parameters_permissions_);
-
- // Check, if RPC is allowed by policy
- if (mobile_apis::Result::SUCCESS != check_result) {
- smart_objects::SmartObjectSPtr response =
- MessageHelper::CreateBlockedByPoliciesResponse(
- static_cast<mobile_api::FunctionID::eType>(function_id()),
- check_result,
- correlation_id(),
- (*it_app_list)->app_id());
-
- application_manager_.SendMessageToMobile(response);
- return false;
- }
-
- // If no parameters specified in policy table, no restriction will be
- // applied for parameters
- if (parameters_permissions_.allowed_params.empty() &&
- parameters_permissions_.disallowed_params.empty() &&
- parameters_permissions_.undefined_params.empty()) {
- return true;
- }
-
- RemoveDisallowedParameters();
+ const ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "There is no registered application with "
+ "connection key '"
+ << connection_key() << "'");
+ return false;
+ }
+
+ RPCParams params;
+
+ const smart_objects::SmartObject& s_map = (*message_)[strings::msg_params];
+ smart_objects::SmartMap::const_iterator iter = s_map.map_begin();
+ smart_objects::SmartMap::const_iterator iter_end = s_map.map_end();
+
+ for (; iter != iter_end; ++iter) {
+ if (iter->second.asBool()) {
+ LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first);
+ params.insert(iter->first);
}
}
+
+ mobile_apis::Result::eType check_result =
+ application_manager_.CheckPolicyPermissions(
+ app,
+ MessageHelper::StringifiedFunctionID(
+ static_cast<mobile_api::FunctionID::eType>(function_id())),
+ params,
+ &parameters_permissions_);
+
+ // Check, if RPC is allowed by policy
+ if (mobile_apis::Result::SUCCESS != check_result) {
+ smart_objects::SmartObjectSPtr response =
+ MessageHelper::CreateBlockedByPoliciesResponse(
+ static_cast<mobile_api::FunctionID::eType>(function_id()),
+ check_result,
+ correlation_id(),
+ app->app_id());
+
+ application_manager_.SendMessageToMobile(response);
+ return false;
+ }
+
+ // If no parameters specified in policy table, no restriction will be
+ // applied for parameters
+ if (parameters_permissions_.allowed_params.empty() &&
+ parameters_permissions_.disallowed_params.empty() &&
+ parameters_permissions_.undefined_params.empty()) {
+ return true;
+ }
+
+ RemoveDisallowedParameters();
+
return true;
}
@@ -438,33 +556,32 @@ void CommandRequestImpl::RemoveDisallowedParameters() {
smart_objects::SmartObject& params = (*message_)[strings::msg_params];
// Remove from request all disallowed parameters
- std::vector<std::string>::const_iterator it_disallowed =
+ RPCParams::const_iterator it_disallowed =
parameters_permissions_.disallowed_params.begin();
- std::vector<std::string>::const_iterator it_disallowed_end =
+ RPCParams::const_iterator it_disallowed_end =
parameters_permissions_.disallowed_params.end();
for (; it_disallowed != it_disallowed_end; ++it_disallowed) {
if (params.keyExists(*it_disallowed)) {
- params.erase(*it_disallowed);
- removed_parameters_permissions_.disallowed_params.push_back(
- *it_disallowed);
- LOG4CXX_INFO(
- logger_,
- "Following parameter is disallowed by user: " << *it_disallowed);
+ const std::string key = *it_disallowed;
+ params.erase(key);
+ removed_parameters_permissions_.disallowed_params.insert(key);
+ LOG4CXX_INFO(logger_,
+ "Following parameter is disallowed by user: " << key);
}
}
// Remove from request all undefined yet parameters
- std::vector<std::string>::const_iterator it_undefined =
+ RPCParams::const_iterator it_undefined =
parameters_permissions_.undefined_params.begin();
- std::vector<std::string>::const_iterator it_undefined_end =
+ RPCParams::const_iterator it_undefined_end =
parameters_permissions_.undefined_params.end();
for (; it_undefined != it_undefined_end; ++it_undefined) {
if (params.keyExists(*it_undefined)) {
- params.erase(*it_undefined);
- removed_parameters_permissions_.undefined_params.push_back(*it_undefined);
- LOG4CXX_INFO(
- logger_,
- "Following parameter is disallowed by policy: " << *it_undefined);
+ const std::string key = *it_undefined;
+ params.erase(key);
+ removed_parameters_permissions_.undefined_params.insert(key);
+ LOG4CXX_INFO(logger_,
+ "Following parameter is disallowed by policy: " << key);
}
}
@@ -482,7 +599,7 @@ void CommandRequestImpl::RemoveDisallowedParameters() {
parameters_permissions_.allowed_params.end(),
key)) {
params.erase(key);
- removed_parameters_permissions_.undefined_params.push_back(key);
+ removed_parameters_permissions_.undefined_params.insert(key);
LOG4CXX_INFO(logger_,
"Following parameter is not found among allowed parameters '"
<< key << "' and will be treated as disallowed.");
@@ -504,7 +621,7 @@ void CommandRequestImpl::AddDisallowedParametersToInfo(
smart_objects::SmartObject& response) const {
std::string info;
- std::vector<std::string>::const_iterator it =
+ RPCParams::const_iterator it =
removed_parameters_permissions_.disallowed_params.begin();
for (; it != removed_parameters_permissions_.disallowed_params.end(); ++it) {
AddDissalowedParameterToInfoString(info, (*it));
@@ -548,6 +665,111 @@ bool CommandRequestImpl::HasDisallowedParams() const {
(!removed_parameters_permissions_.undefined_params.empty()));
}
+bool CommandRequestImpl::PrepareResultForMobileResponse(
+ hmi_apis::Common_Result::eType result_code,
+ HmiInterfaces::InterfaceID interface) const {
+ using namespace helpers;
+ if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED)) {
+ return true;
+ }
+
+ const HmiInterfaces::InterfaceState state =
+ application_manager_.hmi_interfaces().GetInterfaceState(interface);
+ if ((hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code) &&
+ (HmiInterfaces::STATE_NOT_AVAILABLE != state)) {
+ return true;
+ }
+ return false;
+}
+
+bool CommandRequestImpl::PrepareResultForMobileResponse(
+ ResponseInfo& out_first, ResponseInfo& out_second) const {
+ using namespace helpers;
+
+ out_first.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ out_first.result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED);
+
+ out_second.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ out_second.result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED);
+
+ out_first.is_invalid_enum =
+ hmi_apis::Common_Result::INVALID_ENUM == out_first.result_code;
+
+ out_second.is_invalid_enum =
+ hmi_apis::Common_Result::INVALID_ENUM == out_second.result_code;
+
+ out_first.is_unsupported_resource =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_first.result_code;
+
+ out_second.is_unsupported_resource =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_second.result_code;
+
+ out_first.interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ out_first.interface);
+ out_second.interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ out_second.interface);
+
+ bool result = (out_first.is_ok && out_second.is_ok) ||
+ (out_second.is_invalid_enum && out_first.is_ok) ||
+ (out_first.is_invalid_enum && out_second.is_ok);
+ result = result || CheckResultCode(out_first, out_second);
+ result = result || CheckResultCode(out_second, out_first);
+ return result;
+}
+
+void CommandRequestImpl::GetInfo(
+ const smart_objects::SmartObject& response_from_hmi,
+ std::string& out_info) {
+ if (response_from_hmi[strings::msg_params].keyExists(strings::info)) {
+ if (!response_from_hmi[strings::msg_params][strings::info].empty()) {
+ out_info =
+ response_from_hmi[strings::msg_params][strings::info].asString();
+ }
+ }
+}
+
+mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse(
+ const ResponseInfo& first, const ResponseInfo& second) {
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ if (IsResultCodeUnsupported(first, second)) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ } else {
+ // If response contains erroneous result code SDL need return erroneus
+ // result code.
+ hmi_apis::Common_Result::eType first_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType second_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ if (!first.is_unsupported_resource) {
+ first_result = first.result_code;
+ }
+ if (!second.is_unsupported_resource) {
+ second_result = second.result_code;
+ }
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(first_result, second_result));
+ }
+ return result_code;
+}
+
const CommandParametersPermissions& CommandRequestImpl::parameters_permissions()
const {
return parameters_permissions_;
diff --git a/src/components/application_manager/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/src/commands/hmi/close_popup_request.cc
index b0ab48dd96..d628475438 100644
--- a/src/components/application_manager/src/commands/hmi/close_popup_request.cc
+++ b/src/components/application_manager/src/commands/hmi/close_popup_request.cc
@@ -44,7 +44,6 @@ ClosePopupRequest::~ClosePopupRequest() {}
void ClosePopupRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc b/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc
new file mode 100644
index 0000000000..a09fe71bf2
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/hmi/decrypt_certificate_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+DecryptCertificateRequest::DecryptCertificateRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager) {}
+
+void DecryptCertificateRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const uint32_t correlation_id = RequestToHMI::correlation_id();
+ const uint32_t app_id = RequestToHMI::application_id();
+ application_manager_.set_application_id(correlation_id, app_id);
+ SendRequest();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc b/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc
new file mode 100644
index 0000000000..cea9290f7d
--- /dev/null
+++ b/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "application_manager/commands/hmi/decrypt_certificate_response.h"
+
+#include "application_manager/policies/policy_handler.h"
+#ifdef EXTERNAL_PROPRIETARY_MODE
+namespace application_manager {
+
+namespace commands {
+
+DecryptCertificateResponse::DecryptCertificateResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : ResponseFromHMI(message, application_manager) {}
+
+DecryptCertificateResponse::~DecryptCertificateResponse() {}
+
+void DecryptCertificateResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const hmi_apis::Common_Result::eType code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ (*message_)[strings::params][hmi_response::code].asInt());
+
+ const bool is_succeeded = hmi_apis::Common_Result::SUCCESS == code;
+
+ application_manager_.GetPolicyHandler().OnCertificateDecrypted(is_succeeded);
+}
+
+} // namespace commands
+} // namespace application_manager
+#endif // EXTERNAL_PROPRIETARY_MODE
diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc
index af220051d4..a2e1878fac 100644
--- a/src/components/application_manager/src/commands/hmi/get_urls.cc
+++ b/src/components/application_manager/src/commands/hmi/get_urls.cc
@@ -35,18 +35,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler.h"
-namespace {
-struct PolicyAppIdComparator {
- PolicyAppIdComparator(const std::string& policy_app_id)
- : policy_app_id_(policy_app_id) {}
-
- bool operator()(const policy::EndpointData& data) {
- return data.app_id == policy_app_id_;
- }
- std::string policy_app_id_;
-};
-}
-
namespace application_manager {
namespace commands {
@@ -58,41 +46,114 @@ GetUrls::~GetUrls() {}
void GetUrls::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace smart_objects;
- using namespace application_manager;
- using namespace strings;
- using namespace hmi_apis;
+ namespace Common_Result = hmi_apis::Common_Result;
+ using policy::EndpointUrls;
if (!application_manager_.GetPolicyHandler().PolicyEnabled()) {
SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
return;
}
- SmartObject& object = *message_;
- const std::string service_to_check =
- object[msg_params][hmi_request::service].asString();
+ const uint32_t service_to_check =
+ (*message_)[strings::msg_params][hmi_request::service].asUInt();
+
+ EndpointUrls endpoints;
+ application_manager_.GetPolicyHandler().GetUpdateUrls(service_to_check,
+ endpoints);
- policy::EndpointUrls endpoints;
- application_manager_.GetPolicyHandler().GetServiceUrls(
- object[strings::msg_params][hmi_request::service].asString(), endpoints);
if (endpoints.empty()) {
LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check);
SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE);
return;
}
-#ifdef EXTENDED_POLICY
- const std::string policy_service = "7";
+#ifdef PROPRIETARY_MODE
+ const uint32_t policy_service = 7u;
if (policy_service == service_to_check) {
ProcessPolicyServiceURLs(endpoints);
return;
}
-#endif
+#endif // PROPRIETARY_MODE
+
ProcessServiceURLs(endpoints);
}
-#ifdef EXTENDED_POLICY
+void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) {
+ namespace Common_Result = hmi_apis::Common_Result;
+ using smart_objects::SmartObject;
+
+ (*message_)[strings::msg_params].erase(hmi_request::service);
+ SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls];
+
+ size_t index = 0;
+ for (size_t e = 0; e < endpoints.size(); ++e) {
+ ApplicationSharedPtr app =
+ application_manager_.application_by_policy_id(endpoints[e].app_id);
+
+#ifndef PROPRIETARY_MODE
+ bool registered_not_default = false;
+ if (policy::kDefaultId != endpoints[e].app_id) {
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "Can't find application with policy id "
+ << endpoints[e].app_id
+ << " URLs adding for this application is skipped.");
+ continue;
+ }
+ registered_not_default = true;
+ }
+#endif // EXTERNAL_PROPRIETARY_MODE || HTTP
+ for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) {
+ const std::string& app_url = endpoints[e].url[u];
+ SmartObject& service_info = urls[index];
+
+ service_info[strings::url] = app_url;
+#ifndef PROPRIETARY_MODE
+ if (registered_not_default) {
+ service_info[strings::app_id] = app->hmi_app_id();
+ }
+#else // EXTERNAL_PROPRIETARY_MODE || HTTP
+ service_info[hmi_response::policy_app_id] = endpoints[e].app_id;
+#endif
+ }
+ }
+ SendResponseToHMI(Common_Result::SUCCESS);
+}
+
+void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) {
+ (*message_)[strings::params][strings::message_type] = MessageType::kResponse;
+ (*message_)[strings::params][hmi_response::code] = result;
+ application_manager_.ManageHMICommand(message_);
+}
+
+#ifdef PROPRIETARY_MODE
+struct PolicyAppIdComparator {
+ PolicyAppIdComparator(const std::string& policy_app_id)
+ : policy_app_id_(policy_app_id) {}
+
+ bool operator()(const policy::EndpointData& data) {
+ return data.app_id == policy_app_id_;
+ }
+ std::string policy_app_id_;
+};
+
+void FillSODefaultUrls(smart_objects::SmartObject& urls,
+ const policy::EndpointUrls& endpoints) {
+ using smart_objects::SmartObject;
+ PolicyAppIdComparator comparator(policy::kDefaultId);
+ policy::EndpointUrls::const_iterator it =
+ std::find_if(endpoints.begin(), endpoints.end(), comparator);
+ if (it == endpoints.end()) {
+ return;
+ }
+ SmartObject service_info = SmartObject(smart_objects::SmartType_Map);
+ for (size_t i = 0; i < (*it).url.size(); ++i) {
+ service_info[strings::url] = (*it).url[i];
+ urls[i] = service_info;
+ }
+}
+
void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace smart_objects;
@@ -162,58 +223,7 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) {
SendResponseToHMI(Common_Result::SUCCESS);
return;
}
-#endif
-
-void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) {
- using namespace smart_objects;
- using namespace strings;
- using namespace hmi_apis;
-
- SmartObject& object = *message_;
- object[msg_params].erase(hmi_request::service);
- object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array);
-
- SmartObject& urls = object[msg_params][hmi_response::urls];
-
- size_t index = 0;
- for (size_t e = 0; e < endpoints.size(); ++e) {
- for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) {
- const std::string app_url = endpoints[e].url[u];
-
- urls[index] = SmartObject(SmartType_Map);
- SmartObject& service_info = urls[index];
-
- service_info[url] = app_url;
- if (policy::kDefaultId != endpoints[e].app_id) {
- service_info[hmi_response::policy_app_id] = endpoints[e].app_id;
- }
- }
- }
- SendResponseToHMI(Common_Result::SUCCESS);
-}
-
-void GetUrls::FillSODefaultUrls(smart_objects::SmartObject& urls,
- const policy::EndpointUrls& endpoints) {
- using namespace smart_objects;
- LOG4CXX_AUTO_TRACE(logger_);
- PolicyAppIdComparator comparator(policy::kDefaultId);
- policy::EndpointUrls::const_iterator it =
- std::find_if(endpoints.begin(), endpoints.end(), comparator);
- if (it == endpoints.end()) {
- return;
- }
- SmartObject service_info = SmartObject(SmartType_Map);
- for (size_t i = 0; i < (*it).url.size(); ++i) {
- service_info[strings::url] = (*it).url[i];
- urls[i] = service_info;
- }
-}
-
-void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) {
- (*message_)[strings::params][strings::message_type] = MessageType::kResponse;
- (*message_)[strings::params][hmi_response::code] = result;
- application_manager_.ManageHMICommand(message_);
-}
+#endif // PROPRIETARY_MODE
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
index 920c6fbdf9..0bcb26df8a 100644
--- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
@@ -58,21 +58,24 @@ AudioStartStreamRequest::~AudioStartStreamRequest() {}
void AudioStartStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
- SetAllowedToTerminate(false);
- subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream,
- correlation_id());
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
- if (app) {
- app->set_audio_streaming_allowed(true);
- SendRequest();
- } else {
+ if (!app) {
LOG4CXX_ERROR(logger_,
"Applcation with hmi_app_id " << application_id()
<< " does not exist");
+ return;
}
+ SetAllowedToTerminate(false);
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_StartAudioStream,
+ correlation_id());
+ app->set_audio_streaming_allowed(true);
+ SendRequest();
}
void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
@@ -124,7 +127,8 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
void AudioStartStreamRequest::onTimeOut() {
RetryStartSession();
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void AudioStartStreamRequest::RetryStartSession() {
@@ -152,7 +156,7 @@ void AudioStartStreamRequest::RetryStartSession() {
}
uint32_t curr_retry_number = app->audio_stream_retry_number();
- if (curr_retry_number < retry_number_ - 1) {
+ if (curr_retry_number < retry_number_) {
LOG4CXX_DEBUG(
logger_,
"Send AudioStartStream retry. retry_number = " << curr_retry_number);
diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
index d0f1a96282..f86ee8302a 100644
--- a/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_audio_stop_stream_request.cc
@@ -43,7 +43,11 @@ AudioStopStreamRequest::~AudioStopStreamRequest() {}
void AudioStopStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
index 92e972e8f4..4392258a31 100644
--- a/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_request.cc
@@ -38,16 +38,42 @@ namespace commands {
NaviIsReadyRequest::NaviIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
NaviIsReadyRequest::~NaviIsReadyRequest() {}
void NaviIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_IsReady,
+ correlation_id());
SendRequest();
}
+void NaviIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received Navigation_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::Navigation_IsReady);
+ const bool is_available =
+ ChangeInterfaceState(application_manager_,
+ message,
+ HmiInterfaces::HMI_INTERFACE_Navigation);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_navi_cooperating(is_available);
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
index 129900c60f..7daba4258b 100644
--- a/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_is_ready_response.cc
@@ -43,16 +43,9 @@ NaviIsReadyResponse::~NaviIsReadyResponse() {}
void NaviIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
-
- hmi_capabilities.set_is_navi_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::Navigation_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
index f0104cbaee..b06c69e703 100644
--- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
@@ -58,21 +58,24 @@ NaviStartStreamRequest::~NaviStartStreamRequest() {}
void NaviStartStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
- SetAllowedToTerminate(false);
- subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream,
- correlation_id());
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
- if (app) {
- app->set_video_streaming_allowed(true);
- SendRequest();
- } else {
+ if (!app) {
LOG4CXX_ERROR(logger_,
"Applcation with hmi_app_id " << application_id()
<< "does not exist");
+ return;
}
+ SetAllowedToTerminate(false);
+ subscribe_on_event(hmi_apis::FunctionID::Navigation_StartStream,
+ correlation_id());
+ app->set_video_streaming_allowed(true);
+ SendRequest();
}
void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
@@ -110,7 +113,7 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
}
if (hmi_apis::Common_Result::REJECTED == code) {
LOG4CXX_INFO(logger_, "StartStream response REJECTED ");
- SendRequest();
+ RetryStartSession();
break;
}
}
@@ -124,7 +127,8 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
void NaviStartStreamRequest::onTimeOut() {
RetryStartSession();
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void NaviStartStreamRequest::RetryStartSession() {
@@ -152,7 +156,7 @@ void NaviStartStreamRequest::RetryStartSession() {
}
uint32_t curr_retry_number = app->video_stream_retry_number();
- if (curr_retry_number < retry_number_ - 1) {
+ if (curr_retry_number < retry_number_) {
LOG4CXX_DEBUG(
logger_,
"Send NaviStartStream retry. retry_number = " << curr_retry_number);
diff --git a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
index 4b72ff28b4..a40ee13b68 100644
--- a/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_stop_stream_request.cc
@@ -12,7 +12,11 @@ NaviStopStreamRequest::~NaviStopStreamRequest() {}
void NaviStopStreamRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_Navigation)) {
+ LOG4CXX_INFO(logger_, "Interface Navi is not supported by system");
+ return;
+ }
SendRequest();
}
diff --git a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc
index 0efc1aee8a..19577f0127 100644
--- a/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_app_permission_consent_notification.cc
@@ -35,6 +35,78 @@
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/message_helper.h"
+#include <algorithm>
+#include <functional>
+#include <string>
+#include "policy/policy_types.h"
+#include "smart_objects/smart_object.h"
+#include "utils/make_shared.h"
+
+namespace {
+
+/**
+ * @brief Converts SmartObject data to group permission status and appends to
+ * collection
+ */
+struct PermissionsAppender
+ : public std::unary_function<void,
+ const smart_objects::SmartArray::value_type&> {
+ PermissionsAppender(policy::PermissionConsent& consents)
+ : allowed_key_(application_manager::hmi_response::allowed)
+ , consents_(consents) {}
+ void operator()(const smart_objects::SmartArray::value_type& item) const {
+ using namespace policy;
+ using namespace application_manager;
+
+ FunctionalGroupPermission permissions;
+
+ permissions.group_id = static_cast<int32_t>(item[strings::id].asInt());
+ permissions.group_alias = item[strings::name].asString();
+
+ if (item.keyExists(allowed_key_)) {
+ permissions.state =
+ item[allowed_key_].asBool() ? kGroupAllowed : kGroupDisallowed;
+ }
+
+ consents_.group_permissions.push_back(permissions);
+ }
+
+ private:
+ const std::string allowed_key_;
+ policy::PermissionConsent& consents_;
+};
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+/**
+ * @brief Converts SmartObject data to customer connectivity status item and
+ * appends to collection
+ */
+struct ExternalConsentStatusAppender
+ : std::unary_function<void, const smart_objects::SmartArray::value_type&> {
+ ExternalConsentStatusAppender(
+ policy::ExternalConsentStatus& external_consent_status)
+ : external_consent_status_(external_consent_status) {}
+ void operator()(const smart_objects::SmartArray::value_type& item) const {
+ using namespace policy;
+ using namespace hmi_apis;
+ using namespace application_manager;
+
+ ExternalConsentStatusItem status_item(
+ static_cast<uint32_t>(item[strings::entity_type].asUInt()),
+ static_cast<uint32_t>(item[strings::entity_id].asUInt()),
+ static_cast<Common_EntityStatus::eType>(
+ item[strings::status].asUInt()) == Common_EntityStatus::ON
+ ? policy::kStatusOn
+ : policy::kStatusOff);
+
+ external_consent_status_.insert(status_item);
+ }
+
+ private:
+ policy::ExternalConsentStatus& external_consent_status_;
+};
+#endif
+} // namespace
namespace application_manager {
@@ -59,9 +131,9 @@ void OnAppPermissionConsentNotification::Run() {
connection_key = msg_params[strings::app_id].asUInt();
}
- if (msg_params.keyExists("consentedFunctions")) {
- smart_objects::SmartArray* user_consent =
- msg_params["consentedFunctions"].asArray();
+ if (msg_params.keyExists(strings::consented_functions)) {
+ const smart_objects::SmartArray* user_consent =
+ msg_params[strings::consented_functions].asArray();
smart_objects::SmartArray::const_iterator it = user_consent->begin();
smart_objects::SmartArray::const_iterator it_end = user_consent->end();
@@ -80,13 +152,24 @@ void OnAppPermissionConsentNotification::Run() {
permission_consent.group_permissions.push_back(permissions);
}
- permission_consent.consent_source = msg_params["source"].asString();
-
- application_manager_.GetPolicyHandler().OnAppPermissionConsent(
- connection_key, permission_consent);
+ permission_consent.consent_source = msg_params[strings::source].asString();
+ }
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy::ExternalConsentStatus external_consent_status;
+ if (msg_params.keyExists(strings::external_consent_status)) {
+ const smart_objects::SmartArray* system_external_consent_status =
+ msg_params[strings::external_consent_status].asArray();
+ ExternalConsentStatusAppender status_appender(external_consent_status);
+ std::for_each(system_external_consent_status->begin(),
+ system_external_consent_status->end(),
+ status_appender);
}
+ application_manager_.GetPolicyHandler().OnAppPermissionConsent(
+ connection_key, permission_consent, external_consent_status);
+#else
+ application_manager_.GetPolicyHandler().OnAppPermissionConsent(
+ connection_key, permission_consent);
+#endif
}
-
-} // namespace commands
-
+} // commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
index a7b6b9a2cd..0553fbba94 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -68,11 +68,6 @@ void OnExitApplicationNotification::Run() {
switch (reason) {
case Common_ApplicationExitReason::DRIVER_DISTRACTION_VIOLATION: {
- application_manager_.ManageMobileCommand(
- MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
- app_id,
- AppInterfaceUnregisteredReason::DRIVER_DISTRACTION_VIOLATION),
- commands::Command::ORIGIN_SDL);
break;
}
case Common_ApplicationExitReason::USER_EXIT: {
@@ -100,13 +95,9 @@ void OnExitApplicationNotification::Run() {
return;
}
}
- ApplicationSharedPtr app = application_manager_.application(app_id);
- if (app) {
- application_manager_.state_controller().SetRegularState(
- app, HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, false);
- } else {
- LOG4CXX_ERROR(logger_, "Unable to find appication " << app_id);
- }
+
+ application_manager_.state_controller().SetRegularState(
+ app_impl, HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, false);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc
index 03c0bc7378..8724a072ed 100644
--- a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc
+++ b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc
@@ -47,7 +47,7 @@ OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {}
void OnReceivedPolicyUpdate::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-#ifdef EXTENDED_POLICY
+#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
const std::string& file_path =
(*message_)[strings::msg_params][hmi_notification::policyfile].asString();
policy::BinaryMessage file_content;
diff --git a/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc
index b74f1b6799..ea91dca5f1 100644
--- a/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc
@@ -89,6 +89,22 @@ void OnSystemRequestNotification::Run() {
return;
}
+ std::string device_mac;
+ application_manager_.connection_handler()
+ .get_session_observer()
+ .GetDataOnDeviceID(app->device(), NULL, NULL, &device_mac, NULL);
+
+ if (policy::kDeviceAllowed !=
+ application_manager_.GetPolicyHandler().GetUserConsentForDevice(
+ device_mac)) {
+ LOG4CXX_WARN(logger_,
+ "Application "
+ << app->policy_app_id()
+ << " is registered from non-consented device."
+ "Can't forward notification to application.");
+ return;
+ }
+
LOG4CXX_DEBUG(logger_,
"Sending request with application id " << app->policy_app_id());
diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
index 5f8109ccab..5383876714 100644
--- a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
@@ -50,6 +50,13 @@ void OnVIVehicleDataNotification::Run() {
(*message_)[strings::params][strings::function_id] =
static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID);
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+ if (msg_params.keyExists(strings::odometer)) {
+ application_manager_.IviInfoUpdated(ODOMETER,
+ msg_params[strings::odometer].asInt());
+ }
+
SendNotificationToMobile(message_);
}
diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
index be3cd6314c..1119e7c4fd 100644
--- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -65,9 +65,10 @@ void RequestFromHMI::SendResponse(
const uint32_t correlation_id,
const hmi_apis::FunctionID::eType function_id,
const hmi_apis::Common_Result::eType result_code) {
- smart_objects::SmartObject* message =
- new smart_objects::SmartObject(smart_objects::SmartType_Map);
- FillCommonParametersOfSO(message, correlation_id, function_id);
+ smart_objects::SmartObjectSPtr message =
+ ::utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ FillCommonParametersOfSO(*message, correlation_id, function_id);
(*message)[strings::params][strings::message_type] = MessageType::kResponse;
(*message)[strings::params][hmi_response::code] = 0;
(*message)[strings::msg_params][strings::success] = success;
@@ -76,30 +77,31 @@ void RequestFromHMI::SendResponse(
application_manager_.ManageHMICommand(message);
}
-// void RequestFromHMI::SendErrorResponse(uint32_t correlation_id,
-// hmi_apis::FunctionID::eType
-// function_id,
-// hmi_apis::Common_Result::eType
-// result_code) {
-// smart_objects::SmartObject* message = new smart_objects::SmartObject(
-// smart_objects::SmartType_Map);
-// FillCommonParametersOfSO(message, correlation_id, function_id);
-// (*message)[strings::params][strings::message_type] =
-// MessageType::kErrorResponse;
-// (*message)[strings::params][hmi_response::code] = result_code;
-// (*message)[strings::params][strings::error_msg] = "HMIDeactivate is active";
-
-// application_manager_.ManageHMICommand(message);
-//}
+void RequestFromHMI::SendErrorResponse(
+ const uint32_t correlation_id,
+ const hmi_apis::FunctionID::eType function_id,
+ const hmi_apis::Common_Result::eType result_code,
+ const std::string error_message) {
+ smart_objects::SmartObjectSPtr message =
+ ::utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ FillCommonParametersOfSO(*message, correlation_id, function_id);
+ (*message)[strings::params][strings::message_type] =
+ MessageType::kErrorResponse;
+ (*message)[strings::params][hmi_response::code] = result_code;
+ (*message)[strings::params][strings::error_msg] = error_message;
+
+ application_manager_.ManageHMICommand(message);
+}
void RequestFromHMI::FillCommonParametersOfSO(
- smart_objects::SmartObject* message,
- uint32_t correlation_id,
- hmi_apis::FunctionID::eType function_id) {
- (*message)[strings::params][strings::function_id] = function_id;
- (*message)[strings::params][strings::protocol_type] = hmi_protocol_type_;
- (*message)[strings::params][strings::protocol_version] = protocol_version_;
- (*message)[strings::params][strings::correlation_id] = correlation_id;
+ smart_objects::SmartObject& message,
+ const uint32_t correlation_id,
+ const hmi_apis::FunctionID::eType function_id) {
+ (message)[strings::params][strings::function_id] = function_id;
+ (message)[strings::params][strings::protocol_type] = hmi_protocol_type_;
+ (message)[strings::params][strings::protocol_version] = protocol_version_;
+ (message)[strings::params][strings::correlation_id] = correlation_id;
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
index 2e7d7e9df1..39d549ac72 100644
--- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc
@@ -36,6 +36,29 @@ namespace application_manager {
namespace commands {
+bool CheckAvailabilityHMIInterfaces(ApplicationManager& application_manager,
+ HmiInterfaces::InterfaceID interface) {
+ const HmiInterfaces::InterfaceState state =
+ application_manager.hmi_interfaces().GetInterfaceState(interface);
+ return HmiInterfaces::STATE_NOT_AVAILABLE != state;
+}
+
+bool ChangeInterfaceState(ApplicationManager& application_manager,
+ const smart_objects::SmartObject& response_from_hmi,
+ HmiInterfaces::InterfaceID interface) {
+ if (response_from_hmi[strings::msg_params].keyExists(strings::available)) {
+ const bool is_available =
+ response_from_hmi[strings::msg_params][strings::available].asBool();
+ const HmiInterfaces::InterfaceState interface_state =
+ is_available ? HmiInterfaces::STATE_AVAILABLE
+ : HmiInterfaces::STATE_NOT_AVAILABLE;
+ application_manager.hmi_interfaces().SetInterfaceState(interface,
+ interface_state);
+ return is_available;
+ }
+ return false;
+}
+
RequestToHMI::RequestToHMI(const MessageSharedPtr& message,
ApplicationManager& application_manager)
: CommandImpl(message, application_manager) {
@@ -58,7 +81,6 @@ void RequestToHMI::Run() {}
void RequestToHMI::SendRequest() {
(*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_;
(*message_)[strings::params][strings::protocol_version] = protocol_version_;
-
application_manager_.SendMessageToHMI(message_);
}
diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
index 30ea41e0b0..3a5a8d25f9 100644
--- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
+++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc
@@ -84,6 +84,42 @@ SDLActivateAppRequest::SDLActivateAppRequest(
SDLActivateAppRequest::~SDLActivateAppRequest() {}
+uint32_t SDLActivateAppRequest::app_id() const {
+ using namespace strings;
+ if (!(*message_).keyExists(msg_params)) {
+ LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message.");
+ return 0;
+ }
+ if (!(*message_)[msg_params].keyExists(strings::app_id)) {
+ LOG4CXX_DEBUG(logger_,
+ strings::app_id << " section is absent in the message.");
+ return 0;
+ }
+ return (*message_)[msg_params][strings::app_id].asUInt();
+}
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+void SDLActivateAppRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace hmi_apis::FunctionID;
+
+ if (application_manager_.state_controller().IsStateActive(
+ HmiState::STATE_ID_DEACTIVATE_HMI)) {
+ LOG4CXX_DEBUG(logger_,
+ "DeactivateHmi state is active. "
+ "Sends response with result code REJECTED");
+ SendErrorResponse(correlation_id(),
+ static_cast<eType>(function_id()),
+ hmi_apis::Common_Result::REJECTED,
+ "HMIDeactivate is active");
+ } else {
+ const uint32_t application_id = app_id();
+ application_manager_.GetPolicyHandler().OnActivateApp(application_id,
+ correlation_id());
+ }
+}
+
+#else // EXTERNAL_PROPRIETARY_MODE
void SDLActivateAppRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace hmi_apis::FunctionID;
@@ -118,6 +154,18 @@ void SDLActivateAppRequest::Run() {
"Found application to activate. Application id is "
<< app_to_activate->app_id());
+ if (application_manager_.state_controller().IsStateActive(
+ HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) {
+ LOG4CXX_WARN(logger_,
+ "DeactivateHmi state is active. "
+ "Sends response with result code REJECTED");
+ SendErrorResponse(correlation_id(),
+ static_cast<hmi_apis::FunctionID::eType>(function_id()),
+ hmi_apis::Common_Result::REJECTED,
+ "HMIDeactivate is active");
+ return;
+ }
+
if (app_to_activate->IsRegistered()) {
LOG4CXX_DEBUG(logger_, "Application is registered. Activating.");
application_manager_.GetPolicyHandler().OnActivateApp(application_id,
@@ -134,7 +182,8 @@ void SDLActivateAppRequest::Run() {
"Can't find regular foreground app with the same "
"connection id:"
<< device_handle);
- SendResponse(false, correlation_id(), SDL_ActivateApp, NO_APPS_REGISTERED);
+ SendErrorResponse(
+ correlation_id(), SDL_ActivateApp, NO_APPS_REGISTERED, "");
return;
}
@@ -160,13 +209,14 @@ void SDLActivateAppRequest::Run() {
subscribe_on_event(BasicCommunication_OnAppRegistered);
}
+#endif // EXTERNAL_PROPRIETARY_MODE
void SDLActivateAppRequest::onTimeOut() {
using namespace hmi_apis::FunctionID;
using namespace hmi_apis::Common_Result;
using namespace application_manager;
unsubscribe_from_event(BasicCommunication_OnAppRegistered);
- SendResponse(
- false, correlation_id(), SDL_ActivateApp, APPLICATION_NOT_REGISTERED);
+ SendErrorResponse(
+ correlation_id(), SDL_ActivateApp, APPLICATION_NOT_REGISTERED, "");
}
void SDLActivateAppRequest::on_event(const event_engine::Event& event) {
@@ -192,20 +242,6 @@ void SDLActivateAppRequest::on_event(const event_engine::Event& event) {
correlation_id());
}
-uint32_t SDLActivateAppRequest::app_id() const {
- using namespace strings;
- if (!(*message_).keyExists(msg_params)) {
- LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message.");
- return 0;
- }
- if (!(*message_)[msg_params].keyExists(strings::app_id)) {
- LOG4CXX_DEBUG(logger_,
- strings::app_id << " section is absent in the message.");
- return 0;
- }
- return (*message_)[msg_params][strings::app_id].asUInt();
-}
-
uint32_t SDLActivateAppRequest::hmi_app_id(
const smart_objects::SmartObject& so) const {
using namespace strings;
diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc
index e79bca14de..f1fb9ccead 100644
--- a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc
+++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc
@@ -44,7 +44,7 @@ SDLPolicyUpdate::~SDLPolicyUpdate() {}
void SDLPolicyUpdate::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-#ifdef EXTENDED_POLICY
+#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
SendRequest();
#else
LOG4CXX_WARN(logger_,
diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
index e7fd335808..71e89dd9b9 100644
--- a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/tts_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,68 @@ namespace commands {
TTSIsReadyRequest::TTSIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
TTSIsReadyRequest::~TTSIsReadyRequest() {}
void TTSIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::TTS_IsReady, correlation_id());
SendRequest();
}
+void TTSIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::TTS_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received TTS_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::TTS_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_TTS);
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_tts_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_TTS isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void TTSIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void TTSIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::TTS_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::TTS_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
index 91efb293c9..30e2f4816b 100644
--- a/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_response.cc
@@ -43,15 +43,9 @@ TTSIsReadyResponse::~TTSIsReadyResponse() {}
void TTSIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_tts_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::TTS_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
index 463ae9d41d..9e27e23d34 100644
--- a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/ui_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,68 @@ namespace commands {
UIIsReadyRequest::UIIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
UIIsReadyRequest::~UIIsReadyRequest() {}
void UIIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::UI_IsReady, correlation_id());
SendRequest();
}
+void UIIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::UI_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received UI_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_UI);
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_ui_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_UI)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_UI isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void UIIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void UIIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::UI_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::UI_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
index e7fca943bc..088baeb8b2 100644
--- a/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_response.cc
@@ -43,16 +43,10 @@ UIIsReadyResponse::~UIIsReadyResponse() {}
void UIIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
-
- hmi_capabilities.set_is_ui_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::UI_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc b/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc
index c98b7ec028..1653ec0744 100644
--- a/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc
+++ b/src/components/application_manager/src/commands/hmi/ui_set_icon_request.cc
@@ -36,8 +36,9 @@ namespace application_manager {
namespace commands {
-UISetIconRequest::UISetIconRequest(const MessageSharedPtr& message)
- : RequestToHMI(message) {}
+UISetIconRequest::UISetIconRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : RequestToHMI(message, application_manager) {}
UISetIconRequest::~UISetIconRequest() {}
diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
index 3ecc2ffe90..ddd08695a0 100644
--- a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc
@@ -31,6 +31,7 @@
*/
#include "application_manager/commands/hmi/vi_is_ready_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -38,16 +39,65 @@ namespace commands {
VIIsReadyRequest::VIIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
VIIsReadyRequest::~VIIsReadyRequest() {}
void VIIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::VehicleInfo_IsReady,
+ correlation_id());
SendRequest();
}
+void VIIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VehicleInfo_IsReady: {
+ LOG4CXX_DEBUG(logger_, "VehicleInfo_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ const bool is_available =
+ ChangeInterfaceState(application_manager_,
+ message,
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_ivi_cooperating(is_available);
+ application_manager_.GetPolicyHandler().OnVIIsReady();
+ if (!CheckAvailabilityHMIInterfaces(
+ application_manager_, HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
+ LOG4CXX_INFO(
+ logger_,
+ "HmiInterfaces::HMI_INTERFACE_VehicleInfo isn't available");
+ return;
+ }
+ SendMessageToHMI();
+
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void VIIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void VIIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_type(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleType,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_type);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
index 91dae226b6..2f84190494 100644
--- a/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_response.cc
@@ -43,17 +43,9 @@ VIIsReadyResponse::~VIIsReadyResponse() {}
void VIIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_ivi_cooperating(is_available);
-
- application_manager_.GetPolicyHandler().OnVIIsReady();
+ event_engine::Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
index 8c5e8bd49b..086b5d4490 100644
--- a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
+++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc
@@ -38,16 +38,69 @@ namespace commands {
VRIsReadyRequest::VRIsReadyRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : RequestToHMI(message, application_manager) {}
+ : RequestToHMI(message, application_manager)
+ , EventObserver(application_manager.event_dispatcher()) {}
VRIsReadyRequest::~VRIsReadyRequest() {}
void VRIsReadyRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ subscribe_on_event(hmi_apis::FunctionID::VR_IsReady, correlation_id());
SendRequest();
}
+void VRIsReadyRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::VR_IsReady: {
+ LOG4CXX_DEBUG(logger_, "Received VR_IsReady event");
+ unsubscribe_from_event(hmi_apis::FunctionID::VR_IsReady);
+ const bool is_available = ChangeInterfaceState(
+ application_manager_, message, HmiInterfaces::HMI_INTERFACE_VR);
+
+ HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+ hmi_capabilities.set_is_vr_cooperating(is_available);
+ if (!CheckAvailabilityHMIInterfaces(application_manager_,
+ HmiInterfaces::HMI_INTERFACE_VR)) {
+ LOG4CXX_INFO(logger_,
+ "HmiInterfaces::HMI_INTERFACE_VR isn't available");
+ return;
+ }
+ SendMessageToHMI();
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
+ }
+}
+
+void VRIsReadyRequest::onTimeOut() {
+ // Note(dtrunov): According to new requirment APPLINK-27956
+ SendMessageToHMI();
+}
+
+void VRIsReadyRequest::SendMessageToHMI() {
+ utils::SharedPtr<smart_objects::SmartObject> get_language(
+ MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage,
+ application_manager_));
+ HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
+ hmi_capabilities.set_handle_response_for(*get_language);
+ application_manager_.ManageHMICommand(get_language);
+ utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VR_GetSupportedLanguages,
+ application_manager_));
+ application_manager_.ManageHMICommand(get_all_languages);
+ utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
+ MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::VR_GetCapabilities, application_manager_));
+ application_manager_.ManageHMICommand(get_capabilities);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
index 617742a28c..78e2dae23b 100644
--- a/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
+++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_response.cc
@@ -43,15 +43,9 @@ VRIsReadyResponse::~VRIsReadyResponse() {}
void VRIsReadyResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject& object = *message_;
-
- bool is_available = false;
- if (object[strings::msg_params].keyExists(strings::available)) {
- is_available = object[strings::msg_params][strings::available].asBool();
- }
-
- HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities();
- hmi_capabilities.set_is_vr_cooperating(is_available);
+ event_engine::Event event(hmi_apis::FunctionID::VR_IsReady);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc
index 03bdfadd66..a76f537a24 100644
--- a/src/components/application_manager/src/commands/mobile/add_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -289,6 +289,7 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
return true;
}
+// TODO(AKUTSAN) APPLINK-26973: Refactor AddCommandRequest
void AddCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace helpers;
@@ -314,7 +315,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
+ GetInfo(message, ui_info_);
if (hmi_apis::Common_Result::SUCCESS != ui_result_) {
(*message_)[strings::msg_params].erase(strings::menu_params);
}
@@ -325,7 +326,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
is_vr_received_ = true;
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
+ GetInfo(message, vr_info_);
if (hmi_apis::Common_Result::SUCCESS != vr_result_) {
(*message_)[strings::msg_params].erase(strings::vr_commands);
}
@@ -341,10 +342,6 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
return;
}
- if (hmi_apis::Common_Result::REJECTED == ui_result_) {
- RemoveCommand();
- }
-
smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
@@ -358,37 +355,73 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
- const bool is_ui_ivalid_unsupported =
+ const bool is_ui_invalid_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+ const bool is_vr_unsupported =
+ vr_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ const bool is_ui_unsupported =
+ ui_result_ == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
vr_result_,
hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
bool result = (is_no_ui_error && is_no_vr_error) ||
(is_no_ui_error && is_vr_invalid_unsupported) ||
- (is_no_vr_error && is_ui_ivalid_unsupported);
+ (is_no_vr_error && is_ui_invalid_unsupported);
+ LOG4CXX_DEBUG(logger_,
+ "calculated result " << ui_result_ << " " << is_no_ui_error
+ << " " << is_no_vr_error);
const bool is_vr_or_ui_warning =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+ const bool is_vr_or_ui_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ ui_result_,
+ vr_result_);
+
+ const bool is_vr_and_ui_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ ui_result_,
+ vr_result_);
+
if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
result_code = MessageHelper::HMIToMobileResult(ui_result_);
+ } else if (result && is_vr_or_ui_unsupported) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
} else if (is_vr_or_ui_warning) {
result_code = mobile_apis::Result::WARNINGS;
} else {
result_code =
MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) {
+ result_code = MessageHelper::HMIToMobileResult(vr_result_);
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_) {
+ result_code = MessageHelper::HMIToMobileResult(ui_result_);
+ }
+ LOG4CXX_DEBUG(logger_, "HMIToMobileResult " << result_code);
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) {
@@ -410,11 +443,13 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
+ LOG4CXX_DEBUG(logger_, "Result " << result);
}
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ &&
- !is_no_vr_error) {
+ !is_no_vr_error &&
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) {
result_code = vr_result_ == hmi_apis::Common_Result::REJECTED
? mobile_apis::Result::REJECTED
: mobile_apis::Result::GENERIC_ERROR;
@@ -424,9 +459,39 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
+ LOG4CXX_DEBUG(logger_, "Result " << result);
+ }
+
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
+ HmiInterfaces::InterfaceState vr_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VR);
+
+ if (!BothSend() &&
+ ((is_vr_unsupported &&
+ HmiInterfaces::STATE_NOT_AVAILABLE == vr_interface_state) ||
+ (is_ui_unsupported &&
+ HmiInterfaces::STATE_NOT_AVAILABLE == ui_interface_state))) {
+ LOG4CXX_DEBUG(logger_, "!BothSend() && is_vr_or_ui_unsupported");
+ result = false;
+ }
+
+ if (is_vr_and_ui_unsupported) {
+ LOG4CXX_DEBUG(logger_, "UI and VR interface both unsupported");
+ result = false;
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ if (!result) {
+ RemoveCommand();
+ }
+
+ const std::string info = GenerateMobileResponseInfo();
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
@@ -479,6 +544,35 @@ bool AddCommandRequest::BothSend() const {
return send_vr_ && send_ui_;
}
+const std::string AddCommandRequest::GenerateMobileResponseInfo() {
+ // In case if vr_result_ is UNSUPPORTED_RESOURCE vr_info should be on the
+ // first place
+ // In case if ui_result_ is UNSUPPORTED_RESOURCE ui_info should be on the
+ // first place
+ // Other way order is doesn't matter
+
+ HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ HmiInterfaces::InterfaceState ui_interface_state =
+ hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_UI);
+
+ HmiInterfaces::InterfaceState vr_interface_state =
+ hmi_interfaces.GetInterfaceState(HmiInterfaces::HMI_INTERFACE_VR);
+
+ if ((ui_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (vr_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !vr_info_.empty()) {
+ return vr_info_;
+ }
+
+ if ((vr_interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ (ui_interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) &&
+ !ui_info_.empty()) {
+ return ui_info_;
+ }
+
+ return MergeInfos(ui_info_, vr_info_);
+}
+
void AddCommandRequest::RemoveCommand() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app = application_manager_.application(connection_key());
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
index 83f137ac19..6838d1af7d 100644
--- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/add_sub_menu_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application.h"
#include "utils/helpers.h"
@@ -98,19 +99,17 @@ void AddSubMenuRequest::Run() {
void AddSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_AddSubMenu: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
ApplicationSharedPtr application =
application_manager_.application(connection_key());
@@ -125,7 +124,10 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
(*message_)[strings::msg_params][strings::menu_id].asInt(),
(*message_)[strings::msg_params]);
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
index ea00bc8d70..b151990289 100644
--- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
@@ -1,22 +1,17 @@
/*
Copyright (c) 2016, Ford Motor Company
All rights reserved.
-
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the
distribution.
-
Neither the name of the Ford Motor Company nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -33,11 +28,9 @@
#include <cstring>
#include <string>
#include "application_manager/commands/mobile/alert_maneuver_request.h"
-
#include "application_manager/application_impl.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/message_helper.h"
-#include "utils/helpers.h"
namespace application_manager {
@@ -46,8 +39,8 @@ namespace commands {
AlertManeuverRequest::AlertManeuverRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM)
- , navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) {
+ , tts_speak_result_code_(hmi_apis::Common_Result::INVALID_ENUM)
+ , navi_alert_maneuver_result_code_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -136,66 +129,24 @@ void AlertManeuverRequest::Run() {
void AlertManeuverRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
- bool is_tts_ok;
- bool is_no_navi_error;
- hmi_apis::Common_Result::eType tts_result;
- hmi_apis::Common_Result::eType navi_result;
hmi_apis::FunctionID::eType event_id = event.id();
switch (event_id) {
case hmi_apis::FunctionID::Navigation_AlertManeuver: {
LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event");
-
pending_requests_.Remove(event_id);
-
navi_alert_maneuver_result_code_ =
- static_cast<mobile_apis::Result::eType>(
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- navi_result =
- MessageHelper::MobileToHMIResult(navi_alert_maneuver_result_code_);
- is_no_navi_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- navi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_navi_success =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- navi_result, hmi_apis::Common_Result::SUCCESS);
- if (is_navi_success) {
- info_navi_ =
- message[strings::msg_params][hmi_response::message].asString();
- } else {
- info_navi_ = message[strings::msg_params][strings::info].asString();
- }
+ GetInfo(message, info_navi_);
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
-
pending_requests_.Remove(event_id);
-
- tts_speak_result_code_ = static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- tts_result = MessageHelper::MobileToHMIResult(tts_speak_result_code_);
-
- is_tts_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_tts_success =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result, hmi_apis::Common_Result::SUCCESS);
- if (is_tts_success) {
- info_tts_ =
- message[strings::msg_params][hmi_response::message].asString();
- } else {
- info_tts_ = message[strings::msg_params][strings::info].asString();
- }
+ GetInfo(message, info_tts_);
break;
}
case hmi_apis::FunctionID::TTS_OnResetTimeout: {
@@ -219,32 +170,9 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
"AlertManeuverRequest still waiting.");
return;
}
-
- const bool result =
- (is_tts_ok && is_no_navi_error) ||
- (hmi_apis::Common_Result::SUCCESS == tts_result &&
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == navi_result);
-
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- std::max(tts_speak_result_code_, navi_alert_maneuver_result_code_));
-
std::string return_info;
-
- const bool is_tts_or_navi_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, tts_result, navi_result);
-
- if (result && (is_tts_or_navi_warning ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = std::string("Unsupported phoneme type sent in a prompt");
- }
-
- if (!info_tts_.empty() && !info_navi_.empty()) {
- info_tts_ += ". ";
- }
- return_info = info_tts_ + info_navi_;
+ mobile_apis::Result::eType result_code;
+ const bool result = PrepareResponseParameters(result_code, return_info);
bool must_be_empty_info = false;
if (return_info.find("\n") != std::string::npos ||
return_info.find("\t") != std::string::npos) {
@@ -256,6 +184,36 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
&(message[strings::msg_params]));
}
+bool AlertManeuverRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& return_info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ application_manager::commands::ResponseInfo navigation_alert_info(
+ navi_alert_maneuver_result_code_,
+ HmiInterfaces::HMI_INTERFACE_Navigation);
+
+ application_manager::commands::ResponseInfo tts_alert_info(
+ tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info);
+
+ if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ tts_speak_result_code_ &&
+ (HmiInterfaces::STATE_AVAILABLE ==
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)))) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt");
+ return result;
+ }
+ result_code =
+ PrepareResultCodeForResponse(navigation_alert_info, tts_alert_info);
+ return_info =
+ MergeInfos(navigation_alert_info, info_navi_, tts_alert_info, info_tts_);
+ return result;
+}
+
bool AlertManeuverRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc
index 53910a05b7..3288870b92 100644
--- a/src/components/application_manager/src/commands/mobile/alert_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_request.cc
@@ -40,13 +40,12 @@
#include "application_manager/policies/policy_handler.h"
#include "utils/helpers.h"
+#include "smart_objects/smart_object.h"
namespace application_manager {
namespace commands {
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-
AlertRequest::AlertRequest(const MessageSharedPtr& message,
ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
@@ -55,8 +54,8 @@ AlertRequest::AlertRequest(const MessageSharedPtr& message,
, awaiting_tts_stop_speaking_response_(false)
, is_alert_succeeded_(false)
, is_ui_alert_sent_(false)
- , alert_result_(mobile_apis::Result::INVALID_ENUM)
- , tts_speak_result_(mobile_apis::Result::INVALID_ENUM) {
+ , alert_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , tts_speak_result_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -131,8 +130,6 @@ void AlertRequest::onTimeOut() {
void AlertRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
-
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -153,26 +150,21 @@ void AlertRequest::on_event(const event_engine::Event& event) {
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert);
awaiting_ui_alert_response_ = false;
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
- if (awaiting_tts_speak_response_) {
+ if (awaiting_tts_speak_response_ &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) {
awaiting_tts_stop_speaking_response_ = true;
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true);
}
+ alert_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
// Mobile Alert request is successful when UI_Alert is successful
-
- const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::UNSUPPORTED_RESOURCE,
- mobile_apis::Result::WARNINGS);
-
- is_alert_succeeded_ = is_alert_ok;
- alert_result_ = result_code;
alert_response_params_ = message[strings::msg_params];
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
@@ -180,8 +172,9 @@ void AlertRequest::on_event(const event_engine::Event& event) {
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak);
awaiting_tts_speak_response_ = false;
- tts_speak_result_ = static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_StopSpeaking: {
@@ -200,56 +193,44 @@ void AlertRequest::on_event(const event_engine::Event& event) {
if (HasHmiResponsesToWait()) {
return;
}
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string info;
+ const bool result = PrepareResponseParameters(result_code, info);
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ &alert_response_params_);
+}
- const bool is_tts_alert_unsupported =
- Compare<mobile_api::Result::eType, EQ, ALL>(
- mobile_api::Result::UNSUPPORTED_RESOURCE,
- tts_speak_result_,
- alert_result_);
-
- const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- alert_result_, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
-
- std::string response_info;
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
- !is_ui_alert_sent_) {
- is_alert_succeeded_ = false;
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if (is_tts_alert_unsupported) {
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info =
- "Unsupported phoneme type sent in a prompt and "
- "unsupported image sent in soft buttons";
- } else if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
- is_alert_ok) {
- alert_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if (mobile_apis::Result::SUCCESS == tts_speak_result_ &&
- (mobile_apis::Result::INVALID_ENUM == alert_result_ &&
- !is_ui_alert_sent_)) {
- alert_result_ = mobile_apis::Result::SUCCESS;
- is_alert_succeeded_ = true;
- }
-
- const bool is_tts_not_ok =
- Compare<mobile_api::Result::eType, EQ, ONE>(tts_speak_result_,
- mobile_api::Result::ABORTED,
- mobile_api::Result::REJECTED);
-
- if (is_tts_not_ok && !is_ui_alert_sent_) {
- is_alert_succeeded_ = false;
- alert_result_ = tts_speak_result_;
+bool AlertRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ ResponseInfo ui_alert_info(alert_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo tts_alert_info(tts_speak_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info);
+
+ /* result=false if UI interface is ok and TTS interface = UNSUPPORTED_RESOURCE
+ * and sdl receive TTS.IsReady=true or SDL doesn't receive responce for
+ * TTS.IsReady.
+ */
+ if (result && ui_alert_info.is_ok && tts_alert_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != tts_alert_info.interface_state) {
+ result = false;
}
-
- if (mobile_apis::Result::WARNINGS == tts_speak_result_) {
- alert_result_ = mobile_apis::Result::WARNINGS;
+ result_code = mobile_apis::Result::WARNINGS;
+ if ((ui_alert_info.is_ok || ui_alert_info.is_invalid_enum) &&
+ tts_alert_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) {
+ tts_response_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(
+ ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_);
+ return result;
}
-
- SendResponse(is_alert_succeeded_,
- alert_result_,
- response_info.empty() ? NULL : response_info.c_str(),
- &alert_response_params_);
+ result_code = PrepareResultCodeForResponse(ui_alert_info, tts_alert_info);
+ info = MergeInfos(
+ ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_);
+ return result;
}
bool AlertRequest::Validate(uint32_t app_id) {
@@ -263,7 +244,7 @@ bool AlertRequest::Validate(uint32_t app_id) {
}
if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() &&
- app->IsCommandLimitsExceeded(
+ app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::POLICY_TABLE)) {
LOG4CXX_ERROR(logger_, "Alert frequency is too high.");
diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
index 63339fdc33..f1f3b93e24 100644
--- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc
+++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
@@ -38,6 +38,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace {
namespace custom_str = utils::custom_string;
@@ -69,9 +70,6 @@ void ChangeRegistrationRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace smart_objects;
- const HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -91,18 +89,6 @@ void ChangeRegistrationRequest::Run() {
return;
}
- if (!hmi_capabilities.is_ui_cooperating()) {
- ui_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
- if (!hmi_capabilities.is_vr_cooperating()) {
- vr_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
- if (!hmi_capabilities.is_tts_cooperating()) {
- tts_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- }
-
SmartObject& msg_params = (*message_)[strings::msg_params];
const int32_t hmi_language =
@@ -174,15 +160,6 @@ void ChangeRegistrationRequest::Run() {
hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true);
}
-bool ChangeRegistrationRequest::AllHmiResponsesSuccess(
- const hmi_apis::Common_Result::eType ui,
- const hmi_apis::Common_Result::eType vr,
- const hmi_apis::Common_Result::eType tts) {
- return hmi_apis::Common_Result::SUCCESS == ui &&
- hmi_apis::Common_Result::SUCCESS == vr &&
- hmi_apis::Common_Result::SUCCESS == tts;
-}
-
void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
@@ -195,6 +172,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::VR_ChangeRegistration: {
@@ -202,6 +180,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, vr_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_ChangeRegistration: {
@@ -209,6 +188,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
default: {
@@ -237,16 +217,16 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
application->set_language(static_cast<mobile_api::Language::eType>(
(*message_)[strings::msg_params][strings::language].asInt()));
}
-
- int32_t greates_result_code =
- std::max(std::max(ui_result_, vr_result_), tts_result_);
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string response_info;
+ const bool result = PrepareResponseParameters(result_code, response_info);
(*message_)[strings::params][strings::function_id] =
mobile_apis::FunctionID::eType::ChangeRegistrationID;
- SendResponse(AllHmiResponsesSuccess(ui_result_, vr_result_, tts_result_),
- static_cast<mobile_apis::Result::eType>(greates_result_code),
- NULL,
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
} else {
LOG4CXX_INFO(logger_,
@@ -255,6 +235,137 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
}
}
+namespace {
+void CheckInfo(std::string& str) {
+ if (std::string::npos != str.find("is not supported by system")) {
+ str.clear();
+ }
+}
+} // namespace
+
+bool ChangeRegistrationRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& response_info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+ const bool is_tts_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ tts_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_ui_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_vr_succeeded_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ vr_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_tts_ui_vr_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ tts_result_,
+ ui_result_,
+ vr_result_);
+
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ const HmiInterfaces::InterfaceState tts_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS);
+ const HmiInterfaces::InterfaceState vr_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_VR);
+ const HmiInterfaces::InterfaceState ui_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_UI);
+
+ ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+
+ ResponseInfo tts_properties_info(tts_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ ResponseInfo vr_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_VR);
+
+ bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported &&
+ is_ui_succeeded_unsupported && is_vr_succeeded_unsupported);
+
+ const bool is_tts_or_ui_or_vr_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ tts_result_,
+ ui_result_,
+ vr_result_);
+
+ if ((result && is_tts_or_ui_or_vr_unsupported)) {
+ result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ result =
+ PrepareResultForMobileResponse(ui_properties_info,
+ tts_properties_info) &&
+ PrepareResultForMobileResponse(tts_properties_info, vr_properties_info);
+ } else {
+ // If response contains erroneous result code SDL need return erroneus
+ // result code.
+ hmi_apis::Common_Result::eType ui_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType vr_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType tts_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != ui_result_) {
+ ui_result = ui_result_;
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) {
+ vr_result = vr_result_;
+ }
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != tts_result_) {
+ tts_result = tts_result_;
+ }
+ result_code = MessageHelper::HMIToMobileResult(
+ std::max(std::max(ui_result, vr_result), tts_result));
+ }
+
+ const bool is_tts_state_available =
+ tts_state == HmiInterfaces::STATE_AVAILABLE;
+ const bool is_vr_state_available = vr_state == HmiInterfaces::STATE_AVAILABLE;
+ const bool is_ui_state_available = ui_state == HmiInterfaces::STATE_AVAILABLE;
+
+ const bool is_tts_hmi_info =
+ is_tts_state_available && !tts_response_info_.empty();
+ const bool is_vr_hmi_info =
+ is_vr_state_available && !vr_response_info_.empty();
+ const bool is_ui_hmi_info =
+ is_ui_state_available && !ui_response_info_.empty();
+
+ if (is_tts_hmi_info || is_vr_hmi_info || is_ui_hmi_info) {
+ if (!is_tts_hmi_info)
+ CheckInfo(tts_response_info_);
+ if (!is_vr_hmi_info)
+ CheckInfo(ui_response_info_);
+ if (!is_ui_hmi_info)
+ CheckInfo(vr_response_info_);
+ }
+
+ response_info =
+ MergeInfos(ui_response_info_, vr_response_info_, tts_response_info_);
+ return result;
+}
+
bool ChangeRegistrationRequest::IsLanguageSupportedByUI(
const int32_t& hmi_display_lang) {
const HMICapabilities& hmi_capabilities =
diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
index a7bb5ebc0b..46ef39d806 100644
--- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -32,6 +32,7 @@
*/
#include <string>
+#include <cstring>
#include <algorithm>
#include <vector>
#include "application_manager/commands/mobile/create_interaction_choice_set_request.h"
@@ -52,7 +53,8 @@ CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest(
, expected_chs_count_(0)
, received_chs_count_(0)
, error_from_hmi_(false)
- , is_timed_out_(false) {}
+ , is_timed_out_(false)
+ , vr_commands_lock_(true) {}
CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -129,23 +131,32 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
const SmartArray* choice_set =
(*message_)[strings::msg_params][strings::choice_set].asArray();
- SmartArray::const_iterator choice_set_it = choice_set->begin();
+ SmartArray::const_iterator current_choice_set_it = choice_set->begin();
+ SmartArray::const_iterator next_choice_set_it;
- for (; choice_set->end() != choice_set_it; ++choice_set_it) {
+ for (; choice_set->end() != current_choice_set_it; ++current_choice_set_it) {
std::pair<std::set<uint32_t>::iterator, bool> ins_res =
- choice_id_set.insert((*choice_set_it)[strings::choice_id].asInt());
+ choice_id_set.insert(
+ (*current_choice_set_it)[strings::choice_id].asInt());
if (!ins_res.second) {
LOG4CXX_ERROR(logger_,
"Choise with ID "
- << (*choice_set_it)[strings::choice_id].asInt()
+ << (*current_choice_set_it)[strings::choice_id].asInt()
<< " already exists");
return mobile_apis::Result::INVALID_ID;
}
- if (IsWhiteSpaceExist(*choice_set_it)) {
+ if (IsWhiteSpaceExist(*current_choice_set_it)) {
LOG4CXX_ERROR(logger_, "Incoming choice set has contains \t\n \\t \\n");
return mobile_apis::Result::INVALID_DATA;
}
+ for (next_choice_set_it = current_choice_set_it + 1;
+ choice_set->end() != next_choice_set_it;
+ ++next_choice_set_it) {
+ if (compareSynonyms(*current_choice_set_it, *next_choice_set_it)) {
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ }
}
return mobile_apis::Result::SUCCESS;
}
@@ -289,6 +300,48 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_);
}
+void CreateInteractionChoiceSetRequest::ProcessHmiError(
+ const hmi_apis::Common_Result::eType vr_result) {
+ LOG4CXX_DEBUG(logger_,
+ "Hmi response is not Success: "
+ << vr_result << ". Stop sending VRAddCommand requests");
+ if (!error_from_hmi_) {
+ error_from_hmi_ = true;
+ std::string info =
+ vr_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE
+ ? "VR is not supported by system"
+ : "";
+ SendResponse(false, GetMobileResultCode(vr_result), info.c_str());
+ }
+}
+
+bool CreateInteractionChoiceSetRequest::ProcessSuccesfulHMIResponse(
+ const uint32_t corr_id) {
+ SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
+ if (sent_commands_map_.end() == it) {
+ LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
+ return false;
+ }
+ VRCommandInfo& vr_command = it->second;
+ vr_command.succesful_response_received_ = true;
+ return true;
+}
+
+void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() {
+ received_chs_count_++;
+ LOG4CXX_DEBUG(logger_,
+ "Got VR.AddCommand response, there are "
+ << expected_chs_count_ - received_chs_count_
+ << " more to wait.");
+ if (received_chs_count_ < expected_chs_count_) {
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
+ LOG4CXX_DEBUG(logger_, "Timeout for request was updated");
+ } else {
+ OnAllHMIResponsesReceived();
+ }
+}
+
void CreateInteractionChoiceSetRequest::on_event(
const event_engine::Event& event) {
using namespace hmi_apis;
@@ -296,50 +349,24 @@ void CreateInteractionChoiceSetRequest::on_event(
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
+ const Common_Result::eType result = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ const bool is_no_error = Compare<Common_Result::eType, EQ, ONE>(
+ result, Common_Result::SUCCESS, Common_Result::WARNINGS);
+ uint32_t corr_id = static_cast<uint32_t>(
+ message[strings::params][strings::correlation_id].asUInt());
if (event.id() == hmi_apis::FunctionID::VR_AddCommand) {
- received_chs_count_++;
- LOG4CXX_DEBUG(logger_,
- "Got VR.AddCommand response, there are "
- << expected_chs_count_ - received_chs_count_
- << " more to wait.");
-
- uint32_t corr_id = static_cast<uint32_t>(
- message[strings::params][strings::correlation_id].asUInt());
{
sync_primitives::AutoLock commands_lock(vr_commands_lock_);
- SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
- if (sent_commands_map_.end() == it) {
- LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
- return;
- }
-
- Common_Result::eType vr_result = static_cast<Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
- const bool is_vr_no_error = Compare<Common_Result::eType, EQ, ONE>(
- vr_result, Common_Result::SUCCESS, Common_Result::WARNINGS);
-
- if (is_vr_no_error) {
- VRCommandInfo& vr_command = it->second;
- vr_command.succesful_response_received_ = true;
- } else {
- LOG4CXX_DEBUG(logger_,
- "Hmi response is not Success: "
- << vr_result
- << ". Stop sending VRAddCommand requests");
- if (!error_from_hmi_) {
- error_from_hmi_ = true;
- SendResponse(false, GetMobileResultCode(vr_result));
+ if (is_no_error) {
+ if (!ProcessSuccesfulHMIResponse(corr_id)) {
+ return;
}
+ } else {
+ ProcessHmiError(result);
}
}
- if (received_chs_count_ < expected_chs_count_) {
- application_manager_.updateRequestTimeout(
- connection_key(), correlation_id(), default_timeout());
- LOG4CXX_DEBUG(logger_, "Timeout for request was updated");
- return;
- }
- OnAllHMIResponsesReceived();
+ CountReceivedVRResponses();
}
}
@@ -355,7 +382,8 @@ void CreateInteractionChoiceSetRequest::onTimeOut() {
// according to SDLAQ-CRS-2976
sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_);
is_timed_out_ = true;
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
void CreateInteractionChoiceSetRequest::DeleteChoices() {
@@ -381,7 +409,7 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param);
} else {
LOG4CXX_WARN(logger_,
- "Succesfull response has not been received for cmd_id = "
+ "succesful response has not been received for cmd_id = "
<< vr_command_info.cmd_id_);
}
}
@@ -405,7 +433,8 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
DeleteChoices();
}
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
index 9a7b92f7b8..103e87fa00 100644
--- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
@@ -94,16 +94,19 @@ void DeleteCommandRequest::Run() {
if ((*command).keyExists(strings::vr_commands)) {
++chaining_counter;
}
-
+ /* Need to set all flags before sending request to HMI
+ * for correct processing this flags in method on_event */
if ((*command).keyExists(strings::menu_params)) {
is_ui_send_ = true;
-
- SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
}
// check vr params
if ((*command).keyExists(strings::vr_commands)) {
is_vr_send_ = true;
-
+ }
+ if (is_ui_send_) {
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
+ }
+ if (is_vr_send_) {
// VR params
msg_params[strings::grammar_id] = application->get_grammar_id();
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
@@ -111,29 +114,52 @@ void DeleteCommandRequest::Run() {
}
}
+bool DeleteCommandRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ using namespace helpers;
+ ResponseInfo ui_delete_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo vr_delete_info(vr_result_, HmiInterfaces::HMI_INTERFACE_VR);
+ const bool result =
+ PrepareResultForMobileResponse(ui_delete_info, vr_delete_info);
+
+ const bool is_vr_or_ui_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+ info = MergeInfos(ui_delete_info, ui_info_, vr_delete_info, vr_info_);
+ if (is_vr_or_ui_warning && !ui_delete_info.is_unsupported_resource &&
+ !vr_delete_info.is_unsupported_resource) {
+ LOG4CXX_DEBUG(logger_, "VR or UI result is warning");
+ result_code = mobile_apis::Result::WARNINGS;
+ return result;
+ }
+ result_code = PrepareResultCodeForResponse(ui_delete_info, vr_delete_info);
+ LOG4CXX_DEBUG(logger_, "Result is " << (result ? "true" : "false"));
+ return result;
+}
+
void DeleteCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
-
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteCommand: {
is_ui_received_ = true;
- const int result = message[strings::params][hmi_response::code].asInt();
- ui_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
LOG4CXX_DEBUG(logger_,
"Received UI_DeleteCommand event with result "
<< MessageHelper::HMIResultToString(ui_result_));
+ GetInfo(message, ui_info_);
break;
}
case hmi_apis::FunctionID::VR_DeleteCommand: {
is_vr_received_ = true;
- const int result = message[strings::params][hmi_response::code].asInt();
- vr_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
LOG4CXX_DEBUG(logger_,
"Received VR_DeleteCommand event with result "
<< MessageHelper::HMIResultToString(vr_result_));
+ GetInfo(message, vr_info_);
break;
}
default: {
@@ -167,51 +193,14 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
<< connection_key());
return;
}
-
- const bool is_vr_success_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- vr_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_ui_success_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::INVALID_ENUM);
-
- const bool is_vr_ui_invalid =
- Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
- hmi_apis::Common_Result::INVALID_ENUM, vr_result_, ui_result_);
-
- const bool is_vr_or_ui_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
-
- const bool result =
- // In case of UI/VR is SUCCESS and other is SUCCESS/INVALID_ENUM
- (is_vr_success_invalid && is_ui_success_invalid && !is_vr_ui_invalid) ||
- // or one of them is WARNINGS
- is_vr_or_ui_warning;
-
- LOG4CXX_DEBUG(logger_, "Result code is " << (result ? "true" : "false"));
-
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string info;
+ const bool result = PrepareResponseParameters(result_code, info);
if (result) {
application->RemoveCommand(msg_params[strings::cmd_id].asInt());
}
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
- result_code = MessageHelper::HMIToMobileResult(vr_result_);
- } else if (is_vr_or_ui_warning) {
- LOG4CXX_DEBUG(logger_, "VR or UI result is warning");
- result_code = mobile_apis::Result::WARNINGS;
- } else {
- result_code =
- MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
- }
-
- SendResponse(result, result_code, NULL, &msg_params);
+ SendResponse(
+ result, result_code, info.empty() ? NULL : info.c_str(), &msg_params);
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
index 00d23bb094..31ca29cb51 100644
--- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -93,7 +93,7 @@ void DeleteFileRequest::Run() {
SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
}
} else {
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ SendResponse(false, mobile_apis::Result::REJECTED);
}
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
index bdb5521921..57748e6feb 100644
--- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/delete_sub_menu_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
#include "utils/helpers.h"
@@ -138,19 +139,17 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(
void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteSubMenu: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
ApplicationSharedPtr application =
application_manager_.application(connection_key());
@@ -168,7 +167,10 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
(*message_)[strings::msg_params][strings::menu_id].asInt());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
index 5252ea0e33..5c5d250026 100644
--- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
@@ -37,6 +37,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -93,13 +94,17 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
index 5a922f595f..f67d1f2434 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -32,6 +32,7 @@
*/
#include "application_manager/commands/mobile/end_audio_pass_thru_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -55,12 +56,13 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_EndAudioPassThru: {
- mobile_apis::Result::eType mobile_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
-
- bool result = mobile_apis::Result::SUCCESS == mobile_code;
-
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
if (result) {
bool ended_successfully = application_manager_.EndAudioPassThrough();
if (ended_successfully) {
@@ -68,7 +70,10 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
}
}
- SendResponse(result, mobile_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
index 80bc89f853..d98207c772 100644
--- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
@@ -35,6 +35,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -80,13 +81,19 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetDTCs: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
index dc36e9ad3a..25e2da3eb6 100644
--- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
@@ -230,7 +230,7 @@ void GetVehicleDataRequest::Run() {
return;
}
- if (app->IsCommandLimitsExceeded(
+ if (app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high.");
@@ -266,26 +266,28 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = false;
- if (mobile_apis::Result::SUCCESS == result_code ||
- (mobile_apis::Result::VEHICLE_DATA_NOT_AVAILABLE == result_code &&
- message[strings::msg_params].length() > 1)) {
- result = true;
- }
- const char* info = NULL;
- std::string error_message;
+ bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
+ result = result ||
+ ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) &&
+ (message[strings::msg_params].length() > 1));
+
if (true ==
message[strings::msg_params].keyExists(hmi_response::method)) {
message[strings::msg_params].erase(hmi_response::method);
}
if (true == message[strings::params].keyExists(strings::error_msg)) {
- error_message = message[strings::params][strings::error_msg].asString();
- info = error_message.c_str();
+ response_info = message[strings::params][strings::error_msg].asString();
}
- SendResponse(result, result_code, info, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
index 9baf747ee4..198964a333 100644
--- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/get_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -35,16 +36,21 @@ void GetWayPointsRequest::Run() {
void GetWayPointsRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager_.application(connection_key());
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_GetWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
index 64043d2a88..7c631d6d4b 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
@@ -56,8 +56,7 @@ void OnButtonEventNotification::Run() {
const bool is_app_id_exists =
(*message_)[strings::msg_params].keyExists(strings::app_id);
- const ApplicationSharedPtr app = application_manager_.application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
+ ApplicationSharedPtr app;
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
@@ -67,6 +66,9 @@ void OnButtonEventNotification::Run() {
return;
}
+ app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
+
// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false ==
(*message_)[strings::msg_params].keyExists(
@@ -92,6 +94,14 @@ void OnButtonEventNotification::Run() {
return;
}
+ if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) &&
+ (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) {
+ LOG4CXX_WARN(logger_,
+ "CUSTOM_BUTTON OnButtonEvent notification is allowed only "
+ << "in FULL or LIMITED hmi level");
+ return;
+ }
+
SendButtonEvent(app);
return;
}
diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
index fdf8b559bc..ae6658b93a 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
@@ -56,8 +56,7 @@ void OnButtonPressNotification::Run() {
const bool is_app_id_exists =
(*message_)[strings::msg_params].keyExists(strings::app_id);
- const ApplicationSharedPtr app = application_manager_.application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
+ ApplicationSharedPtr app;
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
@@ -67,6 +66,9 @@ void OnButtonPressNotification::Run() {
return;
}
+ app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
+
// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false ==
(*message_)[strings::msg_params].keyExists(
@@ -92,6 +94,15 @@ void OnButtonPressNotification::Run() {
return;
}
+ // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode
+ if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) &&
+ (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) {
+ LOG4CXX_WARN(logger_,
+ "CUSTOM_BUTTON OnButtonPress notification is allowed only "
+ << "in FULL or LIMITED hmi level");
+ return;
+ }
+
SendButtonPress(app);
return;
}
@@ -116,8 +127,14 @@ void OnButtonPressNotification::Run() {
<< "in FULL or LIMITED hmi level");
continue;
}
- // if "app_id" absent send notification only in HMI_FULL mode
- if (is_app_id_exists || subscribed_app->IsFullscreen()) {
+ // if "appID" is present, send it to named app only if its FULL or
+ // LIMITED
+ if (app.valid()) {
+ if (app->app_id() == subscribed_app->app_id()) {
+ SendButtonPress(subscribed_app);
+ }
+ } else if (subscribed_app->IsFullscreen()) {
+ // if No "appID" - send it FULL apps only.
SendButtonPress(subscribed_app);
}
}
diff --git a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
index 851e9f3059..427f52c12b 100644
--- a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
@@ -58,7 +58,9 @@ void OnKeyBoardInputNotification::Run() {
for (; accessor.GetData().end() != it; ++it) {
// if there is app with active perform interaction use it for notification
ApplicationSharedPtr app = *it;
- if (app->is_perform_interaction_active()) {
+ if (app->is_perform_interaction_active() &&
+ (*it)->perform_interaction_layout() ==
+ mobile_apis::LayoutMode::KEYBOARD) {
LOG4CXX_INFO(logger_,
"There is application with active PerformInteraction");
app_to_notify = app;
diff --git a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
index a4167a802e..09c407b8b5 100644
--- a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
@@ -48,9 +48,6 @@ OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {}
void OnPermissionsChangeNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- (*message_)[strings::params][strings::message_type] =
- static_cast<int32_t>(application_manager::MessageType::kNotification);
-
SendNotification();
}
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index b57490806c..a17c76d9c1 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -78,21 +78,24 @@ void OnSystemRequestNotification::Run() {
}
if (RequestType::PROPRIETARY == request_type) {
-/* According to requirements:
- "If the requestType = PROPRIETARY, add to mobile API fileType = JSON
- If the requestType = HTTP, add to mobile API fileType = BINARY"
- Also in Genivi SDL we don't save the PT to file - we put it directly in
- binary_data */
+ /* According to requirements:
+ "If the requestType = PROPRIETARY, add to mobile API fileType = JSON
+ If the requestType = HTTP, add to mobile API fileType = BINARY"
+ Also in Genivi SDL we don't save the PT to file - we put it directly in
+ binary_data */
-#ifdef EXTENDED_POLICY
const std::string filename =
(*message_)[strings::msg_params][strings::file_name].asString();
-
BinaryMessage binary_data;
file_system::ReadBinaryFile(filename, binary_data);
+#if defined(PROPRIETARY_MODE)
AddHeader(binary_data);
+#endif // PROPRIETARY_MODE
+
+#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
(*message_)[strings::params][strings::binary_data] = binary_data;
-#endif
+#endif // PROPRIETARY_MODE
+
(*message_)[strings::msg_params][strings::file_type] = FileType::JSON;
} else if (RequestType::HTTP == request_type) {
(*message_)[strings::msg_params][strings::file_type] = FileType::BINARY;
@@ -101,10 +104,11 @@ void OnSystemRequestNotification::Run() {
SendNotification();
}
-#ifdef EXTENDED_POLICY
+#ifdef PROPRIETARY_MODE
void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
LOG4CXX_AUTO_TRACE(logger_);
- const int timeout = application_manager_.GetPolicyHandler().TimeoutExchange();
+ const uint32_t timeout =
+ application_manager_.GetPolicyHandler().TimeoutExchangeSec();
size_t content_length;
char size_str[24];
@@ -149,7 +153,7 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
","
"\"InstanceFollowRedirects\": false,"
"\"charset\": \"utf-8\","
- "\"Content_-Length\": " +
+ "\"Content-Length\": " +
std::string(size_str) +
"},"
"\"body\": \"" +
@@ -184,7 +188,7 @@ size_t OnSystemRequestNotification::ParsePTString(
pt_string = result;
return result_length;
}
-#endif
+#endif // PROPRIETARY_MODE
} // namespace mobile
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
index d595119d45..9f5fd937f9 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -47,8 +47,10 @@ namespace str = strings;
PerformAudioPassThruRequest::PerformAudioPassThruRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , is_active_tts_speak_(false)
- , result_tts_speak_(mobile_apis::Result::SUCCESS) {
+ , awaiting_tts_speak_response_(false)
+ , awaiting_ui_response_(false)
+ , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM)
+ , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
@@ -92,7 +94,10 @@ void PerformAudioPassThruRequest::Run() {
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
+ // According with new implementation processing of UNSUPPORTE_RESOURCE
+ // need set flag before sending to hmi
+ awaiting_ui_response_ = true;
if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
(0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
// In case TTS Speak, subscribe on notification
@@ -114,56 +119,41 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru");
+ awaiting_ui_response_ = false;
- if (!WaitTTSSpeak()) {
- LOG4CXX_DEBUG(logger_, "TTS.Speak is absent");
- return;
- }
-
- mobile_apis::Result::eType mobile_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
+ result_ui_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, ui_info_);
// in case perform audio is started by other request skip stopping
- if (mobile_apis::Result::REJECTED == mobile_code) {
+ if (hmi_apis::Common_Result::REJECTED == result_ui_) {
LOG4CXX_ERROR(logger_, "Request was rejected");
- SendResponse(false, mobile_code, NULL, &(message[strings::msg_params]));
+ SendResponse(false,
+ MessageHelper::HMIToMobileResult(result_ui_),
+ NULL,
+ &(message[strings::msg_params]));
return;
}
-
FinishTTSSpeak();
-
- std::string return_info;
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- mobile_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::RETRY,
- mobile_apis::Result::WARNINGS);
-
- const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- mobile_code,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::WARNINGS);
-
- if (is_result_ok &&
- mobile_apis::Result::UNSUPPORTED_RESOURCE == result_tts_speak_) {
- mobile_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- }
-
- SendResponse(result,
- mobile_code,
- return_info.empty() ? NULL : return_info.c_str(),
- &(message[strings::msg_params]));
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
- result_tts_speak_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- is_active_tts_speak_ = false;
- if (mobile_apis::Result::SUCCESS == result_tts_speak_) {
+ result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, tts_info_);
+ awaiting_tts_speak_response_ = false;
+ const bool is_tts_speak_success_unsuported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ result_tts_speak_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ if (is_tts_speak_success_unsuported) {
SendRecordStartNotification();
StartMicrophoneRecording();
@@ -185,6 +175,40 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
return;
}
}
+ if (IsWaitingHMIResponse()) {
+ return;
+ }
+
+ std::string return_info;
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ const bool result = PrepareResponseParameters(result_code, return_info);
+
+ SendResponse(result,
+ result_code,
+ return_info.empty() ? NULL : return_info.c_str(),
+ &(message[strings::msg_params]));
+}
+
+bool PerformAudioPassThruRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ResponseInfo ui_perform_info(result_ui_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo tts_perform_info(result_tts_speak_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(ui_perform_info, tts_perform_info);
+
+ if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource &&
+ HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) {
+ result_code = mobile_apis::Result::WARNINGS;
+ tts_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+ return result;
+ }
+ result_code = PrepareResultCodeForResponse(ui_perform_info, tts_perform_info);
+ info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+ return result;
}
void PerformAudioPassThruRequest::SendSpeakRequest() {
@@ -194,23 +218,19 @@ void PerformAudioPassThruRequest::SendSpeakRequest() {
using namespace smart_objects;
SmartObject msg_params = smart_objects::SmartObject(SmartType_Map);
-
- if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
- (0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
- for (uint32_t i = 0;
- i < (*message_)[str::msg_params][str::initial_prompt].length();
- ++i) {
- msg_params[hmi_request::tts_chunks][i][str::text] =
- (*message_)[str::msg_params][str::initial_prompt][i][str::text];
- msg_params[hmi_request::tts_chunks][i][str::type] =
- (*message_)[str::msg_params][str::initial_prompt][i][str::type];
- }
- // app_id
- msg_params[strings::app_id] = connection_key();
- msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU;
- is_active_tts_speak_ = true;
- SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
+ for (uint32_t i = 0;
+ i < (*message_)[str::msg_params][str::initial_prompt].length();
+ ++i) {
+ msg_params[hmi_request::tts_chunks][i][str::text] =
+ (*message_)[str::msg_params][str::initial_prompt][i][str::text];
+ msg_params[hmi_request::tts_chunks][i][str::type] =
+ (*message_)[str::msg_params][str::initial_prompt][i][str::type];
}
+ // app_id
+ msg_params[strings::app_id] = connection_key();
+ msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU;
+ awaiting_tts_speak_response_ = true;
+ SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
}
void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
@@ -333,37 +353,16 @@ void PerformAudioPassThruRequest::FinishTTSSpeak() {
LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
application_manager_.StopAudioPassThru(connection_key());
}
- if (!is_active_tts_speak_) {
+ if (!awaiting_tts_speak_response_) {
LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
return;
}
- is_active_tts_speak_ = false;
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL);
}
-bool PerformAudioPassThruRequest::WaitTTSSpeak() {
+bool PerformAudioPassThruRequest::IsWaitingHMIResponse() {
LOG4CXX_AUTO_TRACE(logger_);
- uint64_t default_timeout_msec =
- application_manager_.get_settings().default_timeout();
- const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
-
- // Waiting for TTS_Speak
- while (is_active_tts_speak_) {
- uint64_t difference_between_start_current_time =
- date_time::DateTime::calculateTimeSpan(start_time);
- // Send GENERIC_ERROR after default timeout
- if (difference_between_start_current_time > default_timeout_msec) {
- LOG4CXX_WARN(logger_, "Expired timeout for TTS.Speak response");
- // Don't use onTimeOut(), because default_timeout_ is bigger than
- // Default time in *.ini file
- FinishTTSSpeak();
- SendResponse(false,
- mobile_apis::Result::eType::GENERIC_ERROR,
- "Expired timeout for TTS.Speak response");
- return false;
- }
- }
- return true;
+ return awaiting_tts_speak_response_ || awaiting_ui_response_;
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
index 39ad51e822..007440e8e6 100644
--- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
@@ -57,13 +57,11 @@ PerformInteractionRequest::PerformInteractionRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
, interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM)
- , ui_response_recived_(false)
- , vr_response_recived_(false)
- , ui_result_(false)
- , vr_result_(false)
+ , ui_response_received_(false)
+ , vr_response_received_(false)
, app_pi_was_active_before_(false)
- , vr_resultCode_(mobile_apis::Result::INVALID_ENUM)
- , ui_resultCode_(mobile_apis::Result::INVALID_ENUM) {
+ , vr_result_code_(hmi_apis::Common_Result::INVALID_ENUM)
+ , ui_result_code_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand);
subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress);
@@ -207,6 +205,7 @@ void PerformInteractionRequest::Run() {
app->set_perform_interaction_mode(static_cast<int32_t>(interaction_mode_));
app->set_perform_interaction_active(true);
+ app->set_perform_interaction_layout(interaction_layout);
// increment amount of active requests
++pi_requests_count_;
SendVRPerformInteractionRequest(app);
@@ -228,22 +227,24 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::UI_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event");
- ui_response_recived_ = true;
+ ui_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
- ui_resultCode_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- ProcessPerformInteractionResponse(event.smart_object(), msg_param);
+ ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, ui_info_);
+ ProcessUIResponse(event.smart_object(), msg_param);
break;
}
case hmi_apis::FunctionID::VR_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction");
- vr_response_recived_ = true;
+ vr_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction);
- vr_resultCode_ =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- ProcessVRResponse(event.smart_object(), msg_param);
+ vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt());
+ GetInfo(message, vr_info_);
+ if (ProcessVRResponse(event.smart_object(), msg_param)) {
+ return;
+ }
break;
}
default: {
@@ -252,8 +253,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
}
- if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
- !HasHMIResponsesToWait()) {
+ if (!HasHMIResponsesToWait()) {
LOG4CXX_DEBUG(logger_, "Send response in BOTH iteraction mode");
SendBothModeResponse(msg_param);
}
@@ -264,7 +264,8 @@ void PerformInteractionRequest::onTimeOut() {
switch (interaction_mode_) {
case mobile_apis::InteractionMode::BOTH: {
- if (true == vr_response_recived_) {
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH");
+ if (true == vr_response_received_) {
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
@@ -275,11 +276,14 @@ void PerformInteractionRequest::onTimeOut() {
break;
}
case mobile_apis::InteractionMode::VR_ONLY: {
- application_manager_.updateRequestTimeout(
- connection_key(), correlation_id(), default_timeout());
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY");
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ DisablePerformInteraction();
+ CommandRequestImpl::onTimeOut();
break;
}
case mobile_apis::InteractionMode::MANUAL_ONLY: {
+ LOG4CXX_DEBUG(logger_, "InteractionMode: MANUAL_ONLY");
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
@@ -292,12 +296,12 @@ void PerformInteractionRequest::onTimeOut() {
};
}
-void PerformInteractionRequest::ProcessVRResponse(
+bool PerformInteractionRequest::ProcessVRResponse(
const smart_objects::SmartObject& message,
smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace hmi_apis;
using namespace mobile_apis;
- using namespace mobile_apis::Result;
using namespace smart_objects;
using namespace helpers;
@@ -305,37 +309,36 @@ void PerformInteractionRequest::ProcessVRResponse(
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
+ return false;
}
- CheckResponseResultCode();
msg_params[strings::trigger_source] =
static_cast<int32_t>(TriggerSource::TS_VR);
- const bool is_vr_aborted_timeout =
- Compare<Result::eType, EQ, ONE>(vr_resultCode_, ABORTED, TIMED_OUT);
+ const bool is_vr_aborted_timeout = Compare<Common_Result::eType, EQ, ONE>(
+ vr_result_code_, Common_Result::ABORTED, Common_Result::TIMED_OUT);
if (is_vr_aborted_timeout) {
LOG4CXX_DEBUG(logger_, "VR response aborted");
if (InteractionMode::VR_ONLY == interaction_mode_) {
LOG4CXX_DEBUG(logger_, "Aborted or Timeout Send Close Popup");
TerminatePerformInteraction();
- SendResponse(false, vr_resultCode_);
- return;
+ SendResponse(false, MessageHelper::HMIToMobileResult(vr_result_code_));
+ return true;
}
LOG4CXX_DEBUG(logger_, "Update timeout for UI");
application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
- return;
+ return false;
}
- if (SUCCESS == vr_resultCode_ &&
+ if (Common_Result::SUCCESS == vr_result_code_ &&
InteractionMode::MANUAL_ONLY == interaction_mode_) {
LOG4CXX_DEBUG(logger_,
"VR response SUCCESS in MANUAL_ONLY mode "
<< "Wait for UI response");
// in case MANUAL_ONLY mode VR.PI SUCCESS just return
- return;
+ return false;
}
const SmartObject& hmi_msg_params = message[strings::msg_params];
@@ -345,26 +348,15 @@ void PerformInteractionRequest::ProcessVRResponse(
LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI");
TerminatePerformInteraction();
SendResponse(
- false, GENERIC_ERROR, "Wrong choiceID was received from HMI");
- return;
+ false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI");
+ return true;
}
msg_params[strings::choice_id] = choise_id;
}
-
- vr_result_ = true;
-
- if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
- mobile_apis::Result::SUCCESS != vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response isn't SUCCESS in BOTH mode");
- return;
- }
-
- LOG4CXX_DEBUG(logger_, "VR response consider to be SUCCESS");
- TerminatePerformInteraction();
- SendResponse(vr_result_, SUCCESS, NULL, &msg_params);
+ return false;
}
-void PerformInteractionRequest::ProcessPerformInteractionResponse(
+void PerformInteractionRequest::ProcessUIResponse(
const smart_objects::SmartObject& message,
smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -377,31 +369,37 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
return;
}
- ui_result_ = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_,
- mobile_apis::Result::SUCCESS,
- mobile_apis::Result::WARNINGS,
- mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ HmiInterfaces::InterfaceState ui_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI);
+ bool result = false;
+ result = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
- const bool is_pi_warning = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_, mobile_apis::Result::WARNINGS);
+ result = result ||
+ (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_code_ &&
+ HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state);
- const bool is_pi_unsupported = Compare<mobile_api::Result::eType, EQ, ONE>(
- ui_resultCode_, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ const bool is_pi_warning = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_, hmi_apis::Common_Result::WARNINGS);
- std::string info;
+ const bool is_pi_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
- if (ui_result_) {
+ if (result) {
if (is_pi_warning) {
- ui_resultCode_ = mobile_apis::Result::WARNINGS;
- info = "Unsupported phoneme type was sent in an item";
+ ui_result_code_ = hmi_apis::Common_Result::WARNINGS;
+ ui_info_ = "Unsupported phoneme type was sent in an item";
if (message.keyExists(strings::params) &&
message[strings::params].keyExists(strings::data)) {
msg_params = message[strings::params][strings::data];
}
} else if (is_pi_unsupported) {
- ui_resultCode_ = mobile_apis::Result::UNSUPPORTED_RESOURCE;
- info = "Unsupported phoneme type was sent in an item";
+ ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
+ ui_info_ = "Unsupported phoneme type was sent in an item";
} else if (message.keyExists(strings::msg_params)) {
msg_params = message[strings::msg_params];
}
@@ -409,8 +407,8 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
if (msg_params.keyExists(strings::choice_id)) {
if (!CheckChoiceIDFromResponse(app,
msg_params[strings::choice_id].asInt())) {
- ui_resultCode_ = mobile_apis::Result::GENERIC_ERROR;
- info = "Wrong choiceID was received from HMI";
+ ui_result_code_ = hmi_apis::Common_Result::GENERIC_ERROR;
+ ui_info_ = "Wrong choiceID was received from HMI";
} else {
msg_params[strings::trigger_source] =
mobile_apis::TriggerSource::TS_MENU;
@@ -423,15 +421,6 @@ void PerformInteractionRequest::ProcessPerformInteractionResponse(
}
}
}
-
- DisablePerformInteraction();
-
- const SmartObject* response_params = msg_params.empty() ? NULL : &msg_params;
-
- if (mobile_apis::InteractionMode::BOTH != interaction_mode_) {
- DisablePerformInteraction();
- SendResponse(ui_result_, ui_resultCode_, info.c_str(), response_params);
- }
}
void PerformInteractionRequest::SendUIPerformInteractionRequest(
@@ -929,60 +918,31 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
const bool PerformInteractionRequest::HasHMIResponsesToWait() const {
LOG4CXX_AUTO_TRACE(logger_);
- return !ui_response_recived_ || !vr_response_recived_;
-}
-
-void PerformInteractionRequest::CheckResponseResultCode() {
- LOG4CXX_AUTO_TRACE(logger_);
- mobile_apis::Result::eType resultCode = mobile_apis::Result::INVALID_ENUM;
- bool result = false;
- if (mobile_apis::Result::GENERIC_ERROR == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response GENERIC_ERROR");
- resultCode = mobile_apis::Result::GENERIC_ERROR;
- } else if (mobile_apis::Result::REJECTED == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR had been rejected.");
- resultCode = mobile_apis::Result::REJECTED;
- } else if (mobile_apis::Result::WARNINGS == vr_resultCode_ ||
- mobile_apis::Result::UNSUPPORTED_REQUEST == vr_resultCode_) {
- LOG4CXX_DEBUG(logger_, "VR response WARNINGS");
- resultCode = mobile_api::Result::WARNINGS;
- result = true;
- }
-
- if (mobile_apis::Result::INVALID_ENUM != resultCode) {
- TerminatePerformInteraction();
- SendResponse(result, resultCode);
- }
+ return !ui_response_received_ || !vr_response_received_;
}
void PerformInteractionRequest::SendBothModeResponse(
const smart_objects::SmartObject& msg_param) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace mobile_apis::Result;
-
- bool result = ui_result_ || vr_result_;
- mobile_apis::Result::eType perform_interaction_result_code = ui_resultCode_;
-
- if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
- UNSUPPORTED_RESOURCE != ui_resultCode_) {
- perform_interaction_result_code = vr_resultCode_;
- } else if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
- UNSUPPORTED_RESOURCE == ui_resultCode_) {
- result = false;
- }
-
- const bool is_error_code = (SUCCESS != perform_interaction_result_code ||
- WARNINGS != perform_interaction_result_code);
-
- if (vr_resultCode_ == ui_resultCode_ && is_error_code) {
- result = false;
- }
-
+ mobile_apis::Result::eType perform_interaction_result_code =
+ mobile_apis::Result::INVALID_ENUM;
+ ResponseInfo ui_perform_info(ui_result_code_,
+ HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo vr_perform_info(vr_result_code_,
+ HmiInterfaces::HMI_INTERFACE_VR);
+ const bool result =
+ PrepareResultForMobileResponse(ui_perform_info, vr_perform_info);
+ perform_interaction_result_code =
+ PrepareResultCodeForResponse(ui_perform_info, vr_perform_info);
const smart_objects::SmartObject* response_params =
msg_param.empty() ? NULL : &msg_param;
-
- TerminatePerformInteraction();
- SendResponse(result, perform_interaction_result_code, NULL, response_params);
+ std::string info =
+ MergeInfos(ui_perform_info, ui_info_, vr_perform_info, vr_info_);
+ DisablePerformInteraction();
+ SendResponse(result,
+ perform_interaction_result_code,
+ info.empty() ? NULL : info.c_str(),
+ response_params);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc
index 69885f9d40..0bf747bde3 100644
--- a/src/components/application_manager/src/commands/mobile/read_did_request.cc
+++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc
@@ -36,6 +36,7 @@
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -65,7 +66,7 @@ void ReadDIDRequest::Run() {
return;
}
- if (app->IsCommandLimitsExceeded(
+ if (app->AreCommandLimitsExceeded(
static_cast<mobile_apis::FunctionID::eType>(function_id()),
application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "ReadDID frequency is too high.");
@@ -96,18 +97,17 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_ReadDID: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- const std::string return_info =
- message[strings::msg_params][hmi_response::message].asString();
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ std::string response_info;
+ GetInfo(message, response_info);
SendResponse(result,
- result_code,
- return_info.c_str(),
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
}
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index e9f6db05b2..413aa1f669 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
@@ -42,8 +42,11 @@
#include "application_manager/application_manager.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/application_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl.h"
#include "application_manager/message_helper.h"
#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/policies/policy_handler.h"
+#include "config_profile/profile.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/generated_msg_version.h"
@@ -139,6 +142,13 @@ struct CheckMissedTypes {
std::string& log_;
};
+class SmartArrayValueExtractor {
+ public:
+ AppHmiType operator()(const smart_objects::SmartObject& so) const {
+ return static_cast<AppHmiType>(so.asInt());
+ }
+};
+
struct IsSameNickname {
IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {}
bool operator()(const policy::StringArray::value_type& nickname) const {
@@ -363,61 +373,40 @@ RegisterAppInterfaceRequest::GetLockScreenIconUrlNotification(
return message;
}
-void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
- LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
-
- const HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
- const uint32_t key = connection_key();
- ApplicationSharedPtr application = application_manager_.application(key);
-
- resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
+void FillVRRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ response_params[strings::language] = hmi_capabilities.active_vr_language();
+ if (hmi_capabilities.vr_capabilities()) {
+ response_params[strings::vr_capabilities] =
+ *hmi_capabilities.vr_capabilities();
+ }
+}
- if (!application) {
- LOG4CXX_ERROR(logger_,
- "There is no application for such connection key" << key);
- LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer");
- resumer.OnAppRegistrationEnd();
- return;
+void FillVIRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ if (hmi_capabilities.vehicle_type()) {
+ response_params[hmi_response::vehicle_type] =
+ *hmi_capabilities.vehicle_type();
}
+}
- response_params[strings::sync_msg_version][strings::major_version] =
- major_version; // From generated file interfaces/generated_msg_version.h
- response_params[strings::sync_msg_version][strings::minor_version] =
- minor_version; // From generated file interfaces/generated_msg_version.h
+void FillTTSRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
+ response_params[strings::language] = hmi_capabilities.active_tts_language();
+ if (hmi_capabilities.speech_capabilities()) {
+ response_params[strings::speech_capabilities] =
+ *hmi_capabilities.speech_capabilities();
+ }
+ if (hmi_capabilities.prerecorded_speech()) {
+ response_params[strings::prerecorded_speech] =
+ *(hmi_capabilities.prerecorded_speech());
+ }
+}
- response_params[strings::language] = hmi_capabilities.active_vr_language();
+void FillUIRelatedFields(smart_objects::SmartObject& response_params,
+ const HMICapabilities& hmi_capabilities) {
response_params[strings::hmi_display_language] =
hmi_capabilities.active_ui_language();
-
- const smart_objects::SmartObject& msg_params =
- (*message_)[strings::msg_params];
-
- if (msg_params[strings::language_desired].asInt() !=
- hmi_capabilities.active_vr_language() ||
- msg_params[strings::hmi_display_language_desired].asInt() !=
- hmi_capabilities.active_ui_language()) {
- LOG4CXX_WARN(logger_,
- "Wrong language on registering application "
- << application->name().c_str());
-
- LOG4CXX_ERROR(
- logger_,
- "VR language desired code is "
- << msg_params[strings::language_desired].asInt()
- << " , active VR language code is "
- << hmi_capabilities.active_vr_language() << ", UI language code is "
- << msg_params[strings::hmi_display_language_desired].asInt()
- << " , active UI language code is "
- << hmi_capabilities.active_ui_language());
-
- result_code = mobile_apis::Result::WRONG_LANGUAGE;
- }
-
if (hmi_capabilities.display_capabilities()) {
response_params[hmi_response::display_capabilities] =
smart_objects::SmartObject(smart_objects::SmartType_Map);
@@ -453,13 +442,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
hmi_capabilities.display_capabilities()->getElement(
hmi_response::num_custom_presets_available);
- if (hmi_capabilities.display_capabilities()
- ->getElement(hmi_response::image_capabilities)
- .length() > 0) {
- display_caps[hmi_response::graphic_supported] = true;
- } else {
- display_caps[hmi_response::graphic_supported] = false;
- }
+ display_caps[hmi_response::graphic_supported] =
+ (hmi_capabilities.display_capabilities()
+ ->getElement(hmi_response::image_capabilities)
+ .length() > 0);
display_caps[hmi_response::templates_available] =
hmi_capabilities.display_capabilities()->getElement(
@@ -474,6 +460,96 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
hmi_response::num_custom_presets_available);
}
+ if (hmi_capabilities.audio_pass_thru_capabilities()) {
+ if (smart_objects::SmartType_Array ==
+ hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
+ // hmi_capabilities json contains array and HMI response object
+ response_params[strings::audio_pass_thru_capabilities] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
+ } else {
+ response_params[strings::audio_pass_thru_capabilities][0] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
+ }
+ }
+ response_params[strings::hmi_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ response_params[strings::hmi_capabilities][strings::navigation] =
+ hmi_capabilities.navigation_supported();
+ response_params[strings::hmi_capabilities][strings::phone_call] =
+ hmi_capabilities.phone_call_supported();
+}
+
+void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
+
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+
+ const uint32_t key = connection_key();
+ ApplicationSharedPtr application = application_manager_.application(key);
+
+ resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
+
+ if (!application) {
+ LOG4CXX_ERROR(logger_,
+ "There is no application for such connection key" << key);
+ LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer");
+ resumer.OnAppRegistrationEnd();
+ return;
+ }
+
+ response_params[strings::sync_msg_version][strings::major_version] =
+ major_version; // From generated file interfaces/generated_msg_version.h
+ response_params[strings::sync_msg_version][strings::minor_version] =
+ minor_version; // From generated file interfaces/generated_msg_version.h
+ response_params[strings::sync_msg_version][strings::patch_version] =
+ patch_version; // From generated file interfaces/generated_msg_version.h
+
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ if (msg_params[strings::language_desired].asInt() !=
+ hmi_capabilities.active_vr_language() ||
+ msg_params[strings::hmi_display_language_desired].asInt() !=
+ hmi_capabilities.active_ui_language()) {
+ LOG4CXX_WARN(logger_,
+ "Wrong language on registering application "
+ << application->name().c_str());
+
+ LOG4CXX_ERROR(
+ logger_,
+ "VR language desired code is "
+ << msg_params[strings::language_desired].asInt()
+ << " , active VR language code is "
+ << hmi_capabilities.active_vr_language() << ", UI language code is "
+ << msg_params[strings::hmi_display_language_desired].asInt()
+ << " , active UI language code is "
+ << hmi_capabilities.active_ui_language());
+
+ result_code = mobile_apis::Result::WRONG_LANGUAGE;
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ FillTTSRelatedFields(response_params, hmi_capabilities);
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VR)) {
+ FillVRRelatedFields(response_params, hmi_capabilities);
+ }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_UI)) {
+ FillUIRelatedFields(response_params, hmi_capabilities);
+ }
+
if (hmi_capabilities.button_capabilities()) {
response_params[hmi_response::button_capabilities] =
*hmi_capabilities.button_capabilities();
@@ -497,36 +573,22 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
*hmi_capabilities.hmi_zone_capabilities();
}
}
- if (hmi_capabilities.speech_capabilities()) {
- response_params[strings::speech_capabilities] =
- *hmi_capabilities.speech_capabilities();
- }
- if (hmi_capabilities.vr_capabilities()) {
- response_params[strings::vr_capabilities] =
- *hmi_capabilities.vr_capabilities();
- }
- if (hmi_capabilities.audio_pass_thru_capabilities()) {
- if (smart_objects::SmartType_Array ==
- hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
- // hmi_capabilities json contains array and HMI response object
- response_params[strings::audio_pass_thru_capabilities] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- } else {
- response_params[strings::audio_pass_thru_capabilities][0] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- }
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS)) {
+ FillTTSRelatedFields(response_params, hmi_capabilities);
}
+
if (hmi_capabilities.pcm_stream_capabilities()) {
response_params[strings::pcm_stream_capabilities] =
*hmi_capabilities.pcm_stream_capabilities();
}
- if (hmi_capabilities.vehicle_type()) {
- response_params[hmi_response::vehicle_type] =
- *hmi_capabilities.vehicle_type();
- }
- if (hmi_capabilities.prerecorded_speech()) {
- response_params[strings::prerecorded_speech] =
- *(hmi_capabilities.prerecorded_speech());
+
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
+ FillVIRelatedFields(response_params, hmi_capabilities);
}
const std::vector<uint32_t>& diag_modes =
@@ -539,13 +601,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
++index;
}
}
-
- response_params[strings::hmi_capabilities] =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- response_params[strings::hmi_capabilities][strings::navigation] =
- hmi_capabilities.navigation_supported();
- response_params[strings::hmi_capabilities][strings::phone_call] =
- hmi_capabilities.phone_call_supported();
response_params[strings::sdl_version] =
application_manager_.get_settings().sdl_version();
const std::string ccpu_version =
@@ -590,31 +645,78 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
application->mac_address());
}
+ AppHmiTypes hmi_types;
+ if ((*message_)[strings::msg_params].keyExists(strings::app_hmi_type)) {
+ smart_objects::SmartArray* hmi_types_ptr =
+ (*message_)[strings::msg_params][strings::app_hmi_type].asArray();
+ DCHECK_OR_RETURN_VOID(hmi_types_ptr);
+ SmartArrayValueExtractor extractor;
+ if (hmi_types_ptr && 0 < hmi_types_ptr->size()) {
+ std::transform(hmi_types_ptr->begin(),
+ hmi_types_ptr->end(),
+ std::back_inserter(hmi_types),
+ extractor);
+ }
+ }
+ policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication(
+ application->policy_app_id(), hmi_types);
+ SendResponse(true, result_code, add_info.c_str(), &response_params);
SendOnAppRegisteredNotificationToHMI(
*(application.get()), resumption, need_restore_vr);
- SendResponse(true, result_code, add_info.c_str(), &response_params);
- // Check if application exists, because application might be unregestered
- // during sending reponse to mobile.
- application = application_manager_.application(key);
- if (application) {
- LOG4CXX_DEBUG(logger_, "Application with app_id = " << key << " exists.");
- if (result_code != mobile_apis::Result::RESUME_FAILED) {
- resumer.StartResumption(application, hash_id);
- } else {
- resumer.StartResumptionOnlyHMILevel(application);
- }
+ // Default HMI level should be set before any permissions validation, since it
+ // relies on HMI level.
+ application_manager_.OnApplicationRegistered(application);
+ (*notify_upd_manager)();
- // By default app subscribed to CUSTOM_BUTTON
- SendSubscribeCustomButtonNotification();
- MessageHelper::SendChangeRegistrationRequestToHMI(application,
- application_manager_);
+ // Start PTU after successfull registration
+ // Sends OnPermissionChange notification to mobile right after RAI response
+ // and HMI level set-up
+ GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id());
+
+ if (result_code != mobile_apis::Result::RESUME_FAILED) {
+ resumer.StartResumption(application, hash_id);
} else {
- LOG4CXX_DEBUG(logger_,
- "Application with app_id = " << key << " doesn't exist.");
+ resumer.StartResumptionOnlyHMILevel(application);
+ }
+
+ // By default app subscribed to CUSTOM_BUTTON
+ SendSubscribeCustomButtonNotification();
+ SendChangeRegistrationOnHMI(application);
+}
+
+void RegisterAppInterfaceRequest::SendChangeRegistration(
+ const hmi_apis::FunctionID::eType function_id,
+ const int32_t language,
+ const uint32_t app_id) {
+ using helpers::Compare;
+ using helpers::EQ;
+ using helpers::ONE;
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ const HmiInterfaces::InterfaceID interface =
+ hmi_interfaces.GetInterfaceFromFunction(function_id);
+ if (hmi_interfaces.GetInterfaceState(interface) !=
+ HmiInterfaces::STATE_NOT_AVAILABLE) {
+ smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
+ msg_params[strings::language] = language;
+ msg_params[strings::app_id] = app_id;
+ SendHMIRequest(function_id, &msg_params);
+ } else {
+ LOG4CXX_DEBUG(logger_, "Interface " << interface << "is not avaliable");
}
}
+void RegisterAppInterfaceRequest::SendChangeRegistrationOnHMI(
+ ApplicationConstSharedPtr app) {
+ using namespace hmi_apis::FunctionID;
+ DCHECK_OR_RETURN_VOID(app);
+ DCHECK_OR_RETURN_VOID(mobile_apis::Language::INVALID_ENUM != app->language());
+ SendChangeRegistration(VR_ChangeRegistration, app->language(), app->app_id());
+ SendChangeRegistration(
+ TTS_ChangeRegistration, app->language(), app->app_id());
+ SendChangeRegistration(UI_ChangeRegistration, app->language(), app->app_id());
+}
+
void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI(
const Application& application_impl,
bool resumption,
@@ -819,7 +921,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
// If AppHMIType is not included in policy - allow any type
if (!app_hmi_types.empty()) {
if (message[strings::msg_params].keyExists(strings::app_hmi_type)) {
- // If AppHMITypes are partially same, the system should allow those listed
+ // If AppHmiTypes are partially same, the system should allow those listed
// in the policy table and send warning info on missed values
smart_objects::SmartArray app_types =
*(message[strings::msg_params][strings::app_hmi_type].asArray());
@@ -829,13 +931,13 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
std::for_each(app_types.begin(), app_types.end(), checker);
if (!log.empty()) {
response_info_ =
- "Following AppHMITypes are not present in policy "
+ "Following AppHmiTypes are not present in policy "
"table:" +
log;
result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS;
}
}
- // Replace AppHMITypes in request with values allowed by policy table
+ // Replace AppHmiTypes in request with values allowed by policy table
message[strings::msg_params][strings::app_hmi_type] =
smart_objects::SmartObject(smart_objects::SmartType_Array);
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
index 1d7f829a68..3e94e652d4 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
@@ -77,15 +77,6 @@ void RegisterAppInterfaceResponse::Run() {
}
SetHeartBeatTimeout(connection_key(), application->policy_app_id());
-
- // Default HMI level should be set before any permissions validation, since it
- // relies on HMI level.
- application_manager_.OnApplicationRegistered(application);
-
- // Sends OnPermissionChange notification to mobile right after RAI response
- // and HMI level set-up
- application_manager_.GetPolicyHandler().OnAppRegisteredOnMobile(
- application->policy_app_id());
}
void RegisterAppInterfaceResponse::SetHeartBeatTimeout(
diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
index 0260fef676..b1dce9151f 100644
--- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
@@ -251,6 +251,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
@@ -258,6 +259,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_tts_received_ = true;
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
default: {
@@ -266,48 +268,63 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
}
- if (!IsPendingResponseExist()) {
- bool result =
- ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) ||
- ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) ||
- ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) &&
- (hmi_apis::Common_Result::SUCCESS == tts_result_));
-
- mobile_apis::Result::eType result_code;
- const char* return_info = NULL;
-
- if (result) {
- if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
- }
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
- }
+ if (IsPendingResponseExist()) {
+ LOG4CXX_DEBUG(logger_, "Waiting for remaining responses");
+ return;
+ }
- SendResponse(result,
- static_cast<mobile_apis::Result::eType>(result_code),
- return_info,
- &(message[strings::msg_params]));
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ std::string response_info;
+ const bool result = PrepareResponseParameters(result_code, response_info);
- if (!application) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
+ SendResponse(result,
+ static_cast<mobile_apis::Result::eType>(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
- if (result) {
- application->UpdateHash();
- }
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ if (result) {
+ application->UpdateHash();
+ }
+}
+
+bool ResetGlobalPropertiesRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& out_result_code,
+ std::string& out_response_info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ bool result = false;
+ ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo tts_properties_info(tts_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ HmiInterfaces::InterfaceState tts_interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_TTS);
+
+ if (hmi_apis::Common_Result::SUCCESS == ui_result_ &&
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ &&
+ HmiInterfaces::STATE_AVAILABLE == tts_interface_state) {
+ result = true;
+ out_result_code = mobile_apis::Result::WARNINGS;
+ out_response_info = "Unsupported phoneme type sent in a prompt";
} else {
- LOG4CXX_WARN(logger_, "unable to find application: " << connection_key());
+ result =
+ PrepareResultForMobileResponse(ui_properties_info, tts_properties_info);
+ out_result_code =
+ PrepareResultCodeForResponse(ui_properties_info, tts_properties_info);
+ out_response_info = MergeInfos(tts_properties_info,
+ tts_response_info_,
+ ui_properties_info,
+ ui_response_info_);
}
+
+ return result;
}
bool ResetGlobalPropertiesRequest::IsPendingResponseExist() {
diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
index 89bd43fcd6..0c770953fe 100644
--- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
@@ -115,7 +115,6 @@ void ScrollableMessageRequest::Run() {
void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -128,24 +127,19 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::UI_ScrollableMessage: {
LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event");
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
- bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code &&
- hmi_capabilities.is_ui_cooperating()) {
- result = true;
- }
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc
index 975f7e43c3..9ec4ca3fcc 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_request.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc
@@ -31,11 +31,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
#include <algorithm>
-
#include "application_manager/commands/mobile/send_location_request.h"
-
#include "application_manager/message_helper.h"
-#include "utils/helpers.h"
#include "utils/custom_string.h"
namespace application_manager {
@@ -65,11 +62,9 @@ void SendLocationRequest::Run() {
smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
if (msg_params.keyExists(strings::delivery_mode)) {
- const std::vector<std::string>& allowed_params =
- parameters_permissions().allowed_params;
- if (allowed_params.end() == std::find(allowed_params.begin(),
- allowed_params.end(),
- strings::delivery_mode)) {
+ const RPCParams& allowed_params = parameters_permissions().allowed_params;
+
+ if (helpers::in_range(allowed_params, strings::delivery_mode)) {
msg_params.erase(strings::delivery_mode);
}
}
@@ -136,21 +131,20 @@ void SendLocationRequest::Run() {
void SendLocationRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- namespace Result = mobile_apis::Result;
- using namespace helpers;
+ using namespace hmi_apis;
const smart_objects::SmartObject& message = event.smart_object();
if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) {
LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- const bool result =
- Compare<Result::eType, EQ, ONE>(result_code,
- Result::SAVED,
- Result::SUCCESS,
- Result::WARNINGS,
- Result::UNSUPPORTED_RESOURCE);
- SendResponse(result, result_code, NULL, &(message[strings::params]));
+ const Common_Result::eType result_code = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::params]));
return;
}
LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
index 40b708e30d..5d70a2fb5b 100644
--- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
@@ -34,6 +34,7 @@
#include <algorithm>
#include "application_manager/commands/mobile/set_app_icon_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -229,20 +230,17 @@ bool SetAppIconRequest::IsEnoughSpaceForIcon(const uint64_t icon_size) const {
void SetAppIconRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetAppIcon: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string response_info;
+ GetInfo(message, response_info);
if (result) {
ApplicationSharedPtr app =
application_manager_.application(connection_key());
@@ -261,7 +259,10 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) {
"Icon path was set to '" << app->app_icon_path() << "'");
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
index 6cb6318791..984690384a 100644
--- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/set_display_layout_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
namespace application_manager {
@@ -69,14 +70,14 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetDisplayLayout: {
LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event");
-
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool response_success = mobile_apis::Result::SUCCESS == result_code;
-
+ const bool response_success = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string info;
+ GetInfo(message, info);
smart_objects::SmartObject msg_params = message[strings::msg_params];
-
if (response_success) {
HMICapabilities& hmi_capabilities =
application_manager_.hmi_capabilities();
@@ -93,7 +94,10 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
}
}
}
- SendResponse(response_success, result_code, NULL, &msg_params);
+ SendResponse(response_success,
+ MessageHelper::HMIToMobileResult(result_code),
+ info.empty() ? NULL : info.c_str(),
+ &msg_params);
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
index 171b902df1..fcfea5e744 100644
--- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
@@ -127,6 +127,12 @@ void SetGlobalPropertiesRequest::Run() {
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
+
+ /* Need to set flags before sending request to HMI
+ * for correct processing this flags in method on_event */
+ if (is_help_prompt_present || is_timeout_prompt_present) {
+ is_tts_send_ = true;
+ }
if (is_vr_help_title_present && is_vr_help_present) {
LOG4CXX_DEBUG(logger_, "VRHelp params presents");
@@ -226,6 +232,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, ui_response_info_);
break;
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
@@ -233,6 +240,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
is_tts_received_ = true;
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ GetInfo(message, tts_response_info_);
break;
}
default: {
@@ -245,54 +253,18 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
LOG4CXX_DEBUG(logger_, "Continue waiting for response");
return;
}
-
- const bool is_tts_succeeded =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- tts_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_ui_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
- hmi_apis::Common_Result::WARNINGS);
-
- const bool is_ui_invalid_unsupported =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- ui_result_,
- hmi_apis::Common_Result::INVALID_ENUM,
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
-
- bool result = (is_tts_succeeded && is_ui_succeeded) ||
- (is_ui_succeeded &&
- hmi_apis::Common_Result::INVALID_ENUM == tts_result_) ||
- (is_ui_invalid_unsupported && is_tts_succeeded);
-
mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- const char* return_info = NULL;
-
- const bool is_ui_or_tts_warning =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_apis::Common_Result::WARNINGS, tts_result_, ui_result_);
-
- if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ ||
- is_ui_or_tts_warning)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info =
- std::string("Unsupported phoneme type sent in a prompt").c_str();
- } else {
- result_code =
- MessageHelper::HMIToMobileResult(std::max(ui_result_, tts_result_));
- }
+ std::string response_info;
+ const bool result = PrepareResponseParameters(result_code, response_info);
// TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse
ApplicationSharedPtr application =
application_manager_.application(connection_key());
- SendResponse(
- result, result_code, return_info, &(message[strings::msg_params]));
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (!application) {
LOG4CXX_DEBUG(logger_, "NULL pointer.");
@@ -304,6 +276,37 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
}
+bool SetGlobalPropertiesRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
+ ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+
+ ResponseInfo tts_properties_info(tts_result_,
+ HmiInterfaces::HMI_INTERFACE_TTS);
+ const bool result =
+ PrepareResultForMobileResponse(ui_properties_info, tts_properties_info);
+ if (result &&
+ (HmiInterfaces::STATE_AVAILABLE == tts_properties_info.interface_state) &&
+ (tts_properties_info.is_unsupported_resource)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ tts_response_info_ = "Unsupported phoneme type sent in a prompt";
+ info = MergeInfos(tts_properties_info,
+ tts_response_info_,
+ ui_properties_info,
+ ui_response_info_);
+ return result;
+ }
+ result_code =
+ PrepareResultCodeForResponse(ui_properties_info, tts_properties_info);
+ info = MergeInfos(tts_properties_info,
+ tts_response_info_,
+ ui_properties_info,
+ ui_response_info_);
+ return result;
+}
+
bool SetGlobalPropertiesRequest::ValidateVRHelpTitle(
const smart_objects::SmartObject* const vr_help_so_ptr) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -397,17 +400,17 @@ void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData(
void SetGlobalPropertiesRequest::SendTTSRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
+ is_tts_send_ = true;
SendHMIRequest(
hmi_apis::FunctionID::TTS_SetGlobalProperties, &params, use_events);
- is_tts_send_ = true;
}
void SetGlobalPropertiesRequest::SendUIRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
+ is_ui_send_ = true;
SendHMIRequest(
hmi_apis::FunctionID::UI_SetGlobalProperties, &params, use_events);
- is_ui_send_ = true;
}
bool SetGlobalPropertiesRequest::IsPendingResponseExist() {
diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
index a198ce63c3..1e0a00318d 100644
--- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
@@ -33,6 +33,7 @@
#include "application_manager/commands/mobile/set_media_clock_timer_request.h"
+#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -84,13 +85,18 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetMediaClockTimer: {
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool result = mobile_apis::Result::SUCCESS == result_code;
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ std::string response_info;
+ GetInfo(message, response_info);
+
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
index 2d79e13582..b1cc40009d 100644
--- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
@@ -178,31 +178,22 @@ void ShowConstantTBTRequest::Run() {
void ShowConstantTBTRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace hmi_apis;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_ShowConstantTBT: {
LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event");
- std::string return_info;
-
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt()));
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
- bool result = false;
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- return_info =
- message[strings::msg_params][hmi_response::message].asString();
- } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- hmi_capabilities.is_ui_cooperating()) {
- result = true;
- }
-
+ const Common_Result::eType result_code =
+ static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
SendResponse(result,
- result_code,
- return_info.empty() ? 0 : return_info.c_str(),
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
}
diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc
index 467d8d0236..cf2509cdb9 100644
--- a/src/components/application_manager/src/commands/mobile/show_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_request.cc
@@ -228,23 +228,19 @@ void ShowRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::UI_Show: {
LOG4CXX_DEBUG(logger_, "Received UI_Show event.");
std::string response_info;
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::SUCCESS,
- mobile_api::Result::WARNINGS);
-
- if (mobile_apis::Result::WARNINGS == result_code &&
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_UI);
+ GetInfo(message, response_info);
+ if (hmi_apis::Common_Result::WARNINGS == result_code &&
message[strings::params].keyExists(hmi_response::message)) {
response_info =
message[strings::params][hmi_response::message].asString();
}
-
SendResponse(result,
- result_code,
+ MessageHelper::HMIToMobileResult(result_code),
response_info.empty() ? NULL : response_info.c_str(),
&(message[strings::msg_params]));
break;
diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc
index 3920b49db3..054d0ec16d 100644
--- a/src/components/application_manager/src/commands/mobile/slider_request.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -154,13 +154,14 @@ void SliderRequest::on_event(const event_engine::Event& event) {
response_msg_params[strings::slider_position] = 0;
}
}
-
- const bool is_response_success = Compare<Common_Result::eType, EQ, ONE>(
- response_code, Common_Result::SUCCESS, Common_Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool is_response_success = PrepareResultForMobileResponse(
+ response_code, HmiInterfaces::HMI_INTERFACE_UI);
SendResponse(is_response_success,
MessageHelper::HMIToMobileResult(response_code),
- 0,
+ response_info.empty() ? NULL : response_info.c_str(),
&response_msg_params);
}
diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc
index 01db47909b..6cbb762102 100644
--- a/src/components/application_manager/src/commands/mobile/speak_request.cc
+++ b/src/components/application_manager/src/commands/mobile/speak_request.cc
@@ -120,24 +120,14 @@ void SpeakRequest::ProcessTTSSpeakResponse(
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result_code);
- const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result_code, HmiInterfaces::HMI_INTERFACE_TTS);
(*message_)[strings::params][strings::function_id] =
mobile_apis::FunctionID::SpeakID;
const char* return_info = NULL;
- const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
- result_code,
- mobile_api::Result::UNSUPPORTED_RESOURCE,
- mobile_api::Result::WARNINGS);
-
- if (is_result_ok) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- }
-
SendResponse(
result, result_code, return_info, &(message[strings::msg_params]));
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
index 7ec4e20fbd..eb6bbf545e 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -58,7 +58,7 @@ void SubscribeButtonRequest::Run() {
const mobile_apis::ButtonName::eType btn_id =
static_cast<mobile_apis::ButtonName::eType>(
- (*message_)[str::msg_params][str::button_name].asUInt());
+ (*message_)[str::msg_params][str::button_name].asInt());
if (!IsSubscriptionAllowed(app, btn_id)) {
LOG4CXX_ERROR(logger_,
@@ -101,7 +101,6 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed(
(mobile_apis::ButtonName::TUNEDOWN == btn_id))) {
return false;
}
-
return true;
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
index 485c5d0009..56027bacaf 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -109,115 +109,21 @@ void SubscribeVehicleDataRequest::Run() {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
-
- // counter for items to subscribe
- int32_t items_to_subscribe = 0;
- // counter for subscribed items by application
- int32_t subscribed_items = 0;
-
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
-
+ std::string info;
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
-
smart_objects::SmartObject response_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
-
- for (; vehicle_data.end() != it; ++it) {
- const std::string& key_name = it->first;
- if ((*message_)[strings::msg_params].keyExists(key_name)) {
- bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
- if (is_key_enabled) {
- ++items_to_subscribe;
-
- VehicleDataType key_type = it->second;
- if (app->IsSubscribedToIVI(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "App with connection key "
- << connection_key()
- << " is subscribed already for VehicleDataType: "
- << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_this_app_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
- continue;
- }
-
- if (IsSomeoneSubscribedFor(key_type)) {
- LOG4CXX_DEBUG(logger_,
- "There are apps subscribed already for "
- "VehicleDataType: "
- << key_type);
- if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
- LOG4CXX_ERROR(
- logger_,
- "Unable to subscribe for VehicleDataType: " << key_type);
- continue;
- }
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- vi_already_subscribed_by_another_apps_.insert(key_type);
- response_params[key_name][strings::data_type] = key_type;
- response_params[key_name][strings::result_code] =
- mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
- continue;
- }
-
- msg_params[key_name] = is_key_enabled;
-
- if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
- LOG4CXX_DEBUG(
- logger_,
- "App with connection key "
- << connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
- ++subscribed_items;
- }
- }
- }
- }
-
- bool is_everything_already_subscribed =
- static_cast<uint32_t>(items_to_subscribe) ==
- vi_already_subscribed_by_another_apps_.size() +
- vi_already_subscribed_by_this_app_.size();
-
- if (0 == items_to_subscribe) {
- if (HasDisallowedParams()) {
- SendResponse(false, mobile_apis::Result::DISALLOWED);
- } else {
- SendResponse(
- false, mobile_apis::Result::INVALID_DATA, "No data in the request");
- }
- return;
- }
-
- if (0 == subscribed_items) {
- SendResponse(false,
- mobile_apis::Result::IGNORED,
- "Already subscribed on provided VehicleData.",
- &response_params);
- return;
- }
-
- if (is_everything_already_subscribed) {
- mobile_apis::Result::eType result_code =
- vi_already_subscribed_by_this_app_.size()
- ? mobile_apis::Result::IGNORED
- : mobile_apis::Result::SUCCESS;
-
- const char* info = vi_already_subscribed_by_this_app_.size()
- ? "Already subscribed on some provided VehicleData."
- : NULL;
-
- SendResponse(true, result_code, info, &response_params);
+ bool result = false;
+ CheckVISubscribtions(
+ app, info, result_code, response_params, msg_params, result);
+
+ if (mobile_apis::Result::INVALID_ENUM != result_code) {
+ SendResponse(result,
+ result_code,
+ info.empty() ? NULL : info.c_str(),
+ response_params.empty() ? NULL : &response_params);
return;
}
@@ -325,27 +231,24 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
}
}
#else
+
hmi_apis::Common_Result::eType hmi_result =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
- const bool is_result_no_error =
- Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
-
- bool is_succeeded =
- is_result_no_error || !vi_already_subscribed_by_another_apps_.empty();
+ bool is_succeeded = result || !vi_already_subscribed_by_another_apps_.empty();
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
- const char* return_info = NULL;
if (is_succeeded) {
if (!vi_already_subscribed_by_this_app_.empty()) {
result_code = mobile_apis::Result::IGNORED;
- return_info = "Already subscribed on some provided VehicleData.";
+ response_info = "Already subscribed on some provided VehicleData.";
}
}
@@ -357,8 +260,10 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
}
- SendResponse(
- is_succeeded, result_code, return_info, &(message[strings::msg_params]));
+ SendResponse(is_succeeded,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (is_succeeded) {
app->UpdateHash();
@@ -429,5 +334,121 @@ bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
return it != accessor.GetData().end();
}
+void SubscribeVehicleDataRequest::CheckVISubscribtions(
+ ApplicationSharedPtr app,
+ std::string& out_info,
+ mobile_apis::Result::eType& out_result_code,
+ smart_objects::SmartObject& out_response_params,
+ smart_objects::SmartObject& out_request_params,
+ bool& out_result) {
+ // counter for items to subscribe
+ VehicleInfoSubscriptions::size_type items_to_subscribe = 0;
+ // counter for subscribed items by application
+ uint32_t subscribed_items = 0;
+
+ const VehicleData& vehicle_data = MessageHelper::vehicle_data();
+ VehicleData::const_iterator it = vehicle_data.begin();
+
+ HmiInterfaces::InterfaceState interface_state =
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+
+ const bool is_interface_not_available =
+ interface_state == HmiInterfaces::STATE_NOT_AVAILABLE;
+
+ for (; vehicle_data.end() != it; ++it) {
+ const std::string& key_name = it->first;
+ if ((*message_)[strings::msg_params].keyExists(key_name)) {
+ const bool is_key_enabled =
+ (*message_)[strings::msg_params][key_name].asBool();
+ if (is_key_enabled) {
+ ++items_to_subscribe;
+ }
+ if (!is_interface_not_available && is_key_enabled) {
+ VehicleDataType key_type = it->second;
+ if (app->IsSubscribedToIVI(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "App with connection key "
+ << connection_key()
+ << " is subscribed already for VehicleDataType: "
+ << key_type);
+ ++subscribed_items;
+ vi_already_subscribed_by_this_app_.insert(key_type);
+ out_response_params[key_name][strings::data_type] = key_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ continue;
+ }
+
+ if (IsSomeoneSubscribedFor(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "There are apps subscribed already for "
+ "VehicleDataType: "
+ << key_type);
+ if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unable to subscribe for VehicleDataType: " << key_type);
+ continue;
+ }
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
+ vi_already_subscribed_by_another_apps_.insert(key_type);
+ out_response_params[key_name][strings::data_type] = key_type;
+ out_response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ continue;
+ }
+
+ out_request_params[key_name] = is_key_enabled;
+
+ if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
+ }
+ }
+ }
+ }
+
+ const bool is_everything_already_subscribed =
+ items_to_subscribe ==
+ vi_already_subscribed_by_another_apps_.size() +
+ vi_already_subscribed_by_this_app_.size();
+
+ if (0 == items_to_subscribe) {
+ if (HasDisallowedParams()) {
+ out_result_code = mobile_apis::Result::DISALLOWED;
+ } else {
+ out_result_code = mobile_apis::Result::INVALID_DATA;
+ out_info = "No data in the request";
+ }
+ out_result = false;
+ }
+
+ if (0 == subscribed_items && !is_interface_not_available) {
+ out_result_code = mobile_apis::Result::IGNORED;
+ out_info = "Already subscribed on provided VehicleData.";
+ out_result = false;
+ }
+
+ if (is_everything_already_subscribed) {
+ out_result_code = vi_already_subscribed_by_this_app_.size()
+ ? mobile_apis::Result::IGNORED
+ : mobile_apis::Result::SUCCESS;
+ if (!(vi_already_subscribed_by_this_app_.empty())) {
+ out_info = "Already subscribed on some provided VehicleData.";
+ }
+ out_result = true;
+ }
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
index 8134730eee..29cc8e6541 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/subscribe_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -47,14 +48,20 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
application_manager_.SubscribeAppForWayPoints(app->app_id());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
app->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc
index b9acf5e930..74d25508e0 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -528,8 +528,8 @@ void SystemRequest::Run() {
}
if (!(mobile_apis::RequestType::HTTP == request_type &&
0 == origin_file_name.compare(kIVSU))) {
- LOG4CXX_DEBUG(logger_, "Binary data required. Reject");
- SendResponse(false, mobile_apis::Result::REJECTED);
+ LOG4CXX_DEBUG(logger_, "Binary data required. Invalid data");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
LOG4CXX_DEBUG(logger_, "IVSU does not require binary data. Continue");
@@ -578,9 +578,9 @@ void SystemRequest::Run() {
msg_params[strings::file_name] = file_dst_path;
}
- if (mobile_apis::RequestType::PROPRIETARY != request_type) {
- msg_params[strings::app_id] = (application->policy_app_id());
- }
+ // expected int, mandatory=true, all Policies flow (HTTP,Proprietary,External)
+ msg_params[strings::app_id] = application->hmi_app_id();
+
msg_params[strings::request_type] =
(*message_)[strings::msg_params][strings::request_type];
SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest,
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
index 86df8fabb1..e1bdba61a0 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
@@ -61,22 +61,16 @@ void UnsubscribeButtonRequest::Run() {
const uint32_t btn_id =
(*message_)[str::msg_params][str::button_name].asUInt();
- if (!app->IsSubscribedToButton(
+ if (!app->UnsubscribeFromButton(
static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id);
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
- app->UnsubscribeFromButton(
- static_cast<mobile_apis::ButtonName::eType>(btn_id));
-
SendUnsubscribeButtonNotification();
- const bool is_succedeed = true;
- SendResponse(is_succedeed, mobile_apis::Result::SUCCESS);
- if (is_succedeed) {
- app->UpdateHash();
- }
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ app->UpdateHash();
}
void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() {
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
index 409579b294..9ac98a27f7 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
@@ -32,6 +32,7 @@
*/
#include "application_manager/commands/mobile/unsubscribe_button_response.h"
+#include "smart_objects/smart_object.h"
namespace application_manager {
@@ -46,8 +47,6 @@ UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {}
void UnsubscribeButtonResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-
// check if response false
if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index 4fcc04c7be..9b0c0a673f 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2017, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -201,16 +201,14 @@ void UnsubscribeVehicleDataRequest::Run() {
}
if (is_everything_already_unsubscribed) {
- mobile_apis::Result::eType result_code =
- vi_already_unsubscribed_by_this_app_.size()
- ? mobile_apis::Result::IGNORED
- : mobile_apis::Result::SUCCESS;
-
- const char* info = vi_already_unsubscribed_by_this_app_.size()
- ? "Already subscribed on some provided VehicleData."
- : NULL;
-
- SendResponse(true, result_code, info, &response_params);
+ if (!vi_already_unsubscribed_by_this_app_.empty()) {
+ SendResponse(false,
+ mobile_apis::Result::IGNORED,
+ "Some provided VehicleData was not subscribed.",
+ &response_params);
+ } else {
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
+ }
return;
}
@@ -315,21 +313,18 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
hmi_apis::Common_Result::eType hmi_result =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
-
- bool is_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- hmi_result,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS);
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo);
mobile_apis::Result::eType result_code =
MessageHelper::HMIToMobileResult(hmi_result);
- const char* return_info = NULL;
-
- if (is_succeeded) {
+ if (result) {
if (vi_already_unsubscribed_by_this_app_.size()) {
result_code = mobile_apis::Result::IGNORED;
- return_info = "Some provided VehicleData was not subscribed.";
+ response_info = "Some provided VehicleData was not subscribed.";
}
}
@@ -339,12 +334,14 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
}
- if (is_succeeded) {
+ if (result) {
SetAllowedToTerminate(false);
}
- SendResponse(
- is_succeeded, result_code, return_info, &(message[strings::msg_params]));
- if (is_succeeded) {
+ SendResponse(result,
+ result_code,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
+ if (result) {
UpdateHash();
}
#endif // #ifdef HMI_DBUS_API
@@ -401,7 +398,8 @@ void UnsubscribeVehicleDataRequest::UpdateHash() const {
"Application with connection_key = " << connection_key()
<< " doesn't exist.");
}
- application_manager_.TerminateRequest(connection_key(), correlation_id());
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
index e06158e4eb..986256d377 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
@@ -32,6 +32,7 @@
*/
#include "application_manager/commands/mobile/unsubscribe_vehicle_data_response.h"
+#include "smart_objects/smart_object.h"
namespace application_manager {
namespace commands {
@@ -45,8 +46,6 @@ UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {}
void UnsubscribeVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-
// check if response false
if (true == (*message_)[strings::msg_params].keyExists(strings::success)) {
if ((*message_)[strings::msg_params][strings::success].asBool() == false) {
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
index b19e292025..728209fcf2 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -1,5 +1,6 @@
#include "application_manager/application_manager.h"
#include "application_manager/commands/mobile/unsubscribe_way_points_request.h"
+#include "application_manager/message_helper.h"
namespace application_manager {
@@ -40,14 +41,20 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event");
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
application_manager_.UnsubscribeAppFromWayPoints(app->app_id());
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
if (result) {
app->UpdateHash();
}
diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
index 9b3b221446..becab175e9 100644
--- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
+++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
@@ -155,18 +155,17 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::Navigation_UpdateTurnList: {
LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event");
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
+ const hmi_apis::Common_Result::eType result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- HMICapabilities& hmi_capabilities =
- application_manager_.hmi_capabilities();
-
- bool result =
- (mobile_apis::Result::SUCCESS == result_code) ||
- ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- (hmi_capabilities.is_ui_cooperating()));
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ std::string response_info;
+ GetInfo(message, response_info);
+ const bool result = PrepareResultForMobileResponse(
+ result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
+ SendResponse(result,
+ MessageHelper::HMIToMobileResult(result_code),
+ response_info.empty() ? NULL : response_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 7535984c16..9d52cc98db 100644
--- a/src/components/application_manager/src/hmi_capabilities.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -30,191 +30,319 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/hmi_capabilities.h"
-
#include <map>
-#include "json/json.h"
-#include "utils/file_system.h"
-#include "interfaces/HMI_API.h"
+#include "utils/logger.h"
+#include "application_manager/hmi_capabilities_impl.h"
+#include "application_manager/application_manager_impl.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/smart_object_keys.h"
#include "application_manager/message_helper.h"
#include "application_manager/smart_object_keys.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/message_helper.h"
+#include "config_profile/profile.h"
#include "formatters/CFormatterJsonBase.h"
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
+#include "interfaces/HMI_API.h"
+#include "utils/file_system.h"
namespace application_manager {
namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
+namespace {
std::map<std::string, hmi_apis::Common_VrCapabilities::eType>
- vr_enum_capabilities = {{"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT}};
-
-std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = {
- {"OK", hmi_apis::Common_ButtonName::OK},
- {"SEEKLEFT", hmi_apis::Common_ButtonName::SEEKLEFT},
- {"SEEKRIGHT", hmi_apis::Common_ButtonName::SEEKRIGHT},
- {"TUNEUP", hmi_apis::Common_ButtonName::TUNEUP},
- {"TUNEDOWN", hmi_apis::Common_ButtonName::TUNEDOWN},
- {"PRESET_0", hmi_apis::Common_ButtonName::PRESET_0},
- {"PRESET_1", hmi_apis::Common_ButtonName::PRESET_1},
- {"PRESET_2", hmi_apis::Common_ButtonName::PRESET_2},
- {"PRESET_3", hmi_apis::Common_ButtonName::PRESET_3},
- {"PRESET_4", hmi_apis::Common_ButtonName::PRESET_4},
- {"PRESET_5", hmi_apis::Common_ButtonName::PRESET_5},
- {"PRESET_6", hmi_apis::Common_ButtonName::PRESET_6},
- {"PRESET_7", hmi_apis::Common_ButtonName::PRESET_7},
- {"PRESET_8", hmi_apis::Common_ButtonName::PRESET_8},
- {"PRESET_9", hmi_apis::Common_ButtonName::PRESET_9},
- {"CUSTOM_BUTTON", hmi_apis::Common_ButtonName::CUSTOM_BUTTON},
- {"SEARCH", hmi_apis::Common_ButtonName::SEARCH},
-
-};
-
-std::map<std::string,
- hmi_apis::Common_TextFieldName::eType> text_fields_enum_name = {
- {"mainField1", hmi_apis::Common_TextFieldName::mainField1},
- {"mainField2", hmi_apis::Common_TextFieldName::mainField2},
- {"mainField3", hmi_apis::Common_TextFieldName::mainField3},
- {"mainField4", hmi_apis::Common_TextFieldName::mainField4},
- {"statusBar", hmi_apis::Common_TextFieldName::statusBar},
- {"mediaClock", hmi_apis::Common_TextFieldName::mediaClock},
- {"mediaTrack", hmi_apis::Common_TextFieldName::mediaTrack},
- {"alertText1", hmi_apis::Common_TextFieldName::alertText1},
- {"alertText2", hmi_apis::Common_TextFieldName::alertText2},
- {"alertText3", hmi_apis::Common_TextFieldName::alertText3},
- {"scrollableMessageBody",
- hmi_apis::Common_TextFieldName::scrollableMessageBody},
- {"initialInteractionText",
- hmi_apis::Common_TextFieldName::initialInteractionText},
- {"navigationText1", hmi_apis::Common_TextFieldName::navigationText1},
- {"navigationText2", hmi_apis::Common_TextFieldName::navigationText2},
- {"ETA", hmi_apis::Common_TextFieldName::ETA},
- {"totalDistance", hmi_apis::Common_TextFieldName::totalDistance},
- {"audioPassThruDisplayText1",
- hmi_apis::Common_TextFieldName::audioPassThruDisplayText1},
- {"audioPassThruDisplayText2",
- hmi_apis::Common_TextFieldName::audioPassThruDisplayText2},
- {"sliderHeader", hmi_apis::Common_TextFieldName::sliderHeader},
- {"sliderFooter", hmi_apis::Common_TextFieldName::sliderFooter},
- {"notificationText", hmi_apis::Common_TextFieldName::notificationText},
- {"menuName", hmi_apis::Common_TextFieldName::menuName},
- {"secondaryText", hmi_apis::Common_TextFieldName::secondaryText},
- {"tertiaryText", hmi_apis::Common_TextFieldName::tertiaryText},
- {"timeToDestination", hmi_apis::Common_TextFieldName::timeToDestination},
- {"locationName", hmi_apis::Common_TextFieldName::locationName},
- {"locationDescription",
- hmi_apis::Common_TextFieldName::locationDescription},
- {"addressLines", hmi_apis::Common_TextFieldName::turnText},
- {"turnText", hmi_apis::Common_TextFieldName::addressLines},
- {"phoneNumber", hmi_apis::Common_TextFieldName::phoneNumber},
- {"turnText", hmi_apis::Common_TextFieldName::turnText},
- {"menuTitle", hmi_apis::Common_TextFieldName::menuTitle},
- {"navigationText", hmi_apis::Common_TextFieldName::navigationText},
-};
-
+ vr_enum_capabilities;
+std::map<std::string, hmi_apis::Common_SpeechCapabilities::eType>
+ tts_enum_capabilities;
+std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name;
+std::map<std::string, hmi_apis::Common_TextFieldName::eType>
+ text_fields_enum_name;
std::map<std::string, hmi_apis::Common_MediaClockFormat::eType>
- media_clock_enum_name = {
- {"CLOCK1", hmi_apis::Common_MediaClockFormat::CLOCK1},
- {"CLOCK2", hmi_apis::Common_MediaClockFormat::CLOCK2},
- {"CLOCK3", hmi_apis::Common_MediaClockFormat::CLOCK3},
- {"CLOCKTEXT1", hmi_apis::Common_MediaClockFormat::CLOCKTEXT1},
- {"CLOCKTEXT2", hmi_apis::Common_MediaClockFormat::CLOCKTEXT2},
- {"CLOCKTEXT3", hmi_apis::Common_MediaClockFormat::CLOCKTEXT3},
- {"CLOCKTEXT4", hmi_apis::Common_MediaClockFormat::CLOCKTEXT4},
-};
-
-std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum = {
- {"STATIC", hmi_apis::Common_ImageType::STATIC},
- {"DYNAMIC", hmi_apis::Common_ImageType::DYNAMIC}};
-
-std::map<std::string, hmi_apis::Common_SamplingRate::eType> sampling_rate_enum =
- {{"RATE_8KHZ", hmi_apis::Common_SamplingRate::RATE_8KHZ},
- {"8KHZ", hmi_apis::Common_SamplingRate::RATE_8KHZ},
- {"RATE_16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ},
- {"16KHZ", hmi_apis::Common_SamplingRate::RATE_16KHZ},
- {"RATE_22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ},
- {"22KHZ", hmi_apis::Common_SamplingRate::RATE_22KHZ},
- {"RATE_44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ},
- {"44KHZ", hmi_apis::Common_SamplingRate::RATE_44KHZ}};
-
+ media_clock_enum_name;
+std::map<std::string, hmi_apis::Common_ImageType::eType> image_type_enum;
+std::map<std::string, hmi_apis::Common_SamplingRate::eType> sampling_rate_enum;
std::map<std::string, hmi_apis::Common_BitsPerSample::eType>
- bit_per_sample_enum = {
- {"RATE_8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT},
- {"8_BIT", hmi_apis::Common_BitsPerSample::RATE_8_BIT},
- {"RATE_16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT},
- {"16_BIT", hmi_apis::Common_BitsPerSample::RATE_16_BIT}};
+ bit_per_sample_enum;
+std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum;
+std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType>
+ hmi_zone_enum;
+std::map<std::string, hmi_apis::Common_ImageFieldName::eType>
+ image_field_name_enum;
+std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum;
+std::map<std::string, hmi_apis::Common_DisplayType::eType> display_type_enum;
+std::map<std::string, hmi_apis::Common_CharacterSet::eType> character_set_enum;
+
+void InitCapabilities() {
+ vr_enum_capabilities.insert(std::make_pair(
+ std::string("TEXT"), hmi_apis::Common_VrCapabilities::VR_TEXT));
+
+ tts_enum_capabilities.insert(std::make_pair(
+ std::string("TEXT"), hmi_apis::Common_SpeechCapabilities::SC_TEXT));
+ tts_enum_capabilities.insert(
+ std::make_pair(std::string("SAPI_PHONEMES"),
+ hmi_apis::Common_SpeechCapabilities::SAPI_PHONEMES));
+ tts_enum_capabilities.insert(
+ std::make_pair(std::string("LHPLUS_PHONEMES"),
+ hmi_apis::Common_SpeechCapabilities::LHPLUS_PHONEMES));
+ tts_enum_capabilities.insert(
+ std::make_pair(std::string("SAPI_PHONEMES"),
+ hmi_apis::Common_SpeechCapabilities::SAPI_PHONEMES));
+ tts_enum_capabilities.insert(
+ std::make_pair(std::string("PRE_RECORDED"),
+ hmi_apis::Common_SpeechCapabilities::PRE_RECORDED));
+ tts_enum_capabilities.insert(std::make_pair(
+ std::string("SILENCE"), hmi_apis::Common_SpeechCapabilities::SILENCE));
+
+ button_enum_name.insert(
+ std::make_pair(std::string("OK"), hmi_apis::Common_ButtonName::OK));
+ button_enum_name.insert(std::make_pair(
+ std::string("SEEKLEFT"), hmi_apis::Common_ButtonName::SEEKLEFT));
+ button_enum_name.insert(std::make_pair(
+ std::string("SEEKRIGHT"), hmi_apis::Common_ButtonName::SEEKRIGHT));
+ button_enum_name.insert(std::make_pair(std::string("TUNEUP"),
+ hmi_apis::Common_ButtonName::TUNEUP));
+ button_enum_name.insert(std::make_pair(
+ std::string("TUNEDOWN"), hmi_apis::Common_ButtonName::TUNEDOWN));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_0"), hmi_apis::Common_ButtonName::PRESET_0));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_1"), hmi_apis::Common_ButtonName::PRESET_1));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_2"), hmi_apis::Common_ButtonName::PRESET_2));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_3"), hmi_apis::Common_ButtonName::PRESET_3));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_4"), hmi_apis::Common_ButtonName::PRESET_4));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_5"), hmi_apis::Common_ButtonName::PRESET_5));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_6"), hmi_apis::Common_ButtonName::PRESET_6));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_7"), hmi_apis::Common_ButtonName::PRESET_7));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_8"), hmi_apis::Common_ButtonName::PRESET_8));
+ button_enum_name.insert(std::make_pair(
+ std::string("PRESET_9"), hmi_apis::Common_ButtonName::PRESET_9));
+ button_enum_name.insert(
+ std::make_pair(std::string("CUSTOM_BUTTON"),
+ hmi_apis::Common_ButtonName::CUSTOM_BUTTON));
+ button_enum_name.insert(std::make_pair(std::string("SEARCH"),
+ hmi_apis::Common_ButtonName::SEARCH));
+
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField1"), hmi_apis::Common_TextFieldName::mainField1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField2"), hmi_apis::Common_TextFieldName::mainField2));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField3"), hmi_apis::Common_TextFieldName::mainField3));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mainField4"), hmi_apis::Common_TextFieldName::mainField4));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("statusBar"), hmi_apis::Common_TextFieldName::statusBar));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mediaClock"), hmi_apis::Common_TextFieldName::mediaClock));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("mediaTrack"), hmi_apis::Common_TextFieldName::mediaTrack));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText1"), hmi_apis::Common_TextFieldName::alertText1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText2"), hmi_apis::Common_TextFieldName::alertText2));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("alertText3"), hmi_apis::Common_TextFieldName::alertText3));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("scrollableMessageBody"),
+ hmi_apis::Common_TextFieldName::scrollableMessageBody));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("initialInteractionText"),
+ hmi_apis::Common_TextFieldName::initialInteractionText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText1"),
+ hmi_apis::Common_TextFieldName::navigationText1));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText2"),
+ hmi_apis::Common_TextFieldName::navigationText2));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("ETA"), hmi_apis::Common_TextFieldName::ETA));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("totalDistance"),
+ hmi_apis::Common_TextFieldName::totalDistance));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("audioPassThruDisplayText1"),
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText1));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("audioPassThruDisplayText2"),
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText2));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("sliderHeader"),
+ hmi_apis::Common_TextFieldName::sliderHeader));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("sliderFooter"),
+ hmi_apis::Common_TextFieldName::sliderFooter));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("navigationText"),
+ hmi_apis::Common_TextFieldName::navigationText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("notificationText"),
+ hmi_apis::Common_TextFieldName::notificationText));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("menuName"), hmi_apis::Common_TextFieldName::menuName));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("secondaryText"),
+ hmi_apis::Common_TextFieldName::secondaryText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("tertiaryText"),
+ hmi_apis::Common_TextFieldName::tertiaryText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("timeToDestination"),
+ hmi_apis::Common_TextFieldName::timeToDestination));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("locationName"),
+ hmi_apis::Common_TextFieldName::locationName));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("locationDescription"),
+ hmi_apis::Common_TextFieldName::locationDescription));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("turnText"), hmi_apis::Common_TextFieldName::turnText));
+ text_fields_enum_name.insert(
+ std::make_pair(std::string("addressLines"),
+ hmi_apis::Common_TextFieldName::addressLines));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("phoneNumber"), hmi_apis::Common_TextFieldName::phoneNumber));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("turnText"), hmi_apis::Common_TextFieldName::turnText));
+ text_fields_enum_name.insert(std::make_pair(
+ std::string("menuTitle"), hmi_apis::Common_TextFieldName::menuTitle));
+
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK1"), hmi_apis::Common_MediaClockFormat::CLOCK1));
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK2"), hmi_apis::Common_MediaClockFormat::CLOCK2));
+ media_clock_enum_name.insert(std::make_pair(
+ std::string("CLOCK3"), hmi_apis::Common_MediaClockFormat::CLOCK3));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT1"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT1));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT2"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT2));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT3"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT3));
+ media_clock_enum_name.insert(
+ std::make_pair(std::string("CLOCKTEXT4"),
+ hmi_apis::Common_MediaClockFormat::CLOCKTEXT4));
+
+ image_type_enum.insert(std::make_pair(std::string("STATIC"),
+ hmi_apis::Common_ImageType::STATIC));
+ image_type_enum.insert(std::make_pair(std::string("DYNAMIC"),
+ hmi_apis::Common_ImageType::DYNAMIC));
+
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("8KHZ"), hmi_apis::Common_SamplingRate::RATE_8KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("16KHZ"), hmi_apis::Common_SamplingRate::RATE_16KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("22KHZ"), hmi_apis::Common_SamplingRate::RATE_22KHZ));
+ sampling_rate_enum.insert(std::make_pair(
+ std::string("44KHZ"), hmi_apis::Common_SamplingRate::RATE_44KHZ));
+
+ bit_per_sample_enum.insert(std::make_pair(
+ std::string("RATE_8_BIT"), hmi_apis::Common_BitsPerSample::RATE_8_BIT));
+ bit_per_sample_enum.insert(std::make_pair(
+ std::string("RATE_16_BIT"), hmi_apis::Common_BitsPerSample::RATE_16_BIT));
+
+ audio_type_enum.insert(
+ std::make_pair(std::string("PCM"), hmi_apis::Common_AudioType::PCM));
+
+ hmi_zone_enum.insert(std::make_pair(
+ std::string("FRONT"), hmi_apis::Common_HmiZoneCapabilities::FRONT));
+ hmi_zone_enum.insert(std::make_pair(
+ std::string("BACK"), hmi_apis::Common_HmiZoneCapabilities::BACK));
+
+ image_field_name_enum.insert(
+ std::make_pair(std::string("softButtonImage"),
+ hmi_apis::Common_ImageFieldName::softButtonImage));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("choiceImage"),
+ hmi_apis::Common_ImageFieldName::choiceImage));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("choiceSecondaryImage"),
+ hmi_apis::Common_ImageFieldName::choiceSecondaryImage));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("vrHelpItem"), hmi_apis::Common_ImageFieldName::vrHelpItem));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("turnIcon"), hmi_apis::Common_ImageFieldName::turnIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("menuIcon"), hmi_apis::Common_ImageFieldName::menuIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("cmdIcon"), hmi_apis::Common_ImageFieldName::cmdIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("appIcon"), hmi_apis::Common_ImageFieldName::appIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("graphic"), hmi_apis::Common_ImageFieldName::graphic));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("showConstantTBTIcon"),
+ hmi_apis::Common_ImageFieldName::showConstantTBTIcon));
+ image_field_name_enum.insert(std::make_pair(
+ std::string("showConstantTBTNextTurnIcon"),
+ hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon));
+ image_field_name_enum.insert(
+ std::make_pair(std::string("locationImage"),
+ hmi_apis::Common_ImageFieldName::locationImage));
+
+ file_type_enum.insert(std::make_pair(std::string("GRAPHIC_BMP"),
+ hmi_apis::Common_FileType::GRAPHIC_BMP));
+ file_type_enum.insert(std::make_pair(
+ std::string("GRAPHIC_JPEG"), hmi_apis::Common_FileType::GRAPHIC_JPEG));
+ file_type_enum.insert(std::make_pair(std::string("GRAPHIC_PNG"),
+ hmi_apis::Common_FileType::GRAPHIC_PNG));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_WAVE"),
+ hmi_apis::Common_FileType::AUDIO_WAVE));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_MP3"),
+ hmi_apis::Common_FileType::AUDIO_MP3));
+ file_type_enum.insert(std::make_pair(std::string("AUDIO_AAC"),
+ hmi_apis::Common_FileType::AUDIO_AAC));
+ file_type_enum.insert(
+ std::make_pair(std::string("BINARY"), hmi_apis::Common_FileType::BINARY));
+ file_type_enum.insert(
+ std::make_pair(std::string("JSON"), hmi_apis::Common_FileType::JSON));
+
+ display_type_enum.insert(
+ std::make_pair(std::string("CID"), hmi_apis::Common_DisplayType::CID));
+ display_type_enum.insert(std::make_pair(std::string("TYPE2"),
+ hmi_apis::Common_DisplayType::TYPE2));
+ display_type_enum.insert(std::make_pair(std::string("TYPE5"),
+ hmi_apis::Common_DisplayType::TYPE5));
+ display_type_enum.insert(
+ std::make_pair(std::string("NGN"), hmi_apis::Common_DisplayType::NGN));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN2_8_DMA"), hmi_apis::Common_DisplayType::GEN2_8_DMA));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN2_6_DMA"), hmi_apis::Common_DisplayType::GEN2_6_DMA));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD3"), hmi_apis::Common_DisplayType::MFD3));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD4"), hmi_apis::Common_DisplayType::MFD4));
+ display_type_enum.insert(
+ std::make_pair(std::string("MFD5"), hmi_apis::Common_DisplayType::MFD5));
+ display_type_enum.insert(std::make_pair(
+ std::string("GEN3_8_INCH"), hmi_apis::Common_DisplayType::GEN3_8_INCH));
+
+ character_set_enum.insert(std::make_pair(
+ std::string("TYPE2SET"), hmi_apis::Common_CharacterSet::TYPE2SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("TYPE5SET"), hmi_apis::Common_CharacterSet::TYPE5SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("CID1SET"), hmi_apis::Common_CharacterSet::CID1SET));
+ character_set_enum.insert(std::make_pair(
+ std::string("CID2SET"), hmi_apis::Common_CharacterSet::CID2SET));
+}
-std::map<std::string, hmi_apis::Common_AudioType::eType> audio_type_enum = {
- {"PCM", hmi_apis::Common_AudioType::PCM}};
+} // namespace
-std::map<std::string, hmi_apis::Common_HmiZoneCapabilities::eType>
- hmi_zone_enum = {
- {"FRONT", hmi_apis::Common_HmiZoneCapabilities::FRONT},
- {"BACK", hmi_apis::Common_HmiZoneCapabilities::BACK},
-};
-
-const std::map<std::string, hmi_apis::Common_ImageFieldName::eType>
- image_field_name_enum = {
- {"softButtonImage", hmi_apis::Common_ImageFieldName::softButtonImage},
- {"choiceImage", hmi_apis::Common_ImageFieldName::choiceImage},
- {"choiceSecondaryImage",
- hmi_apis::Common_ImageFieldName::choiceSecondaryImage},
- {"vrHelpItem", hmi_apis::Common_ImageFieldName::vrHelpItem},
- {"turnIcon", hmi_apis::Common_ImageFieldName::turnIcon},
- {"menuIcon", hmi_apis::Common_ImageFieldName::menuIcon},
- {"cmdIcon", hmi_apis::Common_ImageFieldName::cmdIcon},
- {"appIcon", hmi_apis::Common_ImageFieldName::appIcon},
- {"graphic", hmi_apis::Common_ImageFieldName::graphic},
- {"showConstantTBTIcon",
- hmi_apis::Common_ImageFieldName::showConstantTBTIcon},
- {"showConstantTBTNextTurnIcon",
- hmi_apis::Common_ImageFieldName::showConstantTBTNextTurnIcon},
- {"locationImage", hmi_apis::Common_ImageFieldName::locationImage}};
-
-const std::map<std::string, hmi_apis::Common_FileType::eType> file_type_enum = {
- {"GRAPHIC_BMP", hmi_apis::Common_FileType::GRAPHIC_BMP},
- {"GRAPHIC_JPEG", hmi_apis::Common_FileType::GRAPHIC_JPEG},
- {"GRAPHIC_PNG", hmi_apis::Common_FileType::GRAPHIC_PNG},
- {"AUDIO_WAVE", hmi_apis::Common_FileType::AUDIO_WAVE},
- {"AUDIO_MP3", hmi_apis::Common_FileType::AUDIO_MP3},
- {"AUDIO_AAC", hmi_apis::Common_FileType::AUDIO_AAC},
- {"BINARY", hmi_apis::Common_FileType::BINARY},
- {"JSON", hmi_apis::Common_FileType::JSON}};
-
-const std::map<std::string, hmi_apis::Common_DisplayType::eType>
- display_type_enum = {
- {"CID", hmi_apis::Common_DisplayType::CID},
- {"TYPE2", hmi_apis::Common_DisplayType::TYPE2},
- {"TYPE5", hmi_apis::Common_DisplayType::TYPE5},
- {"NGN", hmi_apis::Common_DisplayType::NGN},
- {"GEN2_8_DMA", hmi_apis::Common_DisplayType::GEN2_8_DMA},
- {"GEN2_6_DMA", hmi_apis::Common_DisplayType::GEN2_6_DMA},
- {"MFD3", hmi_apis::Common_DisplayType::MFD3},
- {"MFD4", hmi_apis::Common_DisplayType::MFD4},
- {"MFD5", hmi_apis::Common_DisplayType::MFD5},
- {"GEN3_8_INCH", hmi_apis::Common_DisplayType::GEN3_8_INCH}};
-
-const std::map<std::string, hmi_apis::Common_CharacterSet::eType>
- character_set_enum = {{"TYPE2SET", hmi_apis::Common_CharacterSet::TYPE2SET},
- {"TYPE5SET", hmi_apis::Common_CharacterSet::TYPE5SET},
- {"CID1SET", hmi_apis::Common_CharacterSet::CID1SET},
- {"CID2SET", hmi_apis::Common_CharacterSet::CID2SET}};
-
-HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
+HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
: is_vr_cooperating_(false)
, is_tts_cooperating_(false)
, is_ui_cooperating_(false)
, is_navi_cooperating_(false)
, is_ivi_cooperating_(false)
- , is_vr_ready_response_recieved_(false)
- , is_tts_ready_response_recieved_(false)
- , is_ui_ready_response_recieved_(false)
- , is_navi_ready_response_recieved_(false)
- , is_ivi_ready_response_recieved_(false)
, attenuated_supported_(false)
, ui_language_(hmi_apis::Common_Language::INVALID_ENUM)
, vr_language_(hmi_apis::Common_Language::INVALID_ENUM)
@@ -236,14 +364,9 @@ HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
, is_navigation_supported_(false)
, is_phone_call_supported_(false)
, app_mngr_(app_mngr)
- , hmi_language_handler_(app_mngr_) {
+ , hmi_language_handler_(app_mngr) {
+ InitCapabilities();
if (false == app_mngr_.get_settings().launch_hmi()) {
- is_vr_ready_response_recieved_ = true;
- is_tts_ready_response_recieved_ = true;
- is_ui_ready_response_recieved_ = true;
- is_navi_ready_response_recieved_ = true;
- is_ivi_ready_response_recieved_ = true;
-
is_vr_cooperating_ = true;
is_tts_cooperating_ = true;
is_ui_cooperating_ = true;
@@ -252,7 +375,7 @@ HMICapabilities::HMICapabilities(ApplicationManager& app_mngr)
}
}
-HMICapabilities::~HMICapabilities() {
+HMICapabilitiesImpl::~HMICapabilitiesImpl() {
delete vehicle_type_;
delete ui_supported_languages_;
delete tts_supported_languages_;
@@ -269,46 +392,7 @@ HMICapabilities::~HMICapabilities() {
delete prerecorded_speech_;
}
-bool HMICapabilities::is_hmi_capabilities_initialized() const {
- bool result = true;
-
- if (is_vr_ready_response_recieved_ && is_tts_ready_response_recieved_ &&
- is_ui_ready_response_recieved_ && is_navi_ready_response_recieved_ &&
- is_ivi_ready_response_recieved_) {
- if (is_vr_cooperating_) {
- if ((!vr_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == vr_language_)) {
- result = false;
- }
- }
-
- if (is_tts_cooperating_) {
- if ((!tts_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == tts_language_)) {
- result = false;
- }
- }
-
- if (is_ui_cooperating_) {
- if ((!ui_supported_languages_) ||
- (hmi_apis::Common_Language::INVALID_ENUM == ui_language_)) {
- result = false;
- }
- }
-
- if (is_ivi_cooperating_) {
- if (!vehicle_type_) {
- result = false;
- }
- }
- } else {
- result = false;
- }
-
- return result;
-}
-
-bool HMICapabilities::VerifyImageType(int32_t image_type) const {
+bool HMICapabilitiesImpl::VerifyImageType(const int32_t image_type) const {
if (!display_capabilities_) {
return false;
}
@@ -326,108 +410,52 @@ bool HMICapabilities::VerifyImageType(int32_t image_type) const {
return false;
}
-void HMICapabilities::set_is_vr_cooperating(bool value) {
- is_vr_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_vr_cooperating(const bool value) {
is_vr_cooperating_ = value;
- if (is_vr_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VR_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VR_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_tts_cooperating(bool value) {
- is_tts_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_tts_cooperating(const bool value) {
is_tts_cooperating_ = value;
- if (is_tts_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::TTS_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::TTS_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_ui_cooperating(bool value) {
- is_ui_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_ui_cooperating(const bool value) {
is_ui_cooperating_ = value;
- if (is_ui_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_language(
- MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage,
- app_mngr_));
- hmi_language_handler_.set_handle_response_for(*get_language);
- app_mngr_.ManageHMICommand(get_language);
- utils::SharedPtr<smart_objects::SmartObject> get_all_languages(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::UI_GetSupportedLanguages, app_mngr_));
- app_mngr_.ManageHMICommand(get_all_languages);
- utils::SharedPtr<smart_objects::SmartObject> get_capabilities(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::UI_GetCapabilities, app_mngr_));
- app_mngr_.ManageHMICommand(get_capabilities);
- }
}
-void HMICapabilities::set_is_navi_cooperating(bool value) {
- is_navi_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_navi_cooperating(const bool value) {
is_navi_cooperating_ = value;
}
-void HMICapabilities::set_is_ivi_cooperating(bool value) {
- is_ivi_ready_response_recieved_ = true;
+void HMICapabilitiesImpl::set_is_ivi_cooperating(const bool value) {
is_ivi_cooperating_ = value;
- if (is_ivi_cooperating_) {
- utils::SharedPtr<smart_objects::SmartObject> get_type(
- MessageHelper::CreateModuleInfoSO(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleType, app_mngr_));
- app_mngr_.ManageHMICommand(get_type);
- }
}
-void HMICapabilities::set_attenuated_supported(bool state) {
+void HMICapabilitiesImpl::set_attenuated_supported(const bool state) {
attenuated_supported_ = state;
}
-void HMICapabilities::set_active_ui_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_ui_language(
+ const hmi_apis::Common_Language::eType language) {
ui_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_UI,
language);
}
-void HMICapabilities::set_active_vr_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_vr_language(
+ const hmi_apis::Common_Language::eType language) {
vr_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_VR,
language);
}
-void HMICapabilities::set_active_tts_language(
- const hmi_apis::Common_Language::eType& language) {
+void HMICapabilitiesImpl::set_active_tts_language(
+ const hmi_apis::Common_Language::eType language) {
tts_language_ = language;
hmi_language_handler_.set_language_for(HMILanguageHandler::INTERFACE_TTS,
language);
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_ui_language()
+const hmi_apis::Common_Language::eType HMICapabilitiesImpl::active_ui_language()
const {
using namespace hmi_apis;
const Common_Language::eType language =
@@ -435,7 +463,7 @@ const hmi_apis::Common_Language::eType HMICapabilities::active_ui_language()
return Common_Language::INVALID_ENUM != language ? language : ui_language_;
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_vr_language()
+const hmi_apis::Common_Language::eType HMICapabilitiesImpl::active_vr_language()
const {
using namespace hmi_apis;
const Common_Language::eType language =
@@ -443,15 +471,15 @@ const hmi_apis::Common_Language::eType HMICapabilities::active_vr_language()
return Common_Language::INVALID_ENUM != language ? language : vr_language_;
}
-const hmi_apis::Common_Language::eType HMICapabilities::active_tts_language()
- const {
+const hmi_apis::Common_Language::eType
+HMICapabilitiesImpl::active_tts_language() const {
using namespace hmi_apis;
const Common_Language::eType language =
hmi_language_handler_.get_language_for(HMILanguageHandler::INTERFACE_TTS);
return Common_Language::INVALID_ENUM != language ? language : tts_language_;
}
-void HMICapabilities::set_ui_supported_languages(
+void HMICapabilitiesImpl::set_ui_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (ui_supported_languages_) {
delete ui_supported_languages_;
@@ -459,7 +487,7 @@ void HMICapabilities::set_ui_supported_languages(
ui_supported_languages_ = new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_tts_supported_languages(
+void HMICapabilitiesImpl::set_tts_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (tts_supported_languages_) {
delete tts_supported_languages_;
@@ -468,7 +496,7 @@ void HMICapabilities::set_tts_supported_languages(
new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_vr_supported_languages(
+void HMICapabilitiesImpl::set_vr_supported_languages(
const smart_objects::SmartObject& supported_languages) {
if (vr_supported_languages_) {
delete vr_supported_languages_;
@@ -476,7 +504,7 @@ void HMICapabilities::set_vr_supported_languages(
vr_supported_languages_ = new smart_objects::SmartObject(supported_languages);
}
-void HMICapabilities::set_display_capabilities(
+void HMICapabilitiesImpl::set_display_capabilities(
const smart_objects::SmartObject& display_capabilities) {
if (display_capabilities_) {
delete display_capabilities_;
@@ -484,7 +512,7 @@ void HMICapabilities::set_display_capabilities(
display_capabilities_ = new smart_objects::SmartObject(display_capabilities);
}
-void HMICapabilities::set_hmi_zone_capabilities(
+void HMICapabilitiesImpl::set_hmi_zone_capabilities(
const smart_objects::SmartObject& hmi_zone_capabilities) {
if (hmi_zone_capabilities_) {
delete hmi_zone_capabilities_;
@@ -493,7 +521,7 @@ void HMICapabilities::set_hmi_zone_capabilities(
new smart_objects::SmartObject(hmi_zone_capabilities);
}
-void HMICapabilities::set_soft_button_capabilities(
+void HMICapabilitiesImpl::set_soft_button_capabilities(
const smart_objects::SmartObject& soft_button_capabilities) {
if (soft_buttons_capabilities_) {
delete soft_buttons_capabilities_;
@@ -502,7 +530,7 @@ void HMICapabilities::set_soft_button_capabilities(
new smart_objects::SmartObject(soft_button_capabilities);
}
-void HMICapabilities::set_button_capabilities(
+void HMICapabilitiesImpl::set_button_capabilities(
const smart_objects::SmartObject& button_capabilities) {
if (button_capabilities_) {
delete button_capabilities_;
@@ -510,7 +538,7 @@ void HMICapabilities::set_button_capabilities(
button_capabilities_ = new smart_objects::SmartObject(button_capabilities);
}
-void HMICapabilities::set_vr_capabilities(
+void HMICapabilitiesImpl::set_vr_capabilities(
const smart_objects::SmartObject& vr_capabilities) {
if (vr_capabilities_) {
delete vr_capabilities_;
@@ -518,7 +546,7 @@ void HMICapabilities::set_vr_capabilities(
vr_capabilities_ = new smart_objects::SmartObject(vr_capabilities);
}
-void HMICapabilities::set_speech_capabilities(
+void HMICapabilitiesImpl::set_speech_capabilities(
const smart_objects::SmartObject& speech_capabilities) {
if (speech_capabilities_) {
delete speech_capabilities_;
@@ -526,7 +554,7 @@ void HMICapabilities::set_speech_capabilities(
speech_capabilities_ = new smart_objects::SmartObject(speech_capabilities);
}
-void HMICapabilities::set_audio_pass_thru_capabilities(
+void HMICapabilitiesImpl::set_audio_pass_thru_capabilities(
const smart_objects::SmartObject& audio_pass_thru_capabilities) {
if (audio_pass_thru_capabilities_) {
delete audio_pass_thru_capabilities_;
@@ -535,7 +563,7 @@ void HMICapabilities::set_audio_pass_thru_capabilities(
new smart_objects::SmartObject(audio_pass_thru_capabilities);
}
-void HMICapabilities::set_pcm_stream_capabilities(
+void HMICapabilitiesImpl::set_pcm_stream_capabilities(
const smart_objects::SmartObject& pcm_stream_capabilities) {
if (pcm_stream_capabilities_) {
delete pcm_stream_capabilities_;
@@ -544,7 +572,7 @@ void HMICapabilities::set_pcm_stream_capabilities(
new smart_objects::SmartObject(pcm_stream_capabilities);
}
-void HMICapabilities::set_preset_bank_capabilities(
+void HMICapabilitiesImpl::set_preset_bank_capabilities(
const smart_objects::SmartObject& preset_bank_capabilities) {
if (preset_bank_capabilities_) {
delete preset_bank_capabilities_;
@@ -553,7 +581,7 @@ void HMICapabilities::set_preset_bank_capabilities(
new smart_objects::SmartObject(preset_bank_capabilities);
}
-void HMICapabilities::set_vehicle_type(
+void HMICapabilitiesImpl::set_vehicle_type(
const smart_objects::SmartObject& vehicle_type) {
if (vehicle_type_) {
delete vehicle_type_;
@@ -561,7 +589,7 @@ void HMICapabilities::set_vehicle_type(
vehicle_type_ = new smart_objects::SmartObject(vehicle_type);
}
-void HMICapabilities::set_prerecorded_speech(
+void HMICapabilitiesImpl::set_prerecorded_speech(
const smart_objects::SmartObject& prerecorded_speech) {
if (prerecorded_speech_) {
delete prerecorded_speech_;
@@ -570,19 +598,14 @@ void HMICapabilities::set_prerecorded_speech(
prerecorded_speech_ = new smart_objects::SmartObject(prerecorded_speech);
}
-void HMICapabilities::set_ccpu_version(const std::string& ccpu_version) {
- ccpu_version_ = ccpu_version;
-}
-
-void HMICapabilities::set_navigation_supported(const bool supported) {
+void HMICapabilitiesImpl::set_navigation_supported(const bool supported) {
is_navigation_supported_ = supported;
}
-
-void HMICapabilities::set_phone_call_supported(const bool supported) {
+void HMICapabilitiesImpl::set_phone_call_supported(const bool supported) {
is_phone_call_supported_ = supported;
}
-void HMICapabilities::Init(resumption::LastState* last_state) {
+void HMICapabilitiesImpl::Init(resumption::LastState* last_state) {
hmi_language_handler_.Init(last_state);
if (false == load_capabilities_from_file()) {
LOG4CXX_ERROR(logger_, "file hmi_capabilities.json was not loaded");
@@ -593,7 +616,107 @@ void HMICapabilities::Init(resumption::LastState* last_state) {
ui_language_, vr_language_, tts_language_);
}
-bool HMICapabilities::load_capabilities_from_file() {
+bool HMICapabilitiesImpl::is_ui_cooperating() const {
+ return is_ui_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_vr_cooperating() const {
+ return is_vr_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_tts_cooperating() const {
+ return is_tts_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_navi_cooperating() const {
+ return is_navi_cooperating_;
+}
+
+bool HMICapabilitiesImpl::is_ivi_cooperating() const {
+ return is_ivi_cooperating_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::ui_supported_languages()
+ const {
+ return ui_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vr_supported_languages()
+ const {
+ return vr_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::tts_supported_languages()
+ const {
+ return tts_supported_languages_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities()
+ const {
+ return display_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::hmi_zone_capabilities()
+ const {
+ return hmi_zone_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::soft_button_capabilities() const {
+ return soft_buttons_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::button_capabilities()
+ const {
+ return button_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::speech_capabilities()
+ const {
+ return speech_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vr_capabilities() const {
+ return vr_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::audio_pass_thru_capabilities() const {
+ return audio_pass_thru_capabilities_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::pcm_stream_capabilities()
+ const {
+ return pcm_stream_capabilities_;
+}
+
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::preset_bank_capabilities() const {
+ return preset_bank_capabilities_;
+}
+
+bool HMICapabilitiesImpl::attenuated_supported() const {
+ return attenuated_supported_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::vehicle_type() const {
+ return vehicle_type_;
+}
+
+const smart_objects::SmartObject* HMICapabilitiesImpl::prerecorded_speech()
+ const {
+ return prerecorded_speech_;
+}
+
+bool HMICapabilitiesImpl::navigation_supported() const {
+ return is_navigation_supported_;
+}
+
+bool HMICapabilitiesImpl::phone_call_supported() const {
+ return is_phone_call_supported_;
+}
+
+bool HMICapabilitiesImpl::load_capabilities_from_file() {
std::string json_string;
std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name();
@@ -620,6 +743,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(ui, "language")) {
const std::string lang = ui.get("language", "EN-US").asString();
set_active_ui_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_ui_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(ui, "languages")) {
@@ -649,10 +775,10 @@ bool HMICapabilities::load_capabilities_from_file() {
}
if (display_capabilities_so.keyExists(hmi_response::text_fields)) {
- uint32_t len =
+ const uint32_t kLen =
display_capabilities_so[hmi_response::text_fields].length();
- for (uint32_t i = 0; i < len; ++i) {
+ for (uint32_t i = 0; i < kLen; ++i) {
if ((display_capabilities_so[hmi_response::text_fields][i])
.keyExists(strings::name)) {
std::map<std::string,
@@ -842,6 +968,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(vr, "language")) {
const std::string lang = vr.get("language", "EN-US").asString();
set_active_vr_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_vr_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(vr, "languages")) {
@@ -871,6 +1000,9 @@ bool HMICapabilities::load_capabilities_from_file() {
if (check_existing_json_member(tts, "language")) {
const std::string lang = tts.get("language", "EN-US").asString();
set_active_tts_language(MessageHelper::CommonLanguageFromString(lang));
+ } else {
+ set_active_tts_language(
+ MessageHelper::CommonLanguageFromString("EN-US"));
}
if (check_existing_json_member(tts, "languages")) {
@@ -882,8 +1014,14 @@ bool HMICapabilities::load_capabilities_from_file() {
}
if (check_existing_json_member(tts, "capabilities")) {
- set_speech_capabilities(
- smart_objects::SmartObject(tts.get("capabilities", "").asString()));
+ Json::Value capabilities = tts.get("capabilities", "");
+ smart_objects::SmartObject tts_capabilities_so =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ for (uint32_t i = 0; i < capabilities.size(); ++i) {
+ tts_capabilities_so[i] =
+ tts_enum_capabilities.find(capabilities[i].asString())->second;
+ }
+ set_speech_capabilities(tts_capabilities_so);
}
} // TTS end
@@ -934,17 +1072,35 @@ bool HMICapabilities::load_capabilities_from_file() {
return true;
}
-bool HMICapabilities::check_existing_json_member(const Json::Value& json_member,
- const char* name_of_member) {
+void HMICapabilitiesImpl::set_ccpu_version(const std::string& ccpu_version) {
+ ccpu_version_ = ccpu_version;
+}
+
+const std::string& HMICapabilitiesImpl::ccpu_version() const {
+ return ccpu_version_;
+}
+
+bool HMICapabilitiesImpl::check_existing_json_member(
+ const Json::Value& json_member, const char* name_of_member) const {
return json_member.isMember(name_of_member);
}
-void HMICapabilities::convert_json_languages_to_obj(
- Json::Value& json_languages, smart_objects::SmartObject& languages) {
+void HMICapabilitiesImpl::convert_json_languages_to_obj(
+ const Json::Value& json_languages,
+ smart_objects::SmartObject& languages) const {
for (uint32_t i = 0, j = 0; i < json_languages.size(); ++i) {
languages[j++] =
MessageHelper::CommonLanguageFromString(json_languages[i].asString());
}
}
+HMILanguageHandler& HMICapabilitiesImpl::get_hmi_language_handler() {
+ return hmi_language_handler_;
+}
+
+void HMICapabilitiesImpl::set_handle_response_for(
+ const smart_objects::SmartObject& request) {
+ hmi_language_handler_.set_handle_response_for(request);
+}
+
} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc
index 67625fde88..3f8a60a4a5 100644
--- a/src/components/application_manager/src/hmi_command_factory.cc
+++ b/src/components/application_manager/src/hmi_command_factory.cc
@@ -157,6 +157,11 @@
#include "application_manager/commands/hmi/on_app_permission_changed_notification.h"
#include "application_manager/commands/hmi/on_event_changed_notification.h"
+#ifdef EXTERNAL_PROPRIETARY_MODE
+#include "application_manager/commands/hmi/decrypt_certificate_request.h"
+#include "application_manager/commands/hmi/decrypt_certificate_response.h"
+#endif // EXTERNAL_PROPRIETARY_MODE
+
#ifdef HMI_DBUS_API
#include "application_manager/commands/hmi/vi_get_vehicle_data_request_template.h"
#include "application_manager/commands/hmi/vi_get_vehicle_data_response_template.h"
@@ -328,6 +333,18 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
}
break;
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ case hmi_apis::FunctionID::BasicCommunication_DecryptCertificate: {
+ if (is_response) {
+ command.reset(new commands::DecryptCertificateResponse(
+ message, application_manager));
+ } else {
+ command.reset(new commands::DecryptCertificateRequest(
+ message, application_manager));
+ }
+ break;
+ }
+#endif // EXTERNAL_PROPRIETARY_MODE
case hmi_apis::FunctionID::BasicCommunication_GetSystemInfo: {
if (is_response) {
command.reset(
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
new file mode 100644
index 0000000000..8a9944bec4
--- /dev/null
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/hmi_interfaces_impl.h"
+namespace application_manager {
+
+std::map<hmi_apis::FunctionID::eType, HmiInterfaces::InterfaceID>
+generate_function_to_interface_convert_map() {
+ using namespace hmi_apis::FunctionID;
+ std::map<hmi_apis::FunctionID::eType, HmiInterfaces::InterfaceID> convert_map;
+ convert_map[Buttons_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonEvent] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonPress] = HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[Buttons_OnButtonSubscription] =
+ HmiInterfaces::HMI_INTERFACE_Buttons;
+ convert_map[BasicCommunication_OnReady] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnStartDeviceDiscovery] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnUpdateDeviceList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnResumeAudioSource] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSDLPersistenceComplete] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_UpdateAppList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_UpdateDeviceList] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnFileRemoved] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_AllowDeviceToConnect] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnDeviceChosen] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnFindApplications] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_ActivateApp] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppActivated] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppDeactivated] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppRegistered] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAppUnregistered] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnExitApplication] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnExitAllApplications] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnAwakeSDL] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_MixingAudioSupported] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_DialNumber] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSystemRequest] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_SystemRequest] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_PolicyUpdate] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSDLClose] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnPutFile] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_GetSystemInfo] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnSystemInfoChanged] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnIgnitionCycleOver] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[BasicCommunication_OnEventChanged] =
+ HmiInterfaces::HMI_INTERFACE_BasicCommunication;
+ convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_AddCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_OnCommand] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetLanguage] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[VR_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_VR;
+ convert_map[TTS_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Started] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Stopped] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_IsReady] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_Speak] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_StopSpeaking] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_GetLanguage] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[TTS_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_TTS;
+ convert_map[UI_Alert] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_Show] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_AddCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_AddSubMenu] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_DeleteSubMenu] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetMediaClockTimer] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnCommand] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnSystemContext] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_GetLanguage] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnDriverDistraction] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetAppIcon] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_SetDisplayLayout] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ShowCustomForm] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnKeyboardInput] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnTouchEvent] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_Slider] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ScrollableMessage] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_PerformAudioPassThru] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_EndAudioPassThru] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_IsReady] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_ClosePopUp] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[UI_OnResetTimeout] = HmiInterfaces::HMI_INTERFACE_UI;
+ convert_map[Navigation_IsReady] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_SendLocation] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_ShowConstantTBT] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_AlertManeuver] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_UpdateTurnList] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnTBTClientState] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StartStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StopStream] = HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StartAudioStream] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_StopAudioStream] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnAudioDataStreaming] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnVideoDataStreaming] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_GetWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_OnWayPointChange] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_SubscribeWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[Navigation_UnsubscribeWayPoints] =
+ HmiInterfaces::HMI_INTERFACE_Navigation;
+ convert_map[VehicleInfo_IsReady] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetVehicleType] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_ReadDID] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetDTCs] = HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_DiagnosticMessage] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_SubscribeVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_UnsubscribeVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_GetVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[VehicleInfo_OnVehicleData] =
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo;
+ convert_map[SDL_ActivateApp] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetUserFriendlyMessage] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAllowSDLFunctionality] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnReceivedPolicyUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnPolicyUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetListOfPermissions] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAppPermissionConsent] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnAppPermissionChanged] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnSDLConsentNeeded] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_UpdateSDL] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_OnSystemError] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_AddStatisticsInfo] = HmiInterfaces::HMI_INTERFACE_SDL;
+ convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL;
+ return convert_map;
+}
+
+HmiInterfacesImpl::HmiInterfacesImpl() {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_BasicCommunication] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_Buttons] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_Navigation] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_SDL] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_TTS] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_UI] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_VehicleInfo] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+ interfaces_states_[HmiInterfaces::HMI_INTERFACE_VR] =
+ HmiInterfaces::STATE_NOT_RESPONSE;
+}
+
+HmiInterfaces::InterfaceState HmiInterfacesImpl::GetInterfaceState(
+ HmiInterfaces::InterfaceID interface) const {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ const InterfaceStatesMap::const_iterator it =
+ interfaces_states_.find(interface);
+ // all interfaces should be presented in interfaces_states_ map.
+ DCHECK_OR_RETURN(it != interfaces_states_.end(), STATE_NOT_RESPONSE);
+ return it->second;
+}
+
+void HmiInterfacesImpl::SetInterfaceState(HmiInterfaces::InterfaceID interface,
+ HmiInterfaces::InterfaceState state) {
+ sync_primitives::AutoLock autolock(interfaces_states_lock_);
+ DCHECK(interfaces_states_.find(interface) != interfaces_states_.end());
+ interfaces_states_[interface] = state;
+}
+
+HmiInterfaces::InterfaceID HmiInterfacesImpl::GetInterfaceFromFunction(
+ hmi_apis::FunctionID::eType function) const {
+ // TODO(AKutsan): APPLINK-26874: Generate map of functionid to inteface
+ // automaticaly from
+ // HMI_API.xml
+ static const std::map<hmi_apis::FunctionID::eType, InterfaceID> convert_map =
+ generate_function_to_interface_convert_map();
+ const std::map<hmi_apis::FunctionID::eType, InterfaceID>::const_iterator it =
+ convert_map.find(function);
+ return it != convert_map.end() ? it->second : HMI_INTERFACE_INVALID_ENUM;
+}
+} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc
index d37467ee76..4e5390a1b4 100644
--- a/src/components/application_manager/src/hmi_language_handler.cc
+++ b/src/components/application_manager/src/hmi_language_handler.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
#include "application_manager/hmi_capabilities.h"
#include "utils/helpers.h"
#include "resumption/last_state.h"
+#include "smart_objects/smart_object.h"
static const std::string LanguagesKey = "Languages";
static const std::string UIKey = "UI";
@@ -79,7 +80,8 @@ void HMILanguageHandler::set_language_for(
LOG4CXX_DEBUG(logger_,
"Setting language " << language << " for interface "
<< interface);
- last_state_->dictionary[LanguagesKey][key] = language;
+ Json::Value& dictionary = last_state_->get_dictionary();
+ dictionary[LanguagesKey][key] = language;
return;
}
@@ -104,10 +106,11 @@ hmi_apis::Common_Language::eType HMILanguageHandler::get_language_for(
return Common_Language::INVALID_ENUM;
}
- if (last_state_->dictionary.isMember(LanguagesKey)) {
- if (last_state_->dictionary[LanguagesKey].isMember(key)) {
+ const Json::Value& dictionary = last_state_->get_dictionary();
+ if (dictionary.isMember(LanguagesKey)) {
+ if (dictionary[LanguagesKey].isMember(key)) {
Common_Language::eType language = static_cast<Common_Language::eType>(
- last_state_->dictionary[LanguagesKey][key].asInt());
+ dictionary[LanguagesKey][key].asInt());
return language;
}
}
@@ -150,7 +153,7 @@ void HMILanguageHandler::on_event(const event_engine::Event& event) {
}
void HMILanguageHandler::set_handle_response_for(
- const event_engine::smart_objects::SmartObject& request) {
+ const smart_objects::SmartObject& request) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace helpers;
if (!request.keyExists(strings::params)) {
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index 80628f9f33..1f05232476 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -175,7 +175,7 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const {
HMILevel::HMI_NONE)) {
return parent()->hmi_level();
}
- if (is_navi_app(app_id_)) {
+ if (is_navi_app(app_id_) || is_voice_communication_app(app_id_)) {
return HMILevel::HMI_LIMITED;
}
return HMILevel::HMI_BACKGROUND;
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 08efba3d70..19bb658bca 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -38,6 +38,7 @@
#include <set>
#include <string>
+#include <strings.h>
#include <algorithm>
#include <utility>
#include <map>
@@ -69,6 +70,8 @@ namespace {
typedef std::map<std::string, hmi_apis::Common_AppPriority::eType>
CommonAppPriorityMap;
+typedef std::vector<policy::FunctionalGroupPermission> PermissionsList;
+
CommonAppPriorityMap app_priority_values = {
{"NORMAL", hmi_apis::Common_AppPriority::NORMAL},
{"COMMUNICATION", hmi_apis::Common_AppPriority::COMMUNICATION},
@@ -96,41 +99,96 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) {
}
}
return true;
-} // namespace
}
+
+struct GroupsAppender
+ : std::unary_function<void, const PermissionsList::value_type&> {
+ GroupsAppender(smart_objects::SmartObject& groups)
+ : groups_(groups), index_(0) {}
+
+ void operator()(const PermissionsList::value_type& item) {
+ using namespace smart_objects;
+ using namespace policy;
+ groups_[index_] = SmartObject(SmartType_Map);
+
+ SmartObject& group = groups_[index_];
+ group[strings::name] = item.group_alias;
+ group[strings::id] = item.group_id;
+ GroupConsent permission_state = item.state;
+ // If state undefined, 'allowed' parameter should be absent
+ if (kGroupUndefined != permission_state) {
+ group["allowed"] = kGroupAllowed == permission_state;
+ }
+ ++index_;
+ }
+
+ private:
+ smart_objects::SmartObject& groups_;
+ int32_t index_;
+};
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+struct ExternalConsentStatusAppender
+ : std::unary_function<void,
+ const policy::ExternalConsentStatus::value_type&> {
+ ExternalConsentStatusAppender(smart_objects::SmartObject& status)
+ : status_(status), index_(0) {}
+
+ void operator()(const policy::ExternalConsentStatus::value_type& item) {
+ using namespace smart_objects;
+ using namespace policy;
+ using namespace hmi_apis;
+ status_[index_] = SmartObject(SmartType_Map);
+
+ SmartObject& external_consent_status = status_[index_];
+ external_consent_status[strings::entity_type] = item.entity_type_;
+ external_consent_status[strings::entity_id] = item.entity_id_;
+ external_consent_status[strings::status] =
+ policy::kStatusOn == item.status_
+ ? static_cast<int32_t>(Common_EntityStatus::ON)
+ : static_cast<int32_t>(Common_EntityStatus::OFF);
+ ++index_;
+ }
+
+ private:
+ smart_objects::SmartObject& status_;
+ int32_t index_;
+};
+#endif // EXTERNAL_PROPRIETARY_MODE
+
+} // namespace
+
std::pair<std::string, VehicleDataType> kVehicleDataInitializer[] = {
- std::make_pair(strings::gps, VehicleDataType::GPS),
- std::make_pair(strings::speed, VehicleDataType::SPEED),
- std::make_pair(strings::rpm, VehicleDataType::RPM),
- std::make_pair(strings::fuel_level, VehicleDataType::FUELLEVEL),
- std::make_pair(strings::fuel_level_state, VehicleDataType::FUELLEVEL_STATE),
- std::make_pair(strings::instant_fuel_consumption,
- VehicleDataType::FUELCONSUMPTION),
- std::make_pair(strings::external_temp, VehicleDataType::EXTERNTEMP),
- std::make_pair(strings::vin, VehicleDataType::VIN),
- std::make_pair(strings::prndl, VehicleDataType::PRNDL),
- std::make_pair(strings::tire_pressure, VehicleDataType::TIREPRESSURE),
- std::make_pair(strings::odometer, VehicleDataType::ODOMETER),
- std::make_pair(strings::belt_status, VehicleDataType::BELTSTATUS),
- std::make_pair(strings::body_information, VehicleDataType::BODYINFO),
- std::make_pair(strings::device_status, VehicleDataType::DEVICESTATUS),
- std::make_pair(strings::driver_braking, VehicleDataType::BRAKING),
- std::make_pair(strings::wiper_status, VehicleDataType::WIPERSTATUS),
- std::make_pair(strings::head_lamp_status, VehicleDataType::HEADLAMPSTATUS),
- std::make_pair(strings::e_call_info, VehicleDataType::ECALLINFO),
- std::make_pair(strings::airbag_status, VehicleDataType::AIRBAGSTATUS),
- std::make_pair(strings::emergency_event, VehicleDataType::EMERGENCYEVENT),
- std::make_pair(strings::cluster_mode_status,
- VehicleDataType::CLUSTERMODESTATUS),
- std::make_pair(strings::my_key, VehicleDataType::MYKEY),
+ std::make_pair(strings::gps, GPS),
+ std::make_pair(strings::speed, SPEED),
+ std::make_pair(strings::rpm, RPM),
+ std::make_pair(strings::fuel_level, FUELLEVEL),
+ std::make_pair(strings::fuel_level_state, FUELLEVEL_STATE),
+ std::make_pair(strings::instant_fuel_consumption, FUELCONSUMPTION),
+ std::make_pair(strings::external_temp, EXTERNTEMP),
+ std::make_pair(strings::vin, VIN),
+ std::make_pair(strings::prndl, PRNDL),
+ std::make_pair(strings::tire_pressure, TIREPRESSURE),
+ std::make_pair(strings::odometer, ODOMETER),
+ std::make_pair(strings::belt_status, BELTSTATUS),
+ std::make_pair(strings::body_information, BODYINFO),
+ std::make_pair(strings::device_status, DEVICESTATUS),
+ std::make_pair(strings::driver_braking, BRAKING),
+ std::make_pair(strings::wiper_status, WIPERSTATUS),
+ std::make_pair(strings::head_lamp_status, HEADLAMPSTATUS),
+ std::make_pair(strings::e_call_info, ECALLINFO),
+ std::make_pair(strings::airbag_status, AIRBAGSTATUS),
+ std::make_pair(strings::emergency_event, EMERGENCYEVENT),
+ std::make_pair(strings::cluster_mode_status, CLUSTERMODESTATUS),
+ std::make_pair(strings::my_key, MYKEY),
/*
NOT DEFINED in mobile API
- std::make_pair(strings::gps, VehicleDataType::BATTVOLTAGE),
+ std::make_pair(strings::gps,
+ BATTVOLTAGE),
*/
- std::make_pair(strings::engine_torque, VehicleDataType::ENGINETORQUE),
- std::make_pair(strings::acc_pedal_pos, VehicleDataType::ACCPEDAL),
- std::make_pair(strings::steering_wheel_angle,
- VehicleDataType::STEERINGWHEEL),
+ std::make_pair(strings::engine_torque, ENGINETORQUE),
+ std::make_pair(strings::acc_pedal_pos, ACCPEDAL),
+ std::make_pair(strings::steering_wheel_angle, STEERINGWHEEL),
};
const VehicleData MessageHelper::vehicle_data_(
@@ -198,17 +256,6 @@ const uint32_t MessageHelper::GetPriorityCode(const std::string& priority) {
return static_cast<uint32_t>(hmi_apis::Common_AppPriority::INVALID_ENUM);
}
-std::string MessageHelper::CommonLanguageToString(
- hmi_apis::Common_Language::eType language) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- const char* str = 0;
- if (EnumConversionHelper<hmi_apis::Common_Language::eType>::EnumToCString(
- language, &str)) {
- return str ? str : "";
- }
- return std::string();
-}
-
hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString(
const std::string& language) {
using namespace NsSmartDeviceLink::NsSmartObjects;
@@ -220,6 +267,26 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString(
return hmi_apis::Common_Language::INVALID_ENUM;
}
+std::string MessageHelper::GetDeviceMacAddressForHandle(
+ const uint32_t device_handle, const ApplicationManager& app_mngr) {
+ std::string device_mac_address = "";
+ app_mngr.connection_handler().get_session_observer().GetDataOnDeviceID(
+ device_handle, NULL, NULL, &device_mac_address);
+ LOG4CXX_DEBUG(logger_, "result : " << device_handle);
+ return device_mac_address;
+}
+
+std::string MessageHelper::CommonLanguageToString(
+ hmi_apis::Common_Language::eType language) {
+ using namespace NsSmartDeviceLink::NsSmartObjects;
+ const char* str = 0;
+ if (EnumConversionHelper<hmi_apis::Common_Language::eType>::EnumToCString(
+ language, &str)) {
+ return str ? str : "";
+ }
+ return std::string();
+}
+
smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject(
const uint32_t correlation_id) {
using namespace smart_objects;
@@ -251,6 +318,25 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification(
return message;
}
+void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name,
+ ApplicationManager& app_mngr) {
+ using namespace smart_objects;
+ SmartObjectSPtr message =
+ CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::BasicCommunication_DecryptCertificate;
+
+ SmartObject msg_params = SmartObject(SmartType_Map);
+
+ msg_params[hmi_request::file_name] = file_name;
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+}
+
void MessageHelper::SendHashUpdateNotification(const uint32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -369,7 +455,7 @@ mobile_apis::HMILevel::eType MessageHelper::StringToHMILevel(
}
std::string MessageHelper::StringifiedHMILevel(
- mobile_apis::HMILevel::eType hmi_level) {
+ const mobile_apis::HMILevel::eType hmi_level) {
using namespace NsSmartDeviceLink::NsSmartObjects;
const char* str = 0;
if (EnumConversionHelper<mobile_apis::HMILevel::eType>::EnumToCString(
@@ -1156,51 +1242,6 @@ void MessageHelper::SendUIChangeRegistrationRequestToHMI(
}
}
-void MessageHelper::SendChangeRegistrationRequestToHMI(
- ApplicationConstSharedPtr app, ApplicationManager& app_mngr) {
- if (!app.valid()) {
- return;
- }
- if (mobile_apis::Language::INVALID_ENUM != app->language()) {
- smart_objects::SmartObjectSPtr vr_command =
- CreateChangeRegistration(hmi_apis::FunctionID::VR_ChangeRegistration,
- app->language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (vr_command) {
- app_mngr.ManageHMICommand(vr_command);
- }
- }
-
- if (mobile_apis::Language::INVALID_ENUM != app->language()) {
- smart_objects::SmartObjectSPtr tts_command =
- CreateChangeRegistration(hmi_apis::FunctionID::TTS_ChangeRegistration,
- app->language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (tts_command) {
- app_mngr.ManageHMICommand(tts_command);
- }
- }
-
- if (mobile_apis::Language::INVALID_ENUM != app->ui_language()) {
- smart_objects::SmartObjectSPtr ui_command =
- CreateChangeRegistration(hmi_apis::FunctionID::UI_ChangeRegistration,
- app->ui_language(),
- app->app_id(),
- NULL,
- app_mngr);
-
- if (ui_command) {
- app_mngr.ManageHMICommand(ui_command);
- }
- }
-}
-
void MessageHelper::SendAddVRCommandToHMI(
const uint32_t cmd_id,
const smart_objects::SmartObject& vr_commands,
@@ -1497,8 +1538,9 @@ void MessageHelper::SendSDLActivateAppResponse(
}
// If application is revoked it should not be activated
- if (permissions.appRevoked || !permissions.isSDLAllowed) {
- return;
+ if (permissions.appRevoked) {
+ (*message)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::REJECTED;
}
app_mngr.ManageHMICommand(message);
@@ -1523,7 +1565,7 @@ void MessageHelper::SendOnSDLConsentNeeded(
}
void MessageHelper::SendPolicyUpdate(const std::string& file_path,
- const int timeout,
+ const uint32_t timeout,
const std::vector<int>& retries,
ApplicationManager& app_mngr) {
smart_objects::SmartObjectSPtr message =
@@ -1541,15 +1583,16 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path,
}
app_mngr.ManageHMICommand(message);
}
-
void MessageHelper::SendGetUserFriendlyMessageResponse(
const std::vector<policy::UserFriendlyMessage>& msg,
- uint32_t correlation_id,
+ const uint32_t correlation_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObjectSPtr message =
- utils::MakeShared<smart_objects::SmartObject>(
- smart_objects::SmartType_Map);
+ new smart_objects::SmartObject(smart_objects::SmartType_Map);
+ if (!message) {
+ return;
+ }
(*message)[strings::params][strings::function_id] =
hmi_apis::FunctionID::SDL_GetUserFriendlyMessage;
@@ -1569,9 +1612,14 @@ void MessageHelper::SendGetUserFriendlyMessageResponse(
smart_objects::SmartObject& user_friendly_messages =
(*message)[strings::msg_params][messages];
-
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ const std::string tts = "ttsString";
+ const std::string label = "label";
+ const std::string line1 = "line1";
+ const std::string line2 = "line2";
+ const std::string textBody = "textBody";
+#endif // EXTERNAL_PROPRIETARY_MODE
const std::string message_code = "messageCode";
-
std::vector<policy::UserFriendlyMessage>::const_iterator it = msg.begin();
std::vector<policy::UserFriendlyMessage>::const_iterator it_end = msg.end();
for (uint32_t index = 0; it != it_end; ++it, ++index) {
@@ -1580,51 +1628,101 @@ void MessageHelper::SendGetUserFriendlyMessageResponse(
smart_objects::SmartObject& obj = user_friendly_messages[index];
obj[message_code] = it->message_code;
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ if (!it->tts.empty()) {
+ obj[tts] = it->tts;
+ }
+ if (!it->label.empty()) {
+ obj[label] = it->label;
+ }
+ if (!it->line1.empty()) {
+ obj[line1] = it->line1;
+ }
+ if (!it->line2.empty()) {
+ obj[line2] = it->line2;
+ }
+ if (!it->text_body.empty()) {
+ obj[textBody] = it->text_body;
+ }
+#endif // EXTERNAL_PROPRIETARY_MODE
}
app_mngr.ManageHMICommand(message);
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
void MessageHelper::SendGetListOfPermissionsResponse(
const std::vector<policy::FunctionalGroupPermission>& permissions,
- const uint32_t correlation_id,
+ const policy::ExternalConsentStatus& external_consent_status,
+ uint32_t correlation_id,
ApplicationManager& app_mngr) {
- smart_objects::SmartObject message(smart_objects::SmartType_Map);
+ using namespace smart_objects;
+ using namespace hmi_apis;
- message[strings::params][strings::function_id] =
- hmi_apis::FunctionID::SDL_GetListOfPermissions;
- message[strings::params][strings::message_type] = MessageType::kResponse;
- message[strings::params][strings::correlation_id] = correlation_id;
- message[strings::params][hmi_response::code] = 0;
+ SmartObjectSPtr message = utils::MakeShared<SmartObject>(SmartType_Map);
+ DCHECK_OR_RETURN_VOID(message);
+
+ SmartObject& params = (*message)[strings::params];
+
+ params[strings::function_id] = FunctionID::SDL_GetListOfPermissions;
+ params[strings::message_type] = MessageType::kResponse;
+ params[strings::correlation_id] = correlation_id;
+ params[hmi_response::code] = static_cast<int32_t>(Common_Result::SUCCESS);
+
+ SmartObject& msg_params = (*message)[strings::msg_params];
const std::string allowed_functions = "allowedFunctions";
- message[strings::msg_params][allowed_functions] =
- smart_objects::SmartObject(smart_objects::SmartType_Array);
+ msg_params[allowed_functions] = SmartObject(SmartType_Array);
- smart_objects::SmartObject& allowed_functions_array =
- message[strings::msg_params][allowed_functions];
+ SmartObject& allowed_functions_array = msg_params[allowed_functions];
- std::vector<policy::FunctionalGroupPermission>::const_iterator it =
- permissions.begin();
- std::vector<policy::FunctionalGroupPermission>::const_iterator it_end =
- permissions.end();
- for (uint32_t index = 0; it != it_end; ++it, ++index) {
- allowed_functions_array[index] =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ GroupsAppender groups_appender(allowed_functions_array);
+ std::for_each(permissions.begin(), permissions.end(), groups_appender);
- smart_objects::SmartObject& item = allowed_functions_array[index];
- item[strings::name] = (*it).group_alias;
- item[strings::id] = (*it).group_id;
- policy::GroupConsent permission_state = (*it).state;
- // If state undefined, 'allowed' parameter should be absent
- if (policy::kGroupUndefined != permission_state) {
- item["allowed"] = policy::kGroupAllowed == permission_state;
- }
- }
+ const std::string external_consent_status_key = "externalConsentStatus";
+ msg_params[external_consent_status_key] = SmartObject(SmartType_Array);
- app_mngr.ManageHMICommand(
- utils::MakeShared<smart_objects::SmartObject>(message));
+ SmartObject& external_consent_status_array =
+ msg_params[external_consent_status_key];
+
+ ExternalConsentStatusAppender external_consent_status_appender(
+ external_consent_status_array);
+ std::for_each(external_consent_status.begin(),
+ external_consent_status.end(),
+ external_consent_status_appender);
+
+ app_mngr.ManageHMICommand(message);
+}
+#else
+void MessageHelper::SendGetListOfPermissionsResponse(
+ const std::vector<policy::FunctionalGroupPermission>& permissions,
+ uint32_t correlation_id,
+ ApplicationManager& app_mngr) {
+ using namespace smart_objects;
+ using namespace hmi_apis;
+
+ SmartObjectSPtr message = utils::MakeShared<SmartObject>(SmartType_Map);
+ DCHECK_OR_RETURN_VOID(message);
+
+ SmartObject& params = (*message)[strings::params];
+
+ params[strings::function_id] = FunctionID::SDL_GetListOfPermissions;
+ params[strings::message_type] = MessageType::kResponse;
+ params[strings::correlation_id] = correlation_id;
+ params[hmi_response::code] = static_cast<int32_t>(Common_Result::SUCCESS);
+
+ SmartObject& msg_params = (*message)[strings::msg_params];
+
+ const std::string allowed_functions = "allowedFunctions";
+ msg_params[allowed_functions] = SmartObject(SmartType_Array);
+
+ SmartObject& allowed_functions_array = msg_params[allowed_functions];
+
+ GroupsAppender groups_appender(allowed_functions_array);
+ std::for_each(permissions.begin(), permissions.end(), groups_appender);
+ app_mngr.ManageHMICommand(message);
}
+#endif // EXTERNAL_PROPRIETARY_MODE
smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse(
uint32_t connection_key,
@@ -1831,12 +1929,15 @@ void MessageHelper::SendPolicySnapshotNotification(
LOG4CXX_WARN(logger_, "No service URLs");
}
- content[strings::msg_params][strings::request_type] =
- mobile_apis::RequestType::PROPRIETARY;
content[strings::params][strings::binary_data] =
smart_objects::SmartObject(policy_data);
- content[strings::msg_params][strings::file_type] =
- mobile_apis::FileType::BINARY;
+#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE)
+ content[strings::msg_params][strings::request_type] =
+ mobile_apis::RequestType::PROPRIETARY;
+#else
+ content[strings::msg_params][strings::request_type] =
+ mobile_apis::RequestType::HTTP;
+#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE
SendSystemRequestNotification(connection_key, content, app_mngr);
}
@@ -1890,16 +1991,14 @@ void MessageHelper::SendQueryApps(const uint32_t connection_key,
policy::PolicyHandlerInterface& policy_handler = app_mngr.GetPolicyHandler();
+ const uint32_t timeout = policy_handler.TimeoutExchangeSec();
smart_objects::SmartObject content(smart_objects::SmartType_Map);
content[strings::msg_params][strings::request_type] = RequestType::QUERY_APPS;
content[strings::msg_params][strings::url] = policy_handler.RemoteAppsUrl();
- content[strings::msg_params][strings::timeout] =
- policy_handler.TimeoutExchange();
+ content[strings::msg_params][strings::timeout] = timeout;
Json::Value http_header;
- const int timeout = policy_handler.TimeoutExchange();
-
http_header[http_request::content_type] = "application/json";
http_header[http_request::connect_timeout] = timeout;
http_header[http_request::do_output] = true;
@@ -2224,7 +2323,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
return mobile_apis::Result::SUCCESS;
}
-mobile_apis::Result::eType MessageHelper::VerifyImage(
+mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath(
smart_objects::SmartObject& image,
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr) {
@@ -2268,15 +2367,33 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
full_file_path += file_name;
}
+ image[strings::value] = full_file_path;
if (!file_system::FileExists(full_file_path)) {
return mobile_apis::Result::INVALID_DATA;
}
- image[strings::value] = full_file_path;
-
return mobile_apis::Result::SUCCESS;
}
+mobile_apis::Result::eType MessageHelper::VerifyImage(
+ smart_objects::SmartObject& image,
+ ApplicationConstSharedPtr app,
+ ApplicationManager& app_mngr) {
+ smart_objects::SmartObject temp_image = image;
+ const uint32_t image_type = image[strings::image_type].asUInt();
+ const mobile_apis::ImageType::eType type =
+ static_cast<mobile_apis::ImageType::eType>(image_type);
+
+ const mobile_apis::Result::eType result =
+ VerifyImageApplyPath(temp_image, app, app_mngr);
+ if ((mobile_apis::Result::SUCCESS == result) &&
+ (mobile_apis::ImageType::DYNAMIC == type)) {
+ image[strings::value] = temp_image[strings::value];
+ }
+
+ return result;
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
@@ -2477,6 +2594,7 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) {
break;
}
case NsSmartDeviceLink::NsSmartObjects::SmartType_Integer:
+ printf("%lld", static_cast<long long int>(object.asInt()));
break;
case NsSmartDeviceLink::NsSmartObjects::SmartType_String:
printf("%s", object.asString().c_str());
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc
index 09d9512b19..b635cb1f84 100644
--- a/src/components/application_manager/src/mobile_message_handler.cc
+++ b/src/components/application_manager/src/mobile_message_handler.cc
@@ -55,9 +55,9 @@ using protocol_handler::Extract;
namespace {
typedef std::map<MessageType, std::string> MessageTypeMap;
-MessageTypeMap messageTypes = {std::make_pair(kRequest, "Request"),
- std::make_pair(kResponse, "Response"),
- std::make_pair(kNotification, "Notification")};
+MessageTypeMap message_types = {std::make_pair(kRequest, "Request"),
+ std::make_pair(kResponse, "Response"),
+ std::make_pair(kNotification, "Notification")};
}
CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
@@ -99,7 +99,7 @@ MobileMessageHandler::HandleIncomingMessageProtocol(
LOG4CXX_DEBUG(logger_,
"Incoming RPC_INFO: " << (out_message->connection_key() >> 16)
<< ", "
- << messageTypes[out_message->type()]
+ << message_types[out_message->type()]
<< ", " << out_message->function_id()
<< ", " << out_message->correlation_id()
<< ", " << out_message->json_message());
@@ -111,7 +111,7 @@ MobileMessageHandler::HandleOutgoingMessageProtocol(
const MobileMessage& message) {
LOG4CXX_DEBUG(logger_,
"Outgoing RPC_INFO: " << (message->connection_key() >> 16)
- << ", " << messageTypes[message->type()]
+ << ", " << message_types[message->type()]
<< ", " << message->function_id() << ", "
<< message->correlation_id() << ", "
<< message->json_message());
@@ -200,19 +200,20 @@ protocol_handler::RawMessage*
MobileMessageHandler::HandleOutgoingMessageProtocolV1(
const MobileMessage& message) {
LOG4CXX_AUTO_TRACE(logger_);
- std::string messageString = message->json_message();
- if (messageString.length() == 0) {
+ std::string message_string = message->json_message();
+ if (message_string.length() == 0) {
LOG4CXX_WARN(logger_, "Drop ill-formed message from mobile");
return NULL;
}
- uint8_t* rawMessage = new uint8_t[messageString.length() + 1];
- memcpy(rawMessage, messageString.c_str(), messageString.length() + 1);
+ BinaryData raw_message(message_string.length() + 1);
+ memcpy(&raw_message[0], message_string.c_str(), message_string.length() + 1);
- protocol_handler::RawMessage* result = new protocol_handler::RawMessage(
- message->connection_key(), 1, rawMessage, messageString.length() + 1);
-
- delete[] rawMessage;
+ protocol_handler::RawMessage* result =
+ new protocol_handler::RawMessage(message->connection_key(),
+ 1,
+ &raw_message[0],
+ message_string.length() + 1);
return result;
}
@@ -224,51 +225,52 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2(
if (message->json_message().length() == 0) {
LOG4CXX_ERROR(logger_, "json string is empty.");
}
- uint32_t jsonSize = message->json_message().length();
- uint32_t binarySize = 0;
+ uint32_t json_size = message->json_message().length();
+ uint32_t binary_size = 0;
if (message->has_binary_data()) {
- binarySize = message->binary_data()->size();
+ binary_size = message->binary_data()->size();
}
- const size_t dataForSendingSize =
- protocol_handler::PROTOCOL_HEADER_V2_SIZE + jsonSize + binarySize;
- uint8_t* dataForSending = new uint8_t[dataForSendingSize];
+ const size_t data_for_sending_size =
+ protocol_handler::PROTOCOL_HEADER_V2_SIZE + json_size + binary_size;
+ BinaryData data_for_sending(data_for_sending_size);
uint8_t offset = 0;
- uint8_t rpcTypeFlag = 0;
+ uint8_t rpc_type_flag = 0;
switch (message->type()) {
case application_manager::kRequest:
- rpcTypeFlag = kRequest;
+ rpc_type_flag = kRequest;
break;
case application_manager::kResponse:
- rpcTypeFlag = kResponse;
+ rpc_type_flag = kResponse;
break;
case application_manager::kNotification:
- rpcTypeFlag = kNotification;
+ rpc_type_flag = kNotification;
break;
default:
NOTREACHED();
break;
}
- uint32_t functionId = message->function_id();
- dataForSending[offset++] = ((rpcTypeFlag << 4) & 0xF0) | (functionId >> 24);
- dataForSending[offset++] = functionId >> 16;
- dataForSending[offset++] = functionId >> 8;
- dataForSending[offset++] = functionId;
+ uint32_t function_id = message->function_id();
+ data_for_sending[offset++] =
+ ((rpc_type_flag << 4) & 0xF0) | (function_id >> 24);
+ data_for_sending[offset++] = function_id >> 16;
+ data_for_sending[offset++] = function_id >> 8;
+ data_for_sending[offset++] = function_id;
- uint32_t correlationId = message->correlation_id();
- dataForSending[offset++] = correlationId >> 24;
- dataForSending[offset++] = correlationId >> 16;
- dataForSending[offset++] = correlationId >> 8;
- dataForSending[offset++] = correlationId;
+ uint32_t correlation_id = message->correlation_id();
+ data_for_sending[offset++] = correlation_id >> 24;
+ data_for_sending[offset++] = correlation_id >> 16;
+ data_for_sending[offset++] = correlation_id >> 8;
+ data_for_sending[offset++] = correlation_id;
- dataForSending[offset++] = jsonSize >> 24;
- dataForSending[offset++] = jsonSize >> 16;
- dataForSending[offset++] = jsonSize >> 8;
- dataForSending[offset++] = jsonSize;
+ data_for_sending[offset++] = json_size >> 24;
+ data_for_sending[offset++] = json_size >> 16;
+ data_for_sending[offset++] = json_size >> 8;
+ data_for_sending[offset++] = json_size;
- memcpy(dataForSending + offset, message->json_message().c_str(), jsonSize);
+ memcpy(&data_for_sending[offset], message->json_message().c_str(), json_size);
// Default the service type to RPC Service
uint8_t type = 0x07;
@@ -276,22 +278,21 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2(
if (message->has_binary_data()) {
// Change the service type to Hybrid Service
type = 0x0F;
- const std::vector<uint8_t>& binaryData = *(message->binary_data());
- uint8_t* currentPointer = dataForSending + offset + jsonSize;
- for (uint32_t i = 0; i < binarySize; ++i) {
- currentPointer[i] = binaryData[i];
+ const BinaryData& binary_data = *(message->binary_data());
+ BinaryData::value_type* current_pointer =
+ &data_for_sending[offset + json_size];
+ for (uint32_t i = 0; i < binary_size; ++i) {
+ current_pointer[i] = binary_data[i];
}
}
- protocol_handler::RawMessage* msgToProtocolHandler =
+ protocol_handler::RawMessage* msg_to_protocol_handler =
new protocol_handler::RawMessage(message->connection_key(),
message->protocol_version(),
- dataForSending,
- dataForSendingSize,
+ &data_for_sending[0],
+ data_for_sending_size,
type);
- delete[] dataForSending;
-
- return msgToProtocolHandler;
+ return msg_to_protocol_handler;
}
} // namespace application_manager
diff --git a/src/components/application_manager/src/policies/delegates/app_permission_delegate.cc b/src/components/application_manager/src/policies/delegates/app_permission_delegate.cc
index 7b5954a3c3..871e96442a 100644
--- a/src/components/application_manager/src/policies/delegates/app_permission_delegate.cc
+++ b/src/components/application_manager/src/policies/delegates/app_permission_delegate.cc
@@ -36,17 +36,35 @@
namespace policy {
CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
+#ifdef EXTERNAL_PROPRIETARY_MODE
AppPermissionDelegate::AppPermissionDelegate(
const uint32_t connection_key,
const PermissionConsent& permissions,
+ const ExternalConsentStatus& external_consent_status,
policy::PolicyHandlerInterface& policy_handler)
: connection_key_(connection_key)
, permissions_(permissions)
+ , external_consent_status_(external_consent_status)
, policy_handler_(policy_handler) {}
+#else
+AppPermissionDelegate::AppPermissionDelegate(
+ const uint32_t connection_key,
+ const PermissionConsent& permissions,
+ policy::PolicyHandlerInterface& policy_handler)
+ : connection_key_(connection_key)
+ , permissions_(permissions)
+ , policy_handler_(policy_handler) {}
+#endif
void AppPermissionDelegate::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy_handler_.OnAppPermissionConsentInternal(
+ connection_key_, external_consent_status_, permissions_);
+#else
policy_handler_.OnAppPermissionConsentInternal(connection_key_, permissions_);
+#endif
}
void AppPermissionDelegate::exitThreadMain() {
diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc
index 492abe499a..828f2d923a 100644
--- a/src/components/application_manager/src/policies/policy_event_observer.cc
+++ b/src/components/application_manager/src/policies/policy_event_observer.cc
@@ -37,7 +37,6 @@
#include "smart_objects/smart_object.h"
namespace policy {
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
using namespace application_manager;
class PolicyHandler;
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index cf312acc6d..840b1ae0f8 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -34,10 +34,11 @@
#include <dlfcn.h>
#include <algorithm>
#include <vector>
+#include <functional>
+#include <utility>
#include "application_manager/smart_object_keys.h"
-
#include "application_manager/policies/delegates/app_permission_delegate.h"
-
+#include "policy/status.h"
#include "application_manager/application_manager.h"
#include "application_manager/state_controller.h"
#include "application_manager/message_helper.h"
@@ -53,6 +54,7 @@
#include "utils/file_system.h"
#include "utils/scope_guard.h"
#include "utils/make_shared.h"
+#include "policy/policy_manager.h"
namespace policy {
@@ -112,7 +114,21 @@ const policy::DeviceParams GetDeviceParams(
device_params.device_handle = device_handle;
return device_params;
}
-}
+
+struct HMILevelPredicate
+ : public std::unary_function<ApplicationSharedPtr, bool> {
+ explicit HMILevelPredicate(const mobile_api::HMILevel::eType level)
+ : level_(level) {}
+
+ bool operator()(const ApplicationSharedPtr app) const {
+ return level_ == app->hmi_level() ? true : false;
+ }
+
+ private:
+ mobile_api::HMILevel::eType level_;
+};
+
+} // namespace
#define POLICY_LIB_CHECK(return_value) \
{ \
@@ -134,25 +150,6 @@ const policy::DeviceParams GetDeviceParams(
static const std::string kCerficateFileName = "certificate";
-struct ApplicationListHmiLevelSorter {
- bool operator()(const application_manager::ApplicationSharedPtr& lhs,
- const application_manager::ApplicationSharedPtr& rhs) {
- if (lhs && rhs) {
- mobile_apis::HMILevel::eType lhs_hmi_level = lhs->hmi_level();
- mobile_apis::HMILevel::eType rhs_hmi_level = rhs->hmi_level();
-
- if (lhs_hmi_level == rhs_hmi_level) {
- return lhs->app_id() < rhs->app_id();
- }
- return lhs_hmi_level < rhs_hmi_level;
- }
- return false;
- }
-};
-
-typedef std::set<application_manager::ApplicationSharedPtr,
- ApplicationListHmiLevelSorter> HmiLevelOrderedApplicationList;
-
struct DeactivateApplication {
explicit DeactivateApplication(
const connection_handler::DeviceHandle& device_id,
@@ -182,11 +179,9 @@ struct SDLAllowedNotification {
, state_controller_(state_controller) {}
void operator()(const ApplicationSharedPtr& app) {
- if (!policy_manager_) {
- return;
- }
+ DCHECK_OR_RETURN_VOID(policy_manager_);
if (device_id_ == app->device()) {
- std::string hmi_level;
+ std::string hmi_level = "NONE";
mobile_apis::HMILevel::eType default_mobile_hmi;
policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level);
if ("BACKGROUND" == hmi_level) {
@@ -210,6 +205,43 @@ struct SDLAllowedNotification {
StateController& state_controller_;
};
+/**
+ * @brief Gets from system list of currently registered applications and
+ * create collection of links device-to-application
+ */
+struct LinksCollector {
+ LinksCollector(const ApplicationManager& application_manager,
+ std::map<std::string, std::string>& out_app_to_device_link)
+ : application_manager_(application_manager)
+ , out_app_to_device_link_(out_app_to_device_link) {
+ out_app_to_device_link_.clear();
+ }
+
+ void operator()(const ApplicationSharedPtr& app) {
+ if (!app.valid()) {
+ LOG4CXX_WARN(logger_,
+ "Invalid pointer to application was passed."
+ "Skip current application.");
+ return;
+ }
+ DeviceParams device_params = GetDeviceParams(
+ app->device(),
+ application_manager_.connection_handler().get_session_observer());
+ const std::string app_id = app->policy_app_id();
+ if (device_params.device_mac_address.empty()) {
+ LOG4CXX_WARN(logger_,
+ "Couldn't find device, which hosts application " << app_id);
+ return;
+ }
+ out_app_to_device_link_.insert(
+ std::make_pair(device_params.device_mac_address, app_id));
+ }
+
+ private:
+ const ApplicationManager& application_manager_;
+ std::map<std::string, std::string>& out_app_to_device_link_;
+};
+
struct LinkAppToDevice {
explicit LinkAppToDevice(
std::map<std::string, std::string>& app_to_device_link,
@@ -296,6 +328,10 @@ PolicyHandler::PolicyHandler(const PolicySettings& settings,
PolicyHandler::~PolicyHandler() {}
+bool PolicyHandler::PolicyEnabled() const {
+ return get_settings().enable_policy();
+}
+
bool PolicyHandler::LoadPolicyLibrary() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoWriteLock lock(policy_manager_lock_);
@@ -304,11 +340,11 @@ bool PolicyHandler::LoadPolicyLibrary() {
"System is configured to work without policy "
"functionality.");
policy_manager_.reset();
- return NULL;
+ return false;
}
dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY);
- char* error = dlerror();
+ const char* error = dlerror();
if (!error) {
if (CreateManager()) {
policy_manager_->set_listener(this);
@@ -323,10 +359,6 @@ bool PolicyHandler::LoadPolicyLibrary() {
return policy_manager_.valid();
}
-bool PolicyHandler::PolicyEnabled() const {
- return get_settings().enable_policy();
-}
-
bool PolicyHandler::CreateManager() {
typedef PolicyManager* (*CreateManager)();
typedef void (*DeleteManager)(PolicyManager*);
@@ -355,7 +387,7 @@ bool PolicyHandler::InitPolicyTable() {
// info necessary for policy table
event_observer_->subscribe_on_event(
hmi_apis::FunctionID::BasicCommunication_OnReady);
- const std::string& preloaded_file = get_settings().preloaded_pt_file();
+ std::string preloaded_file = get_settings().preloaded_pt_file();
if (file_system::FileExists(preloaded_file)) {
return policy_manager_->InitPT(preloaded_file, &get_settings());
}
@@ -366,7 +398,7 @@ bool PolicyHandler::InitPolicyTable() {
bool PolicyHandler::ResetPolicyTable() {
LOG4CXX_TRACE(logger_, "Reset policy table.");
POLICY_LIB_CHECK(false);
- const std::string& preloaded_file = get_settings().preloaded_pt_file();
+ std::string preloaded_file = get_settings().preloaded_pt_file();
if (file_system::FileExists(preloaded_file)) {
return policy_manager_->ResetPT(preloaded_file);
}
@@ -381,38 +413,60 @@ bool PolicyHandler::ClearUserConsent() {
}
uint32_t PolicyHandler::GetAppIdForSending() const {
+ LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK(0);
const ApplicationSet& accessor =
application_manager_.applications().GetData();
- HmiLevelOrderedApplicationList app_list(accessor.begin(), accessor.end());
- LOG4CXX_INFO(logger_, "Apps size: " << app_list.size());
+ HMILevelPredicate has_none_level(mobile_api::HMILevel::HMI_NONE);
+ Applications apps_without_none_level;
+ std::copy_if(accessor.begin(),
+ accessor.end(),
+ std::back_inserter(apps_without_none_level),
+ std::not1(has_none_level));
- for (HmiLevelOrderedApplicationList::const_iterator first = app_list.begin();
- first != app_list.end();
- ++first) {
- if ((*first)->IsRegistered()) {
- const uint32_t app_id = (*first)->app_id();
- DeviceParams device_params = GetDeviceParams(
- (*first)->device(),
- application_manager_.connection_handler().get_session_observer());
+ LOG4CXX_DEBUG(logger_,
+ "Number of apps with different from NONE level: "
+ << apps_without_none_level.size());
- if (kDeviceAllowed ==
- policy_manager_->GetUserConsentForDevice(
- device_params.device_mac_address)) {
- return app_id;
- }
- }
+ uint32_t choosen_app_id =
+ ChooseRandomAppForPolicyUpdate(apps_without_none_level);
+
+ if (choosen_app_id) {
+ return choosen_app_id;
}
- return 0;
+
+ Applications apps_with_none_level;
+ std::copy_if(accessor.begin(),
+ accessor.end(),
+ std::back_inserter(apps_with_none_level),
+ has_none_level);
+
+ LOG4CXX_DEBUG(
+ logger_,
+ "Number of apps with NONE level: " << apps_with_none_level.size());
+
+ return ChooseRandomAppForPolicyUpdate(apps_with_none_level);
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
+void PolicyHandler::OnAppPermissionConsent(
+ const uint32_t connection_key,
+ const PermissionConsent& permissions,
+ const ExternalConsentStatus& external_consent_status) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ AsyncRun(new AppPermissionDelegate(
+ connection_key, permissions, external_consent_status, *this));
+}
+#else
void PolicyHandler::OnAppPermissionConsent(
const uint32_t connection_key, const PermissionConsent& permissions) {
LOG4CXX_AUTO_TRACE(logger_);
AsyncRun(new AppPermissionDelegate(connection_key, permissions, *this));
}
+#endif
+
void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id,
const bool is_allowed) {
POLICY_LIB_CHECK_VOID();
@@ -432,8 +486,10 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id,
if (device_handle == (*it_app_list).get()->device()) {
const std::string policy_app_id = (*it_app_list)->policy_app_id();
- // If app has predata policy, which is assigned without device consent or
- // with negative data consent, there no necessity to change smth and send
+ // If app has predata policy, which is assigned without device consent
+ // or
+ // with negative data consent, there no necessity to change smth and
+ // send
// notification for such app in case of device consent is not allowed
if (policy_manager_->IsPredataPolicy(policy_app_id) && !is_allowed) {
continue;
@@ -463,9 +519,9 @@ void PolicyHandler::SendOnAppPermissionsChanged(
}
void PolicyHandler::OnPTExchangeNeeded() {
+ LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
- MessageHelper::SendOnStatusUpdate(policy_manager_->ForcePTExchange(),
- application_manager_);
+ policy_manager_->ForcePTExchange();
}
void PolicyHandler::GetAvailableApps(std::queue<std::string>& apps) {
@@ -480,9 +536,17 @@ void PolicyHandler::GetAvailableApps(std::queue<std::string>& apps) {
}
}
-void PolicyHandler::AddApplication(const std::string& application_id) {
- POLICY_LIB_CHECK_VOID();
- policy_manager_->AddApplication(application_id);
+struct SmartObjectToInt {
+ int operator()(const smart_objects::SmartObject& item) const {
+ return item.asInt();
+ }
+};
+
+StatusNotifier PolicyHandler::AddApplication(
+ const std::string& application_id,
+ const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) {
+ POLICY_LIB_CHECK(utils::MakeShared<utils::CallNothing>());
+ return policy_manager_->AddApplication(application_id, hmi_types);
}
void PolicyHandler::AddDevice(const std::string& device_id,
@@ -499,69 +563,88 @@ void PolicyHandler::SetDeviceInfo(const std::string& device_id,
policy_manager_->SetDeviceInfo(device_id, device_info);
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
void PolicyHandler::OnAppPermissionConsentInternal(
- const uint32_t connection_key, PermissionConsent& permissions) {
+ const uint32_t connection_key,
+ const ExternalConsentStatus& external_consent_status,
+ PermissionConsent& out_permissions) {
LOG4CXX_AUTO_TRACE(logger_);
+ const PolicyManager::NotificationMode mode =
+ external_consent_status.empty() ? PolicyManager::kNotifyApplicationMode
+ : PolicyManager::kSilentMode;
+#else
+void PolicyHandler::OnAppPermissionConsentInternal(
+ const uint32_t connection_key, PermissionConsent& out_permissions) {
+#endif
POLICY_LIB_CHECK_VOID();
+
if (connection_key) {
ApplicationSharedPtr app = application_manager_.application(connection_key);
if (app.valid()) {
- permissions.policy_app_id = app->policy_app_id();
+ out_permissions.policy_app_id = app->policy_app_id();
DeviceParams device_params = GetDeviceParams(
app->device(),
application_manager_.connection_handler().get_session_observer());
- permissions.device_id = device_params.device_mac_address;
+ out_permissions.device_id = device_params.device_mac_address;
}
- if (!permissions.policy_app_id.empty()) {
- policy_manager_->SetUserConsentForApp(permissions);
+ if (!out_permissions.policy_app_id.empty()) {
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy_manager_->SetUserConsentForApp(out_permissions, mode);
+#else
+ policy_manager_->SetUserConsentForApp(out_permissions);
+#endif
}
+ } else if (!app_to_device_link_.empty()) {
+ sync_primitives::AutoLock lock(app_to_device_link_lock_);
+ std::map<std::string, std::string>::const_iterator it =
+ app_to_device_link_.begin();
+ for (; app_to_device_link_.end() != it; ++it) {
+ ApplicationSharedPtr app =
+ application_manager_.application_by_policy_id(it->second);
+
+ // If list of apps sent to HMI for user consents is not the same as
+ // current,
+ // permissions should be set only for coincident to registered apps
+ if (!app.valid()) {
+ LOG4CXX_WARN(logger_,
+ "Invalid pointer to application was passed."
+ "Permissions setting skipped.");
+ continue;
+ }
- return;
- }
+ DeviceParams device_params = GetDeviceParams(
+ app->device(),
+ application_manager_.connection_handler().get_session_observer());
- sync_primitives::AutoLock lock(app_to_device_link_lock_);
- if (!app_to_device_link_.size()) {
+ if (device_params.device_mac_address != it->first) {
+ LOG4CXX_WARN(logger_,
+ "Device_id of application is changed."
+ "Permissions setting skipped.");
+ continue;
+ }
+
+ out_permissions.policy_app_id = it->second;
+ out_permissions.device_id = it->first;
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy_manager_->SetUserConsentForApp(out_permissions, mode);
+#else
+ policy_manager_->SetUserConsentForApp(out_permissions);
+#endif
+ }
+ } else {
LOG4CXX_WARN(logger_,
"There are no applications previously stored for "
"setting common permissions.");
- return;
}
-
- std::map<std::string, std::string>::const_iterator it =
- app_to_device_link_.begin();
- std::map<std::string, std::string>::const_iterator it_end =
- app_to_device_link_.end();
- for (; it != it_end; ++it) {
- ApplicationSharedPtr app =
- application_manager_.application_by_policy_id(it->first);
-
- // If list of apps sent to HMI for user consents is not the same as current,
- // permissions should be set only for coincident to registered apps
- if (!app.valid()) {
- LOG4CXX_WARN(logger_,
- "Invalid pointer to application was passed."
- "Permissions setting skipped.");
- continue;
- }
-
- DeviceParams device_params = GetDeviceParams(
- app->device(),
- application_manager_.connection_handler().get_session_observer());
-
- if (device_params.device_mac_address != it->second) {
- LOG4CXX_WARN(logger_,
- "Device_id of application is changed."
- "Permissions setting skipped.");
- continue;
- }
-
- permissions.policy_app_id = it->first;
- permissions.device_id = it->second;
- policy_manager_->SetUserConsentForApp(permissions);
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ if (!policy_manager_->SetExternalConsentStatus(external_consent_status)) {
+ LOG4CXX_WARN(logger_,
+ "External User Consent Settings status has not been set!");
}
+#endif
}
void policy::PolicyHandler::SetDaysAfterEpoch() {
@@ -585,77 +668,180 @@ void PolicyHandler::OnGetUserFriendlyMessage(
uint32_t correlation_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
- std::vector<UserFriendlyMessage> result =
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ const std::string active_hmi_language =
+ application_manager::MessageHelper::CommonLanguageToString(
+ application_manager_.hmi_capabilities().active_ui_language());
+ const std::vector<UserFriendlyMessage> result =
+ policy_manager_->GetUserFriendlyMessages(
+ message_codes, language, active_hmi_language);
+#else
+ const std::vector<UserFriendlyMessage> result =
policy_manager_->GetUserFriendlyMessages(message_codes, language);
+#endif // EXTERNAL_PROPRIETARY_MODE
// Send response to HMI with gathered data
MessageHelper::SendGetUserFriendlyMessageResponse(
result, correlation_id, application_manager_);
}
-void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
- const uint32_t correlation_id) {
+void PolicyHandler::GetRegisteredLinks(
+ std::map<std::string, std::string>& out_links) const {
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetConstIt it_app = accessor.GetData().begin();
+ ApplicationSetConstIt it_app_end = accessor.GetData().end();
+
+ LinksCollector linker(application_manager_, out_links);
+ std::for_each(it_app, it_app_end, linker);
+}
+
+std::vector<policy::FunctionalGroupPermission>
+PolicyHandler::CollectRegisteredAppsPermissions() {
LOG4CXX_AUTO_TRACE(logger_);
- POLICY_LIB_CHECK_VOID();
+ POLICY_LIB_CHECK(std::vector<policy::FunctionalGroupPermission>());
// If no specific app was passed, get permissions for all currently registered
// applications
- if (!connection_key) {
- sync_primitives::AutoLock lock(app_to_device_link_lock_);
- LinkAppToDevice linker(app_to_device_link_, application_manager_);
- const ApplicationSet& accessor =
- application_manager_.applications().GetData();
- ApplicationSetConstIt it_app = accessor.begin();
- ApplicationSetConstIt it_app_end = accessor.end();
-
- // Add all currently registered applications
- std::for_each(it_app, it_app_end, linker);
-
- PermissionsConsolidator consolidator;
- std::vector<policy::FunctionalGroupPermission> group_permissions;
- std::map<std::string, std::string>::const_iterator it =
- app_to_device_link_.begin();
- for (; it != app_to_device_link_.end(); ++it) {
- policy_manager_->GetUserConsentForApp(
- it->second, it->first, group_permissions);
- consolidator.Consolidate(group_permissions);
- }
+ sync_primitives::AutoLock lock(app_to_device_link_lock_);
- MessageHelper::SendGetListOfPermissionsResponse(
- consolidator.GetConsolidatedPermissions(),
- correlation_id,
- application_manager_);
+ GetRegisteredLinks(app_to_device_link_);
- return;
+ PermissionsConsolidator consolidator;
+ std::vector<policy::FunctionalGroupPermission> group_permissions;
+ std::map<std::string, std::string>::const_iterator it =
+ app_to_device_link_.begin();
+ for (; it != app_to_device_link_.end(); ++it) {
+ policy_manager_->GetUserConsentForApp(
+ it->first, it->second, group_permissions);
+ consolidator.Consolidate(group_permissions);
}
+ return consolidator.GetConsolidatedPermissions();
+}
+std::vector<FunctionalGroupPermission> PolicyHandler::CollectAppPermissions(
+ const uint32_t connection_key) {
// Single app only
ApplicationSharedPtr app = application_manager_.application(connection_key);
+ std::vector<FunctionalGroupPermission> group_permissions;
- if (!app.valid()) {
+ if (NULL == app.get() || !app.valid()) {
LOG4CXX_WARN(logger_,
"Connection key '"
<< connection_key
<< "' "
"not found within registered applications.");
- return;
+
+ return group_permissions;
}
DeviceParams device_params = GetDeviceParams(
app->device(),
application_manager_.connection_handler().get_session_observer());
- std::vector<FunctionalGroupPermission> group_permissions;
if (device_params.device_mac_address.empty()) {
LOG4CXX_WARN(logger_, "Couldn't find device, which hosts application.");
- } else if (!app) {
- LOG4CXX_WARN(logger_, "Couldn't find application to get permissions.");
- } else {
- policy_manager_->GetUserConsentForApp(device_params.device_mac_address,
- app->policy_app_id(),
- group_permissions);
+ return group_permissions;
+ }
+
+ policy_manager_->GetUserConsentForApp(device_params.device_mac_address,
+ app->policy_app_id(),
+ group_permissions);
+
+ return group_permissions;
+}
+
+void PolicyHandler::OnGetListOfPermissions(const uint32_t connection_key,
+ const uint32_t correlation_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK_VOID();
+
+ application_manager::ApplicationSharedPtr app =
+ application_manager_.application(connection_key);
+ const bool is_app_registered = NULL != app.get();
+ const bool is_connection_key_valid = is_app_registered && connection_key;
+
+ const std::vector<policy::FunctionalGroupPermission> permissions =
+ is_connection_key_valid ? CollectAppPermissions(connection_key)
+ : CollectRegisteredAppsPermissions();
- MessageHelper::SendGetListOfPermissionsResponse(
- group_permissions, correlation_id, application_manager_);
+ if (permissions.empty() && is_connection_key_valid) {
+ LOG4CXX_ERROR(logger_,
+ "No permissions found for application with connection key:"
+ << connection_key);
+ return;
}
+
+ MessageHelper::SendGetListOfPermissionsResponse(
+ permissions,
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy_manager_->GetExternalConsentStatus(),
+#endif // EXTERNAL_PROPRIETARY_MODE
+ correlation_id,
+ application_manager_);
+}
+
+void PolicyHandler::LinkAppsToDevice() {
+ sync_primitives::AutoLock lock(app_to_device_link_lock_);
+ LinkAppToDevice linker(app_to_device_link_, application_manager_);
+ LOG4CXX_DEBUG(logger_, "add links to app. no specific app was passed");
+ {
+ const ApplicationSet& accessor =
+ application_manager_.applications().GetData();
+ if (accessor.empty()) {
+ LOG4CXX_WARN(logger_,
+ "application_manager doesn't have any applications");
+ } else {
+ // Add all currently registered applications
+ std::for_each(accessor.begin(), accessor.end(), linker);
+ }
+ }
+}
+
+bool PolicyHandler::IsAppSuitableForPolicyUpdate(
+ const Applications::value_type value) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const uint32_t app_id = value->app_id();
+
+ if (!value->IsRegistered()) {
+ LOG4CXX_DEBUG(logger_,
+ "Application " << app_id << " is not marked as registered.");
+ return false;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Application " << app_id << " marked as registered."
+ "Checking its parameters.");
+
+ DeviceParams device_params = GetDeviceParams(
+ value->device(),
+ application_manager_.connection_handler().get_session_observer());
+
+ const bool is_device_allowed = (kDeviceAllowed ==
+ policy_manager_->GetUserConsentForDevice(
+ device_params.device_mac_address));
+
+ LOG4CXX_DEBUG(logger_,
+ "Is device " << device_params.device_mac_address << " allowed "
+ << std::boolalpha << is_device_allowed);
+ return is_device_allowed;
+}
+
+uint32_t PolicyHandler::ChooseRandomAppForPolicyUpdate(
+ Applications& app_list) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::random_shuffle(app_list.begin(), app_list.end());
+
+ Applications::const_iterator choosen_app = std::find_if(
+ app_list.begin(),
+ app_list.end(),
+ std::bind1st(std::mem_fun(&PolicyHandler::IsAppSuitableForPolicyUpdate),
+ this));
+
+ if (app_list.end() != choosen_app) {
+ return (*choosen_app)->app_id();
+ }
+
+ return 0;
}
void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) {
@@ -669,6 +855,8 @@ void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) {
void PolicyHandler::OnUpdateStatusChanged(const std::string& status) {
LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->SaveUpdateStatusRequired(policy::kUpToDate != status);
MessageHelper::SendOnStatusUpdate(status, application_manager_);
}
@@ -728,6 +916,21 @@ void PolicyHandler::OnVIIsReady() {
void PolicyHandler::OnVehicleDataUpdated(
const smart_objects::SmartObject& message) {
POLICY_LIB_CHECK_VOID();
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ if (!message.keyExists(strings::msg_params)) {
+ LOG4CXX_ERROR(logger_,
+ "Message does not contains mandatory section "
+ << strings::msg_params);
+ return;
+ }
+ if (message[strings::msg_params].keyExists(strings::vin)) {
+ policy_manager_->SetVINValue(
+ message[strings::msg_params][strings::vin].asString());
+ }
+#else
+ LOG4CXX_DEBUG(logger_,
+ "This functionality is not available for not external policy");
+#endif
}
void PolicyHandler::OnPendingPermissionChange(
@@ -818,11 +1021,18 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string,
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK(false);
- uint32_t app_id = GetAppIdForSending();
+ ApplicationSharedPtr app;
+ uint32_t app_id = 0;
+ if (last_used_app_ids_.empty()) {
+ LOG4CXX_WARN(logger_, "last_used_app_ids_ is empty");
+ return false;
+ } else {
+ app_id = last_used_app_ids_.back();
- ApplicationSharedPtr app = application_manager_.application(app_id);
+ app = application_manager_.application(app_id);
+ }
- if (!app.valid()) {
+ if (!app) {
LOG4CXX_WARN(logger_,
"There is no registered application with "
"connection key '"
@@ -875,8 +1085,9 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file,
correlation_id, vehicle_data_args, application_manager_);
} else {
LOG4CXX_WARN(logger_, "Exchange wasn't successful, trying another one.");
- OnPTExchangeNeeded();
+ policy_manager_->ForcePTExchange();
}
+ OnPTUFinished(ret);
return ret;
}
@@ -897,43 +1108,102 @@ bool PolicyHandler::UnloadPolicyLibrary() {
return ret;
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
+struct SDLAlowedNotification {
+ SDLAlowedNotification(const connection_handler::DeviceHandle& device_id,
+ PolicyManager* policy_manager,
+ StateController& state_controller)
+ : device_id_(device_id)
+ , policy_manager_(policy_manager)
+ , state_controller_(state_controller) {}
+
+ void operator()(const ApplicationSharedPtr& app) {
+ DCHECK_OR_RETURN_VOID(policy_manager_);
+ if (app->device() == device_id_) {
+ std::string hmi_level;
+ mobile_apis::HMILevel::eType default_mobile_hmi;
+ policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level);
+ if ("BACKGROUND" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND;
+ } else if ("FULL" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL;
+ } else if ("LIMITED" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED;
+ } else if ("NONE" == hmi_level) {
+ default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE;
+ } else {
+ return;
+ }
+ state_controller_.SetRegularState(app, default_mobile_hmi, true);
+ }
+ }
+
+ private:
+ connection_handler::DeviceHandle device_id_;
+ PolicyManager* policy_manager_;
+ StateController& state_controller_;
+};
+#endif // EXTERNAL_PROPRIETARY_MODE
+
void PolicyHandler::OnAllowSDLFunctionalityNotification(
bool is_allowed, const std::string& device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
using namespace mobile_apis;
- // Device ids, need to be changed
- std::vector<std::string> device_macs;
const bool device_specific = !device_mac.empty();
// Common devices consents change
connection_handler::ConnectionHandler& connection_handler =
application_manager_.connection_handler();
+
if (!device_specific) {
+ // Device ids, need to be changed
+ std::vector<std::string> device_macs;
connection_handler.GetConnectedDevicesMAC(device_macs);
- } else {
- device_macs.push_back(device_mac);
- }
+ std::vector<std::string>::const_iterator it_ids = device_macs.begin();
+ std::vector<std::string>::const_iterator it_ids_end = device_macs.end();
+ for (; it_ids != it_ids_end; ++it_ids) {
+ const std::string device_id = *it_ids;
+
+ if (kDefaultDeviceMacAddress == device_id) {
+ LOG4CXX_WARN(logger_,
+ "Device with id " << device_id << " wasn't found.");
+ continue;
+ }
+ policy_manager_->SetUserConsentForDevice(device_id, is_allowed);
+ uint32_t device_handle = 0;
+ if (!connection_handler.GetDeviceID(device_id, &device_handle)) {
+ LOG4CXX_WARN(logger_,
+ "Device handle with mac " << device_id
+ << " wasn't found.");
+ }
- std::vector<std::string>::const_iterator it_ids = device_macs.begin();
- std::vector<std::string>::const_iterator it_ids_end = device_macs.end();
- for (; it_ids != it_ids_end; ++it_ids) {
- const std::string device_id = *it_ids;
+#ifdef EXTERNAL_PROPRIETARY_MODE
- if (kDefaultDeviceMacAddress == device_id) {
- LOG4CXX_WARN(logger_, "Device with id " << device_id << " wasn't found.");
- return;
- }
- policy_manager_->SetUserConsentForDevice(device_id, is_allowed);
- uint32_t device_handle = 0;
- if (!connection_handler.GetDeviceID(device_mac, &device_handle)) {
- LOG4CXX_WARN(logger_,
- "Device hadle with mac " << device_mac << " wasn't found.");
+ DataAccessor<ApplicationSet> accessor =
+ application_manager_.applications();
+ if (!is_allowed) {
+ std::for_each(
+ accessor.GetData().begin(),
+ accessor.GetData().end(),
+ DeactivateApplication(device_handle,
+ application_manager_.state_controller()));
+ } else {
+ std::for_each(
+ accessor.GetData().begin(),
+ accessor.GetData().end(),
+ SDLAlowedNotification(device_handle,
+ policy_manager_.get(),
+ application_manager_.state_controller()));
+ }
+
+#endif // EXTERNAL_PROPRIETARY_MODE
}
}
// Case, when specific device was changed
+ uint32_t device_handle = 0u;
if (device_specific) {
- uint32_t device_handle = 0;
+ policy_manager_->SetUserConsentForDevice(device_mac, is_allowed);
if (!connection_handler.GetDeviceID(device_mac, &device_handle)) {
LOG4CXX_WARN(logger_,
"Device hadle with mac " << device_mac << " wasn't found.");
@@ -948,6 +1218,37 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
pending_device_handles_.erase(it);
}
+
+#ifdef EXTERNAL_PROPRIETARY_MODE
+
+ if (last_activated_app_id_) {
+ ApplicationSharedPtr app =
+ application_manager_.application(last_activated_app_id_);
+
+ if (!app) {
+ LOG4CXX_WARN(logger_,
+ "Application with id '"
+ << last_activated_app_id_
+ << "' not found among registered applications.");
+ return;
+ }
+ if (is_allowed) {
+ // Send HMI status notification to mobile
+ // Put application in full
+ AudioStreamingState::eType state = app->is_audio()
+ ? AudioStreamingState::AUDIBLE
+ : AudioStreamingState::NOT_AUDIBLE;
+
+ application_manager_.state_controller().SetRegularState(
+ app, mobile_apis::HMILevel::HMI_FULL, state, true);
+ last_activated_app_id_ = 0;
+ } else {
+ DeactivateApplication deactivate_notification(
+ device_handle, application_manager_.state_controller());
+ deactivate_notification(app);
+ }
+ }
+#endif // EXTERNAL_PROPRIETARY_MODE
}
void PolicyHandler::OnIgnitionCycleOver() {
@@ -977,8 +1278,44 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key,
}
} else {
permissions = policy_manager_->GetAppPermissionsChanges(policy_app_id);
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ UsageStatistics& usage = app->usage_report();
+ usage.RecordAppUserSelection();
+ DeviceParams device_params = GetDeviceParams(
+ app->device(),
+ application_manager_.connection_handler().get_session_observer());
+ permissions.deviceInfo = device_params;
+
+ DeviceConsent consent = policy_manager_->GetUserConsentForDevice(
+ permissions.deviceInfo.device_mac_address);
+ permissions.isSDLAllowed = kDeviceAllowed == consent;
+
+ // According to the SDLAQ-CRS-2794, p.9
+ // 'priority' should be omitted in case when device
+ // is not allowed.
+ if (!permissions.isSDLAllowed) {
+ permissions.priority.clear();
+ last_activated_app_id_ = connection_key;
+ }
+
+ if (permissions.appRevoked) {
+ usage.RecordRunAttemptsWhileRevoked();
+ }
+
+ // If isSDLAllowed is false, we should provide device params for user
+ // consent
+ if (!permissions.isSDLAllowed) {
+ pending_device_handles_.push_back(permissions.deviceInfo.device_handle);
+ }
+
+ if (permissions.appPermissionsConsentNeeded) {
+ MessageHelper::SendOnAppPermissionsChangedNotification(
+ app->app_id(), permissions, application_manager_);
+ }
+#else // EXTERNAL_PROPRIETARY_MODE
permissions.isSDLAllowed = true;
+#endif // EXTERNAL_PROPRIETARY_MODE
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
}
// If application is revoked it should not be activated
@@ -1006,7 +1343,7 @@ void PolicyHandler::KmsChanged(int kilometers) {
void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) {
LOG4CXX_TRACE(logger_, "PT exchange at user request");
POLICY_LIB_CHECK_VOID();
- std::string update_status = policy_manager_->ForcePTExchange();
+ std::string update_status = policy_manager_->ForcePTExchangeAtUserRequest();
MessageHelper::SendUpdateSDLResponse(
update_status, correlation_id, application_manager_);
}
@@ -1091,8 +1428,8 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string,
std::string& snap_path) {
const std::string& policy_snapshot_file_name =
- settings_.policies_snapshot_file_name();
- const std::string& system_files_path = settings_.system_files_path();
+ get_settings().policies_snapshot_file_name();
+ const std::string& system_files_path = get_settings().system_files_path();
snap_path = system_files_path + '/' + policy_snapshot_file_name;
bool result = false;
@@ -1107,30 +1444,56 @@ bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string,
return result;
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
+void PolicyHandler::OnSnapshotCreated(
+ const BinaryMessage& pt_string,
+ const std::vector<int>& retry_delay_seconds,
+ const uint32_t timeout_exchange_ms) {
+ std::string policy_snapshot_full_path;
+ if (SaveSnapshot(pt_string, policy_snapshot_full_path)) {
+ const uint32_t timeout_exchange_s =
+ timeout_exchange_ms / date_time::DateTime::MILLISECONDS_IN_SECOND;
+ MessageHelper::SendPolicyUpdate(policy_snapshot_full_path,
+ timeout_exchange_s,
+ retry_delay_seconds,
+ application_manager_);
+ }
+}
+#else // EXTERNAL_PROPRIETARY_MODE
void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
-#ifdef EXTENDED_POLICY
+#ifdef PROPRIETARY_MODE
std::string policy_snapshot_full_path;
if (!SaveSnapshot(pt_string, policy_snapshot_full_path)) {
LOG4CXX_ERROR(logger_, "Snapshot processing skipped.");
return;
}
MessageHelper::SendPolicyUpdate(policy_snapshot_full_path,
- policy_manager_->TimeoutExchange(),
+ TimeoutExchangeSec(),
policy_manager_->RetrySequenceDelaysSeconds(),
application_manager_);
-#else
+#else // PROPRIETARY_MODE
+ LOG4CXX_ERROR(logger_, "HTTP policy");
EndpointUrls urls;
- policy_manager_->GetServiceUrls("0x07", urls);
+ policy_manager_->GetUpdateUrls("0x07", urls);
if (urls.empty()) {
LOG4CXX_ERROR(logger_, "Service URLs are empty! NOT sending PT to mobile!");
return;
}
- SendMessageToSDK(pt_string, urls.front().url.front());
-#endif
+
+ AppIdURL app_url = policy_manager_->GetNextUpdateUrl(urls);
+ while (!IsUrlAppIdValid(app_url.first, urls)) {
+ app_url = policy_manager_->GetNextUpdateUrl(urls);
+ }
+ const std::string& url = urls[app_url.first].url[app_url.second];
+ SendMessageToSDK(pt_string, url);
+#endif // PROPRIETARY_MODE
+ // reset update required false
+ OnUpdateRequestSentToMobile();
}
+#endif // EXTERNAL_PROPRIETARY_MODE
bool PolicyHandler::GetPriority(const std::string& policy_app_id,
std::string* priority) const {
@@ -1138,13 +1501,27 @@ bool PolicyHandler::GetPriority(const std::string& policy_app_id,
return policy_manager_->GetPriority(policy_app_id, priority);
}
-void PolicyHandler::CheckPermissions(const PTString& app_id,
- const PTString& hmi_level,
- const PTString& rpc,
- const RPCParams& rpc_params,
- CheckPermissionResult& result) {
+void PolicyHandler::CheckPermissions(
+ const application_manager::ApplicationSharedPtr app,
+ const PTString& rpc,
+ const RPCParams& rpc_params,
+ CheckPermissionResult& result) {
POLICY_LIB_CHECK_VOID();
- policy_manager_->CheckPermissions(app_id, hmi_level, rpc, rpc_params, result);
+ const std::string hmi_level =
+ MessageHelper::StringifiedHMILevel(app->hmi_level());
+ const std::string device_id = MessageHelper::GetDeviceMacAddressForHandle(
+ app->device(), application_manager_);
+ LOG4CXX_INFO(logger_,
+ "Checking permissions for " << app->policy_app_id() << " in "
+ << hmi_level << " on device "
+ << device_id << " rpc " << rpc);
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ policy_manager_->CheckPermissions(
+ app->policy_app_id(), hmi_level, rpc, rpc_params, result);
+#else // EXTERNAL_PROPRIETARY_MODE
+ policy_manager_->CheckPermissions(
+ device_id, app->policy_app_id(), hmi_level, rpc, rpc_params, result);
+#endif // EXTERNAL_PROPRIETARY_MODE
}
uint32_t PolicyHandler::GetNotificationsNumber(
@@ -1173,10 +1550,16 @@ bool PolicyHandler::GetInitialAppData(const std::string& application_id,
application_id, nicknames, app_hmi_types);
}
-void PolicyHandler::GetServiceUrls(const std::string& service_type,
- EndpointUrls& end_points) {
+void PolicyHandler::GetUpdateUrls(const std::string& service_type,
+ EndpointUrls& out_end_points) {
POLICY_LIB_CHECK_VOID();
- policy_manager_->GetServiceUrls(service_type, end_points);
+ policy_manager_->GetUpdateUrls(service_type, out_end_points);
+}
+
+void PolicyHandler::GetUpdateUrls(const uint32_t service_type,
+ EndpointUrls& out_end_points) {
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->GetUpdateUrls(service_type, out_end_points);
}
std::string PolicyHandler::GetLockScreenIconUrl() const {
@@ -1184,19 +1567,19 @@ std::string PolicyHandler::GetLockScreenIconUrl() const {
return policy_manager_->GetLockScreenIconUrl();
}
-void PolicyHandler::ResetRetrySequence() {
- POLICY_LIB_CHECK_VOID();
- policy_manager_->ResetRetrySequence();
-}
-
uint32_t PolicyHandler::NextRetryTimeout() {
POLICY_LIB_CHECK(0);
+ LOG4CXX_AUTO_TRACE(logger_);
return policy_manager_->NextRetryTimeout();
}
-int PolicyHandler::TimeoutExchange() {
+uint32_t PolicyHandler::TimeoutExchangeSec() {
+ return TimeoutExchangeMSec() / date_time::DateTime::MILLISECONDS_IN_SECOND;
+}
+
+uint32_t PolicyHandler::TimeoutExchangeMSec() {
POLICY_LIB_CHECK(0);
- return policy_manager_->TimeoutExchange();
+ return policy_manager_->TimeoutExchangeMSec();
}
void PolicyHandler::OnExceededTimeout() {
@@ -1290,9 +1673,86 @@ void PolicyHandler::OnUpdateHMIAppType(
(*it)->OnUpdateHMIAppType(app_hmi_types);
}
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
LOG4CXX_AUTO_TRACE(logger_);
+ if (certificate_data.empty()) {
+ OnEmptyCertificateArrived();
+ return;
+ }
+
+ const std::string file_name =
+ file_system::GetAbsolutePath(get_settings().app_storage_folder()) + "/" +
+ kCerficateFileName;
+ const bool is_written = file_system::Write(
+ file_name,
+ std::vector<uint8_t>(certificate_data.begin(), certificate_data.end()));
+ LOG4CXX_DEBUG(logger_,
+ "Saving encrypted certificate data: \"" << certificate_data
+ << '"');
+ if (!is_written) {
+ LOG4CXX_ERROR(logger_,
+ "Unable to save encrypted certificate to file " << file_name);
+ return;
+ }
+ LOG4CXX_DEBUG(logger_, "Saved encrypted certificate data" << file_name);
+
+ MessageHelper::SendDecryptCertificateToHMI(file_name, application_manager_);
+}
+
+void PolicyHandler::OnEmptyCertificateArrived() const {
+ LOG4CXX_DEBUG(logger_, "Empty certificate arrived");
+ const std::string empty_certificate;
+ sync_primitives::AutoLock lock(listeners_lock_);
+ std::for_each(
+ listeners_.begin(),
+ listeners_.end(),
+ std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated),
+ empty_certificate));
+}
+
+void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK_VOID();
+
+ const std::string file_name =
+ file_system::GetAbsolutePath(get_settings().app_storage_folder()) + +"/" +
+ kCerficateFileName;
+
+ LOG4CXX_DEBUG(logger_, "Loading certificate data from file " << file_name);
+
+ utils::ScopeGuard file_deleter =
+ utils::MakeGuard(file_system::DeleteFile, file_name);
+ UNUSED(file_deleter);
+
+ if (!is_succeeded) {
+ LOG4CXX_ERROR(logger_, "Couldn't delete file " << file_name);
+ return;
+ }
+
+ std::string certificate_data;
+ if (!file_system::ReadFile(file_name, certificate_data)) {
+ LOG4CXX_ERROR(logger_,
+ "Unable to read certificate from file " << file_name);
+ return;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "Loaded decrypted certificate data: \"" << certificate_data
+ << '"');
+
+ policy_manager_->SetDecryptedCertificate(certificate_data);
+
+ sync_primitives::AutoLock lock(listeners_lock_);
+ std::for_each(
+ listeners_.begin(),
+ listeners_.end(),
+ std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated),
+ certificate_data));
+}
+#else // EXTERNAL_PROPRIETARY_MODE
+void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(listeners_lock_);
HandlersCollection::const_iterator it = listeners_.begin();
for (; it != listeners_.end(); ++it) {
@@ -1300,6 +1760,18 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
observer->OnCertificateUpdated(certificate_data);
}
}
+#endif // EXTERNAL_PROPRIETARY_MODE
+
+void PolicyHandler::OnPTUFinished(const bool ptu_result) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(listeners_lock_);
+ HandlersCollection::const_iterator it = listeners_.begin();
+ std::for_each(
+ listeners_.begin(),
+ listeners_.end(),
+ std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnPTUFinished),
+ ptu_result));
+}
bool PolicyHandler::CanUpdate() {
return 0 != GetAppIdForSending();
@@ -1310,6 +1782,17 @@ void PolicyHandler::RemoveDevice(const std::string& device_id) {
POLICY_LIB_CHECK_VOID();
policy_manager_->MarkUnpairedDevice(device_id);
+#ifdef EXTERNAL_PROPRIETARY_MODE
+ connection_handler::DeviceHandle device_uid;
+ if (application_manager_.connection_handler().GetDeviceID(device_id,
+ &device_uid)) {
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ std::for_each(accessor.GetData().begin(),
+ accessor.GetData().end(),
+ DeactivateApplication(
+ device_uid, application_manager_.state_controller()));
+ }
+#endif // EXTERNAL_PROPRIETARY_MODE
}
bool PolicyHandler::IsApplicationRevoked(const std::string& app_id) {
@@ -1363,7 +1846,7 @@ const std::string PolicyHandler::RemoteAppsUrl() const {
const std::string default_url;
POLICY_LIB_CHECK(default_url);
EndpointUrls endpoints;
- policy_manager_->GetServiceUrls("queryAppsUrl", endpoints);
+ policy_manager_->GetUpdateUrls("queryAppsUrl", endpoints);
if (endpoints.empty() || endpoints[0].url.empty()) {
return default_url;
}
@@ -1371,14 +1854,14 @@ const std::string PolicyHandler::RemoteAppsUrl() const {
return endpoints[0].url[0];
}
-void policy::PolicyHandler::OnAppsSearchStarted() {
+void PolicyHandler::OnAppsSearchStarted() {
POLICY_LIB_CHECK();
policy_manager_->OnAppsSearchStarted();
}
-void PolicyHandler::OnAppsSearchCompleted() {
+void PolicyHandler::OnAppsSearchCompleted(const bool trigger_ptu) {
POLICY_LIB_CHECK();
- policy_manager_->OnAppsSearchCompleted();
+ policy_manager_->OnAppsSearchCompleted(trigger_ptu);
}
void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) {
@@ -1422,6 +1905,13 @@ const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const {
return policy_manager_->GetVehicleInfo();
}
+#ifdef EXTERNAL_PROPRIETARY_MODE
+const MetaInfo PolicyHandler::GetMetaInfo() const {
+ POLICY_LIB_CHECK(MetaInfo());
+ return policy_manager_->GetMetaInfo();
+}
+#endif // EXTERNAL_PROPRIETARY_MODE
+
void PolicyHandler::Increment(usage_statistics::GlobalCounterId type) {
POLICY_LIB_CHECK();
policy_manager_->Increment(type);
@@ -1447,4 +1937,17 @@ void PolicyHandler::Add(const std::string& app_id,
policy_manager_->Add(app_id, type, timespan_seconds);
}
+bool PolicyHandler::IsUrlAppIdValid(const uint32_t app_idx,
+ const EndpointUrls& urls) const {
+ const EndpointData& app_data = urls[app_idx];
+ const std::vector<std::string> app_urls = app_data.url;
+ const ApplicationSharedPtr app =
+ application_manager_.application_by_policy_id(app_data.app_id);
+
+ const bool is_registered = (app && (app->IsRegistered()));
+ const bool is_default = (app_data.app_id == policy::kDefaultId);
+ const bool is_empty_urls = app_urls.empty();
+
+ return ((is_registered && !is_empty_urls) || is_default);
+}
} // namespace policy
diff --git a/src/components/application_manager/src/policies/policy_retry_sequence.cc b/src/components/application_manager/src/policies/policy_retry_sequence.cc
index a88aef0cc1..7d24d0b35c 100644
--- a/src/components/application_manager/src/policies/policy_retry_sequence.cc
+++ b/src/components/application_manager/src/policies/policy_retry_sequence.cc
@@ -57,7 +57,7 @@ void RetrySequence::StartNextRetry() {
if (pt_snapshot) {
policy_handler_->SendMessageToSDK(*pt_snapshot);
- const int timeout = policy_handler_->TimeoutExchange();
+ const uint32_t timeout = policy_handler_->TimeoutExchangeSec();
const int seconds = policy_handler_->NextRetryTimeout();
LOG4CXX_DEBUG(logger_,
"Timeout response: " << timeout << " Next try: " << seconds);
@@ -70,6 +70,7 @@ void RetrySequence::StartNextRetry() {
StartNextRetry();
} else {
LOG4CXX_INFO(logger_, "End retry sequence. Update PT was not received");
+ policy_handler_->OnPTUFinished(false);
}
}
}
diff --git a/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc b/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc
deleted file mode 100644
index e1d5199063..0000000000
--- a/src/components/application_manager/src/policies/pt_exchange_handler_ext.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- Copyright (c) 2013, Ford Motor Company
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following
- disclaimer in the documentation and/or other materials provided with the
- distribution.
-
- Neither the name of the Ford Motor Company nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "application_manager/policies/pt_exchange_handler_ext.h"
-
-#include <fstream>
-#include <string>
-
-#include "application_manager/message_helper.h"
-#include "config_profile/profile.h"
-#include "utils/file_system.h"
-
-using application_manager::MessageHelper;
-using profile::Profile;
-using std::string;
-
-namespace policy {
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
-
-PTExchangeHandlerExt::PTExchangeHandlerExt(PolicyHandler* policy_handler)
- : PTExchangeHandler(), policy_handler_(policy_handler) {
- DCHECK(policy_handler_);
-}
-
-PTExchangeHandlerExt::~PTExchangeHandlerExt() {}
-
-void PTExchangeHandlerExt::Start() {
- LOG4CXX_TRACE(logger_, "Start exchange PT");
-
- const string policy_snapshot_file_name =
- policy_handler_->get_settings().policies_snapshot_file_name();
- const std::string system_files_path =
- policy_handler_->get_settings().system_files_path();
- const std::string policy_snapshot_full_path =
- system_files_path + '/' + policy_snapshot_file_name;
- BinaryMessageSptr pt_snapshot = policy_handler_->RequestPTUpdate();
- if (pt_snapshot.valid()) {
- if (file_system::CreateDirectoryRecursively(system_files_path) &&
- file_system::WriteBinaryFile(policy_snapshot_full_path, *pt_snapshot)) {
- MessageHelper::SendPolicyUpdate(
- policy_snapshot_full_path,
- policy_handler_->TimeoutExchange(),
- policy_handler_->RetrySequenceDelaysSeconds());
- } else {
- LOG4CXX_ERROR(logger_,
- "Failed to write snapshot file to "
- << policy_snapshot_file_name);
- }
- } else {
- LOG4CXX_ERROR(logger_, "Failed to obtain policy table snapshot");
- }
-}
-
-void PTExchangeHandlerExt::Stop() {
- // Nothing doing
-}
-
-} // namespace policy
diff --git a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc b/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc
deleted file mode 100644
index d1c6fafb07..0000000000
--- a/src/components/application_manager/src/policies/pt_exchange_handler_impl.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Copyright (c) 2013, Ford Motor Company
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following
- disclaimer in the documentation and/or other materials provided with the
- distribution.
-
- Neither the name of the Ford Motor Company nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "application_manager/policies/pt_exchange_handler_impl.h"
-
-#include "utils/logger.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/policies/policy_retry_sequence.h"
-#include "utils/threads/thread_manager.h"
-
-namespace policy {
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler")
-
-PTExchangeHandlerImpl::PTExchangeHandlerImpl(PolicyHandler* handler)
- : policy_handler_(handler)
- , retry_sequence_(
- threads::CreateThread("RetrySequence", new RetrySequence(handler))) {
- DCHECK(policy_handler_);
- LOG4CXX_INFO(logger_, "Exchan created");
-}
-
-PTExchangeHandlerImpl::~PTExchangeHandlerImpl() {
- Stop();
- policy_handler_ = NULL;
-}
-
-void PTExchangeHandlerImpl::Start() {
- sync_primitives::AutoLock locker(retry_sequence_lock_);
- LOG4CXX_INFO(logger_, "Exchan started");
-
- retry_sequence_->stop();
- threads::DeleteThread(retry_sequence_);
- retry_sequence_ = threads::CreateThread("RetrySequence",
- new RetrySequence(policy_handler_));
-
- if (policy_handler_) {
- policy_handler_->ResetRetrySequence();
- }
- retry_sequence_->start();
-}
-
-void PTExchangeHandlerImpl::Stop() {
- sync_primitives::AutoLock locker(retry_sequence_lock_);
- if (retry_sequence_->is_running()) {
- retry_sequence_->stop();
- }
-}
-
-} // namespace policy
diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc
index b2ced9b01b..77a1853a39 100644
--- a/src/components/application_manager/src/request_controller.cc
+++ b/src/components/application_manager/src/request_controller.cc
@@ -49,17 +49,23 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController")
RequestController::RequestController(const RequestControlerSettings& settings)
: pool_state_(UNDEFINED)
, pool_size_(settings.thread_pool_size())
+ , request_tracker_(settings)
, timer_("AM RequestCtrlTimer",
new timer::TimerTaskImpl<RequestController>(
- this, &RequestController::onTimer))
+ this, &RequestController::TimeoutThread))
+ , timer_stop_flag_(false)
, is_low_voltage_(false)
, settings_(settings) {
LOG4CXX_AUTO_TRACE(logger_);
InitializeThreadpool();
+ timer_.Start(0, timer::kSingleShot);
}
RequestController::~RequestController() {
LOG4CXX_AUTO_TRACE(logger_);
+ timer_stop_flag_ = true;
+ timer_condition_.Broadcast();
+ timer_.Stop();
if (pool_state_ != TPoolState::STOPPED) {
DestroyThreadpool();
}
@@ -96,42 +102,26 @@ void RequestController::DestroyThreadpool() {
}
RequestController::TResult RequestController::CheckPosibilitytoAdd(
- const RequestPtr request) {
+ const RequestPtr request, const mobile_apis::HMILevel::eType level) {
LOG4CXX_AUTO_TRACE(logger_);
- const uint32_t& app_hmi_level_none_time_scale =
- settings_.app_hmi_level_none_time_scale();
-
- // app_hmi_level_none_max_request_per_time_scale
- const uint32_t& hmi_level_none_count =
- settings_.app_hmi_level_none_time_scale_max_requests();
-
- const uint32_t& app_time_scale = settings_.app_time_scale();
-
- const uint32_t& max_request_per_time_scale =
- settings_.app_time_scale_max_requests();
-
- const uint32_t& pending_requests_amount = settings_.pending_requests_amount();
-
- if (!CheckPendingRequestsAmount(pending_requests_amount)) {
+ if (!CheckPendingRequestsAmount(settings_.pending_requests_amount())) {
LOG4CXX_ERROR(logger_, "Too many pending request");
return RequestController::TOO_MANY_PENDING_REQUESTS;
}
- if (!waiting_for_response_.CheckHMILevelTimeScaleMaxRequest(
- mobile_apis::HMILevel::HMI_NONE,
- request->connection_key(),
- app_hmi_level_none_time_scale,
- hmi_level_none_count)) {
+ const TrackResult track_result =
+ request_tracker_.Track(request->connection_key(), level);
+
+ if (TrackResult::kNoneLevelMaxRequestsExceeded == track_result) {
LOG4CXX_ERROR(logger_, "Too many application requests in hmi level NONE");
return RequestController::NONE_HMI_LEVEL_MANY_REQUESTS;
}
- if (!waiting_for_response_.CheckTimeScaleMaxRequest(
- request->connection_key(),
- app_time_scale,
- max_request_per_time_scale)) {
+
+ if (TrackResult::kMaxRequestsExceeded == track_result) {
LOG4CXX_ERROR(logger_, "Too many application requests");
return RequestController::TOO_MANY_REQUESTS;
}
+
return SUCCESS;
}
@@ -166,7 +156,7 @@ RequestController::TResult RequestController::addMobileRequest(
logger_,
"correlation_id : " << request->correlation_id()
<< "connection_key : " << request->connection_key());
- RequestController::TResult result = CheckPosibilitytoAdd(request);
+ RequestController::TResult result = CheckPosibilitytoAdd(request, hmi_level);
if (SUCCESS == result) {
AutoLock auto_lock_list(mobile_request_list_lock_);
mobile_request_list_.push_back(request);
@@ -202,7 +192,7 @@ RequestController::TResult RequestController::addHMIRequest(
LOG4CXX_DEBUG(logger_,
"Waiting for response count:" << waiting_for_response_.Size());
- UpdateTimer();
+ NotifyTimer();
return RequestController::SUCCESS;
}
@@ -219,45 +209,53 @@ void RequestController::removeNotification(
if (it->get() == notification) {
notification_list_.erase(it++);
LOG4CXX_DEBUG(logger_, "Notification removed");
- break;
+ return;
} else {
++it;
}
}
- LOG4CXX_DEBUG(logger_, "Cant find notification");
+ LOG4CXX_DEBUG(logger_, "Cannot find notification");
}
-void RequestController::terminateRequest(const uint32_t& correlation_id,
- const uint32_t& connection_key,
+void RequestController::TerminateRequest(const uint32_t correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id,
bool force_terminate) {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_,
"correlation_id = "
<< correlation_id << " connection_key = " << connection_key
+ << " function_id = " << function_id
<< " force_terminate = " << force_terminate);
RequestInfoPtr request =
waiting_for_response_.Find(connection_key, correlation_id);
- if (request) {
- if (force_terminate || request->request()->AllowedToTerminate()) {
- waiting_for_response_.RemoveRequest(request);
- } else {
- LOG4CXX_WARN(logger_, "Request was not terminated");
- }
- UpdateTimer();
+ if (!request) {
+ LOG4CXX_WARN(logger_, "Request was not found in waiting_for_response");
+ return;
+ }
+ if (request->request()->function_id() != function_id) {
+ LOG4CXX_ERROR(logger_, "Request and response function_id's don't match");
+ return;
+ }
+ if (force_terminate || request->request()->AllowedToTerminate()) {
+ waiting_for_response_.RemoveRequest(request);
} else {
- LOG4CXX_WARN(logger_, "Request not found in waiting_for_response_");
+ LOG4CXX_WARN(logger_, "Request was not terminated");
}
+ NotifyTimer();
}
-void RequestController::OnMobileResponse(const uint32_t& mobile_correlation_id,
- const uint32_t& connection_key) {
+void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id,
+ const uint32_t connection_key,
+ const int32_t function_id) {
LOG4CXX_AUTO_TRACE(logger_);
- terminateRequest(mobile_correlation_id, connection_key);
+ TerminateRequest(mobile_correlation_id, connection_key, function_id);
}
-void RequestController::OnHMIResponse(const uint32_t& correlation_id) {
+void RequestController::OnHMIResponse(const uint32_t correlation_id,
+ const int32_t function_id) {
LOG4CXX_AUTO_TRACE(logger_);
- terminateRequest(correlation_id, RequestInfo::HmiConnectoinKey);
+ TerminateRequest(correlation_id, RequestInfo::HmiConnectoinKey, function_id);
}
void RequestController::terminateWaitingForExecutionAppRequests(
@@ -299,7 +297,7 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) {
terminateWaitingForExecutionAppRequests(app_id);
terminateWaitingForResponseAppRequests(app_id);
- UpdateTimer();
+ NotifyTimer();
}
void RequestController::terminateAllHMIRequests() {
@@ -314,7 +312,7 @@ void RequestController::terminateAllMobileRequests() {
AutoLock waiting_execution_auto_lock(mobile_request_list_lock_);
mobile_request_list_.clear();
LOG4CXX_DEBUG(logger_, "Mobile Requests waiting for execution cleared");
- UpdateTimer();
+ NotifyTimer();
}
void RequestController::updateRequestTimeout(const uint32_t& app_id,
@@ -336,7 +334,7 @@ void RequestController::updateRequestTimeout(const uint32_t& app_id,
waiting_for_response_.RemoveRequest(request_info);
request_info->updateTimeOut(new_timeout);
waiting_for_response_.Add(request_info);
- UpdateTimer();
+ NotifyTimer();
LOG4CXX_INFO(logger_,
"Timeout updated for "
<< " app_id: " << app_id << " correlation_id: "
@@ -367,14 +365,40 @@ bool RequestController::IsLowVoltage() {
return is_low_voltage_;
}
-void RequestController::onTimer() {
+void RequestController::TimeoutThread() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(
logger_,
"ENTER Waiting fore response count: " << waiting_for_response_.Size());
- RequestInfoPtr probably_expired =
- waiting_for_response_.FrontWithNotNullTimeout();
- while (probably_expired && probably_expired->isExpired()) {
+ while (!timer_stop_flag_) {
+ RequestInfoPtr probably_expired =
+ waiting_for_response_.FrontWithNotNullTimeout();
+ if (!probably_expired) {
+ sync_primitives::AutoLock auto_lock(timer_lock);
+ timer_condition_.Wait(auto_lock);
+ continue;
+ }
+ if (!probably_expired->isExpired()) {
+ LOG4CXX_DEBUG(logger_,
+ "Timeout for "
+ << (RequestInfo::HMIRequest ==
+ probably_expired->requst_type()
+ ? "HMI"
+ : "Mobile")
+ << " request id: " << probably_expired->requestId()
+ << " connection_key: " << probably_expired->app_id()
+ << " NOT expired");
+ sync_primitives::AutoLock auto_lock(timer_lock);
+ const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ const TimevalStruct end_time = probably_expired->end_time();
+ if (current_time < end_time) {
+ const uint32_t msecs = static_cast<uint32_t>(
+ date_time::DateTime::getmSecs(end_time - current_time));
+ LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs");
+ timer_condition_.WaitFor(auto_lock, msecs);
+ }
+ continue;
+ }
LOG4CXX_INFO(logger_,
"Timeout for "
<< (RequestInfo::HMIRequest ==
@@ -402,7 +426,6 @@ void RequestController::onTimer() {
}
}
}
- UpdateTimer();
LOG4CXX_DEBUG(
logger_,
"EXIT Waiting for response count : " << waiting_for_response_.Size());
@@ -453,7 +476,7 @@ void RequestController::Worker::threadMain() {
LOG4CXX_DEBUG(logger_, "timeout_in_mseconds " << timeout_in_mseconds);
if (0 != timeout_in_mseconds) {
- request_controller_->UpdateTimer();
+ request_controller_->NotifyTimer();
} else {
LOG4CXX_DEBUG(logger_,
"Default timeout was set to 0. "
@@ -481,37 +504,9 @@ void RequestController::Worker::exitThreadMain() {
// FIXME (dchmerev@luxoft.com): There is no waiting
}
-void RequestController::UpdateTimer() {
+void RequestController::NotifyTimer() {
LOG4CXX_AUTO_TRACE(logger_);
- RequestInfoPtr front = waiting_for_response_.FrontWithNotNullTimeout();
- // Buffer for sending request
- const uint32_t delay_time = 100u;
- if (front) {
- const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
- TimevalStruct end_time = front->end_time();
- date_time::DateTime::AddMilliseconds(end_time, delay_time);
- if (current_time < end_time) {
- const uint32_t msecs = static_cast<uint32_t>(
- date_time::DateTime::getmSecs(end_time - current_time));
- LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs");
- // Timeout for bigger than 5 minutes is a mistake
- timer_.Start(msecs, true);
- } else {
- LOG4CXX_WARN(
- logger_,
- "Request app_id: "
- << front->app_id() << " correlation_id: " << front->requestId()
- << " is expired. "
- << "End time (ms): " << date_time::DateTime::getmSecs(end_time)
- << " Current time (ms): "
- << date_time::DateTime::getmSecs(current_time)
- << " Diff (current - end) (ms): "
- << date_time::DateTime::getmSecs(current_time - end_time)
- << " Request timeout (sec): "
- << front->timeout_msec() /
- date_time::DateTime::MILLISECONDS_IN_SECOND);
- }
- }
+ timer_condition_.NotifyOne();
}
} // namespace request_controller
diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc
index d951d396d9..9a5828d939 100644
--- a/src/components/application_manager/src/request_info.cc
+++ b/src/components/application_manager/src/request_info.cc
@@ -77,10 +77,7 @@ RequestInfo::RequestInfo(RequestPtr request,
const RequestInfo::RequestType requst_type,
const TimevalStruct& start_time,
const uint64_t timeout_msec)
- : request_(request)
- , start_time_(start_time)
- , timeout_msec_(timeout_msec)
- , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) {
+ : request_(request), start_time_(start_time), timeout_msec_(timeout_msec) {
updateEndTime();
requst_type_ = requst_type;
correlation_id_ = request_->correlation_id();
@@ -271,66 +268,6 @@ void RequestInfoSet::CheckSetSizes() {
DCHECK(set_sizes_equal);
}
-bool RequestInfoSet::CheckTimeScaleMaxRequest(
- uint32_t app_id,
- uint32_t app_time_scale,
- uint32_t max_request_per_time_scale) {
- LOG4CXX_AUTO_TRACE(logger_);
- if (max_request_per_time_scale > 0 && app_time_scale > 0) {
- TimevalStruct end = date_time::DateTime::getCurrentTime();
- TimevalStruct start = {0, 0};
- start.tv_sec = end.tv_sec - app_time_scale;
-
- sync_primitives::AutoLock lock(this_lock_);
- TimeScale scale(start, end, app_id);
- const uint32_t count = std::count_if(time_sorted_pending_requests_.begin(),
- time_sorted_pending_requests_.end(),
- scale);
- if (count >= max_request_per_time_scale) {
- LOG4CXX_WARN(logger_,
- "Processing requests count " << count
- << " exceed application limit "
- << max_request_per_time_scale);
- return false;
- }
- LOG4CXX_DEBUG(logger_, "Requests count " << count);
- } else {
- LOG4CXX_DEBUG(logger_, "CheckTimeScaleMaxRequest disabled");
- }
- return true;
-}
-
-bool RequestInfoSet::CheckHMILevelTimeScaleMaxRequest(
- mobile_apis::HMILevel::eType hmi_level,
- uint32_t app_id,
- uint32_t app_time_scale,
- uint32_t max_request_per_time_scale) {
- LOG4CXX_AUTO_TRACE(logger_);
- if (max_request_per_time_scale > 0 && app_time_scale > 0) {
- TimevalStruct end = date_time::DateTime::getCurrentTime();
- TimevalStruct start = {0, 0};
- start.tv_sec = end.tv_sec - app_time_scale;
-
- sync_primitives::AutoLock lock(this_lock_);
- HMILevelTimeScale scale(start, end, app_id, hmi_level);
- const uint32_t count = std::count_if(time_sorted_pending_requests_.begin(),
- time_sorted_pending_requests_.end(),
- scale);
- if (count >= max_request_per_time_scale) {
- LOG4CXX_WARN(logger_,
- "Processing requests count "
- << count << " exceed application limit "
- << max_request_per_time_scale << " in hmi level "
- << hmi_level);
- return false;
- }
- LOG4CXX_DEBUG(logger_, "Requests count " << count);
- } else {
- LOG4CXX_DEBUG(logger_, "CheckHMILevelTimeScaleMaxRequest disabled");
- }
- return true;
-}
-
bool RequestInfoSet::AppIdCompararator::operator()(
const RequestInfoPtr value_compare) const {
switch (compare_type_) {
diff --git a/src/components/application_manager/src/request_tracker.cc b/src/components/application_manager/src/request_tracker.cc
new file mode 100644
index 0000000000..13b3d4d873
--- /dev/null
+++ b/src/components/application_manager/src/request_tracker.cc
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2017, Ford Motor Company
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of the Ford Motor Company nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "utils/logger.h"
+#include "utils/macro.h"
+#include "application_manager/request_tracker.h"
+#include "application_manager/message_helper.h"
+
+namespace application_manager {
+
+namespace request_controller {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController")
+
+RequestTracker::RequestTracker(const RequestControlerSettings& settings)
+ : settings_(settings) {}
+
+TrackResult RequestTracker::Track(const ApplicationID& app_id,
+ const mobile_apis::HMILevel::eType level) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool track_result = false;
+
+ LOG4CXX_DEBUG(logger_,
+ "Tracking request for level: "
+ << MessageHelper::StringifiedHMILevel(level));
+
+ if (mobile_apis::HMILevel::HMI_NONE == level) {
+ track_result = Track(app_id,
+ settings_.app_hmi_level_none_time_scale(),
+ settings_.app_hmi_level_none_time_scale_max_requests(),
+ none_level_tracker_);
+
+ return track_result ? TrackResult::kSuccess
+ : TrackResult::kNoneLevelMaxRequestsExceeded;
+ }
+
+ track_result = Track(app_id,
+ settings_.app_time_scale(),
+ settings_.app_time_scale_max_requests(),
+ tracker_);
+
+ return track_result ? TrackResult::kSuccess
+ : TrackResult::kMaxRequestsExceeded;
+}
+
+bool RequestTracker::Track(const ApplicationID& app_id,
+ const uint32_t time_scale,
+ const uint32_t max_requests,
+ ApplicationsRequestsTracker& tracker) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using date_time::DateTime;
+
+ if (!time_scale || !max_requests) {
+ LOG4CXX_INFO(logger_, "Time scale request tracking is disabled.");
+ return true;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Time scale is: " << time_scale << ". Max requests number is: "
+ << max_requests);
+
+ LOG4CXX_DEBUG(logger_, "Tracking app id: " << app_id);
+ ApplicationsRequestsTracker::iterator it_app = tracker.find(app_id);
+
+ if (tracker.end() == it_app) {
+ LOG4CXX_DEBUG(logger_, "Adding new application into tracking.");
+ tracker[app_id].push_back(DateTime::getCurrentTime());
+ return true;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Amount of known requests is: " << it_app->second.size());
+
+ if (it_app->second.size() < max_requests) {
+ LOG4CXX_DEBUG(logger_, "Adding new request into tracking.");
+ tracker[app_id].push_back(DateTime::getCurrentTime());
+ return true;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Oldest request is added at: "
+ << DateTime::getmSecs(it_app->second.front())
+ << ". Current time is: "
+ << DateTime::getmSecs(DateTime::getCurrentTime())
+ << ". Time scale is: " << time_scale);
+
+ if (DateTime::calculateTimeSpan(it_app->second.front()) > time_scale) {
+ LOG4CXX_DEBUG(logger_, "Dropping oldest request, adding new one.");
+ ApplicationsRequestsTracker::mapped_type& times = tracker[app_id];
+
+ DCHECK_OR_RETURN(!times.empty(), false);
+
+ times.erase(times.begin());
+ times.push_back(DateTime::getCurrentTime());
+ return true;
+ }
+
+ LOG4CXX_DEBUG(logger_, "Requests amount per time scale is exceeded.");
+
+ return false;
+}
+
+} // namespace request_controller
+} // namespace application_manager
diff --git a/src/components/application_manager/src/resumption/resume_ctrl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index 5e24c5572c..ad50bbf104 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -29,7 +29,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/resumption/resume_ctrl_impl.h"
#include <fstream>
#include <algorithm>
@@ -55,28 +55,28 @@ using namespace application_manager;
CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption")
-ResumeCtrl::ResumeCtrl(ApplicationManager& application_manager)
+ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager)
: event_engine::EventObserver(application_manager.event_dispatcher())
, queue_lock_(false)
, restore_hmi_level_timer_(
"RsmCtrlRstore",
- new timer::TimerTaskImpl<ResumeCtrl>(
- this, &ResumeCtrl::ApplicationResumptiOnTimer))
+ new timer::TimerTaskImpl<ResumeCtrlImpl>(
+ this, &ResumeCtrlImpl::ApplicationResumptiOnTimer))
, save_persistent_data_timer_("RsmCtrlPercist",
- new timer::TimerTaskImpl<ResumeCtrl>(
- this, &ResumeCtrl::SaveDataOnTimer))
+ new timer::TimerTaskImpl<ResumeCtrlImpl>(
+ this, &ResumeCtrlImpl::SaveDataOnTimer))
, is_resumption_active_(false)
, is_data_saved_(false)
, launch_time_(time(NULL))
, application_manager_(application_manager) {}
#ifdef BUILD_TESTS
-void ResumeCtrl::set_resumption_storage(
+void ResumeCtrlImpl::set_resumption_storage(
utils::SharedPtr<ResumptionData> mock_storage) {
resumption_storage_ = mock_storage;
}
#endif // BUILD_TESTS
-bool ResumeCtrl::Init(resumption::LastState& last_state) {
+bool ResumeCtrlImpl::Init(resumption::LastState& last_state) {
bool use_db = application_manager_.get_settings().use_db_for_resumption();
if (use_db) {
resumption_storage_.reset(
@@ -115,20 +115,21 @@ bool ResumeCtrl::Init(resumption::LastState& last_state) {
save_persistent_data_timer_.Start(
application_manager_.get_settings()
.app_resumption_save_persistent_data_timeout(),
- false);
+ timer::kPeriodic);
return true;
}
-ResumeCtrl::~ResumeCtrl() {}
+ResumeCtrlImpl::~ResumeCtrlImpl() {}
-void ResumeCtrl::SaveAllApplications() {
+void ResumeCtrlImpl::SaveAllApplications() {
DataAccessor<ApplicationSet> accessor(application_manager_.applications());
- std::for_each(accessor.GetData().begin(),
- accessor.GetData().end(),
- std::bind1st(std::mem_fun(&ResumeCtrl::SaveApplication), this));
+ std::for_each(
+ accessor.GetData().begin(),
+ accessor.GetData().end(),
+ std::bind1st(std::mem_fun(&ResumeCtrlImpl::SaveApplication), this));
}
-void ResumeCtrl::SaveApplication(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
LOG4CXX_INFO(logger_,
@@ -137,11 +138,11 @@ void ResumeCtrl::SaveApplication(ApplicationSharedPtr application) {
resumption_storage_->SaveApplication(application);
}
-void ResumeCtrl::on_event(const event_engine::Event& event) {
+void ResumeCtrlImpl::on_event(const event_engine::Event& event) {
LOG4CXX_DEBUG(logger_, "Event received" << event.id());
}
-bool ResumeCtrl::RestoreAppHMIState(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) {
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -170,7 +171,7 @@ bool ResumeCtrl::RestoreAppHMIState(ApplicationSharedPtr application) {
return result;
}
-bool ResumeCtrl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
mobile_apis::HMILevel::eType default_hmi =
@@ -178,7 +179,7 @@ bool ResumeCtrl::SetupDefaultHMILevel(ApplicationSharedPtr application) {
return SetAppHMIState(application, default_hmi, false);
}
-void ResumeCtrl::ApplicationResumptiOnTimer() {
+void ResumeCtrlImpl::ApplicationResumptiOnTimer() {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(queue_lock_);
WaitingForTimerList::iterator it = waiting_for_timer_.begin();
@@ -196,22 +197,23 @@ void ResumeCtrl::ApplicationResumptiOnTimer() {
StartSavePersistentDataTimer();
}
-void ResumeCtrl::OnAppActivated(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::OnAppActivated(ApplicationSharedPtr application) {
if (is_resumption_active_) {
RemoveFromResumption(application->app_id());
}
}
-void ResumeCtrl::RemoveFromResumption(uint32_t app_id) {
+void ResumeCtrlImpl::RemoveFromResumption(uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
queue_lock_.Acquire();
waiting_for_timer_.remove(app_id);
queue_lock_.Release();
}
-bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application,
- const mobile_apis::HMILevel::eType hmi_level,
- bool check_policy) {
+bool ResumeCtrlImpl::SetAppHMIState(
+ ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
+ bool check_policy) {
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -236,30 +238,30 @@ bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application,
return true;
}
-bool ResumeCtrl::IsHMIApplicationIdExist(uint32_t hmi_app_id) {
+bool ResumeCtrlImpl::IsHMIApplicationIdExist(uint32_t hmi_app_id) {
LOG4CXX_DEBUG(logger_, "hmi_app_id :" << hmi_app_id);
return resumption_storage_->IsHMIApplicationIdExist(hmi_app_id);
}
-bool ResumeCtrl::IsApplicationSaved(const std::string& policy_app_id,
- const std::string& device_id) {
+bool ResumeCtrlImpl::IsApplicationSaved(const std::string& policy_app_id,
+ const std::string& device_id) {
return -1 !=
resumption_storage_->IsApplicationSaved(policy_app_id, device_id);
}
-uint32_t ResumeCtrl::GetHMIApplicationID(const std::string& policy_app_id,
- const std::string& device_mac) const {
+uint32_t ResumeCtrlImpl::GetHMIApplicationID(
+ const std::string& policy_app_id, const std::string& device_mac) const {
return resumption_storage_->GetHMIApplicationID(policy_app_id, device_mac);
}
-bool ResumeCtrl::RemoveApplicationFromSaved(
+bool ResumeCtrlImpl::RemoveApplicationFromSaved(
ApplicationConstSharedPtr application) {
const std::string& device_mac = application->mac_address();
return resumption_storage_->RemoveApplicationFromSaved(
application->policy_app_id(), device_mac);
}
-void ResumeCtrl::OnSuspend() {
+void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
StopSavePersistentDataTimer();
SaveAllApplications();
@@ -267,31 +269,31 @@ void ResumeCtrl::OnSuspend() {
resumption_storage_->Persist();
}
-void ResumeCtrl::OnAwake() {
+void ResumeCtrlImpl::OnAwake() {
ResetLaunchTime();
StartSavePersistentDataTimer();
return resumption_storage_->OnAwake();
}
-void ResumeCtrl::StartSavePersistentDataTimer() {
+void ResumeCtrlImpl::StartSavePersistentDataTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (!save_persistent_data_timer_.is_running()) {
save_persistent_data_timer_.Start(
application_manager_.get_settings()
.app_resumption_save_persistent_data_timeout(),
- false);
+ timer::kPeriodic);
}
}
-void ResumeCtrl::StopSavePersistentDataTimer() {
+void ResumeCtrlImpl::StopSavePersistentDataTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (save_persistent_data_timer_.is_running()) {
save_persistent_data_timer_.Stop();
}
}
-bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
- const std::string& hash) {
+bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application,
+ const std::string& hash) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(
@@ -314,7 +316,8 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application,
return result;
}
-bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::StartResumptionOnlyHMILevel(
+ ApplicationSharedPtr application) {
// sync_primitives::AutoLock lock(resumtion_lock_);
LOG4CXX_AUTO_TRACE(logger_);
if (!application) {
@@ -339,15 +342,19 @@ bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) {
return result;
}
-void ResumeCtrl::StartAppHmiStateResumption(ApplicationSharedPtr application) {
+void ResumeCtrlImpl::StartAppHmiStateResumption(
+ ApplicationSharedPtr application) {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
smart_objects::SmartObject saved_app;
const std::string& device_mac = application->mac_address();
- bool result = resumption_storage_->GetSavedApplication(
+ const bool result = resumption_storage_->GetSavedApplication(
application->policy_app_id(), device_mac, saved_app);
- DCHECK_OR_RETURN_VOID(result);
+ if (!result) {
+ LOG4CXX_ERROR(logger_, "Application was not saved");
+ return;
+ }
const uint32_t ign_off_count = saved_app[strings::ign_off_count].asUInt();
bool restore_data_allowed = false;
restore_data_allowed =
@@ -365,12 +372,12 @@ void ResumeCtrl::StartAppHmiStateResumption(ApplicationSharedPtr application) {
}
}
-void ResumeCtrl::ResetLaunchTime() {
+void ResumeCtrlImpl::ResetLaunchTime() {
LOG4CXX_AUTO_TRACE(logger_);
launch_time_ = time(NULL);
}
-bool ResumeCtrl::CheckPersistenceFilesForResumption(
+bool ResumeCtrlImpl::CheckPersistenceFilesForResumption(
ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
@@ -397,8 +404,8 @@ bool ResumeCtrl::CheckPersistenceFilesForResumption(
return true;
}
-bool ResumeCtrl::CheckApplicationHash(ApplicationSharedPtr application,
- const std::string& hash) {
+bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application,
+ const std::string& hash) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(logger_,
@@ -410,7 +417,7 @@ bool ResumeCtrl::CheckApplicationHash(ApplicationSharedPtr application,
return result ? saved_app[strings::hash_id].asString() == hash : false;
}
-void ResumeCtrl::SaveDataOnTimer() {
+void ResumeCtrlImpl::SaveDataOnTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (is_resumption_active_) {
LOG4CXX_WARN(logger_, "Resumption timer is active skip saving");
@@ -426,14 +433,14 @@ void ResumeCtrl::SaveDataOnTimer() {
}
}
-bool ResumeCtrl::IsDeviceMacAddressEqual(ApplicationSharedPtr application,
- const std::string& saved_device_mac) {
+bool ResumeCtrlImpl::IsDeviceMacAddressEqual(
+ ApplicationSharedPtr application, const std::string& saved_device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
const std::string device_mac = application->mac_address();
return device_mac == saved_device_mac;
}
-bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
+bool ResumeCtrlImpl::RestoreApplicationData(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(application, false);
LOG4CXX_DEBUG(logger_, "app_id : " << application->app_id());
@@ -465,8 +472,8 @@ bool ResumeCtrl::RestoreApplicationData(ApplicationSharedPtr application) {
return result;
}
-void ResumeCtrl::AddFiles(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddFiles(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_files)) {
@@ -493,8 +500,8 @@ void ResumeCtrl::AddFiles(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddSubmenues(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddSubmenues(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_submenus)) {
@@ -511,8 +518,8 @@ void ResumeCtrl::AddSubmenues(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddCommands(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddCommands(ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_commands)) {
@@ -530,8 +537,9 @@ void ResumeCtrl::AddCommands(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddChoicesets(
+ ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_choice_sets)) {
@@ -550,7 +558,7 @@ void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application,
}
}
-void ResumeCtrl::SetGlobalProperties(
+void ResumeCtrlImpl::SetGlobalProperties(
ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -563,7 +571,7 @@ void ResumeCtrl::SetGlobalProperties(
}
}
-void ResumeCtrl::AddWayPointsSubscription(
+void ResumeCtrlImpl::AddWayPointsSubscription(
app_mngr::ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -577,8 +585,9 @@ void ResumeCtrl::AddWayPointsSubscription(
}
}
-void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application,
- const smart_objects::SmartObject& saved_app) {
+void ResumeCtrlImpl::AddSubscriptions(
+ ApplicationSharedPtr application,
+ const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
if (saved_app.keyExists(strings::application_subscribtions)) {
const smart_objects::SmartObject& subscribtions =
@@ -611,7 +620,7 @@ void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application,
}
}
-bool ResumeCtrl::CheckIgnCycleRestrictions(
+bool ResumeCtrlImpl::CheckIgnCycleRestrictions(
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
bool result = true;
@@ -628,7 +637,7 @@ bool ResumeCtrl::CheckIgnCycleRestrictions(
return result;
}
-bool ResumeCtrl::DisconnectedJustBeforeIgnOff(
+bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
const smart_objects::SmartObject& saved_app) {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
@@ -650,7 +659,7 @@ bool ResumeCtrl::DisconnectedJustBeforeIgnOff(
application_manager_.get_settings().resumption_delay_before_ign();
}
-bool ResumeCtrl::CheckAppRestrictions(
+bool ResumeCtrlImpl::CheckAppRestrictions(
ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app) {
using namespace mobile_apis;
@@ -658,7 +667,6 @@ bool ResumeCtrl::CheckAppRestrictions(
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(saved_app.keyExists(strings::hmi_level), false);
- const bool is_media_app = application->is_media_application();
const HMILevel::eType hmi_level =
static_cast<HMILevel::eType>(saved_app[strings::hmi_level].asInt());
const bool result = Compare<HMILevel::eType, EQ, ONE>(
@@ -666,13 +674,14 @@ bool ResumeCtrl::CheckAppRestrictions(
? true
: false;
LOG4CXX_DEBUG(logger_,
- "is_media_app " << is_media_app << "; hmi_level " << hmi_level
- << " result " << result);
+ "is_media_app " << application->is_media_application()
+ << "; hmi_level " << hmi_level << " result "
+ << result);
return result;
}
-bool ResumeCtrl::CheckIcons(ApplicationSharedPtr application,
- smart_objects::SmartObject& obj) {
+bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application,
+ smart_objects::SmartObject& obj) {
using namespace smart_objects;
LOG4CXX_AUTO_TRACE(logger_);
const mobile_apis::Result::eType verify_images =
@@ -680,11 +689,11 @@ bool ResumeCtrl::CheckIcons(ApplicationSharedPtr application,
return mobile_apis::Result::INVALID_DATA != verify_images;
}
-bool ResumeCtrl::CheckDelayAfterIgnOn() {
+bool ResumeCtrlImpl::CheckDelayAfterIgnOn() {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
const time_t curr_time = time(NULL);
- const time_t sdl_launch_time = launch_time();
+ const time_t sdl_launch_time = LaunchTime();
const uint32_t seconds_from_sdl_start = labs(curr_time - sdl_launch_time);
const uint32_t wait_time =
application_manager_.get_settings().resumption_delay_after_ign();
@@ -696,16 +705,16 @@ bool ResumeCtrl::CheckDelayAfterIgnOn() {
return seconds_from_sdl_start <= wait_time;
}
-time_t ResumeCtrl::launch_time() const {
+time_t ResumeCtrlImpl::LaunchTime() const {
return launch_time_;
}
-time_t ResumeCtrl::GetIgnOffTime() {
+time_t ResumeCtrlImpl::GetIgnOffTime() {
return resumption_storage_->GetIgnOffTime();
}
-bool ResumeCtrl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
- bool use_events) {
+bool ResumeCtrlImpl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
+ bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
if (use_events) {
const hmi_apis::FunctionID::eType function_id =
@@ -723,7 +732,7 @@ bool ResumeCtrl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request,
return true;
}
-void ResumeCtrl::ProcessHMIRequests(
+void ResumeCtrlImpl::ProcessHMIRequests(
const smart_objects::SmartObjectList& requests) {
for (smart_objects::SmartObjectList::const_iterator it = requests.begin(),
total = requests.end();
@@ -733,7 +742,7 @@ void ResumeCtrl::ProcessHMIRequests(
}
}
-void ResumeCtrl::AddToResumptionTimerQueue(const uint32_t app_id) {
+void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
queue_lock_.Acquire();
waiting_for_timer_.push_back(app_id);
@@ -744,11 +753,12 @@ void ResumeCtrl::AddToResumptionTimerQueue(const uint32_t app_id) {
if (!is_resumption_active_) {
is_resumption_active_ = true;
restore_hmi_level_timer_.Start(
- application_manager_.get_settings().app_resuming_timeout(), true);
+ application_manager_.get_settings().app_resuming_timeout(),
+ timer::kSingleShot);
}
}
-void ResumeCtrl::LoadResumeData() {
+void ResumeCtrlImpl::LoadResumeData() {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject so_applications_data;
resumption_storage_->GetDataForLoadResumeData(so_applications_data);
@@ -769,8 +779,8 @@ void ResumeCtrl::LoadResumeData() {
}
}
-void ResumeCtrl::OnAppRegistrationStart(const std::string& policy_app_id,
- const std::string& device_id) {
+void ResumeCtrlImpl::OnAppRegistrationStart(const std::string& policy_app_id,
+ const std::string& device_id) {
LOG4CXX_AUTO_TRACE(logger_);
if (IsApplicationSaved(policy_app_id, device_id)) {
LOG4CXX_INFO(
@@ -781,12 +791,22 @@ void ResumeCtrl::OnAppRegistrationStart(const std::string& policy_app_id,
}
}
-void ResumeCtrl::OnAppRegistrationEnd() {
+void ResumeCtrlImpl::OnAppRegistrationEnd() {
LOG4CXX_AUTO_TRACE(logger_);
StartSavePersistentDataTimer();
}
-bool ResumeCtrl::IsAppDataResumptionExpired(
+int32_t ResumeCtrlImpl::GetSavedAppHmiLevel(
+ const std::string& app_id, const std::string& device_id) const {
+ smart_objects::SmartObject saved_app;
+ if (resumption_storage_->GetSavedApplication(app_id, device_id, saved_app)) {
+ const int32_t saved_hmi_level = saved_app[strings::hmi_level].asInt();
+ return saved_hmi_level;
+ }
+ return static_cast<int32_t>(mobile_apis::HMILevel::INVALID_ENUM);
+}
+
+bool ResumeCtrlImpl::IsAppDataResumptionExpired(
const smart_objects::SmartObject& application) const {
const int32_t max_ign_off_count = 3;
return max_ign_off_count <= application[strings::ign_off_count].asInt();
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index f60f934fef..7866fc4de1 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -372,10 +372,9 @@ Json::Value& ResumptionDataJson::GetResumptionData() const {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock autolock(resumption_lock_);
- Json::Value& dictionary = last_state().dictionary;
+ Json::Value& dictionary = last_state().get_dictionary();
if (!dictionary.isMember(strings::resumption)) {
- last_state().dictionary[strings::resumption] =
- Json::Value(Json::objectValue);
+ dictionary[strings::resumption] = Json::Value(Json::objectValue);
LOG4CXX_WARN(logger_, "resumption section is missed");
}
Json::Value& resumption = dictionary[strings::resumption];
@@ -481,7 +480,7 @@ bool ResumptionDataJson::DropAppDataResumption(const std::string& device_id,
}
void ResumptionDataJson::Persist() {
- last_state().SaveToFileSystem();
+ last_state().SaveStateToFileSystem();
}
} // resumption
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 8b8c17fc5a..99d9e4122a 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -18,6 +18,12 @@ const char* msg_params = "msg_params";
const char* method_name = "methodName";
const char* info = "info";
const char* app_id = "appID";
+const char* bundle_id = "appBundleID";
+const char* app_info = "appInfo";
+const char* app_launch = "app_launch";
+const char* app_launch_list = "app_launch_list";
+const char* app_launch_last_session = "app_launch_last_session";
+const char* policy_app_id = "policyAppID";
const char* hmi_app_id = "hmiAppID";
const char* device_id = "deviceID";
const char* subscribed_for_way_points = "subscribed_for_way_points";
@@ -30,6 +36,7 @@ const char* success = "success";
const char* sync_msg_version = "syncMsgVersion";
const char* major_version = "majorVersion";
const char* minor_version = "minorVersion";
+const char* patch_version = "patchVersion";
const char* app_name = "appName";
const char* ngn_media_screen_app_name = "ngnMediaScreenAppName";
const char* vr_synonyms = "vrSynonyms";
@@ -125,6 +132,9 @@ const char* speech_capabilities = "speechCapabilities";
const char* vr_capabilities = "vrCapabilities";
const char* audio_pass_thru_capabilities = "audioPassThruCapabilities";
const char* pcm_stream_capabilities = "pcmStreamCapabilities";
+const char* audio_pass_thru_icon = "audioPassThruIcon";
+const char* way_points = "wayPoints";
+
// PutFile
const char* sync_file_name = "syncFileName";
const char* file_name = "fileName";
@@ -267,6 +277,22 @@ const char* is_suscribed = "isSubscribed";
const char* message_data = "messageData";
const char* delivery_mode = "deliveryMode";
+
+const char* audio_streaming_indicator = "audioStreamingIndicator";
+
+const char* const keyboard_properties_supported = "keyboardPropertiesSupported";
+const char* const language_supported = "languageSupported";
+const char* const keyboard_layout_supported = "keyboardLayoutSupported";
+const char* const keypress_mode_supported = "keypressModeSupported";
+const char* const limited_characters_list_supported =
+ "limitedCharactersListSupported";
+const char* const auto_complete_text_supported = "autoCompleteTextSupported";
+const char* const entity_type = "entityType";
+const char* const entity_id = "entityID";
+const char* const status = "status";
+const char* const external_consent_status = "externalConsentStatus";
+const char* const consented_functions = "consentedFunctions";
+const char* const source = "source";
} // namespace strings
namespace json {
@@ -340,6 +366,7 @@ const char* keyboard_layout = "keyboardLayout";
const char* limited_character_list = "limitedCharacterList";
const char* auto_complete_text = "autoCompleteText";
const char* file = "file";
+const char* file_name = "fileName";
const char* retry = "retry";
const char* service = "service";
} // namespace hmi_request
@@ -401,5 +428,3 @@ const char* event_name = "eventName";
} // namespace hmi_notification
} // namespace application_manager
-
-#
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index 839cc13026..06a7e508e5 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -95,9 +95,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app,
static_cast<hmi_apis::Common_HMILevel::eType>(
resolved_state->hmi_level());
- const bool is_full_allowed = (hmi_apis::Common_HMILevel::FULL == hmi_level);
-
- if (send_activate_app && is_full_allowed) {
+ if (send_activate_app) {
const int64_t corr_id = SendBCActivateApp(app, hmi_level, true);
if (-1 != corr_id) {
subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
diff --git a/src/components/application_manager/src/usage_statistics.cc b/src/components/application_manager/src/usage_statistics.cc
index 42c48520e9..80755b6509 100644
--- a/src/components/application_manager/src/usage_statistics.cc
+++ b/src/components/application_manager/src/usage_statistics.cc
@@ -70,7 +70,9 @@ UsageStatistics::UsageStatistics(
statistics_manager, app_id, RUN_ATTEMPTS_WHILE_REVOKED)
, count_of_removals_for_bad_behavior_(
statistics_manager, app_id, REMOVALS_MISBEHAVED)
- , count_of_tls_error_(statistics_manager, app_id, COUNT_OF_TLS_ERRORS) {
+ , count_of_tls_error_(statistics_manager, app_id, COUNT_OF_TLS_ERRORS)
+ , count_of_rejections_sync_out_of_memory_(
+ statistics_manager, app_id, REJECTIONS_SYNC_OUT_OF_MEMORY) {
time_in_hmi_state_sptr_->Start(SECONDS_HMI_NONE);
}
@@ -90,7 +92,9 @@ UsageStatistics::UsageStatistics(
statistics_manager, app_id, RUN_ATTEMPTS_WHILE_REVOKED)
, count_of_removals_for_bad_behavior_(
statistics_manager, app_id, REMOVALS_MISBEHAVED)
- , count_of_tls_error_(statistics_manager, app_id, COUNT_OF_TLS_ERRORS) {
+ , count_of_tls_error_(statistics_manager, app_id, COUNT_OF_TLS_ERRORS)
+ , count_of_rejections_sync_out_of_memory_(
+ statistics_manager, app_id, REJECTIONS_SYNC_OUT_OF_MEMORY) {
DCHECK(time_in_hmi_state_sptr_.get());
time_in_hmi_state_sptr_->Start(SECONDS_HMI_NONE);
}
@@ -124,7 +128,7 @@ void UsageStatistics::RecordAppRegistrationGuiLanguage(
void UsageStatistics::RecordAppRegistrationVuiLanguage(
Language::eType vui_language) {
- app_registration_language_gui_.Update(LanguageIdToString(vui_language));
+ app_registration_language_vui_.Update(LanguageIdToString(vui_language));
}
void UsageStatistics::RecordRpcSentInHMINone() {
@@ -151,4 +155,8 @@ void UsageStatistics::RecordTLSError() {
++count_of_tls_error_;
}
+void UsageStatistics::RecordRejectionsSyncOutOfMemory() {
+ ++count_of_rejections_sync_out_of_memory_;
+}
+
} // namespace application_manager