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
(cherry picked from commit c507e99e10)
Merged-In: I57d8ab1e1fc9b8a68e94bf8895fd128d1545c45e
This commit is contained in:
Alexandre Francois
2023-01-31 10:44:06 +00:00
committed by Bishoy Gendy
parent 747b4c2b46
commit 8b4bd7c128

View File

@@ -21,7 +21,9 @@ 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 java.io.PrintWriter;
@@ -82,6 +84,10 @@ class MediaSessionStack {
* @param record The record to add.
*/
public void addSession(MediaSessionRecordImpl record) {
Slog.i(TAG, TextUtils.formatSimple(
"addSession to bottom of stack | record: %s",
record
));
mSessions.add(record);
clearCache(record.getUserId());
@@ -97,6 +103,10 @@ class MediaSessionStack {
* @param record The record to remove.
*/
public void removeSession(MediaSessionRecordImpl record) {
Slog.i(TAG, TextUtils.formatSimple(
"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
@@ -142,6 +152,10 @@ class MediaSessionStack {
public void onPlaybackStateChanged(
MediaSessionRecordImpl record, boolean shouldUpdatePriority) {
if (shouldUpdatePriority) {
Slog.i(TAG, TextUtils.formatSimple(
"onPlaybackStateChanged - Pushing session to top | record: %s",
record
));
mSessions.remove(record);
mSessions.add(0, record);
clearCache(record.getUserId());