This should fix pebble-pairing on bt+btle devices #33
This commit is contained in:
parent
9195652f11
commit
87512149a5
|
@ -44,7 +44,11 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
|
||||||
break;
|
break;
|
||||||
case BluetoothAdapter.ACTION_DISCOVERY_FINISHED:
|
case BluetoothAdapter.ACTION_DISCOVERY_FINISHED:
|
||||||
// continue with LE scan, if available
|
// continue with LE scan, if available
|
||||||
|
if (isScanning == Scanning.SCANNING_BT) {
|
||||||
startDiscovery(Scanning.SCANNING_BTLE);
|
startDiscovery(Scanning.SCANNING_BTLE);
|
||||||
|
} else {
|
||||||
|
discoveryFinished();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BluetoothAdapter.ACTION_STATE_CHANGED:
|
case BluetoothAdapter.ACTION_STATE_CHANGED:
|
||||||
int oldState = intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, BluetoothAdapter.STATE_OFF);
|
int oldState = intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, BluetoothAdapter.STATE_OFF);
|
||||||
|
@ -219,15 +223,17 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
|
||||||
private void stopDiscovery() {
|
private void stopDiscovery() {
|
||||||
Log.i(TAG, "Stopping discovery");
|
Log.i(TAG, "Stopping discovery");
|
||||||
if (isScanning()) {
|
if (isScanning()) {
|
||||||
if (isScanning == Scanning.SCANNING_BT) {
|
Scanning wasScanning = isScanning;
|
||||||
|
// unfortunately, we don't always get a call back when stopping the scan, so
|
||||||
|
// we do it manually; BEFORE stopping the scan!
|
||||||
|
discoveryFinished();
|
||||||
|
|
||||||
|
if (wasScanning == Scanning.SCANNING_BT) {
|
||||||
stopBTDiscovery();
|
stopBTDiscovery();
|
||||||
} else if (isScanning == Scanning.SCANNING_BTLE) {
|
} else if (wasScanning == Scanning.SCANNING_BTLE) {
|
||||||
stopBTLEDiscovery();
|
stopBTLEDiscovery();
|
||||||
}
|
}
|
||||||
handler.removeMessages(0, stopRunnable);
|
handler.removeMessages(0, stopRunnable);
|
||||||
// unfortunately, we never get a call back when stopping the scan, so
|
|
||||||
// we do it manually:
|
|
||||||
discoveryFinished();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue