Bug 357193

Summary: KDEConnect does not handle secound batterie in phone
Product: [Applications] kdeconnect Reporter: m.wege
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description m.wege 2015-12-26 22:45:39 UTC
My Android phone (an Innos D6000) has two batteries. KDEconnect so far only seems recognise one of them and show it's status in KDE. Would be cool if KDEconnect would be able to handle both. I am not sure if this is a problem of the KDEpart, the Android app or both.

Reproducible: Always
Comment 1 Philip C 2020-04-13 05:54:15 UTC
Git commit c315170be5e6b2defe1a2768db007d70059c53c8 by Philip Cohn-Cort.
Committed on 13/04/2020 at 05:54.
Pushed by philipc into branch 'master'.

Finally, we have support for sending out Battery information.

## Summary

The core idea is as follows:

1. When a Link loads the BatteryPlugin, we query Solid for a list of batteries.
    1. If the list is empty, we print a warning message and return quickly
    2. Otherwise, we connect *two signals* to every object in that list
2. We send out a single new NetworkPacket as soon as we've processed that list
3. When either of those two signals emits, we send another new NetworkPacket

### Multi-battery Support

To handle devices with multiple batteries (requested in that bug), we average
together the battery percentages. This also includes a new field in the packet for
'number of batteries' called `batteryQuantity`. For backwards compatibility, we can
assume it has a default value of one.

This should ensure we support
- devices with no batteries at all (like many desktop machines)
- devices with hot-pluggable batteries (like those laptops with detachable screens)

### Concerns

Note that the implementation isn't perfect.
We'll need some new localizable text to make it clear that we now support sending
battery status information.

Then there's a rather significant question: maybe we should have two battery plugins
on each client, like we do for the `findmyphone`/`findthisdevice` plugins?

## Test Plan

We need to ensure that other clients (including those using the Android codebase)
will respond correctly. The main things to look at are
1. are these new packets sent when the plugin is enabled, and not sent when it's disabled?
2. is the charge percentage accurate?
3. is the charge state (charging, discharging, or full) accurate?
and
4. do we see the correct number of warnings for low-battery?

M  +1    -1    CMakeLists.txt
M  +1    -0    plugins/battery/CMakeLists.txt
M  +4    -2    plugins/battery/README
M  +76   -2    plugins/battery/batteryplugin.cpp
M  +6    -0    plugins/battery/batteryplugin.h
M  +3    -1    plugins/battery/kdeconnect_battery.json

https://invent.kde.org/kde/kdeconnect-kde/commit/c315170be5e6b2defe1a2768db007d70059c53c8