summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2018-05-08 17:08:07 +0900
committerHwanKyu Jhun <h.jhun@samsung.com>2018-05-30 04:41:24 +0000
commitd30ea372aac6d2d435abaaf87c82aa03a4c23197 (patch)
treeb6fe4d0b95599c078db0f600056c66ef71b81c87
parent3f87111dd1a3935a7cb8b068c8bca98481b94aa7 (diff)
downloadaul-1-d30ea372aac6d2d435abaaf87c82aa03a4c23197.tar.gz
aul-1-d30ea372aac6d2d435abaaf87c82aa03a4c23197.tar.bz2
aul-1-d30ea372aac6d2d435abaaf87c82aa03a4c23197.zip
Fix aul_update_freezer_status API
- Uses a method call instead of a signal Change-Id: Iecad5095f36c0c36d92c6e7cea4116f2e5215446 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/app_signal.h1
-rw-r--r--include/aul_util.h1
-rw-r--r--src/app_signal.c73
3 files changed, 71 insertions, 4 deletions
diff --git a/include/app_signal.h b/include/app_signal.h
index 9df5b23b..e0da2282 100644
--- a/include/app_signal.h
+++ b/include/app_signal.h
@@ -46,6 +46,7 @@
#define TEP_UNMOUNT_METHOD "Unmount"
#define TEP_IS_MOUNTED_METHOD "IsMounted"
+#define RESOURCED_BUS_NAME "org.tizen.resourced"
#define RESOURCED_PROC_PATH "/Org/Tizen/ResourceD/Process"
#define RESOURCED_PROC_INTERFACE "org.tizen.resourced.process"
#define RESOURCED_PROC_STATUS_SIGNAL "ProcStatus"
diff --git a/include/aul_util.h b/include/aul_util.h
index 727ba7c7..c93607f2 100644
--- a/include/aul_util.h
+++ b/include/aul_util.h
@@ -28,6 +28,7 @@
#define _E(fmt, arg...) LOGE(fmt, ##arg)
#define _D(fmt, arg...) LOGD(fmt, ##arg)
#define _W(fmt, arg...) LOGW(fmt, ##arg)
+#define _I(fmt, arg...) LOGI(fmt, ##arg)
#define AUL_UTIL_PID -2
#define MAX_LOCAL_BUFSZ 128
diff --git a/src/app_signal.c b/src/app_signal.c
index d9b29c36..be2dbb25 100644
--- a/src/app_signal.c
+++ b/src/app_signal.c
@@ -342,16 +342,81 @@ end:
return ret;
}
+static void __dbus_message_ready_cb(GObject *source_object,
+ GAsyncResult *res, gpointer user_data)
+{
+ GDBusConnection *conn = (GDBusConnection *)user_data;
+ GError *err = NULL;
+ GDBusMessage *reply;
+ int r;
+
+ reply = g_dbus_connection_send_message_with_reply_finish(conn,
+ res, &err);
+ if (!reply) {
+ _E("No reply. err(%s)", err ? err->message : "Unknown");
+ r = -1;
+ } else {
+ r = 0;
+ }
+
+ g_clear_error(&err);
+ if (reply)
+ g_object_unref(reply);
+ if (conn)
+ g_object_unref(conn);
+
+ _I("Result(%d)", r);
+}
+
+static int __system_dbus_send_message(const char *name,
+ const char *path, const char *interface,
+ const char *method, GVariant *body)
+{
+ GError *err = NULL;
+ GDBusConnection *conn;
+ GDBusMessage *msg;
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (conn == NULL) {
+ _E("Failed to connect to dbus. err(%s)", err->message);
+ g_error_free(err);
+ return AUL_R_ERROR;
+ }
+
+ msg = g_dbus_message_new_method_call(name, path, interface, method);
+ if (msg == NULL) {
+ _E("Failed to create a new message for a method call");
+ g_object_unref(conn);
+ return AUL_R_ERROR;
+ }
+
+ g_dbus_message_set_body(msg, body);
+ g_dbus_connection_send_message_with_reply(conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+ -1, NULL, NULL, __dbus_message_ready_cb,
+ (gpointer)conn);
+
+ return AUL_R_OK;
+}
+
API int aul_update_freezer_status(int pid, const char *type)
{
int ret;
- GVariant *param;
+ GVariant *body;
+
+ body = g_variant_new("(si)", type, pid);
+ if (!body) {
+ _E("Out of memory");
+ return AUL_R_ERROR;
+ }
- param = g_variant_new("(si)", type, pid);
- ret = __system_dbus_send_signal(RESOURCED_PROC_PATH,
+ ret = __system_dbus_send_message(RESOURCED_BUS_NAME,
+ RESOURCED_PROC_PATH,
RESOURCED_PROC_INTERFACE,
RESOURCED_PROC_METHOD,
- param);
+ body);
+ if (ret != AUL_R_OK)
+ g_variant_unref(body);
return ret;
}