From 95c11eec0769def89eb98455d4d4a9deb957bf38 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 5 Dec 2018 20:36:25 -0800 Subject: [PATCH] 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. --- .../org/eehouse/android/xw4/BTService.java | 21 ++++++++++++------- .../java/org/eehouse/android/xw4/XWApp.java | 2 -- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java index 6a0cb9b67..f0277f0c7 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java @@ -969,15 +969,20 @@ public class BTService extends XWService { Set 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() ); } } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java index 441e3d67b..253118efd 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWApp.java @@ -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