Fixed a Bluetooth discovery bug.

+ Now when a user goes to Settings->Bluetooth and turns on Bluetooth,
the device will be discoverable.

Bug: 17368189
Change-Id: Ia0d8000ddf7e3c3b43172c08ee28e7305d205462
This commit is contained in:
PauloftheWest
2014-09-19 12:39:28 -07:00
parent 6e1d8277e6
commit 9bab4ea695

View File

@@ -98,10 +98,17 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
private final BroadcastReceiver mReceiver = new BroadcastReceiver() { private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); final String action = intent.getAction();
final int state =
intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
if (action.equals(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) { if (action.equals(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
updateDeviceName(context); updateDeviceName(context);
} }
if (state == BluetoothAdapter.STATE_ON) {
mInitiateDiscoverable = true;
}
} }
private void updateDeviceName(Context context) { private void updateDeviceName(Context context) {