battery popup : change lowbattery_poweroff process 67/109167/1 accepted/tizen/3.0/common/20170116.122651 accepted/tizen/3.0/mobile/20170114.000334 accepted/tizen/3.0/tv/20170114.000337 accepted/tizen/3.0/wearable/20170114.000340 submit/tizen_3.0/20170113.125122
authorlokilee73 <changjoo.lee@samsung.com>
Mon, 9 Jan 2017 06:03:00 +0000 (15:03 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 9 Jan 2017 06:03:13 +0000 (15:03 +0900)
Change-Id: Ia47f6b2e54f930db6c655ca4abd2c4fb67d4a124
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/battery/battery-wearable.c

index a53a3f5..d0d68f7 100755 (executable)
@@ -28,6 +28,13 @@ static const struct popup_ops charge_error_low_ops;
 static const struct popup_ops charge_error_high_ops;
 static const struct popup_ops battery_disconnected_ops;
 
+#define DEVICED_BUS_NAME        "org.tizen.system.deviced"
+#define POWER_OBJECT_PATH     "/Org/Tizen/System/DeviceD/Power"
+#define POWER_INTERFACE_NAME  DEVICED_BUS_NAME".power"
+
+#define POWER_METHOD            "reboot"
+#define POWER_OPERATION_OFF     "poweroff"
+
 static int lowbattery_launch(bundle *b, const struct popup_ops *ops);
 
 static int remove_other_lowbattery_popups(const struct popup_ops *ops)
@@ -133,14 +140,27 @@ static void lowbattery_terminate(const struct popup_ops *ops)
 
 static void poweroff_clicked(const struct popup_ops *ops)
 {
-       _I("Power off the phone");
-       unload_simple_popup(ops);
+       static int bPowerOff = 0;
+       char *param[2];
+       char data[8];
+       int ret;
 
-       if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS,
-                               VCONFKEY_SYSMAN_POWER_OFF_DIRECT) != 0)
-               _E("Failed to request poweroff to deviced");
+       if (bPowerOff == 1)
+               return;
+       bPowerOff = 1;
 
-       terminate_if_no_popup();
+       unload_simple_popup(ops);
+
+       param[0] = POWER_OPERATION_OFF;
+       snprintf(data, sizeof(data), "0");
+       param[1] = data;
+       ret = popup_dbus_method_sync(DEVICED_BUS_NAME,
+                       POWER_OBJECT_PATH,
+                       POWER_INTERFACE_NAME,
+                       POWER_METHOD,
+                       "si", param);
+       if (ret < 0)
+               _E("Failed to request poweroff to deviced (%d)", ret);
 }
 
 static void charge_error_ok_clicked(const struct popup_ops *ops)