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

Commit b32be0a

Browse files
committed
Version 3.0.0 alexa-client-sdk
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)
1 parent 7f9b5b7 commit b32be0a

File tree

1,909 files changed

+255921
-33966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,909 files changed

+255921
-33966
lines changed

ACL/include/ACL/Transport/MessageRequestHandler.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class MessageRequestHandler
115115
* Record a stream metric once when a specific threshold of bytes have been read from the stream.
116116
* The stream metric name and threshold will be specified in the MessageRequest.
117117
*/
118-
void recordStreamMetric(int bytes);
118+
void recordStreamMetric(std::size_t bytes);
119119

120120
/**
121121
* Record the metric that specifics the start of sending the Message Event to the cloud.
@@ -159,7 +159,7 @@ class MessageRequestHandler
159159
avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status m_resultStatus;
160160

161161
/// The number of bytes that have been read from the stream.
162-
unsigned int m_streamBytesRead;
162+
std::size_t m_streamBytesRead;
163163

164164
/// If the stream metric has already been recorded.
165165
bool m_recordedStreamMetric;

ACL/include/ACL/Transport/MessageRouterFactory.h

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace alexaClientSDK {
2323
namespace acl {
2424

25-
using namespace alexaClientSDK::acl;
2625
using namespace avsCommon::sdkInterfaces;
2726
using namespace avsCommon::avs::attachment;
2827

ACL/include/ACL/Transport/MessageRouterFactoryInterface.h

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace alexaClientSDK {
2323
namespace acl {
2424

25-
using namespace alexaClientSDK::acl;
2625
using namespace avsCommon::sdkInterfaces;
2726
using namespace avsCommon::avs::attachment;
2827

ACL/src/AVSConnectionManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace acl {
2626
using namespace alexaClientSDK::avsCommon::sdkInterfaces;
2727

2828
/// String to identify log entries originating from this file.
29-
static const std::string TAG("AVSConnectionManager");
29+
#define TAG "AVSConnectionManager"
3030

3131
/**
3232
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/DownchannelHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static const std::string DOWNCHANNEL_ID_PREFIX = "AVSDownChannel-";
4343
static const std::chrono::seconds ESTABLISH_CONNECTION_TIMEOUT = std::chrono::seconds(60);
4444

4545
/// String to identify log entries originating from this file.
46-
static const std::string TAG("DownchannelHandler");
46+
#define TAG "DownchannelHandler"
4747

4848
/// String to identify the metric source prefix for @c DownChannelHandler.
4949
static const std::string METRIC_SOURCE_PREFIX = "DOWNCHANNEL_HANDLER-";

ACL/src/Transport/ExchangeHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace acl {
2727
static const std::string AUTHORIZATION_HEADER = "Authorization: Bearer ";
2828

2929
/// String to identify log entries originating from this file.
30-
static const std::string TAG("ExchangeHandler");
30+
#define TAG "ExchangeHandler"
3131

3232
/**
3333
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/HTTP2Transport.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using namespace avsCommon::utils::metrics;
4343
using namespace avsCommon::utils::power;
4444

4545
/// String to identify log entries originating from this file.
46-
static const std::string TAG("HTTP2Transport");
46+
#define TAG "HTTP2Transport"
4747

4848
/**
4949
* Create a LogEntry using this file's TAG and the specified event string.
@@ -288,10 +288,10 @@ HTTP2Transport::HTTP2Transport(
288288
m_disconnectReason{ConnectionStatusObserverInterface::ChangedReason::NONE} {
289289
m_observers.insert(transportObserver);
290290

291-
m_mainLoopPowerResource = PowerMonitor::getInstance()->createLocalPowerResource(TAG + "_mainLoop");
291+
m_mainLoopPowerResource = PowerMonitor::getInstance()->createLocalPowerResource(TAG "_mainLoop");
292292

293293
m_requestActivityPowerResource =
294-
PowerMonitor::getInstance()->createLocalPowerResource(TAG + "_requestActivityResource");
294+
PowerMonitor::getInstance()->createLocalPowerResource(TAG "_requestActivityResource");
295295

296296
if (m_mainLoopPowerResource) {
297297
m_mainLoopPowerResource->acquire();
@@ -772,6 +772,8 @@ HTTP2Transport::State HTTP2Transport::handlePostConnecting() {
772772
}
773773
}
774774

775+
ACSDK_INFO(LX_P("handlePostConnecting").m("completing"));
776+
775777
return sendMessagesAndPings(State::POST_CONNECTING, m_requestQueue);
776778
}
777779

ACL/src/Transport/HTTP2TransportFactory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace avsCommon::sdkInterfaces;
2727
using namespace avsCommon::avs::attachment;
2828

2929
/// String to identify log entries originating from this file.
30-
static const std::string TAG("HTTP2TransportFactory");
30+
#define TAG "HTTP2TransportFactory"
3131

3232
/**
3333
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/MessageRequestHandler.cpp

+38-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
namespace alexaClientSDK {
3333
namespace acl {
3434

35+
using namespace avsCommon::avs;
3536
using namespace avsCommon::avs::attachment;
3637
using namespace avsCommon::sdkInterfaces;
3738
using namespace avsCommon::utils::http;
@@ -66,7 +67,7 @@ static const std::string ATTACHMENT_CONTENT_TYPE = "Content-Type: application/oc
6667
static const std::string MESSAGEREQUEST_ID_PREFIX = "AVSEvent-";
6768

6869
/// String to identify log entries originating from this file.
69-
static const std::string TAG("MessageRequestHandler");
70+
#define TAG "MessageRequestHandler"
7071

7172
/// Prefix used to identify metrics published by this module.
7273
static const std::string ACL_METRIC_SOURCE_PREFIX = "ACL-";
@@ -92,9 +93,18 @@ static const std::string SEND_COMPLETED = "SEND_COMPLETED";
9293
/// Metric identifier for message send error.
9394
static const std::string MESSAGE_SEND_ERROR = "ERROR.MESSAGE_SEND_FAILED";
9495

95-
// Key value separator for HTTP headers
96+
/// Key value separator for HTTP headers
9697
static const std::string HTTP_KEY_VALUE_SEPARATOR = ": ";
9798

99+
/// Event header key for the namespace field.
100+
static const std::string EVENT_HEADER_NAMESPACE = "namespace";
101+
102+
/// Event header key for the name field.
103+
static const std::string EVENT_HEADER_NAME = "name";
104+
105+
/// Event header missing.
106+
static const std::string EVENT_HEADER_MISSING = "EVENT_HEADER_MISSING";
107+
98108
/**
99109
* Create a LogEntry using this file's TAG and the specified event string.
100110
*
@@ -131,10 +141,12 @@ static void collectSendDataResultMetric(
131141
*
132142
* @param metricRecorder The metric recorder object.
133143
* @param status The @c MessageRequestObserverInterface::Status of the message.
144+
* @param messageRequest The @c MessageRequest object.
134145
*/
135146
static void submitMessageSendErrorMetric(
136147
const std::shared_ptr<MetricRecorderInterface>& metricRecorder,
137-
MessageRequestObserverInterface::Status status) {
148+
MessageRequestObserverInterface::Status status,
149+
const std::shared_ptr<MessageRequest>& messageRequest) {
138150
if (!metricRecorder) {
139151
return;
140152
}
@@ -155,11 +167,27 @@ static void submitMessageSendErrorMetric(
155167
return;
156168
}
157169

158-
auto metricEvent = MetricEventBuilder{}
159-
.setActivityName(ACL_METRIC_SOURCE_PREFIX + MESSAGE_SEND_ERROR)
160-
.addDataPoint(DataPointCounterBuilder{}.setName(ss.str()).increment(1).build())
161-
.build();
162-
170+
auto metricEventBuilder = MetricEventBuilder{}
171+
.setActivityName(ACL_METRIC_SOURCE_PREFIX + MESSAGE_SEND_ERROR)
172+
.addDataPoint(DataPointCounterBuilder{}.setName(ss.str()).increment(1).build());
173+
if (messageRequest) {
174+
auto eventHeaders = messageRequest->retrieveEventHeaders();
175+
if (!eventHeaders.eventNamespace.empty()) {
176+
metricEventBuilder.addDataPoint(
177+
DataPointStringBuilder{}.setName(EVENT_HEADER_NAMESPACE).setValue(eventHeaders.eventNamespace).build());
178+
} else {
179+
metricEventBuilder.addDataPoint(
180+
DataPointStringBuilder{}.setName(EVENT_HEADER_NAMESPACE).setValue(EVENT_HEADER_MISSING).build());
181+
}
182+
if (!eventHeaders.eventName.empty()) {
183+
metricEventBuilder.addDataPoint(
184+
DataPointStringBuilder{}.setName(EVENT_HEADER_NAME).setValue(eventHeaders.eventName).build());
185+
} else {
186+
metricEventBuilder.addDataPoint(
187+
DataPointStringBuilder{}.setName(EVENT_HEADER_NAME).setValue(EVENT_HEADER_MISSING).build());
188+
}
189+
}
190+
auto metricEvent = metricEventBuilder.build();
163191
if (!metricEvent) {
164192
ACSDK_ERROR(LX("submitErrorMetricFailed").d("reason", "invalid metric event"));
165193
return;
@@ -168,7 +196,7 @@ static void submitMessageSendErrorMetric(
168196
recordMetric(metricRecorder, metricEvent);
169197
}
170198

171-
void MessageRequestHandler::recordStreamMetric(int bytes) {
199+
void MessageRequestHandler::recordStreamMetric(std::size_t bytes) {
172200
if (m_messageRequest == nullptr) {
173201
return;
174202
}
@@ -506,7 +534,7 @@ void MessageRequestHandler::onResponseFinished(HTTP2ResponseFinishedStatus statu
506534

507535
m_messageRequest->sendCompleted(m_resultStatus);
508536

509-
submitMessageSendErrorMetric(m_metricRecorder, m_resultStatus);
537+
submitMessageSendErrorMetric(m_metricRecorder, m_resultStatus, m_messageRequest);
510538
}
511539

512540
} // namespace acl

ACL/src/Transport/MessageRequestQueue.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace acl {
2424
using namespace avsCommon::avs;
2525

2626
/// String to identify log entries originating from this file.
27-
static const std::string TAG("MessageRequestQueue");
27+
#define TAG "MessageRequestQueue"
2828

2929
/**
3030
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/MessageRouter.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace avsCommon::avs::attachment;
3131
using namespace avsCommon::avs;
3232

3333
/// String to identify log entries originating from this file.
34-
static const std::string TAG("MessageRouter");
34+
#define TAG "MessageRouter"
3535

3636
/// String for logging purpose as the key for the size of m_transports.
3737
static constexpr const char* KEY_SIZEOF_TRANSPORTS = "sizeOf m_transports";
@@ -316,7 +316,7 @@ void MessageRouter::notifyObserverOnConnectionStatusChanged(
316316
m_serverSideDisconnectNotificationPending = true;
317317
m_serverSideDisconnectTimer.start(m_serverSideReconnectGracePeriod, [this]() {
318318
ACSDK_DEBUG0(LX("serverSideDisconectTimerPredicate"));
319-
m_executor.submit([this]() {
319+
m_executor.execute([this]() {
320320
ACSDK_DEBUG0(
321321
LX("serverSideDisconectTimerHandler")
322322
.d("m_serverSideDisconnectNotificationPending", m_serverSideDisconnectNotificationPending));
@@ -335,7 +335,7 @@ void MessageRouter::notifyObserverOnConnectionStatusChanged(
335335
handleNotifyObserverOnConnectionStatusChanged(status, reason);
336336
}
337337
};
338-
m_executor.submit(task);
338+
m_executor.execute(task);
339339
}
340340

341341
void MessageRouter::handleNotifyObserverOnConnectionStatusChanged(
@@ -360,7 +360,7 @@ void MessageRouter::notifyObserverOnReceive(const std::string& contextId, const
360360
temp->receive(contextId, message);
361361
}
362362
};
363-
m_executor.submit(task);
363+
m_executor.execute(task);
364364
}
365365

366366
void MessageRouter::createActiveTransportLocked() {
@@ -428,7 +428,7 @@ void MessageRouter::safelyResetActiveTransportLocked() {
428428
void MessageRouter::safelyReleaseTransport(std::shared_ptr<TransportInterface> transport) {
429429
if (transport) {
430430
auto task = [transport]() { transport->shutdown(); };
431-
m_executor.submit(task);
431+
m_executor.execute(task);
432432
}
433433
}
434434

ACL/src/Transport/MessageRouterFactory.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
namespace alexaClientSDK {
2121
namespace acl {
2222

23-
using namespace alexaClientSDK::acl;
2423
using namespace avsCommon::sdkInterfaces;
2524
using namespace avsCommon::avs::attachment;
2625

ACL/src/Transport/MimeResponseSink.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static const std::string MIME_OCTET_STREAM_CONTENT_TYPE = "application/octet-str
4747
static const size_t NON_MIME_BODY_MAX_SIZE = 4096;
4848

4949
/// String to identify log entries originating from this file.
50-
static const std::string TAG("MimeResponseSink");
50+
#define TAG "MimeResponseSink"
5151

5252
/**
5353
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/PingHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static const uint8_t PING_PRIORITY = 200;
4040
static const std::string PING_ID_PREFIX = "AVSPing-";
4141

4242
/// String to identify log entries originating from this file.
43-
static const std::string TAG("PingHandler");
43+
#define TAG "PingHandler"
4444

4545
/**
4646
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/PostConnectSequencer.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace avsCommon::utils::error;
2727
using namespace avsCommon::utils::power;
2828

2929
/// String to identify log entries originating form this file.
30-
static const std::string TAG("PostConnectSequencer");
30+
#define TAG "PostConnectSequencer"
3131

3232
/**
3333
* Create a LogEntry using this file's TAG and the specified event string.
@@ -50,24 +50,24 @@ std::shared_ptr<PostConnectSequencer> PostConnectSequencer::create(
5050
PostConnectSequencer::PostConnectSequencer(const PostConnectOperationsSet& postConnectOperations) :
5151
m_isStopping{false},
5252
m_postConnectOperations{postConnectOperations} {
53-
ACSDK_DEBUG5(LX("init"));
53+
ACSDK_INFO(LX("init"));
5454

55-
m_mainLoopPowerResource = PowerMonitor::getInstance()->createLocalPowerResource(TAG + "_mainLoop");
55+
m_mainLoopPowerResource = PowerMonitor::getInstance()->createLocalPowerResource(TAG "_mainLoop");
5656

5757
if (m_mainLoopPowerResource) {
5858
m_mainLoopPowerResource->acquire();
5959
}
6060
}
6161

6262
PostConnectSequencer::~PostConnectSequencer() {
63-
ACSDK_DEBUG5(LX("destroy"));
63+
ACSDK_INFO(LX("destroy"));
6464
stop();
6565
}
6666

6767
bool PostConnectSequencer::doPostConnect(
6868
std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> postConnectSender,
6969
std::shared_ptr<PostConnectObserverInterface> postConnectObserver) {
70-
ACSDK_DEBUG5(LX("doPostConnect"));
70+
ACSDK_INFO(LX("doPostConnect"));
7171

7272
if (!postConnectSender) {
7373
ACSDK_ERROR(LX("doPostConnectFailed").d("reason", "nullPostConnectSender"));
@@ -94,7 +94,7 @@ bool PostConnectSequencer::doPostConnect(
9494
void PostConnectSequencer::mainLoop(
9595
std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> postConnectSender,
9696
std::shared_ptr<PostConnectObserverInterface> postConnectObserver) {
97-
ACSDK_DEBUG5(LX("mainLoop"));
97+
ACSDK_INFO(LX("mainLoop"));
9898

9999
PowerMonitor::getInstance()->assignThreadPowerResource(m_mainLoopPowerResource);
100100

@@ -144,11 +144,11 @@ void PostConnectSequencer::mainLoop(
144144
postConnectObserver->onPostConnected();
145145
}
146146

147-
ACSDK_DEBUG5(LX("mainLoopReturning"));
147+
ACSDK_INFO(LX("mainLoopReturning"));
148148
}
149149

150150
void PostConnectSequencer::onDisconnect() {
151-
ACSDK_DEBUG5(LX("onDisconnect"));
151+
ACSDK_INFO(LX("onDisconnect"));
152152
stop();
153153
}
154154

@@ -163,7 +163,7 @@ bool PostConnectSequencer::isStopping() {
163163
}
164164

165165
void PostConnectSequencer::stop() {
166-
ACSDK_DEBUG5(LX("stop"));
166+
ACSDK_INFO(LX("stop"));
167167
{
168168
std::lock_guard<std::mutex> lock{m_mutex};
169169
if (m_isStopping) {

ACL/src/Transport/PostConnectSequencerFactory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace avsCommon::sdkInterfaces;
2727
using namespace acsdkPostConnectOperationProviderRegistrarInterfaces;
2828

2929
/// String to identify log entries originating from this file.
30-
static const std::string TAG("PostConnectSequencerFactory");
30+
#define TAG "PostConnectSequencerFactory"
3131

3232
/**
3333
* Create a LogEntry using this file's TAG and the specified event string.

ACL/src/Transport/SynchronizedMessageRequestQueue.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace acl {
2424
using namespace avsCommon::avs;
2525

2626
/// String to identify log entries originating from this file.
27-
static const std::string TAG("SynchronizedMessageRequestQueue");
27+
#define TAG "SynchronizedMessageRequestQueue"
2828

2929
/**
3030
* Create a LogEntry using this file's TAG and the specified event string.

ACL/test/Transport/Common/MockHTTP2Connection.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ std::shared_ptr<HTTP2RequestInterface> MockHTTP2Connection::createAndSendRequest
5555

5656
if (request->getRequestType() == HTTP2RequestType::POST) {
5757
// Parse POST HTTP2 Requests.
58-
std::lock_guard<std::mutex> lock(m_postRequestMutex);
58+
std::lock_guard<std::mutex> innerLock(m_postRequestMutex);
5959
m_postRequestQueue.push_back(request);
6060
if (m_postResponseCode != HTTPResponseCode::HTTP_RESPONSE_CODE_UNDEFINED) {
6161
request->getSink()->onReceiveResponseCode(responseCodeToInt(m_postResponseCode));
@@ -66,12 +66,12 @@ std::shared_ptr<HTTP2RequestInterface> MockHTTP2Connection::createAndSendRequest
6666
m_requestPostCv.notify_one();
6767
} else if (m_downchannelURL == request->getUrl()) {
6868
// Push downchannel requests to its queue.
69-
std::lock_guard<std::mutex> lock(m_downchannelRequestMutex);
69+
std::lock_guard<std::mutex> innerLock(m_downchannelRequestMutex);
7070
m_downchannelRequestQueue.push_back(request);
7171
m_downchannelRequestCv.notify_all();
7272
} else if (m_pingURL == request->getUrl()) {
7373
// Push ping requests to its queue.
74-
std::lock_guard<std::mutex> lock(m_pingRequestMutex);
74+
std::lock_guard<std::mutex> innerLock(m_pingRequestMutex);
7575
m_pingRequestQueue.push_back(request);
7676
m_pingRequestCv.notify_one();
7777
}

0 commit comments

Comments
 (0)