From 5a620b4a7a2371aadb9f0352f755ec6c9b605f8d Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Fri, 2 Jun 2023 19:43:46 +0200 Subject: [PATCH] Start the timer before the packet has been sent Fixes the loopback provider starting the timer after the paring is already done, causing it to unpair after 30 seconds. --- .../UserInterface/PairingHandler.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/org/kde/kdeconnect/UserInterface/PairingHandler.java b/src/org/kde/kdeconnect/UserInterface/PairingHandler.java index 8b478053..8da03ea7 100644 --- a/src/org/kde/kdeconnect/UserInterface/PairingHandler.java +++ b/src/org/kde/kdeconnect/UserInterface/PairingHandler.java @@ -121,19 +121,19 @@ public class PairingHandler { mPairState = PairState.Requested; + mPairingTimer = new Timer(); + mPairingTimer.schedule(new TimerTask() { + @Override + public void run() { + Log.w("PairingHandler","Unpairing (timeout after receiving pair request)"); + mPairState = PairState.NotPaired; + mCallback.pairingFailed(mDevice.getContext().getString(R.string.error_timed_out)); + } + }, 30*1000); //Time to wait for the other to accept + Device.SendPacketStatusCallback statusCallback = new Device.SendPacketStatusCallback() { @Override - public void onSuccess() { - mPairingTimer = new Timer(); - mPairingTimer.schedule(new TimerTask() { - @Override - public void run() { - Log.w("PairingHandler","Unpairing (timeout after receiving pair request)"); - mPairState = PairState.NotPaired; - mCallback.pairingFailed(mDevice.getContext().getString(R.string.error_timed_out)); - } - }, 30*1000); //Time to wait for the other to accept - } + public void onSuccess() { } @Override public void onFailure(Throwable e) {