Send restart notification when a scheduled restart takes place 30/288230/2 accepted/tizen_7.0_unified accepted/tizen/7.0/unified/20230303.102018
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 9 Feb 2023 08:20:29 +0000 (17:20 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 14 Feb 2023 04:00:38 +0000 (13:00 +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: Id7c3ff404f43e09dfb2488a7402b9afcbc2051f3

inc/service_common.h
inc/service_ipc_dbus.h
src/service_ipc_dbus.cpp
src/service_main.cpp

index 58bbf7c..25444d6 100644 (file)
@@ -90,6 +90,7 @@
 #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"
index 900e792..86796fe 100644 (file)
@@ -35,6 +35,7 @@ public:
        int close_connection();
        int send_hello(pid_t pid);
        int send_error_message(int reason, const char* err_msg);
+       int send_restart_notification();
        int send_streaming_audio_data(std::string appid, int event, void* data, unsigned int data_size);
        int change_active_state(pid_t pid, int state, const char* wakeup_word,
                const unsigned char* wakeup_extra_data, size_t wakeup_extra_data_length,
index 365c3b8..0e30c72 100644 (file)
@@ -217,6 +217,44 @@ int CServiceIpcDbus::send_error_message(int reason, const char* err_msg)
        return 0;
 }
 
+int CServiceIpcDbus::send_restart_notification()
+{
+       if (0 != __dbus_check()) {
+               return -1; //MAS_ERROR_OPERATION_FAILED;
+       }
+
+       if (NULL == mConnectionSender) {
+               MAS_LOGE("[Dbus ERROR] Dbus connection is not available");
+               return -1;
+       }
+
+       DBusMessage* msg = NULL;
+
+       /* create a message */
+       msg = dbus_message_new_signal(
+               MA_CLIENT_SERVICE_OBJECT_PATH,  /* object name of the signal */
+               MA_CLIENT_SERVICE_INTERFACE,    /* interface name of the signal */
+               MAS_METHOD_RESTART_NOTIFICATION);               /* name of the signal */
+
+       if (NULL == msg) {
+               MAS_LOGE("[Dbus ERROR] Fail to create error message");
+               return -1;
+       }
+
+       dbus_message_set_no_reply(msg, TRUE);
+
+       if (!dbus_connection_send(mConnectionSender, msg, NULL)) {
+               MAS_LOGE("[Dbus ERROR] <<<< error message : Out Of Memory !");
+       } else {
+               MAS_LOGI("<<<< Send restart notification message");
+               dbus_connection_flush(mConnectionSender);
+       }
+
+       dbus_message_unref(msg);
+
+       return 0;
+}
+
 const char *message_port = "ma_streaming_port";
 
 #define STREAMING_BUFFER_SIZE 4096
index 874a433..7858a88 100644 (file)
@@ -1464,6 +1464,7 @@ void CServiceMain::app_terminate(void *data)
 
 void CServiceMain::app_restart()
 {
+       mServiceIpc.send_restart_notification();
        service_app_exit();
 }