CatimaLoyalty / Android

Catima, a Loyalty Card & Ticket Manager for Android
https://catima.app
GNU General Public License v3.0
748 stars 140 forks source link

Aztec and binary support #1496

Open phmarek opened 10 months ago

phmarek commented 10 months ago

Hi,

the Austrian Klimaticket (see example below, taken from https://salzburg-verkehr.at/wp-content/uploads/2023/07/SVV_23-Illu-Kartenrohling_KlimaTicket_S_Classic_back.png) uses Aztec codes and binary data.

Please update to a newer ZXing library, or enable Aztec(?); Binary Eye https://github.com/markusfisch/BinaryEye reads these codes just fine, while Catima doesn't accept it.

I tried to save the data as file and then importing into Catima -- but that doesn't work either, the binary data isn't read or reproduced correctly. Going eg. Binary EyeSecScanQR to generate an Aztec code works, though, so it's not the Aztec generation or the data transfer as such -- seems that the import into Catima isn't binary-safe. SVV_23-Illu-Kartenrohling_KlimaTicket_S_Classic_back

phmarek commented 10 months ago

Thanks!

TheLastProject commented 10 months ago

Please update to a newer ZXing library, or enable Aztec(?); Binary Eye https://github.com/markusfisch/BinaryEye reads these codes just fine, while Catima doesn't accept it.

Catima is on the latest zxing and zxing-android-embedded libraries and Aztec is enabled, so this doesn't seem relevant.

However, Binary eye does uses another library than Catima (we use com.google.zxing:core, they use com.github.markusfisch:zxing-cpp). Both seem to still be actively maintained (com.google.zxing:core was last updated July 30th), but it is definitely possible their library is "better".

I tried to save the data as file and then importing into Catima -- but that doesn't work either, the binary data isn't read or reproduced correctly.

Do you have more info on what you mean with "isn't read or reproduced correctly"? In my own testing I get "No barcode was found", which may be #1215.

seems that the import into Catima isn't binary-safe

Given I've scanned cards with binary data before, I don't think this is the issue.


I definitely agree there is a bug here, because Binary Eye scans this with ease and Catima is unable to scan it. But I'm not completely sure where it goes wrong yet. Would need further inspection.

phmarek commented 10 months ago

but it is definitely possible their library is "better".

As another data point, SecScanQR doesn't detect (this) Aztec either -- but when sharing from Binary Eye, it seems able to re-create an Aztec image.

Wouldn't be accepted, though - Binary Eye forwards the binary data as hex digit string, which SecScanQR tries to use as plain string.

I tried to save the data as file and then importing into Catima -- but that doesn't work either, the binary data isn't read or reproduced correctly.

Do you have more info on what you mean with "isn't read or reproduced correctly"? In my own testing I get "No barcode was found", which may be

1215.

I read the Aztec code with Binary Eye, and then tried share → copy, and then paste in the "ID" field in Catima, but the resulting code wasn't accepted in the train.

seems that the import into Catima isn't binary-safe

Given I've scanned cards with binary data before, I don't think this is the issue.

Well, did the data also include NUL bytes? These one do, 4 bytes padding at 0x3c.

I definitely agree there is a bug here, because Binary Eye scans this with ease and Catima is unable to scan it. But I'm not completely sure where it goes wrong yet. Would need further inspection.

Thanks!

TheLastProject commented 10 months ago

As another data point, SecScanQR doesn't detect (this) Aztec either

SecScanQR uses com.google.zxing:core and com.journeyapps:zxing-android-embedded like Catima. So that's another data point in favour of the library having issues indeed yeah, thanks.

I read the Aztec code with Binary Eye, and then tried share → copy, and then paste in the "ID" field in Catima, but the resulting code wasn't accepted in the train.

Binary Eye for some reason seems to use an older version of the share menu for me, so I don't have the native "Copy to clipboard" option and had to install Share to Clipboard to be able to get the data on the clipboard at all. I can confirm the Aztec code Catima generates looks different, but given I needed to install an extra app in between I can't confirm with certainty if it's Catima not handling this binary data correctly or Share to Clipboard.

obfusk commented 10 months ago

I'm planning to look into improving the QR code scanning soon and will make sure to check for this issue as well.