From 1174e03885743b3425b1f33a2b4b4beaf2bef39a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 4 Jan 2019 18:18:32 -0800 Subject: [PATCH] Fix incorrectly persisting host with missing server cert --- .../limelight/computers/ComputerManagerService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/limelight/computers/ComputerManagerService.java b/app/src/main/java/com/limelight/computers/ComputerManagerService.java index 7deb0155..328c779d 100644 --- a/app/src/main/java/com/limelight/computers/ComputerManagerService.java +++ b/app/src/main/java/com/limelight/computers/ComputerManagerService.java @@ -365,8 +365,9 @@ public class ComputerManagerService extends Service { // Block while we try to fill the details try { - runPoll(fakeDetails, true, 0); - if (fakeDetails.state == ComputerDetails.State.ONLINE) { + // We cannot use runPoll() here because it will attempt to persist the state of the machine + // in the database, which would be bad because we don't have our pinned cert loaded yet. + if (pollComputer(fakeDetails)) { // See if we have record of this PC to pull its pinned cert synchronized (pollingTuples) { for (PollingTuple tuple : pollingTuples) { @@ -377,10 +378,9 @@ public class ComputerManagerService extends Service { } } - if (fakeDetails.serverCert != null) { - // Poll again with the pinned cert to get accurate pairing information - runPoll(fakeDetails, true, 0); - } + // Poll again, possibly with the pinned cert, to get accurate pairing information. + // This will insert the host into the database too. + runPoll(fakeDetails, true, 0); } } catch (InterruptedException e) { return false;