protected float parseBalance(Iso7816.Response data) { float ret = 0f; if (data.isOkey() && data.size() >= 4) { int n = Util.toInt(data.getBytes(), 0, 4); if (n > 1000000 || n < -1000000) n -= 0x80000000; ret = n / 100.0f; } return ret; }
protected ArrayList<byte[]> readLog24(Iso7816.StdTag tag, int sfi) throws IOException { final ArrayList<byte[]> ret = new ArrayList<byte[]>(MAX_LOG); final Iso7816.Response rsp = tag.readRecord(sfi); if (rsp.isOkey()) { addLog24(rsp, ret); } else { for (int i = 1; i <= MAX_LOG; ++i) { if (!addLog24(tag.readRecord(sfi, i), ret)) break; } } return ret; }
protected boolean addLog24(final Iso7816.Response r, ArrayList<byte[]> l) { if (!r.isOkey()) return false; final byte[] raw = r.getBytes(); final int N = raw.length - 23; if (N < 0) return false; for (int s = 0, e = 0; s <= N; s = e) { l.add(Arrays.copyOfRange(raw, s, (e = s + 23))); } return true; }
protected void parseInfo21(Application app, Iso7816.Response data, int dec, boolean bigEndian) { if (!data.isOkey() || data.size() < 30) { return; } final byte[] d = data.getBytes(); if (dec < 1 || dec > 10) { app.setProperty(SPEC.PROP.SERIAL, Util.toHexString(d, 10, 10)); } else { final int sn = bigEndian ? Util.toIntR(d, 19, dec) : Util.toInt(d, 20 - dec, dec); app.setProperty(SPEC.PROP.SERIAL, String.format("%d", 0xFFFFFFFFL & sn)); } if (d[9] != 0) app.setProperty(SPEC.PROP.VERSION, String.valueOf(d[9])); app.setProperty( SPEC.PROP.DATE, String.format( "%02X%02X.%02X.%02X - %02X%02X.%02X.%02X", d[20], d[21], d[22], d[23], d[24], d[25], d[26], d[27])); }