mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
logging: handle null buffers in GB.hexdump
Enable dumping null buffers like Logging.formatBytes already supports.
This commit is contained in:
committed by
José Rebelo
parent
630995a04f
commit
de5a1afed1
@@ -38,6 +38,7 @@ import android.text.SpannableString;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
@@ -368,7 +369,8 @@ public class GB {
|
||||
|
||||
public static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
public static String hexdump(byte[] buffer, int offset, int length) {
|
||||
@NonNull
|
||||
public static String hexdump(@NonNull byte[] buffer, int offset, int length) {
|
||||
if (length == -1) {
|
||||
length = buffer.length - offset;
|
||||
}
|
||||
@@ -382,7 +384,11 @@ public class GB {
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static String hexdump(byte[] buffer) {
|
||||
@NonNull
|
||||
public static String hexdump(@Nullable byte[] buffer) {
|
||||
if (buffer == null) {
|
||||
return "(null)";
|
||||
}
|
||||
return hexdump(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user