[Watchdog] Send the watchdog activation signal
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 13 Nov 2023 04:12:53 +0000 (13:12 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 14 Nov 2023 00:47:58 +0000 (09:47 +0900)
When the watchdog option is 'enable-by-default', amd sends the watchdog
activation signal to the running application.

Change-Id: I2b99b9b62b593b44bb82a8662c069251ab086f68
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/lib/amd_app_status.cc
src/lib/api/amd_api_noti_msg.h
src/modules/watchdog/src/amd_watchdog.c

index 49ac9fe3de2a427e77c69e0aa27550f0f6ba9744..20f32d83d148cda027e5a6bada236d760c73ab94 100644 (file)
@@ -855,6 +855,7 @@ static int DispatchAppNotifyStart(request_h req) {
         static_cast<app_status_h>(app.get()), nullptr);
   }
 
+  _noti_send(AMD_NOTI_MSG_APP_STATUS_APP_START, pid, 0, nullptr, nullptr);
   _W("[APP_NOTIFY_START] pid(%d)", pid);
   return 0;
 }
index 8264d3f192b1914cf18b98771317d9881d1dc6b1..0686f0907a7529563674289326156326ea8c7325 100644 (file)
@@ -1032,6 +1032,16 @@ extern "C" {
 #define AMD_NOTI_MSG_LAUNCH_MANAGER_APP_LAUNCHED                               \
        "launch_manager.app.launched"
 
+/**
+ * @brief Definition for the notification message: The app starts.
+ * @details Input: arg1(int) The process ID.\n
+ * @since_tizen 7.0
+ *
+ * @see DispatchAppNotifyStart()
+ */
+#define AMD_NOTI_MSG_APP_STATUS_APP_START                                      \
+       "app_status.app_start"
+
 #ifdef __cplusplus
 }
 #endif
index d40ce9855836caeec0691e8b92d47c81238c7fa0..aec65c127927baa60caf29e0d1c9e610706dd42b 100644 (file)
@@ -347,7 +347,6 @@ static int __on_app_status_add(const char *msg, int arg1, int arg2,
        int pid = amd_app_status_get_pid(app_status);
        uid_t uid;
        proc_context *ctx;
-       int operation_state;
 
        ctx = __find_proc_context(pid);
        if (ctx) {
@@ -364,14 +363,34 @@ static int __on_app_status_add(const char *msg, int arg1, int arg2,
 
        __watchdog.proc_contexts = g_list_append(__watchdog.proc_contexts, ctx);
 
+       return AMD_NOTI_CONTINUE;
+}
+
+static int __on_app_status_app_start(const char *msg, int arg1, int arg2,
+               void *arg3, bundle *arg4)
+{
+       pid_t pid = arg1;
+       proc_context *ctx;
+       int operation_state;
+       int ret;
+
        operation_state = _watchdog_config_get_operation_state();
-       if (operation_state == WATCHDOG_ENABLE_BY_DEFAULT) {
-               __watchdog_set_timer(ctx);
-               ctx->watchdog_enable = true;
-               _watchdog_logger_print("ENABLE", "pid(%d), appid(%s)",
-                               pid, amd_app_status_get_appid(app_status));
+       if (operation_state != WATCHDOG_ENABLE_BY_DEFAULT)
+               return AMD_NOTI_CONTINUE;
+
+       ctx = __find_proc_context(pid);
+       if (ctx == NULL) {
+               _E("Failed to find proc status. pid(%d)", pid);
+               return AMD_NOTI_CONTINUE;
        }
 
+       ret = __send_request(ctx, WATCHDOG_ENABLE, __watchdog.interval);
+       _W("pid(%d), result(%d)", pid, ret);
+
+       __watchdog_set_timer(ctx);
+       ctx->watchdog_enable = true;
+       _watchdog_logger_print("ENABLE", "pid(%d)", pid);
+
        return AMD_NOTI_CONTINUE;
 }
 
@@ -522,6 +541,8 @@ EXPORT int AMD_MOD_INIT(void)
 
        amd_noti_listen(AMD_NOTI_MSG_APP_STATUS_ADD,
                        __on_app_status_add);
+       amd_noti_listen(AMD_NOTI_MSG_APP_STATUS_APP_START,
+                       __on_app_status_app_start);
        amd_noti_listen(AMD_NOTI_MSG_APP_STATUS_CLEANUP,
                        __on_app_status_cleanup);
        amd_noti_listen(AMD_NOTI_MSG_SIGNAL_SEND_WATCHDOG_START,