My Playtime clock app is intended to respond to (and sometimes display) being plugged/unplugged from power.
I'm using getPowerStatus()
, but it fails when the charge is fully 100% (not 99.9% rounded up, but truly 100).
At 100.0%, it ALWAYS reports charging = false
even when power is connected. Only once the reported charge has dropped slightly (which can take a while) will getPowerStatus()
report being connected.
(I know technically it's accurate, since at 100% it can't charge... there's no more battery left to fill! But what the user and apps really want to know is whether you're connected to power or not.)
My semi-workaround is to just assume that at 100.0%, you're plugged into power. But that only "sort of" works: when you unplug, it can take the app quite a while to detect that (depending how fast the battery is draining, and the vague nature of the battery measurement).
So it still fails, just in the other direction. But at least it doesn't appear to the user that their USB connection is coming and going on its own while the PD sits plugged in.
It would be great if we could detect USB/Stereo Dock being CONNECTED, regardless of whether the battery NEEDS power at the moment.