Shorten the output of NetworkAgentInfo#toString().
Currently, printing a NetworkAgentInfo results in a very long
string. Make it a bit shorter by:
- Not printing a number of fields in NetworkInfo that are no
longer used.
- Instead of printing flags regardless of whether they are true
false, only print ones that are true. For example, this changes
everCaptivePortalDetected{true} lastCaptivePortalDetected{false} captivePortalValidationPending{false}
to:
everCaptivePortalDetected
- Only printing clat information if clatd is started.
Also, put the long and variable-length fields lp and nc at the
end of the output.
Test: manual
Change-Id: I3312286be307ef1762890cbc6b717f12ce5b2b92
This commit is contained in:
@@ -22,6 +22,7 @@ import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.Annotation.NetworkType;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
@@ -538,7 +539,7 @@ public class NetworkInfo implements Parcelable {
|
||||
@Override
|
||||
public String toString() {
|
||||
synchronized (this) {
|
||||
StringBuilder builder = new StringBuilder("[");
|
||||
final StringBuilder builder = new StringBuilder("[");
|
||||
builder.append("type: ").append(getTypeName()).append("[").append(getSubtypeName()).
|
||||
append("], state: ").append(mState).append("/").append(mDetailedState).
|
||||
append(", reason: ").append(mReason == null ? "(unspecified)" : mReason).
|
||||
@@ -551,6 +552,32 @@ public class NetworkInfo implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a brief summary string suitable for debugging.
|
||||
* @hide
|
||||
*/
|
||||
public String toShortString() {
|
||||
synchronized (this) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(getTypeName());
|
||||
|
||||
final String subtype = getSubtypeName();
|
||||
if (!TextUtils.isEmpty(subtype)) {
|
||||
builder.append("[").append(subtype).append("]");
|
||||
}
|
||||
|
||||
builder.append(" ");
|
||||
builder.append(mDetailedState);
|
||||
if (mIsRoaming) {
|
||||
builder.append(" ROAMING");
|
||||
}
|
||||
if (mExtraInfo != null) {
|
||||
builder.append(" extra: ").append(mExtraInfo);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user