Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,27 @@ class QrCodeDetectorProcessor {
return true
}

private fun detectInImage(bitmap: Bitmap): Result? {
private fun detectInImage(bitmap: Bitmap, additionalHints: Map<com.google.zxing.DecodeHintType, Any>? = null): Result? {
val qRCodeDetectorReader = QRCodeReader()

// Try with original image first
var result = tryDetectInBitmap(bitmap, qRCodeDetectorReader)
var result = tryDetectInBitmap(bitmap, qRCodeDetectorReader, additionalHints)
if (result != null) return result

// If original fails, try with scaled up image (better for small QR codes)
val scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.width * 2, bitmap.height * 2, true)
result = tryDetectInBitmap(scaledBitmap, qRCodeDetectorReader)
result = tryDetectInBitmap(scaledBitmap, qRCodeDetectorReader, additionalHints)
if (result != null) return result

// If still fails, try with scaled down image (better for very large QR codes)
val scaledDownBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.width / 2, bitmap.height / 2, true)
result = tryDetectInBitmap(scaledDownBitmap, qRCodeDetectorReader)
result = tryDetectInBitmap(scaledDownBitmap, qRCodeDetectorReader, additionalHints)
if (result != null) return result

return null
}

private fun tryDetectInBitmap(bitmap: Bitmap, qRCodeDetectorReader: QRCodeReader): Result? {
private fun tryDetectInBitmap(bitmap: Bitmap, qRCodeDetectorReader: QRCodeReader, additionalHints: Map<com.google.zxing.DecodeHintType, Any>? = null): Result? {
println("Attempting QR detection on bitmap: ${bitmap.width}x${bitmap.height}, hasAlpha: ${bitmap.hasAlpha()}")

val intArray = IntArray(bitmap.width * bitmap.height)
Expand Down Expand Up @@ -167,10 +167,11 @@ class QrCodeDetectorProcessor {
}

// Try with different hints for better detection
val hints = mapOf(
com.google.zxing.DecodeHintType.TRY_HARDER to true,
com.google.zxing.DecodeHintType.POSSIBLE_FORMATS to listOf(com.google.zxing.BarcodeFormat.QR_CODE)
)
val hints = buildMap {
put(com.google.zxing.DecodeHintType.TRY_HARDER, true)
put(com.google.zxing.DecodeHintType.POSSIBLE_FORMATS, listOf(com.google.zxing.BarcodeFormat.QR_CODE))
additionalHints?.forEach { (key, value) -> put(key, value) }
}

for (binarizer in binarizers) {
val binaryBitMap = BinaryBitmap(binarizer)
Expand All @@ -197,7 +198,11 @@ class QrCodeDetectorProcessor {
): Boolean {
val start = System.currentTimeMillis()
executor.execute {
val result = detectInImage(image)
// Added for mAadhar qrcode detection
val hints = mapOf(
com.google.zxing.DecodeHintType.PURE_BARCODE to false
)
val result = detectInImage(image, hints)
val timeRequired = System.currentTimeMillis() - start
println(result)
if (result != null) {
Comment on lines 206 to 208
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid logging decoded payloads (PII risk)

Remove println of Result to prevent leaking Aadhaar data in logs.

Apply:

-            println(result)
🤖 Prompt for AI Agents
In
app/android/app/src/main/java/com/proofofpassportapp/utils/QrCodeDetectorProcessor.kt
around lines 206 to 208 you are printing the decoded Result which may contain
sensitive PII (Aadhaar data); remove the println(result) call and do not log the
decoded payload. If you need telemetry, replace it with a non-sensitive
indicator (e.g., log that a QR was detected or increment a metric) or log only
safe metadata (presence/length or masked value), ensuring no PII is written to
stdout or app logs.

Expand Down
Loading