Do not consider scheduled restart as an error 32/288232/1 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20230303.102015
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 10 Feb 2023 09:56:40 +0000 (18:56 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 14 Feb 2023 04:02:16 +0000 (13:02 +0900)
When a scheduled restart takes place on the agent side,
the client application receives a service reset error,
canceling all the ongoing operations that are not
directly related to the multi-assistant framework.
To avoid this problem, added a restart notification signal
for letting the clients to know the subsequent dbus name owner
change event is caused by a scheduled restart event or not.

Change-Id: I0e1acf293d62d04356a59bb0f9bba29860946285

client/ma.c
client/ma_dbus.c
common/ma_defs.h

index 8eadce7da6964b126ef51490dcb124e58c24fb6c..37e1a6e838cae6f9b890ad72af46550bc77f1b1e 100644 (file)
@@ -738,7 +738,7 @@ int __ma_cb_audio_streaming(int event, char* buffer, int len)
        return 0;
 }
 
-int __ma_cb_error(int reason, char* msg)
+int __ma_cb_error(int reason, char* msg, int notify)
 {
        ma_state_e state;
        if (0 != ma_client_get_client_state(g_ma, &state)) {
@@ -763,10 +763,12 @@ int __ma_cb_error(int reason, char* msg)
                __ma_notify_state_changed((void*)g_ma);
        }
 
-       MA_SLOGE("[ERROR] Error reason(%d), msg(%s)", reason, msg); //LCOV_EXCL_LINE
+       MA_SLOGE("[ERROR] Error reason(%d), msg(%s), notify(%d)", reason, msg, notify); //LCOV_EXCL_LINE
 
        ma_client_set_error(g_ma, reason);
-       __ma_notify_error((void*)g_ma);
+       if (notify) {
+               __ma_notify_error((void*)g_ma);
+       }
 
        if (MA_ERROR_SERVICE_RESET == reason) {
                if (0 != ma_prepare()) {
index dd62350a0239cd5f7d2311b021e5deb468738f0d..eaa6ac896920e4c0b083bc8a9845114cd752529b 100644 (file)
@@ -30,8 +30,9 @@ static DBusConnection* g_conn_sender = NULL;
 static DBusConnection* g_conn_listener = NULL;
 
 static bool g_streaming_requested = false;
+static bool g_restart_notification_received = false;
 
-extern int __ma_cb_error(int reason, char* msg);
+extern int __ma_cb_error(int reason, char* msg, int notify);
 extern int __ma_cb_audio_streaming(int event, char* buffer, int len);
 extern int __ma_cb_active_state_changed(int state, const char* wakeup_word,
        const unsigned char* extra_data, int extra_data_length, const char* extra_data_desc);
@@ -475,11 +476,16 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler* fd_handle
                                //LCOV_EXCL_STOP
                        } else {
                                MA_SLOGD("@@ multi-assistant Get Error message : reason(%d), msg(%s)", reason, err_msg); //LCOV_EXCL_LINE
-                               __ma_cb_error(reason, err_msg);
+                               __ma_cb_error(reason, err_msg, TRUE);
                        }
 
                } /* MAS_METHOD_ERROR */
 
+               else if (dbus_message_is_signal(msg, if_name, MAS_METHOD_RESTART_NOTIFICATION)) {
+                       MA_SLOGE("RESTART NOTIFICATION RECEIVED");
+                       g_restart_notification_received = true;
+               } /* MAS_METHOD_RESTART_NOTIFICATION */
+
                else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) {
                        //LCOV_EXCL_START
                        MA_SLOGD("[DEBUG] Owner Changed"); //LCOV_EXCL_LINE
@@ -496,7 +502,8 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler* fd_handle
                                dbus_error_free(&err);
                        }
 
-                       __ma_cb_error(MA_ERROR_SERVICE_RESET, "Daemon Reset");
+                       __ma_cb_error(MA_ERROR_SERVICE_RESET, "Daemon Reset", g_restart_notification_received ? FALSE : TRUE);
+                       g_restart_notification_received = false;
                        //LCOV_EXCL_STOP
                } /* NameOwnerChanged */
 
index 049d98baafa42d0d2277ae06a7857305293850c3..a889374cc322716060213ee214054c19dc1d467a 100644 (file)
@@ -95,6 +95,7 @@ extern "C"
 #define MAS_METHOD_STREAMING_AUDIO_DATA                                "mas_method_streaming_audio_data"
 #define MAS_METHOD_WAKEUP_ENGINE_COMMAND                       "mas_method_wakeup_engine_command"
 #define MAS_METHOD_ERROR                                                       "mas_method_error"
+#define MAS_METHOD_RESTART_NOTIFICATION                                "mas_method_restart_notification"
 #define MAS_METHOD_SEND_PREPROCESSING_INFORMATION      "mas_method_send_preprocessing_information"
 #define MAS_METHOD_AUDIO_STREAMING_DATA_SECTION                "mas_method_audio_streaming_data_section"
 #define MAS_METHOD_SEND_PREPROCESSING_RESULT           "mas_method_send_preprocessing_result"