Merge "fix bluetooth puller + bluetooth adapter may be lost, in which case we should try to get it again"
diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java
index f498cdd..c280739 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 @@
         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 @@
     }
 
     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;
       }
     }