Avoid NPEs when device-name is null
This commit is contained in:
parent
76895aa2b1
commit
aa00d2f93a
|
@ -1,6 +1,7 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
|
@ -39,8 +40,10 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
|
|||
}
|
||||
// and a heuristic
|
||||
try {
|
||||
if (isHealthWearable(candidate.getDevice())) {
|
||||
return candidate.getDevice().getName().toUpperCase().startsWith(MiBandConst.MI_GENERAL_NAME_PREFIX.toUpperCase());
|
||||
BluetoothDevice device = candidate.getDevice();
|
||||
if (isHealthWearable(device)) {
|
||||
String name = device.getName();
|
||||
return name != null && name.toUpperCase().startsWith(MiBandConst.MI_GENERAL_NAME_PREFIX.toUpperCase());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.error("unable to check device support", ex);
|
||||
|
|
|
@ -23,7 +23,8 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator {
|
|||
|
||||
@Override
|
||||
public boolean supports(GBDeviceCandidate candidate) {
|
||||
return candidate.getDevice().getName().startsWith("Pebble");
|
||||
String name = candidate.getDevice().getName();
|
||||
return name != null && name.startsWith("Pebble");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue