summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nick Pelly <npelly@google.com> 2011-01-03 18:34:37 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2011-01-03 18:34:37 -0800
commit7e4d74f7b9355e8abd6e2fa30e284c9116a08998 (patch)
treea7d173bd220f9374e53e8db43a0f0d442b1ec20c
parente85229988e6350a684be91c3bbf64232271c5663 (diff)
parent4b94dee8336a1135e4fc67a5911223bb5aabad99 (diff)
am 4b94dee8: Merge "Added transfer/restore convience cmds to MF Classic tech." into gingerbread
* commit '4b94dee8336a1135e4fc67a5911223bb5aabad99': Added transfer/restore convience cmds to MF Classic tech.
-rw-r--r--core/java/android/nfc/technology/MifareClassic.java31
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);
}
/**