summaryrefslogtreecommitdiffstats
path: root/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service
diff options
context:
space:
mode:
Diffstat (limited to 'meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service')
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0001-remove-library-dependency-copying.patch16
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0002-update-config.xml.in.patch31
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0003-update-audio-device-configuration.patch197
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0004-update-config-and-database-paths.patch124
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0005-fix-segmentation-fault-for-release-build-mode.patch33
-rw-r--r--meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0006-fix-event-argument-json.patch183
6 files changed, 5 insertions, 579 deletions
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0001-remove-library-dependency-copying.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0001-remove-library-dependency-copying.patch
index 3e45c527..ee61ac20 100644
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0001-remove-library-dependency-copying.patch
+++ b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0001-remove-library-dependency-copying.patch
@@ -10,23 +10,17 @@ Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
-index 4732e7b..938e5f3 100644
+index 8a955feb..5b097877 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
-@@ -70,22 +70,13 @@ add_avs_library(SpeechEncoder ${AAC_HOME}/lib/libSpeechEncoder.so)
- add_avs_library(OpusEncoderContext ${AAC_HOME}/lib/libOpusEncoderContext.so)
- add_avs_library(SpeechSynthesizer ${AAC_HOME}/lib/libSpeechSynthesizer.so)
+@@ -92,16 +92,11 @@ add_avs_library(SQLiteStorage ${AAC_HOME}/lib/libSQLiteStorage.so)
+ add_avs_library(SystemSoundPlayer ${AAC_HOME}/lib/libSystemSoundPlayer.so)
add_avs_library(TemplateRuntime ${AAC_HOME}/lib/libTemplateRuntime.so)
--#add_avs_library(curl ${AAC_HOME}/lib/libcurl.so.4.5.0)
+ add_avs_library(ToggleController ${AAC_HOME}/lib/libToggleController.so)
-add_avs_library(curl ${AAC_HOME}/lib/libcurl.so.4)
--#add_avs_library(nghttp2 ${AAC_HOME}/lib/libnghttp2.so.14.16)
-add_avs_library(nghttp2 ${AAC_HOME}/lib/libnghttp2.so.14)
--#add_avs_library(opus ${AAC_HOME}/lib/libopus.so.0.6.1)
-add_avs_library(opus ${AAC_HOME}/lib/libopus.so.0)
--#add_avs_library(sqlite3 ${AAC_HOME}/lib/libsqlite3.so.0.8.6)
-add_avs_library(sqlite3 ${AAC_HOME}/lib/libsqlite3.so.0)
- add_avs_library(equalizer ${AAC_HOME}/lib/libEqualizer.so)
- add_avs_library(EqualizerImplementations ${AAC_HOME}/lib/libEqualizerImplementations.so)
-if(EXISTS ${AAC_HOME}/lib/libpryon_lite.so.1.13)
+if(EXISTS ${AAC_HOME}/lib/libAACEAmazonLiteEngine.so)
@@ -36,4 +30,4 @@ index 4732e7b..938e5f3 100644
- add_avs_library(pryon_lite ${AAC_HOME}/lib/libpryon_lite.so.1.13)
endif()
- if(EXISTS ${AAC_HOME}/lib/libAACEGStreamerEngine.so)
+ if(EXISTS ${AAC_HOME}/share/cmake/AACESystemAudio.cmake)
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0002-update-config.xml.in.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0002-update-config.xml.in.patch
deleted file mode 100644
index fd5aaf75..00000000
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0002-update-config.xml.in.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-Update config.xml.in
-
-Remove now unneeded 4A binding dependency, and add new required audio
-permission.
-
-Upstream-Status: Pending
-
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-
-diff --git a/platforms/agl/alexa-voiceagent-service/conf.d/wgt/config.xml.in b/platforms/agl/alexa-voiceagent-service/conf.d/wgt/config.xml.in
-index 3486518..14fd6a2 100644
---- a/conf.d/wgt/config.xml.in
-+++ b/conf.d/wgt/config.xml.in
-@@ -9,6 +9,7 @@
-
- <feature name="urn:AGL:widget:required-permission">
- <param name="urn:AGL:permission::public:no-htdocs" value="required" />
-+ <param name="urn:AGL:permission::public:audio" value="required" />
- <param name="urn:AGL:permission:audio:public:audiostream" value="required" />
- <param name="urn:AGL:permission::public:hidden" value="required" />
- <param name="urn:AGL:permission::system:run-by-default" value="required" />
-@@ -23,7 +24,6 @@
- </feature>
-
- <feature name="urn:AGL:widget:required-api">
-- <param name="ahl-4a" value="ws" />
- <param name="vshl-capabilities" value="ws" />
- </feature>
--</widget>
-\ No newline at end of file
-+</widget>
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0003-update-audio-device-configuration.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0003-update-audio-device-configuration.patch
deleted file mode 100644
index ede3d533..00000000
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0003-update-audio-device-configuration.patch
+++ /dev/null
@@ -1,197 +0,0 @@
-Update audio device configuration
-
-Rework the audio output device configuration to match the expectations
-of the PipeWire output sink configuration in the gstreamer output code.
-Currently, this means that the role is being stored as the device name
-so the gstreamer code can use it when setting up the output sink
-properties.
-
-Upstream-Status: Pending
-
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-
-diff --git a/platforms/agl/alexa-voiceagent-service/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp b/platforms/agl/alexa-voiceagent-service/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-index 83d0341..b51185c 100644
---- a/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-+++ b/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-@@ -97,25 +97,25 @@ AASBConfigProviderImpl::AudioIOConfiguration AASBConfigProviderImpl::getAudioIOC
-
- // Output devices
- if(!m_ttsOutputDevice.empty())
-- audioConfig.ttsOutputDevice = m_audio->openAHLChannel(m_ttsOutputDevice);
-+ audioConfig.ttsOutputDevice = m_audio->openChannel(m_ttsOutputDevice);
-
- if(!m_musicOutputDevice.empty())
-- audioConfig.musicOutputDevice = m_audio->openAHLChannel(m_musicOutputDevice);
-+ audioConfig.musicOutputDevice = m_audio->openChannel(m_musicOutputDevice);
-
- if(!m_notificationOutputDevice.empty())
-- audioConfig.notificationOutputDevice = m_audio->openAHLChannel(m_notificationOutputDevice);
-+ audioConfig.notificationOutputDevice = m_audio->openChannel(m_notificationOutputDevice);
-
- if(!m_alarmOutputDevice.empty())
-- audioConfig.alarmOutputDevice = m_audio->openAHLChannel(m_alarmOutputDevice);
-+ audioConfig.alarmOutputDevice = m_audio->openChannel(m_alarmOutputDevice);
-
- if(!m_earconOutputDevice.empty())
-- audioConfig.earconOutputDevice = m_audio->openAHLChannel(m_earconOutputDevice);
-+ audioConfig.earconOutputDevice = m_audio->openChannel(m_earconOutputDevice);
-
- if(!m_communicationOutputDevice.empty())
-- audioConfig.communicationOutputDevice = m_audio->openAHLChannel(m_communicationOutputDevice);
-+ audioConfig.communicationOutputDevice = m_audio->openChannel(m_communicationOutputDevice);
-
- if(!m_ringtoneOutputDevice.empty())
-- audioConfig.ringtoneOutputDevice = m_audio->openAHLChannel(m_ringtoneOutputDevice);
-+ audioConfig.ringtoneOutputDevice = m_audio->openChannel(m_ringtoneOutputDevice);
-
- return audioConfig;
- }
-@@ -585,4 +585,4 @@ void AASBConfigProviderImpl::logCurrentConfiguration() {
- }
-
- } // namespace alexa
--} // namespace agl
-\ No newline at end of file
-+} // namespace agl
-diff --git a/src/plugins/audio/Audio.cpp b/src/plugins/audio/Audio.cpp
-index d662a06..1b2fa9d 100644
---- a/src/plugins/audio/Audio.cpp
-+++ b/src/plugins/audio/Audio.cpp
-@@ -13,8 +13,6 @@
- * permissions and limitations under the License.
- */
-
--#include <json.h>
--
- #include <AACE/Engine/Core/EngineMacros.h>
-
- #include "Audio.h"
-@@ -22,7 +20,7 @@
- namespace agl {
- namespace audio {
-
--/// Shortcut to reach logging level.
-+// Shortcut to reach logging level.
- using Level = agl::common::interfaces::ILogger::Level;
-
- using namespace agl::common::interfaces;
-@@ -31,68 +29,30 @@ static std::string TAG = "agl::audio::Audio";
-
- std::shared_ptr<Audio> Audio::create(
- std::shared_ptr<agl::common::interfaces::ILogger> logger,
-- shared_ptr<agl::common::interfaces::IAFBApi> api) {
-+ shared_ptr<agl::common::interfaces::IAFBApi> api)
-+{
- return std::shared_ptr<Audio>(new Audio(logger, api));
- }
-
- Audio::Audio(std::shared_ptr<ILogger> logger,
- std::shared_ptr<IAFBApi> api) :
- m_logger(logger),
-- m_api(api) {
--
--}
--
--std::string Audio::openAHLChannel(const std::string &role)
-+ m_api(api)
- {
-- json_object *request = json_object_new_object();
-- json_object *response = NULL;
-- json_object_object_add(request, "action", json_object_new_string("open"));
-- if (callAHL(role, request, &response)) {
-- json_object *val = NULL;
-- std::string result;
-- if (json_object_object_get_ex(response, "device_uri", &val)) {
-- const char* device = json_object_get_string(val);
-- m_logger->log(Level::DEBUG, TAG, "openAHLChannel: device=" + std::string(device));
-- result = device;
-- }
-- json_object_put(response);
-- return result;
-- }
-- return "";
- }
-
--bool Audio::setAHLChannelVolume(const std::string &role, int volume)
-+std::string Audio::openChannel(const std::string &role)
- {
-- json_object *request = json_object_new_object();
-- json_object_object_add(request, "action", json_object_new_string("volume"));
-- json_object_object_add(request, "value", json_object_new_int(volume));
-- return callAHL(role, request, NULL);
-+ // For now, return the given role as the device string, to match
-+ // the expectation of the PipeWire sink configuration in the
-+ // gstreamer output code.
-+ return role;
- }
-
--bool Audio::callAHL(const std::string &role, json_object *request, json_object **response)
-+bool Audio::setChannelVolume(const std::string &role, int volume)
- {
-- json_object *object = NULL;
-- std::string error, info;
-- bool result = false;
--
-- if (m_api->callSync("ahl-4a", role, request, &object, error, info) < 0) {
-- m_logger->log(Level::ERROR, TAG, "VA service call=" + role + " failed, error=" + error + ", info=" + info);
-- goto exit;
-- }
--
-- m_logger->log(Level::DEBUG, TAG, "callAHL, response=" + std::string(json_object_get_string(object)));
-- result = true;
-- if (response) {
-- *response = object;
-- }
--
--exit:
-- if (!result && object) {
-- json_object_put(object);
-- }
--
-- return result;
-+ return true;
- }
-
--}
--}
-\ No newline at end of file
-+} // namespace audio
-+} // namespace agl
-diff --git a/src/plugins/audio/Audio.h b/src/plugins/audio/Audio.h
-index 14bef4d..8998242 100644
---- a/src/plugins/audio/Audio.h
-+++ b/src/plugins/audio/Audio.h
-@@ -35,23 +35,21 @@ public:
- std::shared_ptr<agl::common::interfaces::ILogger> logger,
- shared_ptr<agl::common::interfaces::IAFBApi> api);
-
-- std::string openAHLChannel(const std::string &role);
-- bool setAHLChannelVolume(const std::string &role, int volume);
-+ std::string openChannel(const std::string &role);
-+ bool setChannelVolume(const std::string &role, int volume);
-
- private:
- Audio(std::shared_ptr<agl::common::interfaces::ILogger> logger,
- shared_ptr<agl::common::interfaces::IAFBApi> api);
-
-- bool callAHL(const std::string &role, json_object *request, json_object **response);
--
-- // Logger.
-- std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
-+ // Logger.
-+ std::shared_ptr<agl::common::interfaces::ILogger> m_logger;
-
- // AFB API object for events pub/sub, and for calling other AGL services.
-- std::shared_ptr<agl::common::interfaces::IAFBApi> m_api;
-+ std::shared_ptr<agl::common::interfaces::IAFBApi> m_api;
- };
-
--}
--}
-+} // namespace audio
-+} // namespace agl
-
--#endif // AGL_AUDIO_AUDIO_H_
-\ No newline at end of file
-+#endif // AGL_AUDIO_AUDIO_H_
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0004-update-config-and-database-paths.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0004-update-config-and-database-paths.patch
deleted file mode 100644
index 0bf4267f..00000000
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0004-update-config-and-database-paths.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-alexa-voiceagent-service: update config and database file paths
-
-Tweak getDataRootPath in the AASBConfigProviderImpl class to use the
-AFM_WORKDIR environment variable as the basis for the path, which
-moves things from the binding installation hierarchy into the app
-framework's provided application data directory. This avoids the
-permissions problems stemming from the new security model of running
-as non-root. Also reworked the main configuration JSON file location
-logic to use a new helper member function that checks for the file
-in /etc/xdg/AGL and then in AFM_WORKDIR (app-data directory), before
-falling back to the original location in var/config under the binding
-installation directory. The local copy of GetBindingDirPath has been
-removed, as it seems to be working fine now that the binding is being
-built with AFB_BINDING_VERSION = 3.
-
-Upstream-Status: Pending
-
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-
-diff --git a/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp b/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-index b51185c..5d5c3ba 100644
---- a/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-+++ b/src/plugins/aasb-client/config/AASBConfigProviderImpl.cpp
-@@ -19,6 +19,7 @@
- #include <iostream>
- #include <sstream>
- #include <unistd.h>
-+#include <sys/stat.h>
-
- #include <rapidjson/document.h>
- #include <rapidjson/istreamwrapper.h>
-@@ -36,6 +37,9 @@ using Level = agl::common::interfaces::ILogger::Level;
- /// Logging tag for this file.
- static std::string TAG = "agl::alexa::AASBConfigProviderImpl";
-
-+/// Directory where user over-ride alexa json configuration may be.
-+static std::string ALEXA_CONFIG_FILE_OVERRIDE_DIR = "/etc/xdg/AGL/";
-+
- /// File name where alexa json configuration is stored.
- static std::string ALEXA_CONFIG_FILE_NAME = "AlexaAutoCoreEngineConfig.json";
-
-@@ -64,8 +68,7 @@ AASBConfigProviderImpl::AASBConfigProviderImpl(std::shared_ptr<agl::common::inte
- m_enableLocalVoiceControl(false) {
- m_LocalVoiceControlConfiguration = std::unique_ptr<LVCConfiguration>(new LVCConfiguration());
- m_carControlConfiguration = std::unique_ptr<CarControlConfiguration>(new CarControlConfiguration());
-- std::string alexaConfigFile = getDataRootPath() + ALEXA_CONFIG_FILE_NAME;
-- initConfigFromFile(alexaConfigFile);
-+ initConfigFromFile(getAlexaConfigPath());
- logCurrentConfiguration();
- }
-
-@@ -520,32 +523,25 @@ void AASBConfigProviderImpl::initConfigFromFile(const std::string& fileName) {
- }
- }
-
--// GetBindingDirPath() method provided by AGL SDK crashes every single time.
--// It turns out that on latest AGL platforms, GetBindingDirPath(afb_api_t) version
--// is supposed to be the correct version. However when we include filescan-utils.h
--// it compiles a version without "afb_api_t" parameter. For now, I have made a
--// copy of this method here which accepts "afb_api_t" parameter.
--// TODO: Fix it
--std::string GetBindingDirectoryPath(afb_api_t api) {
-- // A file description should not be greater than 999.999.999
-- char fd_link[CONTROL_MAXPATH_LEN];
-- char retdir[CONTROL_MAXPATH_LEN];
-- ssize_t len;
-- sprintf(fd_link, "/proc/self/fd/%d", afb_dynapi_rootdir_get_fd(api));
--
-- if ((len = readlink(fd_link, retdir, sizeof(retdir) - 1)) == -1) {
-- perror("lstat");
-- strncpy(retdir, "/tmp", CONTROL_MAXPATH_LEN - 1);
-- } else {
-- retdir[len] = '\0';
-- }
--
-- return std::string(retdir);
-+std::string AASBConfigProviderImpl::getDataRootPath() {
-+ std::string workDir(getenv("AFM_WORKDIR"));
-+ return workDir + "/";
- }
-
--std::string AASBConfigProviderImpl::getDataRootPath() {
-- std::string bindingDir(GetBindingDirectoryPath(m_api));
-- return bindingDir + "/var/config/";
-+std::string AASBConfigProviderImpl::getAlexaConfigPath() {
-+ struct stat statbuf;
-+
-+ // Look in over-ride directory first
-+ std::string configPath = ALEXA_CONFIG_FILE_OVERRIDE_DIR + ALEXA_CONFIG_FILE_NAME;
-+ if(stat(configPath.c_str(), &statbuf) != 0) {
-+ // Look in work directory (app-data) next
-+ configPath = getDataRootPath() + ALEXA_CONFIG_FILE_NAME;
-+ if(stat(configPath.c_str(), &statbuf) != 0) {
-+ // Fall back to default version in widget
-+ configPath = std::string(GetBindingDirPath(m_api)) + "/var/config/" + ALEXA_CONFIG_FILE_NAME;
-+ }
-+ }
-+ return configPath;
- }
-
- void AASBConfigProviderImpl::logCurrentConfiguration() {
-diff --git a/src/plugins/aasb-client/config/AASBConfigProviderImpl.h b/src/plugins/aasb-client/config/AASBConfigProviderImpl.h
-index 6b79994..e32f7b7 100644
---- a/src/plugins/aasb-client/config/AASBConfigProviderImpl.h
-+++ b/src/plugins/aasb-client/config/AASBConfigProviderImpl.h
-@@ -87,6 +87,11 @@ private:
- */
- std::string getDataRootPath();
-
-+ /**
-+ * Provides the path where alexa json config resides.
-+ */
-+ std::string getAlexaConfigPath();
-+
- /**
- * Logs the current configuration loaded by this object.
- */
-@@ -139,4 +144,4 @@ private:
- } // namespace alexa
- } // namespace agl
-
--#endif // AGL_ALEXA_SVC_AASB_CONFIG_PROVIDER_IMPL_H_
-\ No newline at end of file
-+#endif // AGL_ALEXA_SVC_AASB_CONFIG_PROVIDER_IMPL_H_
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0005-fix-segmentation-fault-for-release-build-mode.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0005-fix-segmentation-fault-for-release-build-mode.patch
deleted file mode 100644
index 5012dfe8..00000000
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0005-fix-segmentation-fault-for-release-build-mode.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-Fix segmentation fault for release build mode
-
-'int IAFBApi::callSync(...)' is missing a return
-statement. When the sdk is compiled in release mode
-executing this code results in a segmentation fault.
-
-According to the C++ standard, a return statement is
-required on a function that returns a non-void value.
-Specifically: <<Flowing off the end of a function is
-equivalent to a return with no value; this results in
-undefined behaviour in a value-returning function.>>
-
-The proposed fix provides the missing return statement
-for IAFBApi's callSync method.
-
-Upstream-Status: Pending
-
-Signed-off-by: Raquel Medina <raquel.medina@konsulko.com>
-
-diff --git a/platforms/agl/alexa-voiceagent-service/src/plugins/afb/AFBApiImpl.cpp b/platforms/agl/alexa-voiceagent-service/src/plugins/afb/AFBApiImpl.cpp
-index 5ed9bce..e68ef7f 100644
---- a/src/plugins/afb/AFBApiImpl.cpp
-+++ b/src/plugins/afb/AFBApiImpl.cpp
-@@ -77,6 +77,8 @@ int AFBApiImpl::callSync(
- info = infoStr;
- free(infoStr);
- }
-+
-+ return rc;
- }
-
- /// Shim to transfer C++ function to C callback using void*
-
diff --git a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0006-fix-event-argument-json.patch b/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0006-fix-event-argument-json.patch
deleted file mode 100644
index 8c6f1e4b..00000000
--- a/meta-speech-framework/meta-aac/recipes-apis/alexa-voiceagent-service/alexa-voiceagent-service/0006-fix-event-argument-json.patch
+++ /dev/null
@@ -1,183 +0,0 @@
-Fix event argument JSON
-
-It was discovered while trying to use some of the capabilities events
-that the argument JSON was incorrectly formatted, with instances of
-all or part of it being double-quoted as strings with escaping. A
-couple instances of this had previously been worked around by hacks
-involving reparsing all or some parts of the arguments a second time
-with a JSON parser, but it seems better to fix it at the source so
-that the events match documentation and are usable as is.
-
-Note that it is ATM not clear if all affected event argument payloads
-are correct, e.g. LocalMediaSource may need some more work.
-
-Upstream-Status: Pending
-
-Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-
-diff --git a/src/plugins/aasb-client/AlexaCapabilityDirectiveRouterImpl.cpp b/src/plugins/aasb-client/AlexaCapabilityDirectiveRouterImpl.cpp
-index 6aea920..23ed90c 100644
---- a/src/plugins/aasb-client/AlexaCapabilityDirectiveRouterImpl.cpp
-+++ b/src/plugins/aasb-client/AlexaCapabilityDirectiveRouterImpl.cpp
-@@ -17,6 +17,8 @@
-
- #include <sstream>
-
-+#include <json-c/json.h>
-+
- #include <aasb/Consts.h>
-
- #include "AlexaConsts.h"
-@@ -322,7 +324,16 @@ void AlexaCapabilityDirectiveRouterImpl::processTemplateRuntimeAction(
-
- json_object* argsJ = json_object_new_object();
- json_object* actionJ = json_object_new_string(vshlCapabilityAction.c_str());
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_ACTION.c_str(), actionJ);
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-
-@@ -343,24 +354,40 @@ void AlexaCapabilityDirectiveRouterImpl::processCBLAction(
- const std::string& payload) {
- m_logger->log(Level::DEBUG, TAG, "Processing CBL action: " + action);
-
-- json_object* eventDataJ = json_object_new_object();
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
-+ // The payload string may already be of the form of a document like
-+ // "{ "payload" : { ... } }", the simplest way to handle that is to use
-+ // it as the event json_object if that's the case, that way we avoid
-+ // having to worry about copying.
-+ json_object* eventDataJ = NULL;
-+ if(json_object_object_get_ex(payloadJ, "payload", NULL)) {
-+ eventDataJ = payloadJ;
-+ } else {
-+ eventDataJ = json_object_new_object();
-+ json_object_object_add(eventDataJ, JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-+ }
- json_object* vaIdJ = json_object_new_string(m_alexaVoiceAgentId.c_str());
--
- json_object_object_add(eventDataJ, JSON_ATTR_VOICEAGENT_ID.c_str(), vaIdJ);
-
- int observers = 0;
- if (action == aasb::bridge::ACTION_CBL_CODEPAIR_RECEIVED) {
- m_logger->log(Level::INFO, TAG, "CBL codepair received: " + payload);
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-- json_object_object_add(eventDataJ, JSON_ATTR_PAYLOAD.c_str(), payloadJ);
- observers = m_cblCodePairReceivedEvent->publishEvent(eventDataJ);
- } else if (action == aasb::bridge::ACTION_CBL_CODEPAIR_EXPIRED) {
- m_logger->log(Level::INFO, TAG, "CBL codepair expired: " + payload);
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-- json_object_object_add(eventDataJ, JSON_ATTR_PAYLOAD.c_str(), payloadJ);
- observers = m_cblCodePairExpiredEvent->publishEvent(eventDataJ);
- } else {
- m_logger->log(Level::INFO, TAG, "Unhandled action: " + action);
-+ json_object_put(eventDataJ);
- }
-
- std::stringstream logMsg;
-diff --git a/src/plugins/dispatchers/local-voice-control/car-control/CarControlDispatcher.cpp b/src/plugins/dispatchers/local-voice-control/car-control/CarControlDispatcher.cpp
-index 096f72f..75108d4 100644
---- a/src/plugins/dispatchers/local-voice-control/car-control/CarControlDispatcher.cpp
-+++ b/src/plugins/dispatchers/local-voice-control/car-control/CarControlDispatcher.cpp
-@@ -72,7 +72,16 @@ void CarControlDispatcher::onReceivedDirective(
-
- json_object* argsJ = json_object_new_object();
- json_object* actionJ = json_object_new_string(vshlCapabilityAction.c_str());
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_ACTION.c_str(), actionJ);
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-
-diff --git a/src/plugins/dispatchers/localmediasource/LocalMediaSourceDispatcher.cpp b/src/plugins/dispatchers/localmediasource/LocalMediaSourceDispatcher.cpp
-index c261a56..04ac10c 100644
---- a/src/plugins/dispatchers/localmediasource/LocalMediaSourceDispatcher.cpp
-+++ b/src/plugins/dispatchers/localmediasource/LocalMediaSourceDispatcher.cpp
-@@ -71,7 +71,16 @@ void LocalMediaSourceDispatcher::onReceivedDirective(
-
- json_object* argsJ = json_object_new_object();
- json_object* actionJ = json_object_new_string(vshlCapabilityAction.c_str());
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_ACTION.c_str(), actionJ);
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-
-diff --git a/src/plugins/dispatchers/navigation/NavigationDispatcher.cpp b/src/plugins/dispatchers/navigation/NavigationDispatcher.cpp
-index 55a6017..283b42b 100644
---- a/src/plugins/dispatchers/navigation/NavigationDispatcher.cpp
-+++ b/src/plugins/dispatchers/navigation/NavigationDispatcher.cpp
-@@ -68,7 +68,16 @@ void NavigationDispatcher::onReceivedDirective(
-
- json_object* argsJ = json_object_new_object();
- json_object* actionJ = json_object_new_string(vshlCapabilityAction.c_str());
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_ACTION.c_str(), actionJ);
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-
-diff --git a/src/plugins/dispatchers/phonecall/PhoneCallDispatcher.cpp b/src/plugins/dispatchers/phonecall/PhoneCallDispatcher.cpp
-index 29ad96a..3432892 100644
---- a/src/plugins/dispatchers/phonecall/PhoneCallDispatcher.cpp
-+++ b/src/plugins/dispatchers/phonecall/PhoneCallDispatcher.cpp
-@@ -86,7 +86,16 @@ void PhoneCallDispatcher::onReceivedDirective(
-
- json_object* argsJ = json_object_new_object();
- json_object* actionJ = json_object_new_string(vshlCapabilityAction.c_str());
-- json_object* payloadJ = json_object_new_string(payload.c_str());
-+ json_object* payloadJ = NULL;
-+ if(payload.length()) {
-+ payloadJ = json_tokener_parse(payload.c_str());
-+ } else {
-+ payloadJ = json_object_new_string("");
-+ }
-+ if(!payloadJ) {
-+ m_logger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload);
-+ return;
-+ }
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_ACTION.c_str(), actionJ);
- json_object_object_add(argsJ, agl::alexa::JSON_ATTR_PAYLOAD.c_str(), payloadJ);
-