Switch to HexEncoding from ByteStringUtils
Migration in preparation for deletion of ByteStringUtils.
Bug: 124232146
Test: build only
Exempt-From-Owner-Approval: Already approved in upstream.
Change-Id: I2cb09da5ec5296799e03bab812b7fb29452a623e
(cherry picked from commit 2344ec4f7563ce3739627255b143a14061a5f9a9)
diff --git a/services/core/java/com/android/server/pm/InstantAppRegistry.java b/services/core/java/com/android/server/pm/InstantAppRegistry.java
index 06f67cd..8b9af7a 100644
--- a/services/core/java/com/android/server/pm/InstantAppRegistry.java
+++ b/services/core/java/com/android/server/pm/InstantAppRegistry.java
@@ -38,7 +38,6 @@
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.AtomicFile;
-import android.util.ByteStringUtils;
import android.util.PackageUtils;
import android.util.Slog;
import android.util.SparseArray;
@@ -52,6 +51,7 @@
import com.android.internal.util.XmlUtils;
import libcore.io.IoUtils;
+import libcore.util.HexEncoding;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -66,7 +66,6 @@
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
import java.util.function.Predicate;
@@ -234,7 +233,7 @@
@UserIdInt int userId) {
byte[] randomBytes = new byte[8];
new SecureRandom().nextBytes(randomBytes);
- String id = ByteStringUtils.toHexString(randomBytes).toLowerCase(Locale.US);
+ String id = HexEncoding.encodeToString(randomBytes, false /* upperCase */);
File appDir = getInstantApplicationDir(packageName, userId);
if (!appDir.exists() && !appDir.mkdirs()) {
Slog.e(LOG_TAG, "Cannot create instant app cookie directory");
diff --git a/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java b/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
index 2c75bcd..75b4e38 100644
--- a/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
+++ b/services/core/java/com/android/server/pm/dex/DynamicCodeLogger.java
@@ -26,7 +26,6 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.storage.StorageManager;
-import android.util.ByteStringUtils;
import android.util.EventLog;
import android.util.PackageUtils;
import android.util.Slog;
@@ -38,6 +37,8 @@
import com.android.server.pm.dex.PackageDynamicCodeLoading.DynamicCodeFile;
import com.android.server.pm.dex.PackageDynamicCodeLoading.PackageDynamicCode;
+import libcore.util.HexEncoding;
+
import java.io.File;
import java.io.IOException;
import java.util.Map;
@@ -153,7 +154,7 @@
// Valid SHA256 will be 256 bits, 32 bytes.
if (hash != null && hash.length == 32) {
- message = message + ' ' + ByteStringUtils.toHexString(hash);
+ message = message + ' ' + HexEncoding.encodeToString(hash);
} else {
Slog.d(TAG, "Got no hash for " + filePath);
// File has probably been deleted.