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

Commit 42a25ba8 authored by Jack He's avatar Jack He
Browse files

Bluetooth: Ensure only desired intents are being handled

* Prevent arbitrary intents from making Bluetooth undiscoverable by only
  allowing DISCOVERABLE_TIMEOUT intent to be handled

Bug: 33058582
Test: make, test for Broadcast and Bluetooth scanning
Change-Id: Ib8b04dddf1610a082d167825253f3e1c968aaa14
parent d6f0b0fc
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -71,12 +71,13 @@ public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction() == null || !intent.getAction().equals(INTENT_DISCOVERABLE_TIMEOUT)) {
            return;
        }
        LocalBluetoothAdapter localBluetoothAdapter = LocalBluetoothAdapter.getInstance();

        if(localBluetoothAdapter != null  &&
            localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
            Log.d(TAG, "Disable discoverable...");

            localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
        } else {
            Log.e(TAG, "localBluetoothAdapter is NULL!!");