mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Ignore results from the QrScanner if task is not ready
* Ignore results until the KeyAgreementTask is ready and returned the local payload Signed-off-by: goapunk <noobie@goapunks.net>
This commit is contained in:
@@ -86,6 +86,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
|||||||
|
|
||||||
private BluetoothStateReceiver receiver;
|
private BluetoothStateReceiver receiver;
|
||||||
private boolean gotRemotePayload, waitingForBluetooth;
|
private boolean gotRemotePayload, waitingForBluetooth;
|
||||||
|
private volatile boolean gotLocalPayload;
|
||||||
private KeyAgreementTask task;
|
private KeyAgreementTask task;
|
||||||
|
|
||||||
public static ShowQrCodeFragment newInstance() {
|
public static ShowQrCodeFragment newInstance() {
|
||||||
@@ -202,6 +203,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
|||||||
statusView.setVisibility(INVISIBLE);
|
statusView.setVisibility(INVISIBLE);
|
||||||
cameraView.setVisibility(VISIBLE);
|
cameraView.setVisibility(VISIBLE);
|
||||||
gotRemotePayload = false;
|
gotRemotePayload = false;
|
||||||
|
gotLocalPayload = false;
|
||||||
startListening();
|
startListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +229,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
|||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
if (e instanceof KeyAgreementListeningEvent) {
|
if (e instanceof KeyAgreementListeningEvent) {
|
||||||
KeyAgreementListeningEvent event = (KeyAgreementListeningEvent) e;
|
KeyAgreementListeningEvent event = (KeyAgreementListeningEvent) e;
|
||||||
|
gotLocalPayload = true;
|
||||||
setQrCode(event.getLocalPayload());
|
setQrCode(event.getLocalPayload());
|
||||||
} else if (e instanceof KeyAgreementFailedEvent) {
|
} else if (e instanceof KeyAgreementFailedEvent) {
|
||||||
keyAgreementFailed();
|
keyAgreementFailed();
|
||||||
@@ -341,6 +344,10 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
LOG.info("Got result from decoder");
|
LOG.info("Got result from decoder");
|
||||||
|
// Ignore results until the KeyAgreementTask is ready
|
||||||
|
if (!gotLocalPayload) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!gotRemotePayload) {
|
if (!gotRemotePayload) {
|
||||||
gotRemotePayload = true;
|
gotRemotePayload = true;
|
||||||
qrCodeScanned(result.getText());
|
qrCodeScanned(result.getText());
|
||||||
|
|||||||
Reference in New Issue
Block a user