[Watchdog] Send the watchdog activation signal 43/301243/8
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:02:25 +0000 (09:02 +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 d289c42662f91e48aa3e9eef9becad7c67a347fe..3ad19ff61bf8aad2dfb886e68eb6687552d9ee7f 100644 (file)
@@ -889,6 +889,7 @@ static int DispatchAppNotifyStart(request_h request) {
         static_cast<app_status_h>(handle.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 bb0410b2dc15568a6dd97c1567d6952881d5014a..db282bf94fcf6ef5d5f70d83d6eea3f61e629c1a 100644 (file)
@@ -1032,12 +1032,22 @@ 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"
+
 /**
  * @brief Definition for the notification message: The app process group set.
  * @details Input: arg1(int) The leader process ID.\n
  *          Input: arg2(int) The sub process ID.\n
  * @since_tizen 8.0
- * 
+ *
  * @see __dispatch_app_set_process_group()
  */
 #define AMD_NOTI_MSG_UTIL_APP_SET_PROCESS_GROUP                                \
@@ -1048,7 +1058,7 @@ extern "C" {
  * @details Input: arg1(int) The leader process ID.\n
  *          Input: arg2(int) The sub process ID.\n
  * @since_tizen 8.0
- * 
+ *
  * @see __app_group_context_set_status()
  */
 #define AMD_NOTI_MSG_APP_GROUP_SET                                             \
index 02f5f5c58f654d560d91d4941d85102ee21dd537..17217f486293c0b94a29ad05b3703e6241ae47eb 100644 (file)
@@ -351,7 +351,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) {
@@ -368,14 +367,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;
 }
 
@@ -526,6 +545,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,