Merge "power: add interface to receive the command name" into tizen
authorChang Joo Lee <changjoo.lee@samsung.com>
Thu, 27 Oct 2016 08:28:36 +0000 (01:28 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 27 Oct 2016 08:28:36 +0000 (01:28 -0700)
src/power/power.c

index 8f2ccff..8d4f9bb 100755 (executable)
@@ -21,6 +21,8 @@
 #include "popup-common.h"
 
 #define APP_PID       "_APP_PID_"
+#define APP_COMM      "_APP_COMM_"
+#define REQ_ID        "_REQUEST_ID_"
 
 #define DBUS_POWER_PATH "/Org/Tizen/System/DeviceD/Power"
 #define DBUS_POWER_IFACE "org.tizen.system.deviced.power"
@@ -28,6 +30,7 @@
 
 static const struct popup_ops power_lock_expired_ops;
 static bool signal_broadcasted;
+static char *request_id;
 
 enum button_selected {
        ALLOW_APP,
@@ -38,19 +41,20 @@ static void send_result_dbus_signal(int result)
 {
        int ret;
        char buf[8];
-       char *param[1];
+       char *param[2];
 
        if (signal_broadcasted)
                return;
 
        signal_broadcasted = true;
 
+       param[0] = request_id;
        snprintf(buf, sizeof(buf), "%d", result);
-       param[0] = buf;
+       param[1] = buf;
        ret = broadcast_dbus_signal(DBUS_POWER_PATH,
                        DBUS_POWER_IFACE,
                        METHOD_POWER_LOCK_EXPIRED,
-                       "i", param);
+                       "si", param);
        if (ret < 0)
                _E("FAIL: broadcast_dbus_signal(%d)", ret);
 }
@@ -77,11 +81,20 @@ static int power_lock_expired_get_content(const struct popup_ops *ops, char *con
                return -ENOENT;
        }
 
+       request_id = (char *)bundle_get_val(obj->b, REQ_ID);
+       if (!request_id) {
+               _E("Failed to get request id");
+               return -ENOENT;
+       }
+
        pid = atoi(pid_str);
        ret = app_manager_get_app_id(pid, &name);
        if (ret != APP_MANAGER_ERROR_NONE) {
-               _E("Failed to get app name(%d)", ret);
-               return -ENOENT;
+               name = (char *)bundle_get_val(obj->b, APP_COMM);
+               if (!name) {
+                       _E("Failed to get app command");
+                       return -ENOENT;
+               }
        }
 
        text = _("\"%s\" is using too much battery power. Close \"%s\" ?");