Added error method to interface Bluetooth stats

Bug: 223344084
Test: atest BluetoothAdapterTest
Tag: #feature
Change-Id: Ie38afa6db3636a8264038be30e9bf025a7a9f09a
This commit is contained in:
Etienne Ruffieux
2022-03-23 16:10:53 +00:00
parent 8d4a9f8d72
commit bc0501e2a1
2 changed files with 36 additions and 9 deletions

View File

@@ -560,11 +560,24 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
new SynchronousResultReceiver("bluetooth");
adapter.requestControllerActivityEnergyInfo(
Runnable::run,
info -> {
Bundle bundle = new Bundle();
bundle.putParcelable(BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY,
info);
resultReceiver.send(0, bundle);
new BluetoothAdapter.OnBluetoothActivityEnergyInfoCallback() {
@Override
public void onBluetoothActivityEnergyInfoAvailable(
BluetoothActivityEnergyInfo info) {
Bundle bundle = new Bundle();
bundle.putParcelable(
BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, info);
resultReceiver.send(0, bundle);
}
@Override
public void onBluetoothActivityEnergyInfoError(int errorCode) {
Slog.w(TAG, "error reading Bluetooth stats: " + errorCode);
Bundle bundle = new Bundle();
bundle.putParcelable(
BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, null);
resultReceiver.send(0, bundle);
}
}
);
bluetoothReceiver = resultReceiver;

View File

@@ -1620,10 +1620,24 @@ public class StatsPullAtomService extends SystemService {
new SynchronousResultReceiver("bluetooth");
adapter.requestControllerActivityEnergyInfo(
Runnable::run,
info -> {
Bundle bundle = new Bundle();
bundle.putParcelable(BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, info);
bluetoothReceiver.send(0, bundle);
new BluetoothAdapter.OnBluetoothActivityEnergyInfoCallback() {
@Override
public void onBluetoothActivityEnergyInfoAvailable(
BluetoothActivityEnergyInfo info) {
Bundle bundle = new Bundle();
bundle.putParcelable(
BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, info);
bluetoothReceiver.send(0, bundle);
}
@Override
public void onBluetoothActivityEnergyInfoError(int errorCode) {
Slog.w(TAG, "error reading Bluetooth stats: " + errorCode);
Bundle bundle = new Bundle();
bundle.putParcelable(
BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY, null);
bluetoothReceiver.send(0, bundle);
}
}
);
return awaitControllerInfo(bluetoothReceiver);