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

Commit c21698d0 authored by Jack He's avatar Jack He Committed by Jakub Pawlowski
Browse files

Battery Level: Add FLAG_RECEIVER_INCLUDE_BACKGROUND flag to intent

* Use FLAG_RECEIVER_INCLUDE_BACKGROUND flag when sending out
  BluetoothDevice.ACTION_BATTERY_LEVEL_CHANGED so that service apps
  can listen to this at background

Fixes: 127742900
Bug: 127862952
Test: make, unit test
Change-Id: Ied884e771c2c798f5219853395ceec3c7e928161
parent db22a417
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -455,6 +455,7 @@ final class RemoteDevices {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_BATTERY_LEVEL, batteryLevel);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        sAdapterService.sendBroadcast(intent, AdapterService.BLUETOOTH_PERM);
    }

+2 −1
Original line number Diff line number Diff line
@@ -440,7 +440,8 @@ public class RemoteDevicesTest {
        Assert.assertEquals(device, intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE));
        Assert.assertEquals(batteryLevel,
                intent.getIntExtra(BluetoothDevice.EXTRA_BATTERY_LEVEL, -15));
        Assert.assertEquals(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, intent.getFlags());
        Assert.assertEquals(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                        | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND, intent.getFlags());
    }

    private static Intent getHeadsetConnectionStateChangedIntent(BluetoothDevice device,