diff options
| author | Nick Pelly <npelly@google.com> | 2011-01-03 18:33:09 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-03 18:33:09 -0800 |
| commit | 4b94dee8336a1135e4fc67a5911223bb5aabad99 (patch) | |
| tree | d394318ad445ca0ccb7d802f0f36422134801d39 /core/java/android | |
| parent | 06fccc325123bf4c9ebd04ac9300b504436724fe (diff) | |
| parent | a42b352594edf959302f8fc98041e76adeb6a20d (diff) | |
Merge "Added transfer/restore convience cmds to MF Classic tech." into gingerbread
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/nfc/technology/MifareClassic.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/core/java/android/nfc/technology/MifareClassic.java b/core/java/android/nfc/technology/MifareClassic.java index 8a9ebf1354c8..799f0a7841ec 100644 --- a/core/java/android/nfc/technology/MifareClassic.java +++ b/core/java/android/nfc/technology/MifareClassic.java @@ -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); } /** |
