From e33ae953933a884fc1cd87af14ba5400a59bd575 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Wed, 21 Dec 2022 16:31:05 -0700 Subject: [PATCH] [homekit] update AuthInfo objects when blockUserDeletion changes (#14017) * [homekit] update AuthInfo objects when blockUserDeletion changes Signed-off-by: Cody Cutrer * [homekit] general cleanup of redundant method call and unused local vars Signed-off-by: Cody Cutrer Signed-off-by: Cody Cutrer Signed-off-by: Doug Culnane --- .../openhab/io/homekit/internal/HomekitAuthInfoImpl.java | 4 ++++ .../org/openhab/io/homekit/internal/HomekitImpl.java | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAuthInfoImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAuthInfoImpl.java index ba538f8a7cc47..941081150f147 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAuthInfoImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitAuthInfoImpl.java @@ -57,6 +57,10 @@ public HomekitAuthInfoImpl(Storage storage, String pin, String setupId, initializeStorage(); } + public void setBlockUserDeletion(boolean blockUserDeletion) { + this.blockUserDeletion = blockUserDeletion; + } + @Override public void createUser(String username, byte[] publicKey) { logger.trace("create user {}", username); diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java index 7e4da4a9ac1fe..8353bedc121b2 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java @@ -171,6 +171,11 @@ protected synchronized void modified(Map config) { for (HomekitChangeListener changeListener : changeListeners) { changeListener.updateSettings(settings); } + if (settings.blockUserDeletion != oldSettings.blockUserDeletion) { + for (HomekitAuthInfoImpl authInfo : authInfos) { + authInfo.setBlockUserDeletion(settings.blockUserDeletion); + } + } } } catch (IOException | InvalidAlgorithmParameterException e) { logger.warn("could not initialize HomeKit bridge: {}", e.getMessage()); @@ -203,10 +208,6 @@ private HomekitRoot startBridge(HomekitServer homekitServer, HomekitAuthInfoImpl changeListener.setBridge(bridge); bridges.add(bridge); bridge.setConfigurationIndex(changeListener.getConfigurationRevision()); - bridge.refreshAuthInfo(); - - final int lastAccessoryCount = changeListener.getLastAccessoryCount(); - int currentAccessoryCount = changeListener.getAccessories().size(); bridge.start(); return bridge; }