AlexaClientSDK  1.19.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent Class Reference

#include <AlertsCapabilityAgent.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent:
Collaboration graph
[legend]

Public Member Functions

void addObserver (std::shared_ptr< AlertObserverInterface > observer)
 
void removeObserver (std::shared_ptr< AlertObserverInterface > observer)
 
void removeAllAlerts ()
 
void onLocalStop ()
 
void clearData () override
 
CapabilityAgent Functions
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration () const override
 
void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
 
void preHandleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void handleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void cancelDirective (std::shared_ptr< DirectiveInfo > info) override
 
void onDeregistered () override
 
void onConnectionStatusChanged (const Status status, const ChangedReason reason) override
 
void onFocusChanged (avsCommon::avs::FocusState focusState, avsCommon::avs::MixingBehavior behavior) override
 
void onAlertStateChange (const std::string &token, const std::string &alertType, AlertObserverInterface::State state, const std::string &reason) override
 
FocusManagerObserverInterface Functions
void onFocusChanged (const std::string &channelName, avsCommon::avs::FocusState newFocus) override
 
CapabilityConfigurationInterface Functions
std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > getCapabilityConfigurations () override
 
SpeakerManagerObserverInterface Functions
void onSpeakerSettingsChanged (const Source &source, const avsCommon::sdkInterfaces::ChannelVolumeInterface::Type &type, const avsCommon::sdkInterfaces::SpeakerInterface::SpeakerSettings &settings) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
virtual ~CapabilityAgent ()=default
 
void preHandleDirective (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) override final
 
bool handleDirective (const std::string &messageId) override final
 
void cancelDirective (const std::string &messageId) override final
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface
virtual ~DirectiveHandlerInterface ()=default
 
virtual void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive)=0
 
virtual void preHandleDirective (std::shared_ptr< avsCommon::avs::AVSDirective > directive, std::unique_ptr< DirectiveHandlerResultInterface > result)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ChannelObserverInterface
virtual ~ChannelObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface
virtual ~StateProviderInterface ()=default
 
virtual void provideState (const avs::NamespaceAndName &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual void provideState (const avs::CapabilityTag &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual bool canStateBeRetrieved ()
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface
virtual ~ContextRequesterInterface ()=default
 
virtual void onContextAvailable (const std::string &jsonContext)
 
virtual void onContextAvailable (const endpoints::EndpointIdentifier &endpointId, const avs::AVSContext &endpointContext, ContextRequestToken requestToken)
 
virtual void onContextFailure (const ContextRequestError error)
 
virtual void onContextFailure (const ContextRequestError error, ContextRequestToken token)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
virtual ~ConnectionStatusObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface
virtual ~CapabilityConfigurationInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeakerManagerObserverInterface
virtual ~SpeakerManagerObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerObserverInterface
virtual ~FocusManagerObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::capabilityAgents::alerts::AlertObserverInterface
virtual ~AlertObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
 
virtual ~RequiresShutdown ()
 Destructor. More...
 
const std::string & name () const
 
void shutdown ()
 
bool isShutdown () const
 
- Public Member Functions inherited from alexaClientSDK::registrationManager::CustomerDataHandler
 CustomerDataHandler (std::shared_ptr< CustomerDataManager > customerDataManager)
 
virtual ~CustomerDataHandler ()
 

Static Public Member Functions

static std::shared_ptr< AlertsCapabilityAgentcreate (std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< avsCommon::sdkInterfaces::AVSConnectionManagerInterface > connectionManager, std::shared_ptr< certifiedSender::CertifiedSender > certifiedMessageSender, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerManagerInterface > speakerManager, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender, std::shared_ptr< storage::AlertStorageInterface > alertStorage, std::shared_ptr< avsCommon::sdkInterfaces::audio::AlertsAudioFactoryInterface > alertsAudioFactory, std::shared_ptr< renderer::RendererInterface > alertRenderer, std::shared_ptr< registrationManager::CustomerDataManager > dataManager, std::shared_ptr< settings::AlarmVolumeRampSetting > alarmVolumeRampSetting, std::shared_ptr< settings::DeviceSettingsManager > settingsManager, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder)
 
static settings::SettingEventMetadata getAlarmVolumeRampMetadata ()
 
- Static Public Member Functions inherited from alexaClientSDK::capabilityAgents::alerts::AlertObserverInterface
static std::string stateToString (State state)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
enum  Status { Status::DISCONNECTED, Status::PENDING, Status::CONNECTED }
 
enum  ChangedReason {
  ChangedReason::NONE, ChangedReason::SUCCESS, ChangedReason::UNRECOVERABLE_ERROR, ChangedReason::ACL_CLIENT_REQUEST,
  ChangedReason::ACL_DISABLED, ChangedReason::DNS_TIMEDOUT, ChangedReason::CONNECTION_TIMEDOUT, ChangedReason::CONNECTION_THROTTLED,
  ChangedReason::INVALID_AUTH, ChangedReason::PING_TIMEDOUT, ChangedReason::WRITE_TIMEDOUT, ChangedReason::READ_TIMEDOUT,
  ChangedReason::FAILURE_PROTOCOL_ERROR, ChangedReason::INTERNAL_ERROR, ChangedReason::SERVER_INTERNAL_ERROR, ChangedReason::SERVER_SIDE_DISCONNECT,
  ChangedReason::SERVER_ENDPOINT_CHANGED
}
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeakerManagerObserverInterface
enum  Source { Source::DIRECTIVE, Source::LOCAL_API }
 Indicates whether the source of the call is from an AVS Directive or through a Local API call. More...
 
- Public Types inherited from alexaClientSDK::capabilityAgents::alerts::AlertObserverInterface
enum  State {
  State::READY, State::STARTED, State::STOPPED, State::SNOOZED,
  State::COMPLETED, State::PAST_DUE, State::FOCUS_ENTERED_FOREGROUND, State::FOCUS_ENTERED_BACKGROUND,
  State::ERROR, State::DELETED, State::SCHEDULED_FOR_LATER
}
 
- Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
 CapabilityAgent (const std::string &nameSpace, std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender)
 
virtual std::shared_ptr< DirectiveInfocreateDirectiveInfo (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result)
 
void removeDirective (const std::string &messageId)
 
void sendExceptionEncounteredAndReportFailed (std::shared_ptr< DirectiveInfo > info, const std::string &message, avsCommon::avs::ExceptionErrorType type=avsCommon::avs::ExceptionErrorType::INTERNAL_ERROR)
 
const std::pair< std::string, std::string > buildJsonEventString (const std::string &eventName, const std::string &dialogRequestIdString="", const std::string &payload="{}", const std::string &context="") const
 
- Protected Attributes inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
const std::string m_namespace
 The namespace of the capability agent. More...
 
std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterfacem_exceptionEncounteredSender
 Object to use to send exceptionEncountered messages. More...
 

Detailed Description

This class implements an Alerts capability agent.

Member Function Documentation

◆ addObserver()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::addObserver ( std::shared_ptr< AlertObserverInterface observer)

Adds an observer to be notified of alert status changes.

Parameters
observerThe observer to add.

◆ cancelDirective()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::cancelDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Cancel an ongoing preHandleDirective() or handleDirective() operation for the AVSDirective in . Once this has been called the CapabilityAgent should not expect to receive further calls regarding this directive.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ clearData()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::clearData ( )
overridevirtual

Clear all scheduled alerts.

Implements alexaClientSDK::registrationManager::CustomerDataHandler.

◆ create()

std::shared_ptr< AlertsCapabilityAgent > alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::create ( std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface messageSender,
std::shared_ptr< avsCommon::sdkInterfaces::AVSConnectionManagerInterface connectionManager,
std::shared_ptr< certifiedSender::CertifiedSender certifiedMessageSender,
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface focusManager,
std::shared_ptr< avsCommon::sdkInterfaces::SpeakerManagerInterface speakerManager,
std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface contextManager,
std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface exceptionEncounteredSender,
std::shared_ptr< storage::AlertStorageInterface alertStorage,
std::shared_ptr< avsCommon::sdkInterfaces::audio::AlertsAudioFactoryInterface alertsAudioFactory,
std::shared_ptr< renderer::RendererInterface alertRenderer,
std::shared_ptr< registrationManager::CustomerDataManager dataManager,
std::shared_ptr< settings::AlarmVolumeRampSetting alarmVolumeRampSetting,
std::shared_ptr< settings::DeviceSettingsManager settingsManager,
std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder 
)
static

Create function.

Parameters
messageSenderAn interface to which this object will send Events to AVS.
connectionManagerAn AVSConnectionManagerInterface instance to listen for connection status updates.
certifiedMessageSenderAn interface to which this object will send guaranteed Events to AVS.
focusManagerAn interface with which this object will request and release Alert channel focus.
speakerManagerAn interface to control volume of the Alerts.
contextManagerAn interface to which this object will send context updates as alert states change.
exceptionEncounteredSenderAn interface which allows ExceptionEncountered Events to be sent to AVS.
alertStorageAn interface to store, load, modify and delete Alerts.
alertsAudioFactoryA provider of audio streams specific to Alerts.
alertRendererAn alert renderer, which Alerts will use to generate user-perceivable effects when active.
dataManagerA dataManager object that will track the CustomerDataHandler.
alarmVolumeRampSettingThe alarm volume ramp setting.
settingsManagerA settingsManager object that manages alarm volume ramp setting.
metricRecorderThe metric recorder.
Returns
A pointer to an object of this type, or nullptr if there were problems during construction.

◆ getAlarmVolumeRampMetadata()

settings::SettingEventMetadata alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::getAlarmVolumeRampMetadata ( )
static

Return the alarm volume ramp event metadata.

Returns
The alarm volume ramp event metadata.

◆ getCapabilityConfigurations()

std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::getCapabilityConfigurations ( )
overridevirtual

Returns the configurations of the capability interfaces being implemented.

Returns
A set of CapabilityConfigurations

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface.

◆ getConfiguration()

avsCommon::avs::DirectiveHandlerConfiguration alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::getConfiguration ( ) const
overridevirtual

Returns the configuration of the directive handler.

The configuration consists of multiple directive routing rules and their respective blocking policy. The directives will be matched from the most specific rule (with all fields defined) to the least specific rule (which only matches the directive endpointId).

Returns
The avs::DirectiveHandlerConfiguration of the handler.

Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.

◆ handleDirective()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::handleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Handle the action specified by the AVSDirective in info. The handling of subsequent directives with the same DialogRequestId may be blocked until the DirectiveHandler calls the setSucceeded() method of the DirectiveHandlingResult present in info. If handling of this directive fails setFailed() should be called to indicate a failure.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ handleDirectiveImmediately()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::handleDirectiveImmediately ( std::shared_ptr< avsCommon::avs::AVSDirective directive)
override

◆ onAlertStateChange()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onAlertStateChange ( const std::string &  alertToken,
const std::string &  alertType,
AlertObserverInterface::State  state,
const std::string &  reason 
)
overridevirtual

A callback function to notify an object that an alert has updated its state.

Parameters
alertTokenThe AVS token of the alert.
alertTypeThe type of the alert.
stateThe state of the alert.
reasonThe reason for the state change.

Implements alexaClientSDK::capabilityAgents::alerts::AlertObserverInterface.

◆ onConnectionStatusChanged()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onConnectionStatusChanged ( const Status  status,
const ChangedReason  reason 
)
overridevirtual

Called when the AVS connection state changes.

Parameters
statusThe current connection status.
reasonThe reason the status change occurred.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface.

◆ onDeregistered()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onDeregistered ( )
overridevirtual

Notification that this handler has been de-registered and will not receive any more calls.

Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ onFocusChanged() [1/2]

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onFocusChanged ( avsCommon::avs::FocusState  newFocus,
avsCommon::avs::MixingBehavior  behavior 
)
overridevirtual

Used to notify the observer of the Channel of focus changes. Once called, the client should make a user observable change only and return immediately. Any additional work that needs to be done should be done on a separate thread or after returning. "User observable change" here refers to events that the end user of the product can visibly see or hear. For example, Alexa speech or music playing would be examples of user observable changes. Other work, such as database storing, logging, or communicating via network should be done on a different thread. Not doing so could result in delays for other clients trying to access the Channel.

Parameters
newFocusThe new Focus of the channel.
behaviorThe mixingBehavior for the ChannelObserver to take as per the interrupt model
Note
when newFocus is FocusState::FOREGROUND, the MixingBehavior shall be guaranteed to be PRIMARY when newFocus is FocusState::NONE, the MixingBehavior shall be guaranteed to be MUST_STOP

Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ onFocusChanged() [2/2]

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onFocusChanged ( const std::string &  channelName,
avsCommon::avs::FocusState  newFocus 
)
overridevirtual

Used to notify the observer of focus changes. This function should return quickly.

Parameters
channelNameThe name of the channel which changed FocusState.
newFocusThe new FocusState of channelName.

Implements alexaClientSDK::avsCommon::sdkInterfaces::FocusManagerObserverInterface.

◆ onLocalStop()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onLocalStop ( )

This function provides a way for application code to request this object stop any active alert as the result of a user action, such as pressing a physical 'stop' button on the device.

◆ onSpeakerSettingsChanged()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::onSpeakerSettingsChanged ( const Source source,
const avsCommon::sdkInterfaces::ChannelVolumeInterface::Type type,
const avsCommon::sdkInterfaces::SpeakerInterface::SpeakerSettings settings 
)
overridevirtual

A callback for when the SpeakerInterface::SpeakerSettings successfully changes.

Parameters
source.This indicates the origin of the call.
type.This indicates the type of ChannelVolumeInterface that was modified.
settings.This indicates the current settings after the change.

Implements alexaClientSDK::avsCommon::sdkInterfaces::SpeakerManagerObserverInterface.

◆ preHandleDirective()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::preHandleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Notification that a directive has arrived. This notification gives the DirectiveHandler a chance to prepare for handling of an AVSDirective. If an error occurs during the pre-Handling phase and that error should cancel the handling of subsequent AVSDirectives with the same DialogRequestId, the DirectiveHandler should call the setFailed method on the result instance passed in to this call.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ removeAllAlerts()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::removeAllAlerts ( )

A function that allows an application to clear all alerts from storage. This may be useful for a scenario where a user logs out of a device, and another user will log in. As the first user logs out, their pending alerts should not go off.

◆ removeObserver()

void alexaClientSDK::capabilityAgents::alerts::AlertsCapabilityAgent::removeObserver ( std::shared_ptr< AlertObserverInterface observer)

Removes an observer from being notified of alert status changes.

Parameters
observerThe observer to remove.

The documentation for this class was generated from the following files:

AlexaClientSDK 1.19.0 - Copyright 2016-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0