Minor fixes to NetworkCapabilities#toString.
1. The current code only prints the array of administrator UIDs if it's empty. This is clearly an oversight. Print it only if it's non-empty. 2. Only print requestor UID and package name if they are set. This makes output shorter in the common case that they are unset. 3. Reorder the output at the end: group all UIDs together, and place SSID and private DNS broken bit after that. 4. Make the private DNS broken indication a single word instead of a sentence. This saves space and makes it easier to write regexps. New format: ... SignalStrength: -72 OwnerUid: 1000 AdminUids: [1000] SSID: ... ... Uid: 1000 RequestorUid: 1000 RequestorPkg: android ... Test: manual Change-Id: I2f5ccc1d9e4af6ddacc4d193185a17723822972b
This commit is contained in:
@@ -1802,20 +1802,26 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
sb.append(" OwnerUid: ").append(mOwnerUid);
|
sb.append(" OwnerUid: ").append(mOwnerUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAdministratorUids.length == 0) {
|
if (!ArrayUtils.isEmpty(mAdministratorUids)) {
|
||||||
sb.append(" AdministratorUids: ").append(Arrays.toString(mAdministratorUids));
|
sb.append(" AdminUids: ").append(Arrays.toString(mAdministratorUids));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRequestorUid != Process.INVALID_UID) {
|
||||||
|
sb.append(" RequestorUid: ").append(mRequestorUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRequestorPackageName != null) {
|
||||||
|
sb.append(" RequestorPkg: ").append(mRequestorPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != mSSID) {
|
if (null != mSSID) {
|
||||||
sb.append(" SSID: ").append(mSSID);
|
sb.append(" SSID: ").append(mSSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPrivateDnsBroken) {
|
|
||||||
sb.append(" Private DNS is broken");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(" RequestorUid: ").append(mRequestorUid);
|
if (mPrivateDnsBroken) {
|
||||||
sb.append(" RequestorPackageName: ").append(mRequestorPackageName);
|
sb.append(" PrivateDnsBroken");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user