New APIs and commands are added for supporting watchdog timer.
Adds:
- aul_watchdog_enable()
- aul_watchdog_disable()
- aul_watchdog_kick()
Requires:
- https://review.tizen.org/gerrit/#/c/185276/ [aul-1]
- https://review.tizen.org/gerrit/#/c/185882/ [app-core]
- https://review.tizen.org/gerrit/#/c/185884/ [amd]
- https://review.tizen.org/gerrit/#/c/186247/ [app-common]
Change-Id: I52c61b8bccc9070603900878a5044c0ab6325829
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_rpc_port.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_complication.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_debug_info.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_watchdog.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
RPC_PORT_NOTIFY_RPC_FINISHED = 102,
COMPLICATION_UPDATE_REQUEST = 103,
APP_NOTIFY_START = 104,
+ WATCHDOG_ENABLE = 105,
+ WATCHDOG_DISABLE = 106,
+ WATCHDOG_PING = 107,
+ WATCHDOG_KICK = 108,
APP_CMD_MAX
};
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AUL_WATCHDOG_H__
+#define __AUL_WATCHDOG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Enables watchdog timer.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_watchdog_enable(void);
+
+/**
+ * @brief Disables watchdog timer.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_watchdog_disable(void);
+
+/**
+ * @brief Kicks whatchdog timer.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_watchdog_kick(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUL_WATCHDOG_H__ */
return "COMPLICATION_UPDATE_REQUEST";
case APP_NOTIFY_START:
return "APP_NOTIFY_START";
+ case WATCHDOG_ENABLE:
+ return "WATCHDOG_ENABLE";
+ case WATCHDOG_DISABLE:
+ return "WATCHDOG_DISABLE";
+ case WATCHDOG_PING:
+ return "WATCHDOG_PING";
+ case WATCHDOG_KICK:
+ return "WATCHDOG_KICK";
default:
return "CUSTOM_COMMAND";
}
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdbool.h>
+#include <glib.h>
+
+#include "aul_api.h"
+#include "aul_util.h"
+#include "aul_sock.h"
+#include "aul_error.h"
+#include "aul_watchdog.h"
+#include "aul.h"
+
+typedef struct watchdog_context_s {
+ bool enabled;
+} watchdog_context;
+
+static watchdog_context __context;
+
+API int aul_watchdog_enable(void)
+{
+ int r;
+
+ if (__context.enabled) {
+ _W("Watchdog is already enabled");
+ return AUL_R_OK;
+ }
+
+ r = aul_sock_send_raw(AUL_UTIL_PID, getuid(),
+ WATCHDOG_ENABLE, NULL, 0, AUL_SOCK_NONE);
+ if (r < 0) {
+ _E("Failed to send the watchdog request. ret(%d)", r);
+ return aul_error_convert(r);
+ }
+
+ __context.enabled = true;
+ _D("[__WATCHDOG__] enabled, result(%d)", r);
+ return AUL_R_OK;
+}
+
+API int aul_watchdog_disable(void)
+{
+ int r;
+
+ if (!__context.enabled) {
+ _W("Watchdog is not enabled");
+ return AUL_R_ERROR;
+ }
+
+ r = aul_sock_send_raw(AUL_UTIL_PID, getuid(),
+ WATCHDOG_DISABLE, NULL, 0, AUL_SOCK_NONE);
+ if (r < 0) {
+ _E("Failed to send the watchdog request. ret(%d)", r);
+ return aul_error_convert(r);
+ }
+
+ __context.enabled = false;
+ _D("[__WATCHDOG__] disabled, result(%d)", r);
+ return AUL_R_OK;
+}
+
+API int aul_watchdog_kick(void)
+{
+ int r;
+
+ if (!__context.enabled) {
+ _W("Watchdog is not enabled");
+ return AUL_R_ERROR;
+ }
+
+ r = aul_sock_send_raw(AUL_UTIL_PID, getuid(),
+ WATCHDOG_KICK, NULL, 0, AUL_SOCK_NONE);
+ if (r < 0) {
+ _E("Failed to send the watchdog request. ret(%d)", r);
+ return aul_error_convert(r);
+ }
+
+ _D("[__WATCHDOG__] kicked, result(%d)", r);
+ return AUL_R_OK;
+}
bundle *kbundle = NULL;
int clifd;
struct ucred cr;
-
const char *pid_str;
+ const char *start_time;
+ struct timeval tv;
int pid = -1;
int ret;
} else {
ret = __send_result_to_launchpad(clifd, 0);
if (ret < 0) {
+ _E("Failed to send the result. cmd(%s:%d)",
+ aul_cmd_convert_to_string(pkt->cmd),
+ pkt->cmd);
free(pkt);
return -1;
}
case APP_UPDATE_REQUESTED:
app_update_requested();
break;
+ case WATCHDOG_PING:
+ gettimeofday(&tv, NULL);
+ start_time = bundle_get_val(kbundle, AUL_K_STARTTIME);
+ _W("[__WATCHDOG__] Start time: %s, response time: %ld/%ld",
+ start_time ? start_time : "Unknown",
+ tv.tv_sec, tv.tv_usec);
+ break;
default:
_E("no support packet");
}