Loading common/netlinkclient/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ java_library { name: "netlink-client", srcs: [ "src/**/*.java", ":framework-networkstack-shared-srcs", ":framework-annotations", ], libs: [ "androidx.annotation_annotation", Loading common/netlinkclient/src/android/net/netlink/NetlinkConstants.java +20 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.net.netlink; import android.system.OsConstants; import com.android.internal.util.HexDump; import java.nio.ByteBuffer; Loading Loading @@ -62,12 +61,12 @@ public class NetlinkConstants { public static String hexify(byte[] bytes) { if (bytes == null) { return "(null)"; } return HexDump.toHexString(bytes); return toHexString(bytes, 0, bytes.length); } public static String hexify(ByteBuffer buffer) { if (buffer == null) { return "(null)"; } return HexDump.toHexString( return toHexString( buffer.array(), buffer.position(), buffer.remaining()); } Loading Loading @@ -126,4 +125,22 @@ public class NetlinkConstants { return "unknown RTM type: " + String.valueOf(nlm_type); } } private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Convert a byte array to a hexadecimal string. */ public static String toHexString(byte[] array, int offset, int length) { char[] buf = new char[length * 2]; int bufIndex = 0; for (int i = offset; i < offset + length; i++) { byte b = array[i]; buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F]; buf[bufIndex++] = HEX_DIGITS[b & 0x0F]; } return new String(buf); } } Loading
common/netlinkclient/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ java_library { name: "netlink-client", srcs: [ "src/**/*.java", ":framework-networkstack-shared-srcs", ":framework-annotations", ], libs: [ "androidx.annotation_annotation", Loading
common/netlinkclient/src/android/net/netlink/NetlinkConstants.java +20 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.net.netlink; import android.system.OsConstants; import com.android.internal.util.HexDump; import java.nio.ByteBuffer; Loading Loading @@ -62,12 +61,12 @@ public class NetlinkConstants { public static String hexify(byte[] bytes) { if (bytes == null) { return "(null)"; } return HexDump.toHexString(bytes); return toHexString(bytes, 0, bytes.length); } public static String hexify(ByteBuffer buffer) { if (buffer == null) { return "(null)"; } return HexDump.toHexString( return toHexString( buffer.array(), buffer.position(), buffer.remaining()); } Loading Loading @@ -126,4 +125,22 @@ public class NetlinkConstants { return "unknown RTM type: " + String.valueOf(nlm_type); } } private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** * Convert a byte array to a hexadecimal string. */ public static String toHexString(byte[] array, int offset, int length) { char[] buf = new char[length * 2]; int bufIndex = 0; for (int i = offset; i < offset + length; i++) { byte b = array[i]; buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F]; buf[bufIndex++] = HEX_DIGITS[b & 0x0F]; } return new String(buf); } }