battery:Fixed a bug of battery popup 25/126125/3 accepted/tizen/unified/20170420.155650 submit/tizen/20170420.075753
authorwchang kim <wchang.kim@samsung.com>
Thu, 20 Apr 2017 07:27:18 +0000 (16:27 +0900)
committerwchang kim <wchang.kim@samsung.com>
Thu, 20 Apr 2017 07:50:16 +0000 (16:50 +0900)
Battery popup does not appear when device boots up.
This bug is fixed.

Change-Id: I3d99cc095fdbcae0e3dede70f361c6013b71083a

src/battery/lowbat-handler.c

index a42f2a9..d1c2d68 100644 (file)
@@ -133,8 +133,10 @@ static int lowbat_scenario(int old, int now, void *data)
                        continue;
                if (!scenario->func)
                        continue;
-               scenario->func(data);
-               found = 1;
+               if (scenario->func(data) == 0)
+                       found = 1;
+               else
+                       found = 0;
                break;
        }
        return found;
@@ -306,7 +308,7 @@ static int get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char
                *actvie_noti = NULL;
                *event_noti = NULL;
        }
-       _I("actvie_noti=%s event_noti=%s", actvie_noti, event_noti);
+       _D("actvie_noti=%s event_noti=%s", *actvie_noti, *event_noti);
        return ret;
 }
 
@@ -429,8 +431,10 @@ direct_launch:
                } else
                        return launch_system_app(APP_DEFAULT,
                                        2, APP_KEY_TYPE, value);
-       } else
+       } else {
                _D("boot-animation running yet");
+               return -1;
+       }
 
        return 0;
 }
@@ -438,57 +442,51 @@ direct_launch:
 static int battery_check_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CHARGE_CHECK_ACT);
-       return 0;
+       return lowbat_popup(CHARGE_CHECK_ACT);
 }
 
 static int battery_warning_low_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(WARNING_LOW_BAT_ACT);
-       return 0;
+       return lowbat_popup(WARNING_LOW_BAT_ACT);
 }
 
 static int battery_critical_low_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CRITICAL_LOW_BAT_ACT);
-       return 0;
+       return lowbat_popup(CRITICAL_LOW_BAT_ACT);
 }
 
 int battery_power_off_act(void *data)
 {
-       lowbat_popup(CRITICAL_LOW_BAT_ACT);
+       int ret;
+       ret = lowbat_popup(CRITICAL_LOW_BAT_ACT);
        power_off_timer_start();
-       return 0;
+       return ret;
 }
 
 int battery_charge_err_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_ACT);
-       return 0;
+       return lowbat_popup(CHARGE_ERROR_ACT);
 }
 
 int battery_charge_err_low_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_LOW_ACT);
-       return 0;
+       return lowbat_popup(CHARGE_ERROR_LOW_ACT);
 }
 
 int battery_charge_err_high_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_HIGH_ACT);
-       return 0;
+       return lowbat_popup(CHARGE_ERROR_HIGH_ACT);
 }
 
 int battery_charge_err_ovp_act(void *data)
 {
        power_off_timer_stop();
-       lowbat_popup(CHARGE_ERROR_OVP_ACT);
-       return 0;
+       return lowbat_popup(CHARGE_ERROR_OVP_ACT);
 }
 
 static void lowbat_scenario_init(void)
@@ -717,13 +715,15 @@ static int lowbat_process(int bat_percent, void *ad)
                cur_bat_state = battery_info.normal;
        if (battery.charge_now) {
                clear_noti_if_needed("clear", "all");
+               result = 1;
        } else {
                result = lowbat_scenario(cur_bat_state, new_bat_state, NULL);
                if (result)
                        _I("cur %d, new %d(capacity %d)",
                        cur_bat_state, new_bat_state, bat_percent);
        }
-       cur_bat_state = new_bat_state;
+       if (result == 1)
+               cur_bat_state = new_bat_state;
 exit:
        if (lock == 0)
                pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);