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