Merge "Add logging to MediaSessionStack"
This commit is contained in:
committed by
Android (Google) Code Review
commit
b6159f3186
@@ -24,6 +24,8 @@ import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.server.utils.EventLogger;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -38,6 +40,8 @@ class MediaSessionStack {
|
||||
private static final boolean DEBUG = MediaSessionService.DEBUG;
|
||||
private static final String TAG = "MediaSessionStack";
|
||||
|
||||
private static final int DUMP_EVENTS_MAX_COUNT = 70;
|
||||
|
||||
/**
|
||||
* Listen the change in the media button session.
|
||||
*/
|
||||
@@ -57,6 +61,8 @@ 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.
|
||||
@@ -80,6 +86,11 @@ 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",
|
||||
record
|
||||
));
|
||||
mSessions.add(record);
|
||||
clearCache(record.getUserId());
|
||||
|
||||
@@ -95,6 +106,11 @@ class MediaSessionStack {
|
||||
* @param record The record to remove.
|
||||
*/
|
||||
public void removeSession(MediaSessionRecordImpl record) {
|
||||
mEventLogger.enqueue(EventLogger.StringEvent.from(
|
||||
"removeSession()",
|
||||
"record: %s",
|
||||
record
|
||||
));
|
||||
mSessions.remove(record);
|
||||
if (mMediaButtonSession == record) {
|
||||
// When the media button session is removed, nullify the media button session and do not
|
||||
@@ -140,6 +156,11 @@ class MediaSessionStack {
|
||||
public void onPlaybackStateChanged(
|
||||
MediaSessionRecordImpl record, boolean shouldUpdatePriority) {
|
||||
if (shouldUpdatePriority) {
|
||||
mEventLogger.enqueue(EventLogger.StringEvent.from(
|
||||
"onPlaybackStateChanged() - Pushing session to top",
|
||||
"record: %s",
|
||||
record
|
||||
));
|
||||
mSessions.remove(record);
|
||||
mSessions.add(0, record);
|
||||
clearCache(record.getUserId());
|
||||
@@ -344,6 +365,8 @@ class MediaSessionStack {
|
||||
for (MediaSessionRecordImpl record : mSessions) {
|
||||
record.dump(pw, indent);
|
||||
}
|
||||
pw.println(prefix + "Session stack events:");
|
||||
mEventLogger.dump(pw, indent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user