diff options
-rw-r--r-- | common/netlinkclient/Android.bp | 4 | ||||
-rw-r--r-- | common/netlinkclient/src/android/net/netlink/NetlinkConstants.java | 23 |
2 files changed, 22 insertions, 5 deletions
diff --git a/common/netlinkclient/Android.bp b/common/netlinkclient/Android.bp index 32e6d56..a61cdbd 100644 --- a/common/netlinkclient/Android.bp +++ b/common/netlinkclient/Android.bp @@ -18,10 +18,10 @@ java_library { name: "netlink-client", srcs: [ "src/**/*.java", - ":framework-networkstack-shared-srcs", + ":framework-annotations", ], libs: [ "androidx.annotation_annotation", ], sdk_version: "system_current", -}
\ No newline at end of file +} diff --git a/common/netlinkclient/src/android/net/netlink/NetlinkConstants.java b/common/netlinkclient/src/android/net/netlink/NetlinkConstants.java index fc1551c..181a361 100644 --- a/common/netlinkclient/src/android/net/netlink/NetlinkConstants.java +++ b/common/netlinkclient/src/android/net/netlink/NetlinkConstants.java @@ -17,7 +17,6 @@ package android.net.netlink; import android.system.OsConstants; -import com.android.internal.util.HexDump; import java.nio.ByteBuffer; @@ -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()); } @@ -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); + } } |