Loading core/java/com/android/internal/util/HexDump.java +6 −3 Original line number Diff line number Diff line Loading @@ -16,18 +16,21 @@ package com.android.internal.util; import android.annotation.Nullable; public class HexDump { private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private final static char[] HEX_LOWER_CASE_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String dumpHexString(byte[] array) { public static String dumpHexString(@Nullable byte[] array) { if (array == null) return "(null)"; return dumpHexString(array, 0, array.length); } public static String dumpHexString(byte[] array, int offset, int length) public static String dumpHexString(@Nullable byte[] array, int offset, int length) { if (array == null) return "(null)"; StringBuilder result = new StringBuilder(); byte[] line = new byte[16]; Loading core/tests/coretests/src/com/android/internal/util/HexDumpTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -25,4 +25,7 @@ public final class HexDumpTest extends TestCase { assertEquals("ABCDEF", HexDump.toHexString( new byte[] { (byte) 0xab, (byte) 0xcd, (byte) 0xef }, true)); } public void testNullArray() { assertEquals("(null)", HexDump.toHexString(null)); } } Loading
core/java/com/android/internal/util/HexDump.java +6 −3 Original line number Diff line number Diff line Loading @@ -16,18 +16,21 @@ package com.android.internal.util; import android.annotation.Nullable; public class HexDump { private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private final static char[] HEX_LOWER_CASE_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String dumpHexString(byte[] array) { public static String dumpHexString(@Nullable byte[] array) { if (array == null) return "(null)"; return dumpHexString(array, 0, array.length); } public static String dumpHexString(byte[] array, int offset, int length) public static String dumpHexString(@Nullable byte[] array, int offset, int length) { if (array == null) return "(null)"; StringBuilder result = new StringBuilder(); byte[] line = new byte[16]; Loading
core/tests/coretests/src/com/android/internal/util/HexDumpTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -25,4 +25,7 @@ public final class HexDumpTest extends TestCase { assertEquals("ABCDEF", HexDump.toHexString( new byte[] { (byte) 0xab, (byte) 0xcd, (byte) 0xef }, true)); } public void testNullArray() { assertEquals("(null)", HexDump.toHexString(null)); } }