pmqos: Add callbacks for dbus messages 53/117153/5
authorWook Song <wook16.song@samsung.com>
Fri, 3 Mar 2017 03:48:25 +0000 (12:48 +0900)
committerWook Song <wook16.song@samsung.com>
Fri, 10 Mar 2017 07:26:49 +0000 (16:26 +0900)
This patch adds the callback functions for dbus messages that start and
stop the pmqos module.

Change-Id: I6a9203a766469c49ff9b9b96eb594082057288d7
Signed-off-by: Wook Song <wook16.song@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pmqos/pmqos.c

index 1ade574eebc1f321112e50f31d5a90b119cca002..6b7c2f1a2301a147cf60fd6c9efa978bace43306 100644 (file)
@@ -51,6 +51,43 @@ static struct timespec unlock_timer_start_st;
 static struct timespec unlock_timer_end_st;
 static struct pmqos_cpu unlock_timer_owner = {"", 0};
 
+/******************************************************
+ *       PMQOS callback functions for Init/Exit       *
+ *                   (Declarations)                   *
+ ******************************************************/
+static int pmqos_init_done(void *data, void *user_data);
+static void pmqos_free(void);
+
+/******************************************************
+ *                PASS D-Bus interface                *
+ ******************************************************/
+static DBusMessage* e_dbus_start_cb(E_DBus_Object *obj, DBusMessage* msg)
+{
+       DBusMessage *ret_dbus = NULL;
+       bool booting_done = true;
+       int ret;
+
+       ret = pmqos_init_done(&booting_done, NULL);
+       if (ret < 0) {
+               _E("failed to initialize the daemon in dbus callback \
+                               for a start message\n");
+               return ret_dbus;
+       }
+
+       ret_dbus = dbus_message_new_method_return(msg);
+       return ret_dbus;
+}
+
+static DBusMessage* e_dbus_stop_cb(E_DBus_Object *obj, DBusMessage* msg)
+{
+       DBusMessage *ret_dbus;
+
+       pmqos_free();
+
+       ret_dbus = dbus_message_new_method_return(msg);
+       return ret_dbus;
+}
+
 int set_pmqos(const char *name, int val)
 {
        char scenario[100];
@@ -364,6 +401,12 @@ static int get_methods_from_conf(const char *path, struct edbus_method **edbus_m
 
 /* Add pmqos name as alphabetically */
 static const struct edbus_method edbus_methods[] = {
+        { "start",             NULL,  NULL, e_dbus_start_cb },
+        { "stop",              NULL,  NULL, e_dbus_stop_cb },
+       /*
+        * TODO: The hard-coded scenario info is no longer required. Therefore,
+        * the following code will be removed.
+       */
        { "AppLaunch",            "i",    "i", dbus_pmqos_handler },
        { "AppLaunchHome",        "i",    "i", dbus_pmqos_handler },
        { "BeautyShot",           "i",    "i", dbus_pmqos_handler },