diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b55f4..e49cdb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,10 @@ The changes documented here do not include those from the original repository. ## [Unreleased] -### 01-12-2026 +### 2026-12-02 +- Fix: avoid a crash when the scan parameters are missing from the scanner activity's intent; the scan now fails with the "Scanning parameters are invalid" error instead of a generic scanning error (https://github.com/OutSystems/OSBarcodeLib-Android/pull/58). + +### 2026-12-01 - Fix: torch, zoom and scanning state are kept when the screen rotates, and the camera permission is no longer requested again on rotation (https://outsystemsrd.atlassian.net/browse/RMET-4398). ## [2.1.2] diff --git a/src/main/kotlin/com/outsystems/plugins/barcode/controller/OSBARCController.kt b/src/main/kotlin/com/outsystems/plugins/barcode/controller/OSBARCController.kt index 81aaefe..50266b0 100644 --- a/src/main/kotlin/com/outsystems/plugins/barcode/controller/OSBARCController.kt +++ b/src/main/kotlin/com/outsystems/plugins/barcode/controller/OSBARCController.kt @@ -76,6 +76,8 @@ class OSBARCController { onError(OSBARCError.ZXING_LIBRARY_ERROR) OSBARCError.MLKIT_LIBRARY_ERROR.code -> onError(OSBARCError.MLKIT_LIBRARY_ERROR) + OSBARCError.INVALID_PARAMETERS_ERROR.code -> + onError(OSBARCError.INVALID_PARAMETERS_ERROR) else -> { Log.d(LOG_TAG, "Invalid result code") onError(OSBARCError.SCANNING_GENERAL_ERROR) diff --git a/src/test/kotlin/com/outsystems/plugins/barcode/ScanCodeTests.kt b/src/test/kotlin/com/outsystems/plugins/barcode/ScanCodeTests.kt index 5d366ed..197512a 100644 --- a/src/test/kotlin/com/outsystems/plugins/barcode/ScanCodeTests.kt +++ b/src/test/kotlin/com/outsystems/plugins/barcode/ScanCodeTests.kt @@ -206,6 +206,20 @@ class ScanCodeTests { ) } + @Test + fun givenInvalidParametersResultCodeWhenHandleScanResultThenInvalidParametersError() { + val barcodeController = OSBARCController() + barcodeController.handleActivityResult(SCAN_REQUEST_CODE, OSBARCError.INVALID_PARAMETERS_ERROR.code, mockIntent, + { + fail() + }, + { + assertEquals(OSBARCError.INVALID_PARAMETERS_ERROR.code, it.code) + assertEquals(OSBARCError.INVALID_PARAMETERS_ERROR.description, it.description) + } + ) + } + @Test fun givenResultOKAndBarcodeEmptyWhenHandleScanResultThenScanningError() { mockIntentCompat