Message ID | 20240723082843.184915-2-YanceyChiew@gmail.com |
---|---|
State | New |
Headers | show |
Series | Fix com.bluez.battery1 randomly missing percentage value | 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); } }