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
This commit is contained in:
@@ -71,14 +71,15 @@ 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 &&
|
||||
if(localBluetoothAdapter != null &&
|
||||
localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
|
||||
Log.d(TAG, "Disable discoverable...");
|
||||
|
||||
localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
|
||||
} else {
|
||||
} else {
|
||||
Log.e(TAG, "localBluetoothAdapter is NULL!!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user