Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53e843c4 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "MediaMetricsManager: Authorize log session ids" into sc-v2-dev am: 5a972949 am: e6e2c080

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

Change-Id: I7f06fa35f8365cc5fd0fc3a1f265ae2b9abc8d4b
parents 83fbe443 e6e2c080
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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 =
+9 −0
Original line number Diff line number Diff line
@@ -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;
        }