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

Commit c507e99e authored by Alexandre Francois's avatar Alexandre Francois
Browse files

Use Slog instead of EventLogger in MediaSessionStack

Logs that previously appeared in dumpsys now appear in
system logs.

For testing, get system logs live with logcat, for example:
adb logcat MediaSessionStack:I *:S
or generate a bug report, for example:
adb bugreport
then browse the file with the Android Bug Tool UI at
go/abt-web

Bug: 259705163
Test: manually
Change-Id: I57d8ab1e1fc9b8a68e94bf8895fd128d1545c45e
parent 7bf48dc5
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -21,11 +21,11 @@ import static com.android.server.media.MediaSessionPolicyProvider.SESSION_POLICY
import android.media.Session2Token;
import android.media.session.MediaSession;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;

import com.android.server.utils.EventLogger;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
@@ -61,8 +61,6 @@ class MediaSessionStack {
    private final AudioPlayerStateMonitor mAudioPlayerStateMonitor;
    private final OnMediaButtonSessionChangedListener mOnMediaButtonSessionChangedListener;

    private final EventLogger mEventLogger = new EventLogger(DUMP_EVENTS_MAX_COUNT, TAG);

    /**
     * The media button session which receives media key events.
     * It could be null if the previous media button session is released.
@@ -86,9 +84,8 @@ class MediaSessionStack {
     * @param record The record to add.
     */
    public void addSession(MediaSessionRecordImpl record) {
        mEventLogger.enqueue(EventLogger.StringEvent.from(
                "addSession() (to bottom of stack)",
                "record: %s",
        Slog.i(TAG, TextUtils.formatSimple(
                "addSession to bottom of stack | record: %s",
                record
        ));
        mSessions.add(record);
@@ -106,9 +103,8 @@ class MediaSessionStack {
     * @param record The record to remove.
     */
    public void removeSession(MediaSessionRecordImpl record) {
        mEventLogger.enqueue(EventLogger.StringEvent.from(
                "removeSession()",
                "record: %s",
        Slog.i(TAG, TextUtils.formatSimple(
                "removeSession | record: %s",
                record
        ));
        mSessions.remove(record);
@@ -156,9 +152,8 @@ class MediaSessionStack {
    public void onPlaybackStateChanged(
            MediaSessionRecordImpl record, boolean shouldUpdatePriority) {
        if (shouldUpdatePriority) {
            mEventLogger.enqueue(EventLogger.StringEvent.from(
                    "onPlaybackStateChanged() - Pushing session to top",
                    "record: %s",
            Slog.i(TAG, TextUtils.formatSimple(
                    "onPlaybackStateChanged - Pushing session to top | record: %s",
                    record
            ));
            mSessions.remove(record);
@@ -365,8 +360,6 @@ class MediaSessionStack {
        for (MediaSessionRecordImpl record : mSessions) {
            record.dump(pw, indent);
        }
        pw.println(prefix + "Session stack events:");
        mEventLogger.dump(pw, indent);
    }

    /**