char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
+ const char delimeter = '|';
+
/* Add 1 for additional pipe character */
char wakeup_words[MAX_WAKEUP_WORDS_NUM * (MAX_WAKEUP_WORD_LEN + 1)];
char wakeup_languages[MAX_WAKEUP_WORDS_NUM * (MAX_SUPPORTED_LANGUAGE_LEN + 1)];
char *language_end = NULL;
int index = 0;
while (index < MAX_WAKEUP_WORDS_NUM) {
- word_end = strchrnul(word_start, '|');
- language_end = strchrnul(language_start, '|');
+ word_end = strchrnul(word_start, delimeter);
+ language_end = strchrnul(language_start, delimeter);
if ('\0' == *word_end || '\0' == *language_end) break;
*word_end = '\0';
*language_end = '\0';
char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN],
char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN])
{
+ const char* delimeter = "|";
/* Add 1 for additional pipe character */
char wakeup_words[MAX_WAKEUP_WORDS_NUM * (MAX_WAKEUP_WORD_LEN + 1)];
char wakeup_languages[MAX_WAKEUP_WORDS_NUM * (MAX_SUPPORTED_LANGUAGE_LEN + 1)];
int wakeup_words_len = strlen(wakeup_words);
strncat(wakeup_words, wakeup_word_storage[loop],
sizeof(wakeup_words) - wakeup_words_len - 1);
- strcat(wakeup_words, "|");
+ strncat(wakeup_words, delimeter, strlen(delimeter));
int wakeup_languages_len = strlen(wakeup_languages);
strncat(wakeup_languages, wakeup_language_storage[loop],
sizeof(wakeup_languages) - wakeup_languages_len - 1);
- strcat(wakeup_languages, "|");
+ strncat(wakeup_languages, delimeter, strlen(delimeter));
}
}
wakeup_words[sizeof(wakeup_words) - 1] = '\0';
if (0 == mServiceConfig.get_assistant_info(mas_assistant_info_cb, this)) {
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
int inner_loop;
- if (mClientInfo[loop].used && mClientInfo[loop].appid &&
- 0 < strlen(mClientInfo[loop].appid)) {
+ if (0 < strlen(mClientInfo[loop].appid)) {
mServiceConfig.load_custom_wake_words(mClientInfo[loop].appid,
mClientInfo[loop].wakeup_word, mClientInfo[loop].wakeup_language);
- if (mClientInfo[loop].wakeup_engine &&
- 0 < strlen(mClientInfo[loop].wakeup_engine)) {
+ if (0 < strlen(mClientInfo[loop].wakeup_engine)) {
mServicePlugin.set_assistant_wakeup_engine(
mClientInfo[loop].appid,
mClientInfo[loop].wakeup_engine);
}
for (inner_loop = 0; inner_loop < MAX_WAKEUP_WORDS_NUM; inner_loop++) {
- if (mClientInfo[loop].wakeup_word[inner_loop] &&
- 0 < strlen(mClientInfo[loop].wakeup_word[inner_loop])) {
+ if (0 < strlen(mClientInfo[loop].wakeup_word[inner_loop])) {
MAS_LOGD("Registering wakeup word %s for app %s",
mClientInfo[loop].wakeup_word[inner_loop], mClientInfo[loop].appid);
if (0 != mServicePlugin.add_assistant_wakeup_word(
}
}
for (inner_loop = 0; inner_loop < MAX_SUPPORTED_LANGUAGES_NUM; inner_loop++) {
- if (mClientInfo[loop].supported_language[inner_loop] &&
- 0 < strlen(mClientInfo[loop].supported_language[inner_loop])) {
+ if (0 < strlen(mClientInfo[loop].supported_language[inner_loop])) {
MAS_LOGD("Adding language %s for app %s",
mClientInfo[loop].supported_language[inner_loop], mClientInfo[loop].appid);
if (0 != mServicePlugin.add_assistant_language(
{
MAS_LOGD("[SUCCESS] __error_cb is called, error(%d), err_msg(%s)", error, err_msg);
- CServiceIpcDbus* service_ipc = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_ipc = plugin->get_service_ipc();
- }
+ if (nullptr == plugin) return;
+
+ CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
if (plugin->is_ui_panel_enabled() && service_ipc) {
int ret = service_ipc->masc_ui_dbus_send_error_message(error, err_msg);
if (0 != ret) {
static void __setting_changed_cb(void *user_data)
{
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_main = plugin->get_service_main();
- }
+ if (nullptr == plugin) return;
+
+ CServiceMain* service_main = plugin->get_service_main();
if (service_main) {
service_main->mas_prelaunch_default_assistant();
service_main->mas_update_voice_key_support_mode();
{
MAS_LOGD("[SUCCESS] __streaming_section_changed_cb is called, section(%d)", section);
- CServiceIpcDbus *service_ipc = nullptr;
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_ipc = plugin->get_service_ipc();
- service_main = plugin->get_service_main();
- }
+ if (nullptr == plugin) return;
+
+ CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
+ CServiceMain* service_main = plugin->get_service_main();
if (service_ipc && service_main) {
int pid = service_main->mas_get_current_client_pid();
int ret = service_ipc->send_streaming_section_changed(pid, (int)section);
{
MAS_LOGD("[SUCCESS] __wakeup_engine_command_cb is called, command(%s)", command);
- CServiceIpcDbus *service_ipc = nullptr;
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_ipc = plugin->get_service_ipc();
- service_main = plugin->get_service_main();
- }
+ if (nullptr == plugin) return;
+
+ CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
+ CServiceMain* service_main = plugin->get_service_main();
if (service_ipc && service_main) {
int pid = service_main->mas_get_client_pid_by_appid(assistant_name);
if (-1 != pid) {
{
MAS_LOGD("[SUCCESS] __wakeup_service_state_changed_cb is called, state(%d)", state);
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_main = plugin->get_service_main();
- }
+ if (nullptr == plugin) return;
+
+ CServiceMain* service_main = plugin->get_service_main();
if (service_main) {
service_main->mas_set_current_service_state(state);
}
{
MAS_LOGD("[SUCCESS] __wakeup_service_voice_key_status_changed_cb is called, state(%d)", status);
- CServiceIpcDbus *service_ipc = nullptr;
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
- if (plugin) {
- service_ipc = plugin->get_service_ipc();
- service_main = plugin->get_service_main();
- }
+ if (nullptr == plugin) return;
+
+ CServiceIpcDbus *service_ipc = plugin->get_service_ipc();
+ CServiceMain* service_main = plugin->get_service_main();
if (service_ipc && service_main) {
int pid = service_main->mas_get_current_client_pid();
int ret = service_ipc->change_voice_key_status(pid, status);