2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <sys/types.h>
24 #define RESOURCED_DBUS_BUS_NAME "org.tizen.resourced"
25 #define RESOURCED_PATH_WATCHDOG "/Org/Tizen/ResourceD/Watchdog"
26 #define RESOURCED_INTERFACE_WATCHDOG "org.tizen.resourced.watchdog"
27 #define WATCHDOG_START "Start"
29 static unsigned int dbus_watchdog_timeout=0;
31 static int aw_send_watchdog(unsigned int timeout)
34 static GDBusConnection *g_dbus_conn = NULL;
35 GVariant *param = NULL;
38 g_dbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
43 param = g_variant_new("(iu)", getpid(), timeout);
44 g_dbus_connection_call(g_dbus_conn, RESOURCED_DBUS_BUS_NAME,
45 RESOURCED_PATH_WATCHDOG, RESOURCED_INTERFACE_WATCHDOG, WATCHDOG_START,
46 param, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
51 int aw_register_dbus(unsigned int timeout)
58 aw_send_watchdog(timeout);
59 dbus_watchdog_timeout = timeout;
63 int aw_control_dbus(aw_op_e op, void *data)
66 unsigned int* timeout;
70 ret = aw_send_watchdog(0);
74 ret = aw_send_watchdog(dbus_watchdog_timeout);
77 case AW_OP_CHANGE_TIMEOUT:
78 timeout = (unsigned int*)(data);
83 dbus_watchdog_timeout = *timeout;
84 ret = aw_send_watchdog(*timeout);
94 int aw_notify_dbus(void)
96 return aw_send_watchdog(dbus_watchdog_timeout);