summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungjae Cho <y0.cho@samsung.com>2020-06-23 10:37:42 +0900
committerYoungjae Cho <y0.cho@samsung.com>2020-06-23 13:03:46 +0900
commita527409e299dfb4ef4dd10e7d1a42a6ced600728 (patch)
tree6f15d161a338561a9646749ac419246c72e8831d
parentaf9af1daecc71b28cc20f6e265a81f0def00fb17 (diff)
downloaddeviced-a527409e299dfb4ef4dd10e7d1a42a6ced600728.tar.gz
deviced-a527409e299dfb4ef4dd10e7d1a42a6ced600728.tar.bz2
deviced-a527409e299dfb4ef4dd10e7d1a42a6ced600728.zip
Add varialbe for checking battery initialization
Change-Id: Ib3e325abdb0da182a86d07c56796db2366f2722e Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
-rw-r--r--src/battery/lowbat-handler.c2
-rw-r--r--src/battery/power-supply.c27
-rw-r--r--src/battery/power-supply.h1
3 files changed, 22 insertions, 8 deletions
diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c
index d86d224e..7e56f442 100644
--- a/src/battery/lowbat-handler.c
+++ b/src/battery/lowbat-handler.c
@@ -469,7 +469,7 @@ static int lowbat_process(int bat_percent, void *ad)
bool low_bat = false;
int result = 0;
- if (battery.online == POWER_SUPPLY_TYPE_UNKNOWN)
+ if (!battery_initialized)
return -EINVAL;
new_bat_capacity = bat_percent;
diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c
index 766a7379..0cca7e83 100644
--- a/src/battery/power-supply.c
+++ b/src/battery/power-supply.c
@@ -98,6 +98,8 @@ static bool launching_health_popup;
static guint power_timer;
static device_notifier_state_e old_state = -1;
+bool battery_initialized;
+
bool battery_do_not_disturb(void);
int battery_pm_change_internal(int pid, int s_bits);
static int booting_done(void *data);
@@ -902,6 +904,8 @@ static void uevent_power_handler(struct udev_device *dev)
env_value = udev_device_get_property_value(dev, CAPACITY);
check_capacity_status(env_value);
+ battery_initialized = true;
+
ret = booting_done(NULL);
if (ret) {
if (battery.online > POWER_SUPPLY_TYPE_BATTERY)
@@ -995,6 +999,8 @@ static void battery_changed(struct battery_info *info, void *data)
battery.voltage_average = info->voltage_average;
battery.freq_strength = info->freq_strength;
+ battery_initialized = true;
+
ret = battery_state(info);
if (ret != 1)
return;
@@ -1249,6 +1255,7 @@ static GVariant *dbus_power_supply_handler(GDBusConnection *conn,
check_present_status(argv[4]);
check_misc_status(argv[5]);
check_freq_strength_status(argv[6]);
+
if (battery_dev)
battery_changed(NULL, NULL);
snprintf(battery.status_s, sizeof(battery.status_s), "%s",
@@ -1324,15 +1331,18 @@ static GVariant *dbus_get_battery_info(GDBusConnection *conn,
if (old_state == DEVICE_NOTIFIER_STATE_STOP)
goto out;
+ if (battery_initialized)
+ goto out;
+
if (battery_dev && battery_dev->get_current_state) {
- ret = battery_dev->get_current_state(battery_get_info, &info);
- if (ret < 0)
- _E("Failed to get battery info: %d", ret);
+ ret = battery_dev->get_current_state(battery_get_info, &info);
+ if (ret < 0)
+ _E("Failed to get battery info: %d", ret);
- battery_changed(&info, NULL);
- free(info.status);
- free(info.health);
- free(info.power_source);
+ battery_changed(&info, NULL);
+ free(info.status);
+ free(info.health);
+ free(info.power_source);
} else {
if (vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, &val) == 0 &&
val != VCONFKEY_SYSMAN_USB_DISCONNECTED)
@@ -1623,6 +1633,9 @@ static void power_supply_init(void *data)
battery.misc = MISC_NONE;
battery.freq_strength = 0;
+ /* It will be true on initializing battery structure */
+ battery_initialized = false;
+
/* process check battery timer until booting done */
power_supply_timer_start();
diff --git a/src/battery/power-supply.h b/src/battery/power-supply.h
index af4fb0c5..1a2dfee5 100644
--- a/src/battery/power-supply.h
+++ b/src/battery/power-supply.h
@@ -120,6 +120,7 @@ struct battery_status {
extern struct battery_status battery;
extern struct battery_status old_battery;
+extern bool battery_initialized;
int power_supply_broadcast(char *sig, int status);
int battery_pm_change_internal(int pid, int s_bits);