Merge "Log transferring and fix verbose system logs" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6edbf48c2b
@@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
*/
|
*/
|
||||||
public abstract class MediaRoute2ProviderService extends Service {
|
public abstract class MediaRoute2ProviderService extends Service {
|
||||||
private static final String TAG = "MR2ProviderService";
|
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.
|
* 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) {
|
@NonNull RoutingSessionInfo sessionInfo) {
|
||||||
Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");
|
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)) {
|
if (requestId != REQUEST_ID_NONE && !removeRequestId(requestId)) {
|
||||||
Log.w(TAG, "notifySessionCreated: The requestId doesn't exist. requestId=" + requestId);
|
Log.w(TAG, "notifySessionCreated: The requestId doesn't exist. requestId=" + requestId);
|
||||||
return;
|
return;
|
||||||
@@ -269,6 +275,10 @@ public abstract class MediaRoute2ProviderService extends Service {
|
|||||||
public final void notifySessionUpdated(@NonNull RoutingSessionInfo sessionInfo) {
|
public final void notifySessionUpdated(@NonNull RoutingSessionInfo sessionInfo) {
|
||||||
Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");
|
Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "notifySessionUpdated: Updating session id=" + sessionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
String sessionId = sessionInfo.getId();
|
String sessionId = sessionInfo.getId();
|
||||||
synchronized (mSessionLock) {
|
synchronized (mSessionLock) {
|
||||||
if (mSessionInfo.containsKey(sessionId)) {
|
if (mSessionInfo.containsKey(sessionId)) {
|
||||||
@@ -299,6 +309,10 @@ public abstract class MediaRoute2ProviderService extends Service {
|
|||||||
if (TextUtils.isEmpty(sessionId)) {
|
if (TextUtils.isEmpty(sessionId)) {
|
||||||
throw new IllegalArgumentException("sessionId must not be empty");
|
throw new IllegalArgumentException("sessionId must not be empty");
|
||||||
}
|
}
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "notifySessionReleased: Releasing session id=" + sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
RoutingSessionInfo sessionInfo;
|
RoutingSessionInfo sessionInfo;
|
||||||
synchronized (mSessionLock) {
|
synchronized (mSessionLock) {
|
||||||
sessionInfo = mSessionInfo.remove(sessionId);
|
sessionInfo = mSessionInfo.remove(sessionId);
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ public final class MediaRouter2 {
|
|||||||
*/
|
*/
|
||||||
public void transferTo(@NonNull MediaRoute2Info route) {
|
public void transferTo(@NonNull MediaRoute2Info route) {
|
||||||
Objects.requireNonNull(route, "route must not be null");
|
Objects.requireNonNull(route, "route must not be null");
|
||||||
|
Log.v(TAG, "Transferring to route: " + route);
|
||||||
transfer(getCurrentController(), route);
|
transfer(getCurrentController(), route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,6 +321,8 @@ public final class MediaRouter2Manager {
|
|||||||
Objects.requireNonNull(packageName, "packageName must not be null");
|
Objects.requireNonNull(packageName, "packageName must not be null");
|
||||||
Objects.requireNonNull(route, "route 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);
|
List<RoutingSessionInfo> sessionInfos = getRoutingSessions(packageName);
|
||||||
RoutingSessionInfo targetSession = sessionInfos.get(sessionInfos.size() - 1);
|
RoutingSessionInfo targetSession = sessionInfos.get(sessionInfos.size() - 1);
|
||||||
transfer(targetSession, route);
|
transfer(targetSession, route);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import android.os.Looper;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.R;
|
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.
|
// TODO: check thread safety. We may need to use lock to protect variables.
|
||||||
class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
||||||
private static final String TAG = "MR2SystemProvider";
|
private static final String TAG = "MR2SystemProvider";
|
||||||
// TODO(b/156996903): Revert it when releasing the framework.
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
private static final boolean DEBUG = true;
|
|
||||||
|
|
||||||
static final String DEFAULT_ROUTE_ID = "DEFAULT_ROUTE";
|
static final String DEFAULT_ROUTE_ID = "DEFAULT_ROUTE";
|
||||||
static final String DEVICE_ROUTE_ID = "DEVICE_ROUTE";
|
static final String DEVICE_ROUTE_ID = "DEVICE_ROUTE";
|
||||||
|
|||||||
Reference in New Issue
Block a user