Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2d6544e authored by Chenjie Yu's avatar Chenjie Yu
Browse files

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
parent bbd31263
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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;
      }
    }