Skip to content

Commit

Permalink
fix(capture-sdk): Discard QR code detections after the `PaymentQRCode…
Browse files Browse the repository at this point in the history
…Reader` is released

PIA-4414
  • Loading branch information
a-szotyori committed Aug 30, 2023
1 parent b5c0709 commit ba8a2ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,6 @@ private void initFlashButton() {
* @suppress
*/
public void onResume() {
if (mPaymentQRCodePopup != null) {
mPaymentQRCodePopup.hide();
}
if (mUnsupportedQRCodePopup != null) {
mUnsupportedQRCodePopup.hide();
}
initMultiPageDocument();
}

Expand Down Expand Up @@ -584,6 +578,12 @@ void onSaveInstanceState(@NonNull final Bundle outState) {

void onStop() {
closeCamera();
if (mPaymentQRCodePopup != null) {
mPaymentQRCodePopup.hide();
}
if (mUnsupportedQRCodePopup != null) {
mUnsupportedQRCodePopup.hide();
}
}

void onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void onNonPaymentQRCodeDetected(@NonNull final String qrCodeContent) {
public void onQRCodeReaderFail() {
}
};
private boolean isReleased = false;

/**
* Create a new instance which uses the provided {@link QRCodeDetectorTask} to do QRCode
Expand All @@ -66,6 +67,9 @@ private PaymentQRCodeReader(
mDetector.setListener(new QRCodeDetector.Listener() {
@Override
public void onQRCodesDetected(@NonNull final List<String> qrCodes) {
if (isReleased) {
return;
}
for (final String qrCodeContent : qrCodes) {
try {
final PaymentQRCodeData paymentData = mParser.parse(qrCodeContent);
Expand Down Expand Up @@ -119,6 +123,7 @@ public void readFromByteArray(@NonNull final byte[] image, @NonNull final Size i
* Release all resources. Detection not possible after this has been called.
*/
public void release() {
isReleased = true;
mDetector.release();
}

Expand Down

0 comments on commit ba8a2ea

Please sign in to comment.