Skip to content
Commit 1f64ce02 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

BatteryController: Listen to battery changes from Bluetooth metadata

Some Bluetooth devices report battery state through Bluetooth metadata,
which can be obtained through BluetoothDevice#getMetadata. This is
another channel through which battery information can be obtained, and
is different than the BluetoothDevice#getBatteryLevel API which reports
the values from the Bluetooth Hands-Free Protocol (HFP).

In this CL, we start listening to Bluetooth metadata changes when a
Bluetooth input device is added.

In particular, we parse the following two keys:
- METADATA_MAIN_BATTERY - the battery level of the device
- METADATA_MAIN_CHARGING - whether or not the battery is being charged

To start listening to changes in metadata values, we add an
OnMetadataChangedListener for each monitored Bluetooth input device.

We prioritize the battery level from the metadata over the battery level
obtained from the BluetoothDevice#getBatteryLevel API.

Bug: 243005009
Test: atest BatteryControllerTests
Change-Id: I28d77e660b18821b14a67798fb88a5e926a7bebc
parent 95b9a3dd
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment