Merge "Bluetooth: Ensure only desired intents are being handled" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-04 03:49:14 +00:00
committed by Android (Google) Code Review

View File

@@ -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!!");
}
}