summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chenjie Yu <cjyu@google.com> 2018-02-01 22:27:17 -0800
committer Chenjie Yu <cjyu@google.com> 2018-02-05 19:16:34 +0000
commitc2d6544e049cf11f4a0923558fb7c71f2b90219c (patch)
tree99b591c24da585dd82c3ba315b7162a327677bcc
parentbbd31263b5c96de43296762ba8814a379b94755a (diff)
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
-rw-r--r--services/core/java/com/android/server/stats/StatsCompanionService.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index f498cdd85ee8..c280739f2e1a 100644
--- a/services/core/java/com/android/server/stats/StatsCompanionService.java
+++ b/services/core/java/com/android/server/stats/StatsCompanionService.java
@@ -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;
}
}