[Docs] add Docs of dev

This commit is contained in:
wk 2022-10-15 00:12:07 +08:00
parent 3d9918072f
commit ee9e813304
3 changed files with 744 additions and 0 deletions

View File

@ -0,0 +1,505 @@
# 1. 修改根目录编译配置文件 /CMakeLists.txt 增加以下内容
~~~cmake {.line-numbers}
if (COMPANION_APP_AUTH)
add_definitions("-DCOMPANION_APP_AUTH")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(AUTH_APP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extension/avs-app-auth/include" CACHE INTERNAL "")
if (ASPMIC)
add_subdirectory("extension/mic-asp-sdk")
endif()
add_subdirectory("extension/avs-app-auth")
add_subdirectory("extension/avs-msg-sdk")
~~~
# 2. 增加CA认证功能
## 2.1. 修改编译配置文件SampleApp/src/CMakeLists.txt增加CA认证编译配置
~~~cmake {.line-numbers}
# 修改对应代码增加CA认证库
if (COMPANION_APP_AUTH)
target_link_libraries(LibSampleApp
CAAuthDelegate
app_auth
)
else ()
target_link_libraries(LibSampleApp CBLAuthDelegate)
endif ()
~~~
## 2.2. 增加以下目录以及目录下的所有源码文件
* SampleApp/Authorization/CAAuthDelegate/
* applications/acsdkCAAuthorizationDelegate/
* applications\acsdkSampleApplicationCAAuthRequester/
## 2.3. 修改编译配置文件SampleApp/Authorization/CMakeLists.txt 增加CA认证源码支持
~~~cmake {.line-numbers}
if (COMPANION_APP_AUTH)
add_subdirectory("CAAuthDelegate")
else ()
add_subdirectory("CBLAuthDelegate")
endif ()
~~~
## 2.4. 修改编译配置文件applications/CMakeLists.txt 增加CA认证源码支持
### 2.4.1. 删除原配置
~~add_subdirectory("acsdkCBLAuthorizationDelegate")~~
### 2.4.2. 增加以下代码
~~~cmake {.line-numbers}
if (COMPANION_APP_AUTH)
add_subdirectory("acsdkSampleApplicationCAAuthRequester")
add_subdirectory("acsdkCAAuthorizationDelegate")
else ()
add_subdirectory("acsdkSampleApplicationCBLAuthRequester")
add_subdirectory("acsdkCBLAuthorizationDelegate")
endif ()
~~~
## 2.5. 修改编译配置文件applications/acsdkDefaultSampleApplicationOptions/src/CMakeLists.txt 增加CA认证源码支持
~~~cmake {.line-numbers}
target_link_libraries(acsdkDefaultSampleApplicationOptions
acsdkCore
acsdkManufactory
acsdkNullMetricRecorder
acsdkSampleApplicationInterfaces
acsdkShared
)
if (COMPANION_APP_AUTH)
target_link_libraries(acsdkDefaultSampleApplicationOptions
acsdkSampleApplicationCAAuthRequester
CAAuthDelegate
)
else ()
target_link_libraries(acsdkDefaultSampleApplicationOptions
acsdkSampleApplicationCBLAuthRequester
CBLAuthDelegate
)
endif ()
~~~
## 2.6. 修改编译配置文件applications/acsdkPreviewAlexaClient/src/CMakeLists.txt 增加CA认证源码支持
~~~cmake {.line-numbers}
if (COMPANION_APP_AUTH)
SET(ACSDKAUTHORIZATIONDELEGATE_LIB acsdkCAAuthorizationDelegate)
else ()
SET(ACSDKAUTHORIZATIONDELEGATE_LIB acsdkCBLAuthorizationDelegate)
endif ()
~~~
## 2.7. 修改编译配置文件cmakeBuild/cmake/DefaultLibNames.cmake 增加CA认证源码支持
~~~cmake {.line-numbers}
if (COMPANION_APP_AUTH)
UseDefaultIfNotSet(ACSDKAUTHORIZATIONDELEGATE_LIB acsdkCAAuthorizationDelegate)
elseif()
UseDefaultIfNotSet(ACSDKAUTHORIZATIONDELEGATE_LIB acsdkCBLAuthorizationDelegate)
endif()
~~~
## 2.8. 修改源码
### 2.8.1. applications/acsdkDefaultSampleApplicationOptions/include/acsdkDefaultSampleApplicationOptions/DefaultSampleApplicationOptionsComponent.h
~~~cpp {.line-numbers}
#ifdef COMPANION_APP_AUTH
#include <CAAuthDelegate/CAAuthRequesterInterface.h>
#else
#include <CBLAuthDelegate/CBLAuthRequesterInterface.h>
#endif
......
using SampleApplicationOptionsComponent = acsdkManufactory::Component<
std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>,
std::shared_ptr<avsCommon::utils::logger::Logger>,
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>,
#ifdef COMPANION_APP_AUTH
acsdkManufactory::Import<std::shared_ptr<authorization::caAuthDelegate::CAAuthRequesterInterface>>,
#else
acsdkManufactory::Import<std::shared_ptr<authorization::cblAuthDelegate::CBLAuthRequesterInterface>>,
#endif
acsdkManufactory::Import<std::unique_ptr<avsCommon::utils::libcurlUtils::HttpPostInterface>>,
acsdkManufactory::Import<std::shared_ptr<avsCommon::utils::DeviceInfo>>,
acsdkManufactory::Import<std::shared_ptr<registrationManager::CustomerDataManagerInterface>>,
acsdkManufactory::Import<std::shared_ptr<acsdkCryptoInterfaces::CryptoFactoryInterface>>,
acsdkManufactory::Import<std::shared_ptr<acsdkCryptoInterfaces::KeyStoreInterface>>>;
~~~
### 2.8.2. applications/acsdkDefaultSampleApplicationOptions/src/DefaultSampleApplicationOptionsComponent.cpp
~~~cpp {.line-numbers}
#ifdef COMPANION_APP_AUTH
#include <CAAuthDelegate/CAAuthDelegate.h>
#include <CAAuthDelegate/SQLiteCAAuthDelegateStorage.h>
#else
#include <CBLAuthDelegate/CBLAuthDelegate.h>
#include <CBLAuthDelegate/SQLiteCBLAuthDelegateStorage.h>
#endif
......
#ifdef COMPANION_APP_AUTH
using namespace authorization::caAuthDelegate;
#else
using namespace authorization::cblAuthDelegate;
#endif
......
static acsdkManufactory::Component<
std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>,
#ifdef COMPANION_APP_AUTH
acsdkManufactory::Import<std::shared_ptr<authorization::caAuthDelegate::CAAuthRequesterInterface>>,
#else
acsdkManufactory::Import<std::shared_ptr<authorization::cblAuthDelegate::CBLAuthRequesterInterface>>,
#endif
acsdkManufactory::Import<std::shared_ptr<avsCommon::utils::DeviceInfo>>,
acsdkManufactory::Import<std::shared_ptr<avsCommon::utils::configuration::ConfigurationNode>>,
acsdkManufactory::Import<std::unique_ptr<avsCommon::utils::libcurlUtils::HttpPostInterface>>,
acsdkManufactory::Import<std::shared_ptr<registrationManager::CustomerDataManagerInterface>>,
acsdkManufactory::Import<std::shared_ptr<acsdkCryptoInterfaces::CryptoFactoryInterface>>,
acsdkManufactory::Import<std::shared_ptr<acsdkCryptoInterfaces::KeyStoreInterface>>>
......
return ComponentAccumulator<>()
#ifdef COMPANION_APP_AUTH
.addRetainedFactory(CAAuthDelegate::createAuthDelegateInterface)
.addRetainedFactory(SQLiteCAAuthDelegateStorage::createCAAuthDelegateStorageInterface);
#else
.addRetainedFactory(CBLAuthDelegate::createAuthDelegateInterface)
.addRetainedFactory(SQLiteCBLAuthDelegateStorage::createCBLAuthDelegateStorageInterface);
#endif
}
~~~
### 2.8.3. applications/acsdkPreviewAlexaClient/include/acsdkPreviewAlexaClient/PreviewAlexaClientComponent.h
~~~cpp {.line-numbers}
#ifdef COMPANION_APP_AUTH
#include <CAAuthDelegate/CAAuthDelegateStorageInterface.h>
#include <CAAuthDelegate/CAAuthRequesterInterface.h>
#else
#include <CBLAuthDelegate/CBLAuthDelegateStorageInterface.h>
#include <CBLAuthDelegate/CBLAuthRequesterInterface.h>
#endif
~~~
### 2.8.4. applications/acsdkPreviewAlexaClient/src/PreviewAlexaClientComponent.cpp
~~~cpp {.line-numbers}
#ifdef COMPANION_APP_AUTH
#include <acsdkSampleApplicationCAAuthRequester/SampleApplicationCAAuthRequester.h>
#else
#include <acsdkSampleApplicationCBLAuthRequester/SampleApplicationCBLAuthRequester.h>
#endif
......
#ifdef COMPANION_APP_AUTH
using namespace acsdkSampleApplicationCAAuthRequester;
#else
using namespace acsdkSampleApplicationCBLAuthRequester;
#endif
......
.addRetainedFactory(createUIManagerInterface)
.addRetainedFactory(defaultClient::EqualizerRuntimeSetup::createEqualizerRuntimeSetupInterface)
.addRequiredFactory(sampleApp::CaptionPresenter::createCaptionPresenterInterface)
.addRetainedFactory(sampleApp::LocaleAssetsManager::createLocaleAssetsManagerInterface)
.addRetainedFactory(sampleApp::SampleEqualizerModeController::createEqualizerModeControllerInterface)
.addRetainedFactory(sampleApp::UIManager::create)
#ifdef COMPANION_APP_AUTH
.addUnloadableFactory(SampleApplicationCAAuthRequester::createCAAuthRequesterInterface)
#else
.addUnloadableFactory(SampleApplicationCBLAuthRequester::createCBLAuthRequesterInterface)
#endif
/// SQLite implementations of databases used by Capability Agents and other components.
/// Applications may choose to replace these with their own database implementations.
.addRetainedFactory(acsdkAlerts::storage::SQLiteAlertStorage::createAlertStorageInterface)
.addRetainedFactory(acsdkBluetooth::SQLiteBluetoothStorage::createBluetoothStorageInterface)
.addRetainedFactory(acsdkNotifications::SQLiteNotificationsStorage::createNotificationsStorageInterface)
.addRetainedFactory(certifiedSender::SQLiteMessageStorage::createMessageStorageInterface)
~~~
### 2.8.5. AVSCommon/SDKInterfaces/include/AVSCommon/SDKInterfaces/AuthObserverInterface.h
~~~cpp {.line-numbers}
AUTHORIZATION_PENDING,
/// Client should slow down in the rate of requests polling for an access token.
SLOW_DOWN,
/// Internal error in client code.
INTERNAL_ERROR,
/// Client ID not valid for use with code based linking.
INVALID_CLIENT_ID
};
......
case AuthObserverInterface::Error::AUTHORIZATION_PENDING:
return stream << "AUTHORIZATION_PENDING";
case AuthObserverInterface::Error::SLOW_DOWN:
return stream << "SLOW_DOWN";
case AuthObserverInterface::Error::INTERNAL_ERROR:
return stream << "INTERNAL_ERROR";
case AuthObserverInterface::Error::INVALID_CLIENT_ID:
return stream << "INVALID_CLIENT_ID";
}
~~~
### 2.8.6. core/Authorization/acsdkAuthorization/include/acsdkAuthorization/LWA/LWAAuthorizationAdapter.h
~~~cpp {.line-numbers}
#ifdef COMPANION_APP_AUTH
bool authorizeUsingCA(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CAAuthorizationObserverInterface>& observer) override;
bool authorizeUsingCAWithCustomerProfile(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CAAuthorizationObserverInterface>& observer) override;
#else
bool authorizeUsingCBL(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CBLAuthorizationObserverInterface>& observer) override;
bool authorizeUsingCBLWithCustomerProfile(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CBLAuthorizationObserverInterface>& observer) override;
#endif
......
#ifdef COMPANION_APP_AUTH
bool authorizeUsingCAHelper(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CAAuthorizationObserverInterface>& observer,
bool requestCustomerProfile);
#else
bool authorizeUsingCBLHelper(
const std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CBLAuthorizationObserverInterface>& observer,
bool requestCustomerProfile);
#endif
......
/// The interval to make token requests to LWA.
std::chrono::seconds m_tokenRequestInterval;
/// The observer that will respond to CBL related callbacks.
#ifdef COMPANION_APP_AUTH
std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CAAuthorizationObserverInterface> m_cblRequester;
#else
std::shared_ptr<acsdkAuthorizationInterfaces::lwa::CBLAuthorizationObserverInterface> m_cblRequester;
#endif
/// Whether to request extended customer profile information such as name and email.
bool m_requestCustomerProfile;
/// @}
/// True if an authorization failure was reported for the current value of m_accessToken.
bool m_authFailureReported;
~~~
### 2.8.7. core/Authorization/acsdkAuthorization/include/acsdkAuthorization/LWA/LWAAuthorizationConfiguration.h
~~~cpp {.line-numbers}
* @return The URL to use when getting the user profile.
*/
std::string getCustomerProfileUrl() const;
std::string getManufacturerName() const;
std::string getDescription() const;
private:
/**
* Initialize the new instance.
*
* @param root The root level node of the raw configuration from which to populate this instance.
* @param deviceInfo The deviceInfo instance.
~~~
### 2.8.8. core/Authorization/acsdkAuthorization/src/LWA/LWAAuthorizationAdapter.cpp
~~~cpp {.line-numbers}
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CLIENT_ID:
return result;
// Retry Errors
case AuthObserverInterface::Error::UNKNOWN_ERROR:
......
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CLIENT_ID:
return result;
/// Retriable errors.
case AuthObserverInterface::Error::SLOW_DOWN:
......
case AuthObserverInterface::Error::INVALID_REQUEST:
if (!m_refreshTokenResponse.isRefreshTokenVerified) {
error = AuthObserverInterface::Error::INVALID_CLIENT_ID;
}
// Falls through
case AuthObserverInterface::Error::AUTHORIZATION_FAILED:
......
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CLIENT_ID: {
updateStateAndNotifyManager(AuthObserverInterface::State::UNRECOVERABLE_ERROR, error);
return FlowState::IDLE;
}
......
#ifdef COMPANION_APP_AUTH
bool LWAAuthorizationAdapter::authorizeUsingCAHelper(
const std::shared_ptr<CAAuthorizationObserverInterface>& observer,
#else
bool LWAAuthorizationAdapter::authorizeUsingCBLHelper(
const std::shared_ptr<CBLAuthorizationObserverInterface>& observer,
#endif
bool requestCustomerProfile) {
if (!observer) {
ACSDK_ERROR(LX("authorizeUsingCBLHelperFailed").d("reason", "nullObserver"));
return false;
}
......
#ifdef COMPANION_APP_AUTH
bool LWAAuthorizationAdapter::authorizeUsingCA(const std::shared_ptr<CAAuthorizationObserverInterface>& observer) {
return authorizeUsingCAHelper(observer, false);
}
bool LWAAuthorizationAdapter::authorizeUsingCAWithCustomerProfile(
const std::shared_ptr<CAAuthorizationObserverInterface>& observer) {
return authorizeUsingCAHelper(observer, true);
}
#else
bool LWAAuthorizationAdapter::authorizeUsingCBL(const std::shared_ptr<CBLAuthorizationObserverInterface>& observer) {
return authorizeUsingCBLHelper(observer, false);
}
bool LWAAuthorizationAdapter::authorizeUsingCBLWithCustomerProfile(
const std::shared_ptr<CBLAuthorizationObserverInterface>& observer) {
return authorizeUsingCBLHelper(observer, true);
}
#endif
std::string LWAAuthorizationAdapter::getId() {
// m_adapterId is const, no need to lock.
ACSDK_DEBUG5(LX("getId").d("id", m_adapterId));
return m_adapterId;
}
~~~
### 2.8.9. core/Authorization/acsdkAuthorization/src/LWA/LWAAuthorizationConfiguration.cpp
~~~cpp {.line-numbers}
std::string LWAAuthorizationConfiguration::getCustomerProfileUrl() const {
return CUSTOMER_PROFILE_URL;
}
std::string LWAAuthorizationConfiguration::getManufacturerName() const {
return m_deviceInfo->getManufacturerName();
}
std::string LWAAuthorizationConfiguration::getDescription() const {
return m_deviceInfo->getDeviceDescription();
}
bool LWAAuthorizationConfiguration::initScopeData() {
ACSDK_DEBUG5(LX("initScopeData"));
~~~
### 2.8.10. 增加文件 core/Authorization/acsdkAuthorizationInterfaces/include/acsdkAuthorizationInterfaces/LWA/CAAuthorizationObserverInterface.h
### 2.8.11. core/Authorization/acsdkAuthorizationInterfaces/include/acsdkAuthorizationInterfaces/LWA/LWAAuthorizationInterface.h
~~~cpp {.line-numbers}
#include <memory>
#include <acsdkAuthorizationInterfaces/AuthorizationInterface.h>
#ifdef COMPANION_APP_AUTH
#include "CAAuthorizationObserverInterface.h"
#else
#include "CBLAuthorizationObserverInterface.h"
#endif
......
/**
* Authorize using LWA and the Code Based Linking method.
*
* @param observer The CBL observer which will receive a callback to display information back to the user.
* This will be be sent in an @c CBLAuthorizationObserverInterface callback.
*/
#ifdef COMPANION_APP_AUTH
virtual bool authorizeUsingCA(const std::shared_ptr<CAAuthorizationObserverInterface>& observer) = 0;
#else
virtual bool authorizeUsingCBL(const std::shared_ptr<CBLAuthorizationObserverInterface>& observer) = 0;
#endif
/**
* Authorize using LWA and the Code Based Linking method. This API additionally requets customer profile information
* (name, email).
*
* @attention THE USER MUST CONSENT (EX. UI DIALOG) BEFORE APPLICATION CAN REQUEST CUSTOMER PROFILE INFORMATION.
*
* @param observer The CBL observer which will receive a callback to display information back to the user.
* This will be sent in an @c CBLAuthorizationObserverInterface callback.
*/
#ifdef COMPANION_APP_AUTH
virtual bool authorizeUsingCAWithCustomerProfile(
const std::shared_ptr<CAAuthorizationObserverInterface>& observer) = 0;
#else
virtual bool authorizeUsingCBLWithCustomerProfile(
const std::shared_ptr<CBLAuthorizationObserverInterface>& observer) = 0;
#endif
};
~~~
### 2.8.12. SampleApp/Authorization/CBLAuthDelegate/src/CBLAuthDelegate.cpp
~~~cpp {.line-numbers}
case AuthObserverInterface::Error::UNSUPPORTED_GRANT_TYPE:
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CBL_CLIENT_ID: {
setAuthState(AuthObserverInterface::State::UNRECOVERABLE_ERROR);
return FlowState::STOPPING;
}
......
case AuthObserverInterface::Error::INVALID_CODE_PAIR:
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CBL_CLIENT_ID: {
setAuthState(AuthObserverInterface::State::UNRECOVERABLE_ERROR);
return FlowState::STOPPING;
}
......
case AuthObserverInterface::Error::AUTHORIZATION_PENDING:
case AuthObserverInterface::Error::SLOW_DOWN:
m_timeToRefresh = calculateTimeToRetry(m_retryCount++);
break;
case AuthObserverInterface::Error::INVALID_REQUEST:
if (newRefreshToken) {
setAuthError(AuthObserverInterface::Error::INVALID_CBL_CLIENT_ID);
}
// Falls through
case AuthObserverInterface::Error::AUTHORIZATION_FAILED:
case AuthObserverInterface::Error::UNAUTHORIZED_CLIENT:
case AuthObserverInterface::Error::INVALID_VALUE:
case AuthObserverInterface::Error::AUTHORIZATION_EXPIRED:
case AuthObserverInterface::Error::UNSUPPORTED_GRANT_TYPE:
case AuthObserverInterface::Error::INVALID_CODE_PAIR:
case AuthObserverInterface::Error::INTERNAL_ERROR:
case AuthObserverInterface::Error::INVALID_CBL_CLIENT_ID: {
setAuthState(AuthObserverInterface::State::UNRECOVERABLE_ERROR);
return FlowState::STOPPING;
~~~
## 2.9. 增加以下目录以及子目录下所有新文件
* extension/avs-app-auth/
* extension/avs-msg-sdk/
# 3. 集成MIC语言采样SDK
## 3.1. 增加以下新文件
* cmakeBuild/cmake/AspMic.cmake
* SampleApp/include/SampleApp/AspMicrophoneWrapper.h
* SampleApp/src/AspMicrophoneWrapper.cpp
## 3.2. 修改编译配置文件 cmakeBuild/BuildDefaults.cmake增加ASP MIC语音处理编译配置
~~~cmake {.line-numbers}
# Setup AspMic variables.
include_once(AspMic)
~~~
## 3.3. 修改编译配置文件 SampleApp/CMakeLists.txt增加ASP MIC语音处理编译配置
~~~cmake {.line-numbers}
if (PORTAUDIO AND (GSTREAMER_MEDIA_PLAYER OR CUSTOM_MEDIA_PLAYER))
set(VALID TRUE)
elseif (ASPMIC AND (GSTREAMER_MEDIA_PLAYER OR CUSTOM_MEDIA_PLAYER))
set(VALID TRUE)
elseif (ANDROID_MEDIA_PLAYER AND ANDROID_MICROPHONE)
set(VALID TRUE)
elseif (AUDIO_INJECTION AND (GSTREAMER_MEDIA_PLAYER OR ANDROID_MEDIA_PLAYER OR CUSTOM_MEDIA_PLAYER))
set(VALID TRUE)
endif()
~~~
## 3.4. 增加以下目录以及子目录下所有新文件
* extension/mic-asp-sdk/
# 4. 集成KWD唤醒
## 4.1 参考KWD集成文档

View File

@ -0,0 +1,239 @@
# AVS SDK DEV
base on AVS SDK 1.2.6.0
## 1. 说明
基于 AVS SDK 的修改说明
## 2. 开发内容
### 2.1. 通信模块
引入通信模块 **transport**
#### 2.1.1. 源码相关改动
* SampleApp/CMakeLists.txt
```text
add_subdirectory("Authorization")
+add_subdirectory("transport")
```
* SampleApp/src 以及 include/SampleApp 下面几个文件
详情参见git diff
#### 2.1.2. transport 模块
具体参见源码SampleApp/transport
### 2.2. 添加与config_app交互以及对应的业务逻辑执行代码
具体代码参见UserInputManager.cpp部分代码如下
```c++
#define CMD_KEY "cmd"
#define CMD_VAL_BUTTON "button"
#define CMD_VAL_NET "net"
#define CMD_VAL_FACTORYRESET "factoryreset"
#define CMD_VAL_SET_LIGHTING "set_lighting"
#define CMD_VAL_SET_SPEAKER_VOL "set_speaker_volume"
#define CMD_VAL_SET_ALERT_VOL "set_alert_volume"
#define CMD_VAL_SET_UX_LEN "set_ux_led"
#define CMD_DATA_KEY "data"
#define CMD_DATA_VALUE_KEY "value"
void UserInputManager::OnCfgMessage(std::shared_ptr<alexaClientSDK::buffer::Buffer> buffer) {
}
```
### 2.3. 添加音量设置接口
接口形式如下,详细内容参见源码
```c++
// InteractionManager.h/cpp
void InteractionManager::setVolume(avsCommon::sdkInterfaces::ChannelVolumeInterface::Type type, int8_t volume) {
}
```
### 2.4. 添加认证接口给LWA
参见源码 AuthInputManager.h
### 2.5. 添加UI执行模块
引入灯效与音效处理 **ui**
#### 2.5.1. 源码相关改动
* SampleApp/CMakeLists.txt
```text
add_subdirectory("transport")
+add_subdirectory("ui")
```
#### 2.5.2. 代码
参见 SampleApp/ui 部分代码
### 2.6. 导入音效文件
参见 Resources/Audio/include/Audio/Data 目录下面文件
### 2.7. DSN 处理
DSN使用MAC地址参见文件:
srcs/AVSCommon/Utils/src/DeviceInfo.cpp
部分代码如下:
```c++
const std::string DEFAULT_DSN = "avs_def_dsn";
const std::string DEFAULT_IF = "wlan0";
static std::string GetAvaliableMac() {
}
```
### 2.8. 导入灯效驱动文件
#### 2.8.1. 导入driver到内核
详情参见文件
<<"led drivers && hal.pdf">>
#### 2.8.2. 导入hal文件以及解决编译问题
详情参见文件
<<"led drivers && hal.pdf">>
以及 ledhal模块
### 2.9. 唤醒词切换
#### 2.9.1. 相关源码文件修改
* srcs/extension/avs-cpp-sdk/KWD/AmazonLite/src/PryonLiteKeywordDetector.cpp
* srcs/extension/avs-cpp-sdk/KWD/AmazonLite/include/AmazonLite/PryonLiteKeywordDetector.h
* srcs/extension/avs-cpp-sdk/KWD/KWDProvider/src/PryonLiteRegistration.cpp
* srcs/SampleApp/include/SampleApp/InteractionManager.h
* srcs/SampleApp/include/SampleApp/SampleApplication.h
* srcs/SampleApp/src/InteractionManager.cpp
* srcs/SampleApp/src/SampleApplication.cpp
* srcs/shared/KWD/acsdkKWDProvider/src/KeywordDetectorProvider.cpp
* srcs/shared/KWD/acsdkKWDProvider/include/acsdkKWDProvider/KWDProvider/KeywordDetectorProvider.h
#### 2.9.2. 新增
添加 管理类 KDWModelSel部分代码如下:
```c++
class KDWModelSel {
public:
KDWModelSel() {
#ifdef KWD
model_map_["ja-JP"] = "X.ja-JP.alexa.bin";
model_map_["en-US"] = "X.en-CA+en-US.alexa.bin";
#endif
}
std::unique_ptr<alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector> UpdateModel(
const std::string& local) {
#ifdef KWD
ACSDK_INFO(alexaClientSDK::avsCommon::utils::logger::LogEntry("KDWModelSel", "UpdateModel").d("local", local));
return alexaClientSDK::kwd::KeywordDetectorProvider::updateKWDModel(suffix_ + model_map_[local]);
#endif
return nullptr;
}
private:
const std::string suffix_ = "/data/avs/wakeword-models/x1f8/";
std::unordered_map<std::string, std::string> model_map_;
};
```
### 2.10. 添加 onNotificationReceived 接口
添加Notification接口以及相关的业务功能
```c++
void onNotificationReceived() override;
```
### 2.11. 添加数据库模块
参见源码: db_wrapper.h/cpp
### 2.12. 程序启动音量处理
部分代码
```c++
std::string vol_str;
bool ret = db_wrapper_->Load(::avs::db::USER_DB_KEY_SPEAKER_VOL, vol_str);
if (ret) {
m_interactionManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, std::atoi(vol_str.c_str()));
} else {
// database has val,use config file
int vol_int;
alexaClientSDK::avsCommon::utils::configuration::ConfigurationNode::getRoot()[SPEAKER_MANAGER_CAPABILITY_AGENT]
.getInt("defaultSpeakerVolume", &vol_int, 80);
m_interactionManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, vol_int);
}
ret = db_wrapper_->Load(::avs::db::USER_DB_KEY_ALERT_VOL, vol_str);
if (ret) {
m_interactionManager->setVolume(ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME, std::atoi(vol_str.c_str()));
} else {
// database has val,use config file
int vol_int;
alexaClientSDK::avsCommon::utils::configuration::ConfigurationNode::getRoot()[SPEAKER_MANAGER_CAPABILITY_AGENT]
.getInt("defaultAlertsVolume", &vol_int, 80);
m_interactionManager->setVolume(ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME, vol_int);
}
```
### 2.13. DND状态存入数据库与开机加载
```c++
auto dnd = m_client->getSettingsManager()->getValue<settings::DO_NOT_DISTURB>();
ACSDK_INFO(LX("DNS").d("enable", dnd.second));
::avs::ui::UiExector::Instance()->SetDND(dnd.second);
```
### 2.14. 添加解绑功能
支持app解绑、按键解绑、云端解绑关于云端解绑修改的源文件有
* srcs/ApplicationUtilities/DefaultClient/src/DefaultClient.cpp
* srcs/ApplicationUtilities/DefaultClient/include/DefaultClient/DefaultClient.h
* srcs/AVSCommon/SDKInterfaces/include/AVSCommon/SDKInterfaces/UserInactivityMonitorObserverInterface.h
* srcs/capabilities/MultiRoomMusic/acsdkMultiRoomMusic/include/acsdkMultiRoomMusic/MRMCapabilityAgent.h
* srcs/CapabilityAgents/System/src/UserInactivityMonitor.cpp
* srcs/CapabilityAgents/System/include/System/UserInactivityMonitor.h
### 2.15. 添加编译和git信息
```text
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
)
string (REGEX REPLACE "[\n\t\r]" "" GIT_VERSION ${GIT_VERSION})
add_definitions( -DGIT_VERSION=\"${GIT_VERSION}\")
string(TIMESTAMP COMPILE_TIME "%Y%m%d %H%M%S")
add_definitions( -DCOMPILE_TIME=\"${COMPILE_TIME}\")
```
```c++
#if defined(GIT_VERSION) && defined(COMPILE_TIME)
ACSDK_CRITICAL(LX("SampleApplication").d("version", GIT_VERSION).d("build", COMPILE_TIME));
#endif
```

BIN
docs/led drivers && hal.pdf Executable file

Binary file not shown.