return 1;
}
+static void battery_invalidate_vconf(int value)
+{
+ int retval;
+ const char *vconf[] = {
+ VCONFKEY_SYSMAN_BATTERY_CAPACITY,
+ VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
+ VCONFKEY_SYSMAN_BATTERY_LEVEL_STATUS,
+ };
+
+ _D("Invalidate battery vconfs to %d", value);
+
+ for (int i = 0; i < ARRAY_SIZE(vconf); ++i) {
+ retval = vconf_set_int(vconf[i], value);
+ if (retval == 0)
+ _D("Set vconf %s to %d", vconf[i], value);
+ else
+ _E("Failed to set %s to %d, %d", vconf[i], value, retval);
+ }
+}
+
static void battery_changed(struct battery_info *info, void *data)
{
int ret_val;
battery.present = PRESENT_NORMAL;
}
- process_power_supply(&battery.capacity);
-
+ if (battery.present) {
+ process_power_supply(&battery.capacity);
+ } else {
+ _D("Battery disconnected");
+ battery_invalidate_vconf(-ENODEV);
+ }
}
static void power_supply_status_init(void)
static void power_supply_timer_stop(void)
{
+ int retval;
+
if (power_timer == 0)
return;
_I("Stop battery init timer during booting.");
g_source_remove(power_timer);
power_timer = 0;
+
+ /* check battery has been initialized until booting done */
+ retval = hal_device_battery_get_current_state(battery_changed, NULL);
+ if (retval < 0) {
+ _E("Failed to initialize battery state");
+ battery_invalidate_vconf(retval);
+ }
}
static GVariant *dbus_get_charger_status(GDBusConnection *conn,