Update monitored InputDevice battery state on an UEvent notification

When the battery state of any input device is being monitored, we will
register a UEventObserver to listen to all UEvents sent by the
power_supply subsystem.

When we receive a UEvent that notifies us of changes to any batteries,
we will query the battery status of that device, and notify listeners
if there was a change in the state.

The last known battery state of a monitored device is tracked in the
MonitoredDeviceState class in BatteryController.

BatteryController will only start listening to UEvents for a device if
it has a battery, and will update its UEvent listeners based on the
battery presence.

DD: go/inputdevice-battery-notifications

Bug: 243005009
Test: atest InputDeviceBatteryControllerTests
Change-Id: Ic16e1e4aba3bb6371c57f042004844fd78989582
3 files changed