diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-06-18 08:22:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-18 08:22:27 -0700 |
commit | 7f4db1878dc618e3d8454d9b70b665bf79fea5ed (patch) | |
tree | 9e3aa46ba0691d1f830a0208f585573cb9bd4993 /src/components/application_manager/include | |
parent | 1527db9a68a54e07891ccfad0c2532f0813704d7 (diff) | |
parent | d99d7f2fa71205a5f1a69d07b1abb75ef2c1fc7f (diff) | |
download | sdl_core-7f4db1878dc618e3d8454d9b70b665bf79fea5ed.tar.gz |
Merge pull request #2105 from smartdevicelink/feature/get_system_time
Feature/get system time
Diffstat (limited to 'src/components/application_manager/include')
7 files changed, 402 insertions, 2 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 30816e0ffa..aa3763108e 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 @@ -815,6 +815,12 @@ class ApplicationManagerImpl security_manager::SSLContext::HandshakeResult result) OVERRIDE; /** + * @brief Notification about handshake failure + * @return true on success notification handling or false otherwise + */ + bool OnHandshakeFailed() OVERRIDE; + + /** * @brief Notification that certificate update is required. */ void OnCertificateUpdateRequired() OVERRIDE; diff --git a/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_request.h b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_request.h new file mode 100644 index 0000000000..1dd0d8c6bb --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_request.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018, 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_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ + +#include "application_manager/commands/hmi/request_to_hmi.h" +#include "utils/macro.h" + +namespace application_manager { +namespace commands { + +/** + * @brief The BasicCommunicationGetSystemTimeRequest class sends the request + * to the HMI in order to receive current system time. + */ +class BasicCommunicationGetSystemTimeRequest : public RequestToHMI { + public: + /** + * @brief BasicCommunicationGetSystemTimeRequest does nothing except of + * initializing base class with the passed parameters. + * @param message the message to send to HMI + * @param application_manager application manager. Location service which + * is provides neccessary api to send the request. + */ + BasicCommunicationGetSystemTimeRequest( + const MessageSharedPtr& message, ApplicationManager& application_manager); + + /** + * @brief onTimeOut allows to handle case when + * system does not respond for certain request in + * appropriate time window. + */ + void onTimeOut() FINAL; +}; + +} // namespace commands +} // namespace application_manager +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_REQUEST_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_response.h new file mode 100644 index 0000000000..5e9ae4b1bb --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_get_system_time_response.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018, 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_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ + +#include "application_manager/commands/hmi/response_from_hmi.h" + +#include "utils/macro.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief The BasicCommunicationGetSystemTimeResponse class represents the + * HMI response which is contains data obtained from HMI. + */ +class BasicCommunicationGetSystemTimeResponse : public ResponseFromHMI { + public: + /** + * @brief BasicCommunicationGetSystemTimeResponse does nothing except of + * initializing base class with the passed parameters. + * @param message the message to send to HMI + * @param application_manager Location service which which is provides + * neccessary api to send the request. + */ + BasicCommunicationGetSystemTimeResponse( + const MessageSharedPtr& message, ApplicationManager& application_manager); + + /** + * @brief Run takes the message obtained from the HMI and + * sends this data to the subscribed on certain event class + */ + void Run() FINAL; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_GET_SYSTEM_TIME_RESPONSE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/include/application_manager/commands/hmi/on_system_time_ready_notification.h new file mode 100644 index 0000000000..c3031da809 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_system_time_ready_notification.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, 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_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ + +#include "application_manager/commands/hmi/notification_from_hmi.h" +#include "application_manager/application_manager_impl.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief OnSystemTimeReadyNotification command class. + * Notifies SDL whenever system time module is ready. + * It could be GPS or any other module which is allows + * to obtain system time. Once SDL receive this notification + * it is allowed to use GetSystemTimeRequest to rerieve system time. + */ +class OnSystemTimeReadyNotification : public NotificationFromHMI { + public: + /** + * @brief OnSystemTimeReadyNotification create the command. + * @param message content of the command. Passed directy to base class. + */ + OnSystemTimeReadyNotification(const MessageSharedPtr& message, + ApplicationManager& application_manager); + + /** + * @brief ~OnSystemTimeReadyNotification destroys the command object. + */ + ~OnSystemTimeReadyNotification(); + + /** + * @brief Run creates SystemTimeReady event + * and notifies all the subscribers. + */ + void Run() FINAL; +}; + +} // namespace commands +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 57a2f847bf..4cd18b3c36 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -107,6 +107,15 @@ class MessageHelper { static void SendDecryptCertificateToHMI(const std::string& file_name, ApplicationManager& app_mngr); + /** + * @brief SendGetSystemTimeRequest sends mentioned request to HMI. + * @param correlation_id the message correlation id, required for proper + * response processing. + * @param app_mngr + */ + static void SendGetSystemTimeRequest(const uint32_t correlation_id, + ApplicationManager& app_mngr); + /* * @brief Retrieve vehicle data map for param name in mobile request * to VehicleDataType diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index ce5b68ee3c..50d70591c9 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -422,7 +422,19 @@ extern const char* kFull; extern const char* kLimited; extern const char* kBackground; extern const char* kNone; -} +} // namespace hmi_levels + +namespace time_keys { +extern const char* millisecond; +extern const char* second; +extern const char* minute; +extern const char* hour; +extern const char* day; +extern const char* month; +extern const char* year; +extern const char* tz_hour; +extern const char* tz_minute; +} // namespace time_keys namespace hmi_request { extern const char* parent_id; @@ -495,7 +507,7 @@ extern const char* num_custom_presets_available; extern const char* urls; extern const char* policy_app_id; extern const char* enabled; - +extern const char* system_time; } // namespace hmi_response namespace hmi_notification { diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h new file mode 100644 index 0000000000..add440ad80 --- /dev/null +++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2018, 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_SYSTEM_TIME_SYSTEM_TIME_HANDLER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SYSTEM_TIME_SYSTEM_TIME_HANDLER_IMPL_H_ + +#include <time.h> +#include <vector> + +#include "utils/lock.h" +#include "utils/macro.h" +#include "utils/system_time_handler.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/event_engine/event_observer.h" + +namespace application_manager { + +/** + * @brief The SystemTimeHandlerImpl class. + * Responsible for the system time notification. It keeps the list + * of system time listeners, sends appropriate request to the system + * and notifies the listeners with new time right after response has appeared. + */ +class SystemTimeHandlerImpl : public utils::SystemTimeHandler, + public event_engine::EventObserver { + public: + /** + * @brief SystemTimeHandlerImpl creates the instance of the class. + */ + explicit SystemTimeHandlerImpl(ApplicationManager& application_manager); + + /** + * @brief ~SystemTimeHandlerImpl + */ + ~SystemTimeHandlerImpl(); + + private: + /** + * @brief on_event allows to process certain events from the system. + * Event which are handles within this methods are: OnSystemTimeReady + * in order to send system time query and GetSystemTimeResponse in order + * to retrieve utc time and notify all the listeners with new time value. + */ + void on_event(const application_manager::event_engine::Event& event) FINAL; + + /** + * @brief DoSystemTimeQuery sends the appropriate request to the system + * and subscribes the class to the response. This is asynchronous request + * thus it won't block until the system respond and returns immediately. + */ + void DoSystemTimeQuery() FINAL; + + /** + * @brief DoSubscribe allows to subscribe certain listener for + * SystemTime. This certain implementation does not maintain + * listeners collection instead it save the pointer to listener. + * @note the class is not reponsible for the pointer's lifecycle. + * So consider to explicitly unsibsscribe from event when listener + * is going to be destroyed. + * @param listener the listener which will be notified + * in case of SystemTime appeared. + */ + void DoSubscribe(utils::SystemTimeListener* listener) FINAL; + + /** + * @brief DoUnsubscribe assigns the pointer to listener to NULL. + * This certain implementation ignores passed parameter. + * @param listener pointer to the object which should be + * unsubscribed from events. + */ + void DoUnsubscribe(utils::SystemTimeListener* listener) FINAL; + + /** + * @brief FetchSystemTime this method allows to obtain + * recently received utc time. + * @note it is up to user to check whether the returned + * argument is valid + * @return the time value returned by system. + */ + time_t FetchSystemTime() FINAL; + + /** + * @brief SendTimeRequest sends the request to the system + * and subscribes for response. + */ + void SendTimeRequest(); + + /** + * @brief ProcessSystemTimeResponse allows to process GetSystemTimeResponse + * @param event contains response parameters aka "systemTime". + */ + void ProcessSystemTimeResponse( + const application_manager::event_engine::Event& event); + + /** + * @brief ProcessSystemTimeReadyNotification allows to process + * OnSystemTimeready notification + * from HMI. It unsubscribes from the mentioned notification and sends + * GetSystemTimeRequest to HMI in order to obtain system time + */ + void ProcessSystemTimeReadyNotification(); + + /** + * @brief Checks if UTC time is ready to provided by HMI + * and can be requested by GetSystemTime request + * @return True if HMI is ready to provide UTC time + * otherwise False + */ + bool utc_time_can_be_received() const FINAL; + + mutable sync_primitives::Lock state_lock_; + // Variable means HMI readiness to provide system time by request + volatile bool utc_time_can_be_received_; + + /** + * @brief Flag used to control that only GetSystemTime request at time could + * be sent to HMI + */ + volatile bool awaiting_get_system_time_; + + // Varible used to store result for GetSystemTime request + time_t last_time_; + + sync_primitives::Lock system_time_listener_lock_; + utils::SystemTimeListener* system_time_listener_; + ApplicationManager& app_manager_; +}; + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SYSTEM_TIME_SYSTEM_TIME_HANDLER_IMPL_H_ |