diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2016-05-28 16:01:17 +0300 |
---|---|---|
committer | Levchenko <slevchenko@SLevchenko-lws-unq> | 2016-08-04 17:30:11 +0300 |
commit | f0ab94ebeed8a82e355ca6838e4b427831789288 (patch) | |
tree | f13fb7019afd6bae73230ca88935689cf03fec18 | |
parent | 2b41357ed319cdc0606b23ef09643be24bf486bc (diff) | |
download | sdl_core-f0ab94ebeed8a82e355ca6838e4b427831789288.tar.gz |
AppLaunch Common interfaces
Related issue : APPLINK-24892
9 files changed, 208 insertions, 2 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index d44cf6c69e..4137a67891 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -46,6 +46,7 @@ include_directories ( ${COMPONENTS_DIR}/config_profile/include/ ${COMPONENTS_DIR}/request_watchdog/include/ ${COMPONENTS_DIR}/resumption/include/ + ${COMPONENTS_DIR}/app_launch/include/ ${COMPONENTS_DIR}/rpc_base/include/ ${COMPONENTS_DIR}/interfaces ${CMAKE_BINARY_DIR}/src/components/ @@ -95,6 +96,12 @@ file (GLOB RESUMPTION ${AM_SOURCE_DIR}/src/resumption/* ) + +file (GLOB APP_LAUNCH + ${AM_SOURCE_DIR}/src/app_launch/* +) + + file (GLOB MOBILE_COMMANDS_SOURCES ${AM_SOURCE_DIR}/src/commands/* ${AM_SOURCE_DIR}/src/commands/mobile/* @@ -382,7 +389,8 @@ add_library("MessageHelper" ${MESSAGE_HELPER_SOURCES}) add_library("AMMobileCommandsLibrary" ${MOBILE_COMMANDS_SOURCES} ) target_link_libraries("AMMobileCommandsLibrary" ${LIBRARIES} AMEventEngine) -add_library("ApplicationManager" ${SOURCES} ${RESUMPTION}) +add_library("ApplicationManager" ${SOURCES} ${RESUMPTION} ${APP_LAUNCH}) + target_link_libraries("ApplicationManager" ${LIBRARIES} AMHMICommandsLibrary AMMobileCommandsLibrary AMEventEngine diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h new file mode 100644 index 0000000000..8345b20c3a --- /dev/null +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h @@ -0,0 +1,74 @@ +/* + * 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ +#include <string> +#include "utils/shared_ptr.h" + +namespace application_manager { +class Application; +typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr; +} // namesapce application_manager + +namespace app_launch { + +/** + * @brief The AppLaunchCtrl class manage logic of AppLaunch feature + * It launches all known applications on newly connected device + */ +class AppLaunchCtrl { + public: + /** + * @brief OnAppRegistered should be called when application registered + * Save application parameters to database + * @param app application to save + */ + virtual void OnAppRegistered(const application_manager::Application& app) = 0; + + /** + * @brief OnDeviceConnected shoudl be called on device connected event + * Start launching saaved applications on ios device + * @param device_mac + */ + virtual void OnDeviceConnected(const std::string& device_mac) = 0; + + /** + * @brief OnMasterReset clear database of saved applications + */ + virtual void OnMasterReset() = 0; + virtual ~AppLaunchCtrl() {} +}; + +} // namespace app_launch + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h new file mode 100644 index 0000000000..7c875520aa --- /dev/null +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h @@ -0,0 +1,103 @@ +/* + * 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. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_ + +#include <stdint.h> +#include <vector> +#include <string> +#include "utils/shared_ptr.h" + +namespace app_launch { + +/** + * @brief struct holds AppLaunch data + */ +struct ApplicationData { + ApplicationData(const std::string& mobile_app_id, + const std::string& bundle_id, + const std::string& device_id) + : mobile_app_id_(mobile_app_id) + , bundle_id_(bundle_id) + , device_mac_(device_id) {} + + std::string mobile_app_id_; + std::string bundle_id_; + std::string device_mac_; + bool operator==(const ApplicationData& app_data) const { + return mobile_app_id_ == app_data.mobile_app_id_ && + bundle_id_ == app_data.bundle_id_ && device_mac_ == device_mac_; + } +}; +typedef utils::SharedPtr<ApplicationData> ApplicationDataPtr; + +/** + * @brief class contains interfaces to AppLaunchDataDB and AppLaunchDataJson + */ +class AppLaunchData { + public: + /** + * @brief allows correct delete heir object + */ + virtual ~AppLaunchData() {} + + /** + * @brief insert new data to DB + * @param app_data - data to inserting + * @return true in success cases and false othrewise + */ + virtual bool AddApplicationData(const ApplicationData& app_data) = 0; + + /** + * @brief select from DB all records with this dev_mac + * @param app_data - data to inserting + * @param dev_apps - pointer to vector with result of select + * @return true in success cases and false othrewise + */ + virtual std::vector<ApplicationDataPtr> GetApplicationDataByDevice( + const std::string& dev_mac) = 0; + /** + * @brief delete App_launch table in DB, after calling this + * one, it should again call init + * @return true in success cases and false othrewise + */ + virtual bool Clear() = 0; + + /** + * @brief Persist saves resumption data on file system + */ + virtual bool Persist() = 0; +}; +} // namespace app_launch + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_ diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 612db6be03..0d0001dfd6 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -109,6 +109,8 @@ class InitialApplicationData { virtual const smart_objects::SmartObject* app_types() const = 0; virtual const smart_objects::SmartObject* vr_synonyms() const = 0; virtual const std::string& mac_address() const = 0; + virtual const std::string& bundle_id() const = 0; + virtual void set_bundle_id(const std::string& bundle_id) = 0; virtual std::string policy_app_id() const = 0; virtual const smart_objects::SmartObject* tts_name() const = 0; virtual const smart_objects::SmartObject* ngn_media_screen_name() const = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 75496b2761..ab31f7a59f 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -139,6 +139,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, const std::string& app_icon_path() const; connection_handler::DeviceHandle device() const; const std::string& mac_address() const OVERRIDE; + const std::string& bundle_id() const OVERRIDE; + void set_bundle_id(const std::string& bundle_id) OVERRIDE; void set_tts_properties_in_none(bool active); bool tts_properties_in_none(); void set_tts_properties_in_full(bool active); @@ -357,7 +359,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, std::string app_icon_path_; connection_handler::DeviceHandle device_; const std::string mac_address_; - + std::string bundle_id_; AppFilesMap app_files_; std::set<mobile_apis::ButtonName::eType> subscribed_buttons_; VehicleInfoSubscriptions subscribed_vehicle_info_; diff --git a/src/components/application_manager/include/application_manager/application_manager.h b/src/components/application_manager/include/application_manager/application_manager.h index 97c38cd134..a7949d535f 100644 --- a/src/components/application_manager/include/application_manager/application_manager.h +++ b/src/components/application_manager/include/application_manager/application_manager.h @@ -52,6 +52,9 @@ namespace resumption { class LastState; } +namespace app_launch { +class AppLaunchCtrl; +} // namespace app_launch namespace media_manager { class MediaManager; } @@ -490,6 +493,8 @@ class ApplicationManager { uint32_t connection_key, const std::string& policy_app_id) const = 0; virtual resumption::ResumeCtrl& resume_controller() = 0; + + virtual app_launch::AppLaunchCtrl& app_launch_ctrl() = 0; /* * @brief Converts connection string transport type representation * to HMI Common_TransportType diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index dda192f8b0..6249e15f35 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -49,6 +49,7 @@ #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/vehicle_info_data.h" #include "application_manager/state_controller_impl.h" +#include "application_manager/app_launch/app_launch_data.h" #include "application_manager/application_manager_settings.h" #include "application_manager/event_engine/event_dispatcher_impl.h" @@ -1102,6 +1103,8 @@ class ApplicationManagerImpl const ApplicationManagerSettings& get_settings() const OVERRIDE; virtual event_engine::EventDispatcher& event_dispatcher() OVERRIDE; + app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE; + private: /** * @brief PullLanguagesInfo allows to pull information about languages. @@ -1430,6 +1433,8 @@ class ApplicationManagerImpl sync_primitives::Lock timer_pool_lock_; sync_primitives::Lock stopping_application_mng_lock_; StateControllerImpl state_ctrl_; + std::auto_ptr<app_launch::AppLaunchData> app_launch_dto_; + std::auto_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_; #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 066ad9baae..6c3822deda 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -36,6 +36,7 @@ #include "application_manager/application.h" #include "smart_objects/smart_object.h" #include "utils/custom_string.h" +#include "application_manager/usage_statistics.h" namespace test { namespace components { @@ -271,6 +272,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(is_reset_global_properties_active, bool()); MOCK_CONST_METHOD0(app_id, uint32_t()); MOCK_CONST_METHOD0(mac_address, const std::string&()); + MOCK_CONST_METHOD0(bundle_id, const std::string&()); + MOCK_METHOD1(set_bundle_id, void(const std::string& bundle_id)); MOCK_METHOD0(GetAvailableDiskSpace, uint32_t()); MOCK_METHOD1(set_mobile_app_id, void(const std::string& policy_app_id)); MOCK_CONST_METHOD0(is_foreground, bool()); diff --git a/src/components/application_manager/test/include/application_manager/mock_application_manager.h b/src/components/application_manager/test/include/application_manager/mock_application_manager.h index 6ad8aeb250..f334093b5e 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_application_manager.h @@ -47,6 +47,9 @@ #include "application_manager/state_controller.h" #include "resumption/last_state.h" #include "interfaces/MOBILE_API.h" +#include "application_manager/app_launch/app_launch_ctrl.h" +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/state_controller.h" namespace test { namespace components { @@ -197,6 +200,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { bool(uint32_t connection_key, const std::string& policy_app_id)); MOCK_METHOD0(resume_controller, resumption::ResumeCtrl&()); + MOCK_METHOD0(app_launch_ctrl, app_launch::AppLaunchCtrl&()); MOCK_METHOD1( GetDeviceTransportType, hmi_apis::Common_TransportType::eType(const std::string& transport_type)); |