SUNMI Kernel GetData Command - chuwuwang/ReadingNote GitHub Wiki

like this

private String get9F57String() {
    try {
        ApduRecvV2 rec = new ApduRecvV2();
        ApduSendV2 send = new ApduSendV2();
        send.command = ByteUtil.hexStr2Bytes("80CA9F57");
        send.lc = 0;
        send.le = 256;
        send.dataIn = ByteUtil.hexStr2Bytes("");
        int result = readCardOptV2.apduCommand(cardType, send, rec);
        String string = rec.toString();
        LogUtil.e(Constant.TAG, "9F57: " + result);
        LogUtil.e(Constant.TAG, "9F57: " + string);
        String swa = ByteUtil.bytes2HexStr(rec.swa);
        String swb = ByteUtil.bytes2HexStr(rec.swb);
        LogUtil.e(Constant.TAG, "swa: " + swa + " swb: " + swb);
        boolean bool = TextUtils.equals(swa, "90") && TextUtils.equals(swb, "00");
        if (bool) {
            Map<String, TLV> map = TLVUtil.buildTLVMap(rec.outData);
            TLV tlv = map.get("9F57");
            if (tlv != null && tlv.getValue().length() > 0) {
                return tlv.getValue();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}