Implement dump method in MediaRoute2Info
Bug: b/243116883 Test: adb shell dumpsys media_router Change-Id: Ic3269c7fc1e96f5cf8c17aad15afebdc324c4356
This commit is contained in:
@@ -28,11 +28,13 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -622,6 +624,58 @@ public final class MediaRoute2Info implements Parcelable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps the current state of the object to the given {@code pw} as a human-readable string.
|
||||
*
|
||||
* <p> Used in the context of dumpsys. </p>
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {
|
||||
pw.println(prefix + "MediaRoute2Info");
|
||||
|
||||
String indent = prefix + " ";
|
||||
|
||||
pw.println(indent + "mId=" + mId);
|
||||
pw.println(indent + "mName=" + mName);
|
||||
pw.println(indent + "mFeatures=" + mFeatures);
|
||||
pw.println(indent + "mIsSystem=" + mIsSystem);
|
||||
pw.println(indent + "mIconUri=" + mIconUri);
|
||||
pw.println(indent + "mDescription=" + mDescription);
|
||||
pw.println(indent + "mConnectionState=" + mConnectionState);
|
||||
pw.println(indent + "mClientPackageName=" + mClientPackageName);
|
||||
pw.println(indent + "mPackageName=" + mPackageName);
|
||||
|
||||
dumpVolume(pw, indent);
|
||||
|
||||
pw.println(indent + "mAddress=" + mAddress);
|
||||
pw.println(indent + "mDeduplicationIds=" + mDeduplicationIds);
|
||||
pw.println(indent + "mExtras=" + mExtras);
|
||||
pw.println(indent + "mProviderId=" + mProviderId);
|
||||
}
|
||||
|
||||
private void dumpVolume(@NonNull PrintWriter pw, @NonNull String prefix) {
|
||||
String volumeHandlingName;
|
||||
|
||||
switch (mVolumeHandling) {
|
||||
case PLAYBACK_VOLUME_FIXED:
|
||||
volumeHandlingName = "FIXED";
|
||||
break;
|
||||
case PLAYBACK_VOLUME_VARIABLE:
|
||||
volumeHandlingName = "VARIABLE";
|
||||
break;
|
||||
default:
|
||||
volumeHandlingName = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
String volume = String.format(Locale.US,
|
||||
"volume(current=%d, max=%d, handling=%s(%d))",
|
||||
mVolume, mVolumeMax, volumeHandlingName, mVolumeHandling);
|
||||
|
||||
pw.println(prefix + volume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -2438,6 +2438,7 @@ class MediaRouter2ServiceImpl {
|
||||
pw.println(indent + "mUniqueRequestId=" + mUniqueRequestId);
|
||||
pw.println(indent + "mManagerRequestId=" + mManagerRequestId);
|
||||
mOldSession.dump(pw, indent);
|
||||
mRoute.dump(pw, prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user