Merge "MediaMetricsManager: Authorize log session ids" into sc-v2-dev am: 5a97294940 am: e6e2c080e2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15247197

Change-Id: I7f06fa35f8365cc5fd0fc3a1f265ae2b9abc8d4b
This commit is contained in:
Andy Hung
2021-07-19 21:58:47 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 4 deletions

View File

@@ -53,6 +53,7 @@ public class MediaMetrics {
public static final String AUDIO_VOLUME = AUDIO + SEPARATOR + "volume";
public static final String AUDIO_VOLUME_EVENT = AUDIO_VOLUME + SEPARATOR + "event";
public static final String AUDIO_MODE = AUDIO + SEPARATOR + "mode";
public static final String METRICS_MANAGER = "metrics" + SEPARATOR + "manager";
}
/**
@@ -120,10 +121,11 @@ public class MediaMetrics {
createKey("gainDb", Double.class);
public static final Key<String> GROUP =
createKey("group", String.class);
// For volume
public static final Key<Integer> INDEX = createKey("index", Integer.class);
public static final Key<Integer> MAX_INDEX = createKey("maxIndex", Integer.class);
public static final Key<Integer> MIN_INDEX = createKey("minIndex", Integer.class);
public static final Key<Integer> INDEX = createKey("index", Integer.class); // volume
public static final Key<String> LOG_SESSION_ID = createKey("logSessionId", String.class);
public static final Key<Integer> MAX_INDEX = createKey("maxIndex", Integer.class); // vol
public static final Key<Integer> MIN_INDEX = createKey("minIndex", Integer.class); // vol
public static final Key<String> MODE =
createKey("mode", String.class); // audio_mode
public static final Key<String> MUTE =

View File

@@ -18,6 +18,7 @@ package com.android.server.media.metrics;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.MediaMetrics;
import android.media.metrics.IMediaMetricsManager;
import android.media.metrics.NetworkEvent;
import android.media.metrics.PlaybackErrorEvent;
@@ -65,6 +66,8 @@ public final class MediaMetricsManagerService extends SystemService {
private static final int LOGGING_LEVEL_NO_UID = 1000;
private static final int LOGGING_LEVEL_BLOCKED = 99999;
private static final String mMetricsId = MediaMetrics.Name.METRICS_MANAGER;
private static final String FAILED_TO_GET = "failed_to_get";
private final SecureRandom mSecureRandom;
@GuardedBy("mLock")
@@ -199,6 +202,12 @@ public final class MediaMetricsManagerService extends SystemService {
mSecureRandom.nextBytes(byteId);
String id = Base64.encodeToString(
byteId, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE);
// Authorize these session ids in the native mediametrics service.
new MediaMetrics.Item(mMetricsId)
.set(MediaMetrics.Property.EVENT, "create")
.set(MediaMetrics.Property.LOG_SESSION_ID, id)
.record();
return id;
}