Skip to content

Commit ae4a8ec

Browse files
committed
check for AccessoryInformationService by UUID, not by class
in case someone is using some form of decorator or replacement class, but is still exposing the proper type
1 parent 66d53b5 commit ae4a8ec

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/io/github/hapjava/server/impl/HomekitRegistry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public synchronized void reset() {
4343
try {
4444
newServices = new ArrayList<>(2);
4545
Collection<Service> services = accessory.getServices();
46-
if (!services.stream().anyMatch(s -> s instanceof AccessoryInformationService)) {
46+
if (!services.stream()
47+
.anyMatch(s -> s.getType().equals(AccessoryInformationService.TYPE))) {
4748
newServices.add(new AccessoryInformationService(accessory));
4849
}
4950
for (Service service : services) {

src/main/java/io/github/hapjava/services/impl/AccessoryInformationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
/** Accessory Information service. */
1616
public class AccessoryInformationService extends AbstractServiceImpl {
17+
public static final String TYPE = "0000003E-0000-1000-8000-0026BB765291";
1718

1819
public AccessoryInformationService(
1920
IdentifyCharacteristic identify,
@@ -22,7 +23,7 @@ public AccessoryInformationService(
2223
NameCharacteristic name,
2324
SerialNumberCharacteristic serialNumber,
2425
FirmwareRevisionCharacteristic firmwareRevision) {
25-
super("0000003E-0000-1000-8000-0026BB765291");
26+
super(TYPE);
2627
addCharacteristic(identify);
2728
addCharacteristic(manufacturer);
2829
addCharacteristic(model);

0 commit comments

Comments
 (0)