Skip to content

Commit 065743f

Browse files
committed
Collaps unnecessary if-block.
1 parent 2037619 commit 065743f

File tree

1 file changed

+12
-26
lines changed
  • Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities

1 file changed

+12
-26
lines changed

Mifare Classic Tool/app/src/main/java/de/syss/MifareClassicTool/Activities/WriteTag.java

+12-26
Original file line numberDiff line numberDiff line change
@@ -588,33 +588,19 @@ private void writeBlock() {
588588

589589
// Write. There are some tags which report a successful write, although
590590
// the write was not successful. Therefore, we try to write it using both keys.
591-
if (sector == 0 && block == 0) {
592-
// Write the manufacturer bock. This is only possible on gen2 tags.
593-
if (keys[1] != null) {
594-
resultKeyB = reader.writeBlock(sector, block,
595-
Common.hex2Bytes(data),
596-
keys[1], true);
597-
}
598-
if (keys[0] != null) {
599-
resultKeyA = reader.writeBlock(sector, block,
600-
Common.hex2Bytes(data),
601-
keys[0], false);
602-
}
603-
} else {
604-
// Normal block. Try key B first.
605-
if (keys[1] != null) {
606-
resultKeyB = reader.writeBlock(sector, block,
607-
Common.hex2Bytes(data),
608-
keys[1], true);
609-
}
610-
// Try to write with key A (if there is one).
611-
if (keys[0] != null) {
612-
resultKeyA = reader.writeBlock(sector, block,
613-
Common.hex2Bytes(data),
614-
keys[0], false);
615-
}
616-
591+
// Try key B first.
592+
if (keys[1] != null) {
593+
resultKeyB = reader.writeBlock(sector, block,
594+
Common.hex2Bytes(data),
595+
keys[1], true);
617596
}
597+
// Try to write with key A (if there is one).
598+
if (keys[0] != null) {
599+
resultKeyA = reader.writeBlock(sector, block,
600+
Common.hex2Bytes(data),
601+
keys[0], false);
602+
}
603+
618604
reader.close();
619605
if (resultKeyA == 0 || resultKeyB == 0) {
620606
result = 0;

0 commit comments

Comments
 (0)