Fix AdMob history banner and refine Felica history mapping

This commit is contained in:
2026-04-24 21:32:56 +07:00
parent 8f0b001501
commit 7882f77a27
6 changed files with 289 additions and 38 deletions

View File

@ -229,25 +229,12 @@ public class UnifiedNfcApi {
if (uid == 0){
normal = false
}
if (data.count > 10){
let type = data[10]
debugLog(type)
switch type {
case 0x01:
riwayat.setProsesTipe(1)
riwayat.setTitle("payment".localizeString(string: self.langCode!))
debugLog("Pembayaran")
case 0x00, 0x03:
riwayat.setProsesTipe(0)
riwayat.setTitle("topup".localizeString(string: self.langCode!))
debugLog("Topup")
default:
riwayat.setProsesTipe(1)
riwayat.setTitle("payment".localizeString(string: self.langCode!))
debugLog("Other")
}
if data.count >= 13 {
let transactionKind = self.felicaTransactionKind(for: [UInt8](data))
riwayat.setProsesTipe(transactionKind.prosesTipe)
riwayat.setTitle(transactionKind.title.localizeString(string: self.langCode!))
debugLog("signature: \(transactionKind.signature)")
debugLog(transactionKind.logLabel)
}
if let station = self.stationMap[uid]{
debugLog("station", station.name)
@ -391,6 +378,33 @@ public class UnifiedNfcApi {
return Int(bytes.withUnsafeBytes { $0.load(as: Int32.self).bigEndian })
}
}
private func felicaTransactionKind(for bytes: [UInt8]) -> (prosesTipe: Int, title: String, logLabel: String, signature: String) {
let signatureBytes = Array(bytes[10...12])
let signature = signatureBytes.map { String(format: "%02X", $0) }.joined(separator: " ")
switch signatureBytes {
case [0x00, 0x02, 0x00],
[0x03, 0x01, 0x00]:
return (0, "topup", "Topup", signature)
case [0x01, 0x01, 0x01],
[0x01, 0x58, 0x01],
[0x03, 0x61, 0x01]:
return (1, "payment", "Pembayaran", signature)
default:
let type = bytes[10]
switch type {
case 0x00:
return (0, "topup", "Topup (fallback)", signature)
case 0x01:
return (1, "payment", "Pembayaran (fallback)", signature)
case 0x03:
return (1, "payment", "Pembayaran (fallback 0x03)", signature)
default:
return (1, "payment", "Other", signature)
}
}
}
public func stopCheckCard(message : String){
apduRunner.sessionEx?.invalidate(errorMessage: message)