Skip to content

Commit

Permalink
Fixed the dash error on Galaxy S5 devices.
Browse files Browse the repository at this point in the history
This is just a workaround. The real issue is a bug in the
Android ROM of S5 devices.
  • Loading branch information
ikarus23 committed Mar 30, 2015
1 parent 8d7ee82 commit 6412ec6
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,16 @@ public String[] readSector(int sectorIndex, byte[] key,
// At least this is what the documentation says.
// On Samsung's Galaxy S5 and Sony's Xperia Z2 however, it
// sometimes returns < 16 bytes for unknown reasons.
if (blockBytes.length != 16) {
// Update: Aaand sometimes it returns more than 16 bytes...
// The appended byte(s) are 0x00.
if (blockBytes.length < 16) {
throw new IOException();
}
if (blockBytes.length > 16) {
byte[] blockBytesTmp = Arrays.copyOf(blockBytes,16);
blockBytes = blockBytesTmp;
}

blocks.add(Common.byte2HexString(blockBytes));
} catch (TagLostException e) {
throw e;
Expand Down Expand Up @@ -584,10 +591,13 @@ public HashMap<Integer, HashMap<Integer, Integer>> isWritableOnPositions(
// At least this is what the documentation says.
// On Samsung's Galaxy S5 and Sony's Xperia Z2 however, it
// sometimes returns < 16 bytes for unknown reasons.
if (ac.length != 16) {
// Update: Aaand sometimes it returns more than 16 bytes...
// The appended byte(s) are 0x00.
if (ac.length < 16) {
ret.put(sector, null);
continue;
}

ac = Arrays.copyOfRange(ac, 6, 9);
byte[][] acMatrix = Common.acBytesToACMatrix(ac);
if (acMatrix == null) {
Expand Down

0 comments on commit 6412ec6

Please sign in to comment.