Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Version 1.21 alexa-client-sdk
Browse files Browse the repository at this point in the history
Changes in this update:

Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html)
  • Loading branch information
womw committed Oct 27, 2020
1 parent 4bb0d23 commit 6840059
Show file tree
Hide file tree
Showing 585 changed files with 30,385 additions and 4,199 deletions.
51 changes: 36 additions & 15 deletions ACL/include/ACL/AVSConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
#include <string>
#include <unordered_set>

#include <acsdkShutdownManagerInterfaces/ShutdownNotifierInterface.h>
#include <AVSCommon/AVS/AbstractAVSConnectionManager.h>
#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/SDKInterfaces/AVSGatewayAssignerInterface.h>
#include <AVSCommon/SDKInterfaces/ConnectionStatusObserverInterface.h>
#include <AVSCommon/SDKInterfaces/InternetConnectionMonitorInterface.h>
#include <AVSCommon/SDKInterfaces/MessageObserverInterface.h>
#include <AVSCommon/SDKInterfaces/MessageSenderInterface.h>
#include <AVSCommon/Utils/RequiresShutdown.h>

#include "ACL/Transport/MessageRouterInterface.h"
Expand Down Expand Up @@ -69,22 +68,44 @@ namespace acl {
*/
class AVSConnectionManager
: public avsCommon::avs::AbstractAVSConnectionManager
, public avsCommon::sdkInterfaces::MessageSenderInterface
, public avsCommon::sdkInterfaces::AVSGatewayAssignerInterface
, public MessageRouterObserverInterface
, public avsCommon::sdkInterfaces::InternetConnectionObserverInterface
, public avsCommon::utils::RequiresShutdown
, public std::enable_shared_from_this<AVSConnectionManager> {
public:
/**
* A factory function that forwards an instance of @c AVSConnectionManagerInterface to a @c MessageSenderInterface.
*
* @param connectionManager The @c MessageSenderInterface implementation to forward.
* @return A shared pointer to a @c MessageSenderInterface.
*/
static std::shared_ptr<MessageSenderInterface> createMessageSenderInterface(
const std::shared_ptr<AVSConnectionManagerInterface>& connectionManager);

/**
* A factory function that creates an instance of AVSConnectionManagerInterface.
*
* @param shutdownNotifier The object with which to register to be told when to shut down.
* @param messageRouter The entity which handles sending and receiving of AVS messages.
* @param internetConnectionMonitor The iobject to use to monitor connectivity with the internet.
* @return The created AVSConnectionManager object.
*/
static std::shared_ptr<AVSConnectionManagerInterface> createAVSConnectionManagerInterface(
const std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownNotifierInterface>& shutdownNotifier,
const std::shared_ptr<MessageRouterInterface>& messageRouter,
const std::shared_ptr<avsCommon::sdkInterfaces::InternetConnectionMonitorInterface>& internetConnectionMonitor);

/**
* A factory function that creates an AVSConnectionManager object.
*
* @deprecated in release 1.21
* @param messageRouter The entity which handles sending and receiving of AVS messages.
* @param isEnabled The enablement setting. If true, then the created object will attempt to connect to AVS.
* @param connectionStatusObservers An optional set of observers which will be notified when the connection status
* changes. The observers cannot be a nullptr.
* @param messageObservers An optional set of observer which will be sent messages that arrive from AVS.
* The observers cannot be a nullptr.
* @param internetConnectionMonitor The object to use to monitor connectivity with the internet.
* @return The created AVSConnectionManager object.
*/
static std::shared_ptr<AVSConnectionManager> create(
Expand All @@ -110,18 +131,16 @@ class AVSConnectionManager
void removeMessageObserver(std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> observer) override;
/// @}

/// @name MessageSenderInterface methods.
/// @{
void sendMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request) override;
/// @}

/**
* @note Set the gateway URL for the AVS connection. Calling this function with a new value will cause the
* current active connection to be closed, and a new one opened to the new gateway.
*/
/// @name AVSGatewayAssignerInterface methods.
/// @{
void setAVSGateway(const std::string& avsGateway) override;

/**
* @return The current gateway URL for AVS connection.
*/
std::string getAVSGateway();
std::string getAVSGateway() const override;
/// @}

/// @name InternetConnectionObserverInterface method overrides.
/// @{
Expand All @@ -136,6 +155,7 @@ class AVSConnectionManager
* @param connectionStatusObservers An optional set of observers which will be notified when the connection status
* changes.
* @param messageObserver An optional observer which will be sent messages that arrive from AVS.
* @param internetConnectionMonitor Interner connection status monitor
*/
AVSConnectionManager(
std::shared_ptr<MessageRouterInterface> messageRouter,
Expand All @@ -150,8 +170,9 @@ class AVSConnectionManager
void doShutdown() override;

void onConnectionStatusChanged(
const avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::Status status,
const avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::ChangedReason reason) override;
const ConnectionStatusObserverInterface::Status status,
const std::vector<ConnectionStatusObserverInterface::EngineConnectionStatus>& engineConnectionStatuses)
override;

void receive(const std::string& contextId, const std::string& message) override;

Expand Down
8 changes: 6 additions & 2 deletions ACL/include/ACL/Transport/DownchannelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

#include <memory>

#include <AVSCommon/AVS/Attachment/AttachmentManager.h>
#include <AVSCommon/AVS/Attachment/AttachmentManagerInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2RequestSourceInterface.h>
#include <AVSCommon/Utils/Power/PowerResource.h>

#include "ACL/Transport/ExchangeHandler.h"
#include "ACL/Transport/MessageConsumerInterface.h"
Expand Down Expand Up @@ -52,7 +53,7 @@ class DownchannelHandler
std::shared_ptr<ExchangeHandlerContextInterface> context,
const std::string& authToken,
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager);
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager);

private:
/**
Expand All @@ -76,6 +77,9 @@ class DownchannelHandler
void onResponseFinished(avsCommon::utils::http2::HTTP2ResponseFinishedStatus status, const std::string& nonMimeBody)
override;
/// @}

/// The power resource to prevent device from going to LPM.
std::shared_ptr<avsCommon::utils::power::PowerResource> m_powerResource;
};

} // namespace acl
Expand Down
23 changes: 15 additions & 8 deletions ACL/include/ACL/Transport/HTTP2Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@

#include <atomic>
#include <chrono>
#include <condition_variable>
#include <deque>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <unordered_set>

#include <AVSCommon/AVS/Attachment/AttachmentManager.h>
#include <AVSCommon/AVS/Attachment/AttachmentManagerInterface.h>
#include <AVSCommon/SDKInterfaces/AuthDelegateInterface.h>
#include <AVSCommon/SDKInterfaces/EventTracerInterface.h>
#include <AVSCommon/SDKInterfaces/MessageSenderInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2ConnectionInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2ConnectionObserverInterface.h>
#include <AVSCommon/Utils/Metrics/MetricRecorderInterface.h>
#include <AVSCommon/Utils/Power/PowerResource.h>
#include <AVSCommon/Utils/Timing/DistantFuture.h>
#include <AVSCommon/Utils/Threading/ConditionVariableWrapper.h>

#include "ACL/Transport/MessageConsumerInterface.h"
#include "ACL/Transport/PingHandler.h"
Expand Down Expand Up @@ -90,7 +92,7 @@ class HTTP2Transport
const std::string& avsGateway,
std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> http2Connection,
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
std::shared_ptr<TransportObserverInterface> transportObserver,
std::shared_ptr<PostConnectFactoryInterface> postConnectFactory,
std::shared_ptr<SynchronizedMessageRequestQueue> sharedRequestQueue,
Expand Down Expand Up @@ -223,7 +225,7 @@ class HTTP2Transport
const std::string& avsGateway,
std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> http2Connection,
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
std::shared_ptr<TransportObserverInterface> transportObserver,
std::shared_ptr<PostConnectFactoryInterface> postConnectFactory,
std::shared_ptr<SynchronizedMessageRequestQueue> sharedRequestQueue,
Expand Down Expand Up @@ -309,8 +311,7 @@ class HTTP2Transport
*/
State monitorSharedQueueWhileWaiting(
State whileState,
std::chrono::time_point<std::chrono::steady_clock> maxWakeTime =
std::chrono::time_point<std::chrono::steady_clock>::max());
std::chrono::time_point<std::chrono::steady_clock> maxWakeTime = avsCommon::utils::timing::getDistantFuture());

/**
* Handle sending @c MessageRequests and pings while in @c State::POST_CONNECTING or @c State::CONNECTED.
Expand Down Expand Up @@ -377,7 +378,7 @@ class HTTP2Transport
std::mutex m_mutex;

/// Condition variable use to wake the @c m_thread from various waits.
std::condition_variable m_wakeEvent;
avsCommon::utils::threading::ConditionVariableWrapper m_wakeEvent;

/// The current state of this HTTP2Transport.
State m_state;
Expand All @@ -395,7 +396,7 @@ class HTTP2Transport
std::shared_ptr<MessageConsumerInterface> m_messageConsumer;

/// Object for creating and accessing attachments.
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> m_attachmentManager;
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> m_attachmentManager;

/// Factory for creating @c PostConnectInterface instances.
std::shared_ptr<PostConnectFactoryInterface> m_postConnectFactory;
Expand Down Expand Up @@ -441,6 +442,12 @@ class HTTP2Transport

/// The reason for disconnecting.
avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::ChangedReason m_disconnectReason;

/// The mainloop thread power resource.
std::shared_ptr<avsCommon::utils::power::PowerResource> m_mainLoopPowerResource;

/// The power resource to prevent the device from going into LPM when a messageRequest is active.
std::shared_ptr<avsCommon::utils::power::PowerResource> m_requestActivityPowerResource;
};

} // namespace acl
Expand Down
19 changes: 17 additions & 2 deletions ACL/include/ACL/Transport/HTTP2TransportFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>
#include <string>

#include <AVSCommon/AVS/Attachment/AttachmentManager.h>
#include <AVSCommon/AVS/Attachment/AttachmentManagerInterface.h>
#include <AVSCommon/SDKInterfaces/AuthDelegateInterface.h>
#include <AVSCommon/SDKInterfaces/EventTracerInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2ConnectionFactoryInterface.h>
Expand All @@ -38,9 +38,24 @@ namespace acl {
*/
class HTTP2TransportFactory : public TransportFactoryInterface {
public:
/**
* Factory to create instances of TransportFactoryInterface.
*
* @param connectionFactory Object used to create instances of HTTP2ConnectionInterface.
* @param postConnectFactory Object used to create instances of the PostConnectInterface.
* @param metricRecorder The metric recorder.
* @param eventTracer Object used to trace events sent to AVS.
*/
static std::shared_ptr<TransportFactoryInterface> createTransportFactoryInterface(
const std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionFactoryInterface>& connectionFactory,
const std::shared_ptr<PostConnectFactoryInterface>& postConnectFactory,
const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>& metricRecorder,
const std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface>& eventTracer);

/**
* HTTP2TransportFactory constructor.
*
* @deprecated
* @param connectionFactory Object used to create instances of HTTP2ConnectionInterface.
* @param postConnectFactory Object used to create instances of the PostConnectInterface.
* @param metricRecorder The metric recorder.
Expand All @@ -56,7 +71,7 @@ class HTTP2TransportFactory : public TransportFactoryInterface {
/// @{
std::shared_ptr<TransportInterface> createTransport(
std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
const std::string& avsGateway,
std::shared_ptr<MessageConsumerInterface> messageConsumerInterface,
std::shared_ptr<TransportObserverInterface> transportObserverInterface,
Expand Down
16 changes: 12 additions & 4 deletions ACL/include/ACL/Transport/MessageRequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

#include <memory>

#include <AVSCommon/AVS/Attachment/AttachmentManager.h>
#include <AVSCommon/AVS/Attachment/AttachmentManagerInterface.h>
#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/SDKInterfaces/EventTracerInterface.h>
#include <AVSCommon/Utils/Power/PowerResource.h>
#include <AVSCommon/Utils/HTTP2/HTTP2MimeRequestSourceInterface.h>
#include <AVSCommon/Utils/Metrics/MetricRecorderInterface.h>

Expand Down Expand Up @@ -55,16 +56,18 @@ class MessageRequestHandler
* @param attachmentManager Where to get attachments to write to.
* @param metricRecorder The metric recorder.
* @param eventTracer The object to trace events sent to AVS.
* @param powerResource The optional @c PowerResource to prevent device from going into LPM.
* @return A new MessageRequestHandler or nullptr if the operation fails.
*/
static std::shared_ptr<MessageRequestHandler> create(
std::shared_ptr<ExchangeHandlerContextInterface> context,
const std::string& authToken,
std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
std::shared_ptr<MessageConsumerInterface> messageConsumer,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager,
std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer = nullptr);
std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer = nullptr,
const std::shared_ptr<avsCommon::utils::power::PowerResource>& powerResource = nullptr);

/// @name HTTP2MimeRequestSourceInterface methods
/// @{
Expand All @@ -88,12 +91,14 @@ class MessageRequestHandler
* @param authToken The token to use to authorize the request.
* @param messageRequest The MessageRequest to send.
* @param metricRecorder The metric recorder.
* @param powerResource The pointer to @c PowerResource to prevent device from going into LPM.
*/
MessageRequestHandler(
std::shared_ptr<ExchangeHandlerContextInterface> context,
const std::string& authToken,
std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder);
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
const std::shared_ptr<avsCommon::utils::power::PowerResource>& powerResource);

/**
* Notify the associated HTTP2Transport instance that the message request failed or was acknowledged by AVS.
Expand Down Expand Up @@ -134,6 +139,9 @@ class MessageRequestHandler

/// Response code received through @c onReceiveResponseCode (or zero).
long m_responseCode;

/// The reference to @c PowerResource to prevent device from going into LPM.
std::shared_ptr<avsCommon::utils::power::PowerResource> m_powerResource;
};

} // namespace acl
Expand Down
Loading

0 comments on commit 6840059

Please sign in to comment.