Merge "Print human-readable OEM managed states"
This commit is contained in:
@@ -26,8 +26,10 @@ import android.service.NetworkIdentityProto;
|
||||
import android.telephony.Annotation.NetworkType;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import com.android.net.module.util.NetworkCapabilitiesUtils;
|
||||
import com.android.net.module.util.NetworkIdentityUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -121,11 +123,37 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
||||
}
|
||||
builder.append(", metered=").append(mMetered);
|
||||
builder.append(", defaultNetwork=").append(mDefaultNetwork);
|
||||
// TODO(180557699): Print a human readable string for OEM managed state.
|
||||
builder.append(", oemManaged=").append(mOemManaged);
|
||||
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
|
||||
return builder.append("}").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the human readable representation of a bitfield representing the OEM managed state of a
|
||||
* network.
|
||||
*/
|
||||
static String getOemManagedNames(int oemManaged) {
|
||||
if (oemManaged == OEM_NONE) {
|
||||
return "OEM_NONE";
|
||||
}
|
||||
final int[] bitPositions = NetworkCapabilitiesUtils.unpackBits(oemManaged);
|
||||
final ArrayList<String> oemManagedNames = new ArrayList<String>();
|
||||
for (int position : bitPositions) {
|
||||
oemManagedNames.add(nameOfOemManaged(1 << position));
|
||||
}
|
||||
return String.join(",", oemManagedNames);
|
||||
}
|
||||
|
||||
private static String nameOfOemManaged(int oemManagedBit) {
|
||||
switch (oemManagedBit) {
|
||||
case OEM_PAID:
|
||||
return "OEM_PAID";
|
||||
case OEM_PRIVATE:
|
||||
return "OEM_PRIVATE";
|
||||
default:
|
||||
return "Invalid(" + oemManagedBit + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpDebug(ProtoOutputStream proto, long tag) {
|
||||
final long start = proto.start(tag);
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ public class NetworkTemplate implements Parcelable {
|
||||
builder.append(", subType=").append(mSubType);
|
||||
}
|
||||
if (mOemManaged != OEM_MANAGED_ALL) {
|
||||
builder.append(", oemManaged=").append(mOemManaged);
|
||||
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
|
||||
}
|
||||
builder.append(", subscriberIdMatchRule=")
|
||||
.append(subscriberIdMatchRuleToString(mSubscriberIdMatchRule));
|
||||
@@ -777,6 +777,19 @@ public class NetworkTemplate implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOemManagedNames(int oemManaged) {
|
||||
switch (oemManaged) {
|
||||
case OEM_MANAGED_ALL:
|
||||
return "OEM_MANAGED_ALL";
|
||||
case OEM_MANAGED_NO:
|
||||
return "OEM_MANAGED_NO";
|
||||
case OEM_MANAGED_YES:
|
||||
return "OEM_MANAGED_YES";
|
||||
default:
|
||||
return NetworkIdentity.getOemManagedNames(oemManaged);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Examine the given template and normalize if it refers to a "merged"
|
||||
* mobile subscriber. We pick the "lowest" merged subscriber as the primary
|
||||
|
||||
Reference in New Issue
Block a user