Merge "Add basic dumpsys logging for providers" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0d415cbe21
@@ -19,6 +19,7 @@ package com.android.server.media;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ComponentName;
|
||||
import android.media.MediaRoute2Info;
|
||||
import android.media.MediaRoute2ProviderInfo;
|
||||
import android.media.RouteDiscoveryPreference;
|
||||
import android.media.RoutingSessionInfo;
|
||||
@@ -26,6 +27,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -108,6 +110,28 @@ abstract class MediaRoute2Provider {
|
||||
&& mComponentName.getClassName().equals(className);
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw, String prefix) {
|
||||
pw.println(prefix + getDebugString());
|
||||
prefix += " ";
|
||||
if (mProviderInfo == null) {
|
||||
pw.println(prefix + "<provider info not received, yet>");
|
||||
} else if (mProviderInfo.getRoutes().isEmpty()) {
|
||||
pw.println(prefix + "<provider info has no routes>");
|
||||
} else {
|
||||
for (MediaRoute2Info route : mProviderInfo.getRoutes()) {
|
||||
pw.printf("%s%s | %s\n", prefix, route.getId(), route.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDebugString();
|
||||
}
|
||||
|
||||
/** Returns a human-readable string describing the instance, for debugging purposes. */
|
||||
protected abstract String getDebugString();
|
||||
|
||||
public interface Callback {
|
||||
void onProviderStateChanged(@Nullable MediaRoute2Provider provider);
|
||||
void onSessionCreated(@NonNull MediaRoute2Provider provider,
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.util.Slog;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -83,10 +82,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
|
||||
mHandler = new Handler(Looper.myLooper());
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw, String prefix) {
|
||||
pw.println(prefix + getDebugString());
|
||||
}
|
||||
|
||||
public void setManagerScanning(boolean managerScanning) {
|
||||
if (mIsManagerScanning != managerScanning) {
|
||||
mIsManagerScanning = managerScanning;
|
||||
@@ -488,11 +483,7 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDebugString();
|
||||
}
|
||||
|
||||
private String getDebugString() {
|
||||
protected String getDebugString() {
|
||||
return TextUtils.formatSimple(
|
||||
"ProviderServiceProxy - package: %s, bound: %b, connection (active:%b, ready:%b)",
|
||||
mComponentName.getPackageName(),
|
||||
|
||||
@@ -1751,6 +1751,7 @@ class MediaRouter2ServiceImpl {
|
||||
String indent = prefix + " ";
|
||||
pw.println(indent + "mRunning=" + mRunning);
|
||||
|
||||
mSystemProvider.dump(pw, prefix);
|
||||
mWatcher.dump(pw, prefix);
|
||||
}
|
||||
|
||||
|
||||
@@ -392,6 +392,15 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
||||
mCallback.onSessionUpdated(this, sessionInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDebugString() {
|
||||
return TextUtils.formatSimple(
|
||||
"SystemMR2Provider - package: %s, selected route id: %s, bluetooth impl: %s",
|
||||
mComponentName.getPackageName(),
|
||||
mSelectedRouteId,
|
||||
mBluetoothRouteController.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
private static class SessionCreationRequest {
|
||||
final long mRequestId;
|
||||
final String mRouteId;
|
||||
|
||||
Reference in New Issue
Block a user