Added transfer/restore convience cmds to MF Classic tech.
Change-Id: I675993bc3aae6a741d63be458a0dfea240dd5316
diff --git a/core/java/android/nfc/technology/MifareClassic.java b/core/java/android/nfc/technology/MifareClassic.java
index 8a9ebf1..799f0a78 100644
--- a/core/java/android/nfc/technology/MifareClassic.java
+++ b/core/java/android/nfc/technology/MifareClassic.java
@@ -205,6 +205,15 @@
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 @@
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);
}
/**