to avoid a situation writing a vconf value over and over again 20/14920/2
authorjy910.yun <jy910.yun@samsung.com>
Wed, 8 May 2013 08:46:39 +0000 (17:46 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Thu, 16 Jan 2014 10:38:45 +0000 (11:38 +0100)
Change-Id: I9d637e567446e3ac9ce061e7ff77c0fb5b71eb7c
Signed-off-by: jy910.yun <jy910.yun@samsung.com>
src/battery/lowbat-handler.c

index 38338f2..eaca795 100644 (file)
@@ -24,6 +24,8 @@
 #include <fcntl.h>
 #include <device-node.h>
 #include <bundle.h>
+#include <stdbool.h>
+
 #include "core/log.h"
 #include "core/launch.h"
 #include "core/noti.h"
@@ -148,14 +150,22 @@ static int battery_charge_act(void *data)
        return 0;
 }
 
-int ss_lowbat_set_charge_on(int onoff)
+int ss_lowbat_set_charge_on(int on)
 {
-       if(vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, onoff) != 0) {
+       static bool state = -1;
+
+       if (state == on)
+               return 0;
+
+       if (vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, on) != 0) {
                _E("fail to set charge vconf value");
-               return -1;
+               return -EPERM;
        }
+
        if (update_pm_setting)
-               update_pm_setting(SETTING_CHARGING, onoff);
+               update_pm_setting(SETTING_CHARGING, on);
+
+       state = on;
        return 0;
 }