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
Loading
Please register or sign in to comment