Fix rare NPE

master
cpfeiffer 2017-04-22 23:56:04 +02:00
parent 3f8620e026
commit 9ed8004a69
1 changed files with 2 additions and 3 deletions

View File

@ -207,14 +207,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
String action = intent.getAction();
if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
GBDevice device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
// FIXME: mGBDevice was null here once
if (mGBDevice.equals(device)) {
if (mGBDevice != null && mGBDevice.equals(device)) {
mGBDevice = device;
boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized());
setReceiversEnableState(enableReceivers, mGBDevice.isInitialized(), DeviceHelper.getInstance().getCoordinator(device));
GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), mGBDevice.isInitialized(), context);
} else {
LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice);
LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + device);
}
}
}