fix bluetooth puller

+ bluetooth adapter may be lost, in which case we should try to get it
again

Test: cts test
Change-Id: I331ab45cea930cb5b8b95885442214d4a410b13b

Fix: 72949299
This commit is contained in:
Chenjie Yu
2018-02-01 22:27:17 -08:00
parent bbd31263b5
commit c2d6544e04

View File

@@ -113,7 +113,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
new StatFs(Environment.getRootDirectory().getAbsolutePath());
private final StatFs mStatFsTemp =
new StatFs(Environment.getDownloadCacheDirectory().getAbsolutePath());
private final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
public StatsCompanionService(Context context) {
super();
@@ -677,12 +676,13 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
}
private synchronized BluetoothActivityEnergyInfo pullBluetoothData() {
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
SynchronousResultReceiver bluetoothReceiver = null;
bluetoothReceiver = new SynchronousResultReceiver("bluetooth");
SynchronousResultReceiver bluetoothReceiver = new SynchronousResultReceiver("bluetooth");
adapter.requestControllerActivityEnergyInfo(bluetoothReceiver);
return awaitControllerInfo(bluetoothReceiver);
} else {
Slog.e(TAG, "Failed to get bluetooth adapter!");
return null;
}
}