Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e4d74f7 authored by Nick Pelly's avatar Nick Pelly Committed by Android Git Automerger
Browse files

am 4b94dee8: Merge "Added transfer/restore convience cmds to MF Classic tech." into gingerbread

* commit '4b94dee8':
  Added transfer/restore convience cmds to MF Classic tech.
parents e8522998 4b94dee8
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -205,6 +205,15 @@ public final class MifareClassic extends BasicTagTechnology {
        return getBlockCount(sector) * 16;
    }

    public int getTotalBlockCount() {
        int totalBlocks = 0;
        for (int sec = 0; sec < getSectorCount(); sec++) {
            totalBlocks += getSectorSize(sec);
        }

        return totalBlocks;
    }

    public int getBlockCount(int sector) {
        if (sector >= getSectorCount()) {
            throw new IllegalArgumentException("this card only has " + getSectorCount() +
@@ -343,9 +352,27 @@ public final class MifareClassic extends BasicTagTechnology {
        checkConnected();

        byte addr = (byte) block;
        byte[] incr_cmd = { (byte) 0xC0, (byte) block };
        byte[] decr_cmd = { (byte) 0xC0, (byte) block };

        transceive(incr_cmd);
        transceive(decr_cmd);
    }

    public void transfer(int block) throws IOException {
        checkConnected();

        byte addr = (byte) block;
        byte[] trans_cmd = { (byte) 0xB0, (byte) block };

        transceive(trans_cmd);
    }

    public void restore(int block) throws IOException {
        checkConnected();

        byte addr = (byte) block;
        byte[] rest_cmd = { (byte) 0xC2, (byte) block };

        transceive(rest_cmd);
    }

    /**