Merge "Switch from Byte.toHexString() to HexEncoding"
This commit is contained in:
@@ -39,6 +39,8 @@ import com.android.internal.util.BitUtils;
|
||||
import com.android.internal.util.ObjectUtils;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
@@ -152,7 +154,7 @@ public final class BluetoothLeDeviceFilter implements DeviceFilter<ScanResult> {
|
||||
int initial = mRenameBytesReverseOrder ? endInclusive : startInclusive;
|
||||
int step = mRenameBytesReverseOrder ? -1 : 1;
|
||||
for (int i = initial; startInclusive <= i && i <= endInclusive; i += step) {
|
||||
sb.append(Byte.toHexString(bytes[i], true));
|
||||
sb.append(HexEncoding.encodeToString(bytes[i], true));
|
||||
}
|
||||
} else {
|
||||
sb.append(
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -146,7 +148,7 @@ public class ContextHubMessage implements Parcelable {
|
||||
ret += "data = 0x";
|
||||
}
|
||||
for (int i = 0; i < Math.min(length, DEBUG_LOG_NUM_BYTES); i++) {
|
||||
ret += Byte.toHexString(mData[i], true /* upperCase */);
|
||||
ret += HexEncoding.encodeToString(mData[i], true /* upperCase */);
|
||||
|
||||
if ((i + 1) % 4 == 0) {
|
||||
ret += " ";
|
||||
|
||||
@@ -19,6 +19,8 @@ import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
/**
|
||||
* A class describing messages send to or from nanoapps through the Context Hub Service.
|
||||
*
|
||||
@@ -155,7 +157,7 @@ public final class NanoAppMessage implements Parcelable {
|
||||
ret += "data = 0x";
|
||||
}
|
||||
for (int i = 0; i < Math.min(length, DEBUG_LOG_NUM_BYTES); i++) {
|
||||
ret += Byte.toHexString(mMessageBody[i], true /* upperCase */);
|
||||
ret += HexEncoding.encodeToString(mMessageBody[i], true /* upperCase */);
|
||||
|
||||
if ((i + 1) % 4 == 0) {
|
||||
ret += " ";
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
@@ -71,11 +73,7 @@ public class RecoverySession implements AutoCloseable {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] sessionId = new byte[SESSION_ID_LENGTH_BYTES];
|
||||
secureRandom.nextBytes(sessionId);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : sessionId) {
|
||||
sb.append(Byte.toHexString(b, /*upperCase=*/ false));
|
||||
}
|
||||
return sb.toString();
|
||||
return HexEncoding.encodeToString(sessionId, /*upperCase=*/ false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,8 @@ import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -1301,7 +1303,8 @@ public class ViewDebug {
|
||||
if (type == int.class) {
|
||||
fieldValue = formatIntToHexString((Integer) fieldValue);
|
||||
} else if (type == byte.class) {
|
||||
fieldValue = "0x" + Byte.toHexString((Byte) fieldValue, true);
|
||||
fieldValue = "0x"
|
||||
+ HexEncoding.encodeToString((Byte) fieldValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import static com.android.server.backup.BackupManagerService.TAG;
|
||||
|
||||
import android.util.Slog;
|
||||
|
||||
import libcore.util.HexEncoding;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
@@ -74,11 +76,7 @@ public class PasswordUtils {
|
||||
* Creates hex string representation of the byte array.
|
||||
*/
|
||||
public static String byteArrayToHex(byte[] data) {
|
||||
StringBuilder buf = new StringBuilder(data.length * 2);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
buf.append(Byte.toHexString(data[i], true));
|
||||
}
|
||||
return buf.toString();
|
||||
return HexEncoding.encodeToString(data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user