Merge "[FUI21] Move scrubSubscriberId to utils class" am: f6c7f61d27
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1565195 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I7afe5684997a5c47bcee269d2310fc61715ec13a
This commit is contained in:
@@ -28,7 +28,6 @@ import android.content.Context;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.DataUsageRequest;
|
import android.net.DataUsageRequest;
|
||||||
import android.net.INetworkStatsService;
|
import android.net.INetworkStatsService;
|
||||||
import android.net.NetworkIdentity;
|
|
||||||
import android.net.NetworkStack;
|
import android.net.NetworkStack;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.net.netstats.provider.INetworkStatsProviderCallback;
|
import android.net.netstats.provider.INetworkStatsProviderCallback;
|
||||||
@@ -47,6 +46,7 @@ import android.util.DataUnit;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.net.module.util.NetworkIdentityUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -628,7 +628,7 @@ public class NetworkStatsManager {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Cannot create template for network type "
|
throw new IllegalArgumentException("Cannot create template for network type "
|
||||||
+ networkType + ", subscriberId '"
|
+ networkType + ", subscriberId '"
|
||||||
+ NetworkIdentity.scrubSubscriberId(subscriberId) + "'.");
|
+ NetworkIdentityUtils.scrubSubscriberId(subscriberId) + "'.");
|
||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import static android.net.ConnectivityManager.TYPE_WIFI;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
|
||||||
import android.service.NetworkIdentityProto;
|
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.NetworkIdentityUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +90,8 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
|||||||
builder.append(mSubType);
|
builder.append(mSubType);
|
||||||
}
|
}
|
||||||
if (mSubscriberId != null) {
|
if (mSubscriberId != null) {
|
||||||
builder.append(", subscriberId=").append(scrubSubscriberId(mSubscriberId));
|
builder.append(", subscriberId=")
|
||||||
|
.append(NetworkIdentityUtils.scrubSubscriberId(mSubscriberId));
|
||||||
}
|
}
|
||||||
if (mNetworkId != null) {
|
if (mNetworkId != null) {
|
||||||
builder.append(", networkId=").append(mNetworkId);
|
builder.append(", networkId=").append(mNetworkId);
|
||||||
@@ -110,7 +112,8 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
|||||||
// Not dumping mSubType, subtypes are no longer supported.
|
// Not dumping mSubType, subtypes are no longer supported.
|
||||||
|
|
||||||
if (mSubscriberId != null) {
|
if (mSubscriberId != null) {
|
||||||
proto.write(NetworkIdentityProto.SUBSCRIBER_ID, scrubSubscriberId(mSubscriberId));
|
proto.write(NetworkIdentityProto.SUBSCRIBER_ID,
|
||||||
|
NetworkIdentityUtils.scrubSubscriberId(mSubscriberId));
|
||||||
}
|
}
|
||||||
proto.write(NetworkIdentityProto.NETWORK_ID, mNetworkId);
|
proto.write(NetworkIdentityProto.NETWORK_ID, mNetworkId);
|
||||||
proto.write(NetworkIdentityProto.ROAMING, mRoaming);
|
proto.write(NetworkIdentityProto.ROAMING, mRoaming);
|
||||||
@@ -148,32 +151,6 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
|||||||
return mDefaultNetwork;
|
return mDefaultNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scrub given IMSI on production builds.
|
|
||||||
*/
|
|
||||||
public static String scrubSubscriberId(String subscriberId) {
|
|
||||||
if (Build.IS_ENG) {
|
|
||||||
return subscriberId;
|
|
||||||
} else if (subscriberId != null) {
|
|
||||||
// TODO: parse this as MCC+MNC instead of hard-coding
|
|
||||||
return subscriberId.substring(0, Math.min(6, subscriberId.length())) + "...";
|
|
||||||
} else {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scrub given IMSI on production builds.
|
|
||||||
*/
|
|
||||||
public static String[] scrubSubscriberId(String[] subscriberId) {
|
|
||||||
if (subscriberId == null) return null;
|
|
||||||
final String[] res = new String[subscriberId.length];
|
|
||||||
for (int i = 0; i < res.length; i++) {
|
|
||||||
res[i] = NetworkIdentity.scrubSubscriberId(subscriberId[i]);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a {@link NetworkIdentity} from the given {@link NetworkState} and {@code subType},
|
* Build a {@link NetworkIdentity} from the given {@link NetworkState} and {@code subType},
|
||||||
* assuming that any mobile networks are using the current IMSI. The subType if applicable,
|
* assuming that any mobile networks are using the current IMSI. The subType if applicable,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
|
import com.android.net.module.util.NetworkIdentityUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
@@ -296,11 +297,11 @@ public class NetworkTemplate implements Parcelable {
|
|||||||
builder.append("matchRule=").append(getMatchRuleName(mMatchRule));
|
builder.append("matchRule=").append(getMatchRuleName(mMatchRule));
|
||||||
if (mSubscriberId != null) {
|
if (mSubscriberId != null) {
|
||||||
builder.append(", subscriberId=").append(
|
builder.append(", subscriberId=").append(
|
||||||
NetworkIdentity.scrubSubscriberId(mSubscriberId));
|
NetworkIdentityUtils.scrubSubscriberId(mSubscriberId));
|
||||||
}
|
}
|
||||||
if (mMatchSubscriberIds != null) {
|
if (mMatchSubscriberIds != null) {
|
||||||
builder.append(", matchSubscriberIds=").append(
|
builder.append(", matchSubscriberIds=").append(
|
||||||
Arrays.toString(NetworkIdentity.scrubSubscriberId(mMatchSubscriberIds)));
|
Arrays.toString(NetworkIdentityUtils.scrubSubscriberIds(mMatchSubscriberIds)));
|
||||||
}
|
}
|
||||||
if (mNetworkId != null) {
|
if (mNetworkId != null) {
|
||||||
builder.append(", networkId=").append(mNetworkId);
|
builder.append(", networkId=").append(mNetworkId);
|
||||||
|
|||||||
Reference in New Issue
Block a user