MediaMetrics: Cleanup the formatting of session ID

Use the flags Base64.NO_PADDING|Base64.NO_WRAP|Base64.URL_SAFE

This formats the id as one long string without == passing at the end,
Using -_ instead of +/ characters

Bug: 175357495
Test: atest android.media.metrics.cts.MediaMetricsAtomHostSideTests
Change-Id: Iba73976b5677e9a2e5fd3e156a55499005e26904
This commit is contained in:
shubang
2021-06-10 04:28:27 -07:00
committed by Shubang Lu
parent 55b9b53e34
commit 3406ff9b16

View File

@@ -98,7 +98,8 @@ public final class MediaMetricsManagerService extends SystemService {
private String getSessionIdInternal(int userId) {
byte[] byteId = new byte[16]; // 128 bits
mSecureRandom.nextBytes(byteId);
String id = Base64.encodeToString(byteId, Base64.DEFAULT);
String id = Base64.encodeToString(
byteId, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE);
return id;
}