Message ID | 20240724085318.209318-2-YanceyChiew@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | Fix com.bluez.battery1 randomly missing percentage | expand |
diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c index 02d024d92..b2699c0d7 100644 --- a/profiles/battery/battery.c +++ b/profiles/battery/battery.c @@ -94,13 +94,15 @@ static void parse_battery_level(struct batt *batt, uint8_t percentage; percentage = value[0]; + + if (!batt->battery) { + warn("Trying to update an unregistered battery"); + return; + } + if (batt->percentage != percentage) { batt->percentage = percentage; DBG("Battery Level updated: %d%%", percentage); - if (!batt->battery) { - warn("Trying to update an unregistered battery"); - return; - } btd_battery_update(batt->battery, batt->percentage); } }