[homekit] fix potential null pointer exceptions (#13122)
* fix potential null pointer exceptions * use contains key Signed-off-by: Eugen Freiter <freiter@gmx.de>
This commit is contained in:
parent
7a53e313cd
commit
94615b7728
@ -148,6 +148,8 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener {
|
||||
try {
|
||||
HomekitSettings oldSettings = settings;
|
||||
settings = processConfig(config);
|
||||
if ((oldSettings == null) || (settings == null))
|
||||
return;
|
||||
changeListener.updateSettings(settings);
|
||||
if (!oldSettings.networkInterface.equals(settings.networkInterface) || oldSettings.port != settings.port
|
||||
|| oldSettings.useOHmDNS != settings.useOHmDNS) {
|
||||
|
||||
@ -142,16 +142,17 @@ public class HomekitAccessoryFactory {
|
||||
};
|
||||
|
||||
private static List<HomekitCharacteristicType> getRequiredCharacteristics(HomekitTaggedItem taggedItem) {
|
||||
final List<HomekitCharacteristicType> characteristics = new ArrayList<>();
|
||||
if (MANDATORY_CHARACTERISTICS.containsKey(taggedItem.getAccessoryType())) {
|
||||
characteristics.addAll(Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType())));
|
||||
}
|
||||
if (taggedItem.getAccessoryType() == BATTERY) {
|
||||
final String isChargeable = taggedItem.getConfiguration(HomekitBatteryImpl.BATTERY_TYPE, "false");
|
||||
if ("true".equalsIgnoreCase(isChargeable) || "yes".equalsIgnoreCase(isChargeable)) {
|
||||
final List<HomekitCharacteristicType> characteristics = new ArrayList<>();
|
||||
characteristics.addAll(Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType())));
|
||||
characteristics.add(BATTERY_CHARGING_STATE);
|
||||
return characteristics;
|
||||
}
|
||||
}
|
||||
return Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType()));
|
||||
return characteristics;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user