Merge "Print human-readable OEM managed states" am: 9374ca2698
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1636561 Change-Id: I38380b1f6a80fdfbbcc21124470929530131fcdd
This commit is contained in:
@@ -26,8 +26,10 @@ import android.service.NetworkIdentityProto;
|
|||||||
import android.telephony.Annotation.NetworkType;
|
import android.telephony.Annotation.NetworkType;
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
|
import com.android.net.module.util.NetworkCapabilitiesUtils;
|
||||||
import com.android.net.module.util.NetworkIdentityUtils;
|
import com.android.net.module.util.NetworkIdentityUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,11 +123,37 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
|||||||
}
|
}
|
||||||
builder.append(", metered=").append(mMetered);
|
builder.append(", metered=").append(mMetered);
|
||||||
builder.append(", defaultNetwork=").append(mDefaultNetwork);
|
builder.append(", defaultNetwork=").append(mDefaultNetwork);
|
||||||
// TODO(180557699): Print a human readable string for OEM managed state.
|
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
|
||||||
builder.append(", oemManaged=").append(mOemManaged);
|
|
||||||
return builder.append("}").toString();
|
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) {
|
public void dumpDebug(ProtoOutputStream proto, long tag) {
|
||||||
final long start = proto.start(tag);
|
final long start = proto.start(tag);
|
||||||
|
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
builder.append(", subType=").append(mSubType);
|
builder.append(", subType=").append(mSubType);
|
||||||
}
|
}
|
||||||
if (mOemManaged != OEM_MANAGED_ALL) {
|
if (mOemManaged != OEM_MANAGED_ALL) {
|
||||||
builder.append(", oemManaged=").append(mOemManaged);
|
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
|
||||||
}
|
}
|
||||||
builder.append(", subscriberIdMatchRule=")
|
builder.append(", subscriberIdMatchRule=")
|
||||||
.append(subscriberIdMatchRuleToString(mSubscriberIdMatchRule));
|
.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"
|
* Examine the given template and normalize if it refers to a "merged"
|
||||||
* mobile subscriber. We pick the "lowest" merged subscriber as the primary
|
* mobile subscriber. We pick the "lowest" merged subscriber as the primary
|
||||||
|
|||||||
Reference in New Issue
Block a user