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

Commit a464837e authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Log transferring and fix verbose system logs

This CL logs transfer between routes to easily track potential bugs.
Selecting a route was also logged in MediaRouter.

It also reverts the log level of SystemMediaRoute2Provider because
we resolved issues related to it.

Bug: 156996903
Test: N/A
Change-Id: I6d7e165a79679305fd21a378fd3ae35b941c17c6
parent 7d985f79
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 */
public abstract class MediaRoute2ProviderService extends Service {
    private static final String TAG = "MR2ProviderService";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    /**
     * The {@link Intent} action that must be declared as handled by the service.
@@ -238,6 +239,11 @@ public abstract class MediaRoute2ProviderService extends Service {
            @NonNull RoutingSessionInfo sessionInfo) {
        Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");

        if (DEBUG) {
            Log.d(TAG, "notifySessionCreated: Creating a session. requestId=" + requestId
                    + ", sessionInfo=" + sessionInfo);
        }

        if (requestId != REQUEST_ID_NONE && !removeRequestId(requestId)) {
            Log.w(TAG, "notifySessionCreated: The requestId doesn't exist. requestId=" + requestId);
            return;
@@ -269,6 +275,10 @@ public abstract class MediaRoute2ProviderService extends Service {
    public final void notifySessionUpdated(@NonNull RoutingSessionInfo sessionInfo) {
        Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");

        if (DEBUG) {
            Log.d(TAG, "notifySessionUpdated: Updating session id=" + sessionInfo);
        }

        String sessionId = sessionInfo.getId();
        synchronized (mSessionLock) {
            if (mSessionInfo.containsKey(sessionId)) {
@@ -299,6 +309,10 @@ public abstract class MediaRoute2ProviderService extends Service {
        if (TextUtils.isEmpty(sessionId)) {
            throw new IllegalArgumentException("sessionId must not be empty");
        }
        if (DEBUG) {
            Log.d(TAG, "notifySessionReleased: Releasing session id=" + sessionId);
        }

        RoutingSessionInfo sessionInfo;
        synchronized (mSessionLock) {
            sessionInfo = mSessionInfo.remove(sessionId);
+1 −0
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ public final class MediaRouter2 {
     */
    public void transferTo(@NonNull MediaRoute2Info route) {
        Objects.requireNonNull(route, "route must not be null");
        Log.v(TAG, "Transferring to route: " + route);
        transfer(getCurrentController(), route);
    }

+2 −0
Original line number Diff line number Diff line
@@ -321,6 +321,8 @@ public final class MediaRouter2Manager {
        Objects.requireNonNull(packageName, "packageName must not be null");
        Objects.requireNonNull(route, "route must not be null");

        Log.v(TAG, "Selecting route. packageName= " + packageName + ", route=" + route);

        List<RoutingSessionInfo> sessionInfos = getRoutingSessions(packageName);
        RoutingSessionInfo targetSession = sessionInfos.get(sessionInfos.size() - 1);
        transfer(targetSession, route);
+2 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.R;
@@ -58,8 +59,7 @@ import java.util.Objects;
// TODO: check thread safety. We may need to use lock to protect variables.
class SystemMediaRoute2Provider extends MediaRoute2Provider {
    private static final String TAG = "MR2SystemProvider";
    // TODO(b/156996903): Revert it when releasing the framework.
    private static final boolean DEBUG = true;
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    static final String DEFAULT_ROUTE_ID = "DEFAULT_ROUTE";
    static final String DEVICE_ROUTE_ID = "DEVICE_ROUTE";