don't try to connect to non-phones

When a device is paired but not a phone (or computer, which is how
tablets identify), don't bother trying to scan it.
This commit is contained in:
Eric House 2018-12-05 20:36:25 -08:00
parent 051aeba57c
commit 95c11eec07
2 changed files with 13 additions and 10 deletions

View file

@ -969,15 +969,20 @@ public class BTService extends XWService {
Set<BluetoothDevice> pairedDevs = m_adapter.getBondedDevices();
// DbgUtils.logf( "ping: got %d paired devices", pairedDevs.size() );
for ( BluetoothDevice dev : pairedDevs ) {
String btAddr = dev.getAddress();
if ( sendPing( dev, 0 ) ) { // did we get a reply?
if ( null != addrs ) {
addrs.add( dev );
}
if ( null != event ) {
postEvent( event, dev.getName() );
// Skip things that can't host an Android app
int clazz = dev.getBluetoothClass().getMajorDeviceClass();
if ( Major.PHONE == clazz || Major.COMPUTER == clazz ) {
if ( sendPing( dev, 0 ) ) { // did we get a reply?
if ( null != addrs ) {
addrs.add( dev );
}
if ( null != event ) {
postEvent( event, dev.getName() );
}
}
} else {
Log.d( TAG, "skipping %s; not an android device!",
dev.getName() );
}
}
}

View file

@ -50,8 +50,6 @@ public class XWApp extends Application implements LifecycleObserver {
public static final boolean LOCUTILS_ENABLED = false;
public static final boolean CONTEXT_MENUS_ENABLED = true;
public static final boolean OFFER_DUALPANE = false;
// BT class "COMPUTERS" includes tablets like the Nexus 9
public static final boolean BT_SCAN_COMPUTERS = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h