From 0f0b83badce3049d4ba33c8500311f054053f2e0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 5 Nov 2016 20:20:09 -0700 Subject: [PATCH] Properly invalidate pairing state after pairing --- app/src/main/java/com/limelight/PcView.java | 5 ++++- .../computers/ComputerManagerService.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/limelight/PcView.java b/app/src/main/java/com/limelight/PcView.java index 4715031f..63167d9f 100644 --- a/app/src/main/java/com/limelight/PcView.java +++ b/app/src/main/java/com/limelight/PcView.java @@ -353,6 +353,10 @@ public class PcView extends Activity implements AdapterFragmentCallbacks { // Just navigate to the app view without displaying a toast message = null; success = true; + + // Invalidate reachability information after pairing to force + // a refresh before reading pair state again + managerBinder.invalidateStateForComputer(computer.uuid); } else { // Should be no other values @@ -381,7 +385,6 @@ public class PcView extends Activity implements AdapterFragmentCallbacks { if (toastSuccess) { // Open the app list after a successful pairing attempt - computer.pairState = PairState.PAIRED; doAppList(computer); } else { diff --git a/app/src/main/java/com/limelight/computers/ComputerManagerService.java b/app/src/main/java/com/limelight/computers/ComputerManagerService.java index 9dc1708e..84f2f753 100644 --- a/app/src/main/java/com/limelight/computers/ComputerManagerService.java +++ b/app/src/main/java/com/limelight/computers/ComputerManagerService.java @@ -238,6 +238,21 @@ public class ComputerManagerService extends Service { return null; } + + public void invalidateStateForComputer(UUID uuid) { + synchronized (pollingTuples) { + for (PollingTuple tuple : pollingTuples) { + if (uuid.equals(tuple.computer.uuid)) { + // We need the network lock to prevent a concurrent poll + // from wiping this change out + synchronized (tuple.networkLock) { + tuple.computer.state = ComputerDetails.State.UNKNOWN; + tuple.computer.reachability = ComputerDetails.Reachability.UNKNOWN; + } + } + } + } + } } @Override