Skip to content

Commit

Permalink
[miio] force start cloudconnector after credentials are updated (open…
Browse files Browse the repository at this point in the history
…hab#11459)

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
  • Loading branch information
marcelrv authored and NickWaterton committed Dec 30, 2021
1 parent dc8157e commit b2feda9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MiIoHandlerFactory(@Reference HttpClientFactory httpClientFactory,
cloudConnector.setCredentials(username, password, country);
try {
if (!scheduler.isShutdown()) {
scheduledTask = scheduler.submit(() -> cloudConnector.isConnected());
scheduledTask = scheduler.submit(() -> cloudConnector.isConnected(true));
} else {
logger.debug("Unexpected: ScheduledExecutorService is shutdown.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,17 @@ public void dispose() {
}

public boolean isConnected() {
return isConnected(false);
}

public boolean isConnected(boolean force) {
final MiCloudConnector cl = cloudConnector;
if (cl != null && cl.hasLoginToken()) {
return true;
}
if (force) {
logonCache.invalidateValue();
}
final @Nullable Boolean c = logonCache.getValue();
if (c != null && c.booleanValue()) {
return true;
Expand Down

0 comments on commit b2feda9

Please sign in to comment.