summaryrefslogtreecommitdiff
path: root/framework-t/src/android/net/NetworkStateSnapshot.java
diff options
context:
space:
mode:
authorlifr <lifr@google.com>2021-11-01 18:50:54 +0800
committerFrank <lifr@google.com>2022-02-10 22:49:05 +0800
commit2c266fbc3b1507029aec8003d9ddd8e9ef16b028 (patch)
treed46d7f775c7b6a33aaf587802519d0b15c2aadb2 /framework-t/src/android/net/NetworkStateSnapshot.java
parentc305fb04f147cfa319d9fc16f232c21d0a9b9de7 (diff)
[SUBID01-0]Grow NetworkIdentity to include a new mSubId field
In the previous design of NSS and NPMS, those only had IMSI to identify the cell network. Now the telephony has created the "subId" handle, which is the preferred mechanism for identifying subscribers. This commit adds NetworkStats support for subscriberId as a part of the network identity key Bug: 80526261 Test: atest NetworkTemplateTest NetworkStatsCollectionTest NetworkStatsServiceTest NetworkIdentityTest NetworkStatsDataMigrationUtilsTest Change-Id: Ie1fe81006555dbcca4b62457fa6c319f04b4576d
Diffstat (limited to 'framework-t/src/android/net/NetworkStateSnapshot.java')
-rw-r--r--framework-t/src/android/net/NetworkStateSnapshot.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/framework-t/src/android/net/NetworkStateSnapshot.java b/framework-t/src/android/net/NetworkStateSnapshot.java
index d577aa8fba..c018e91655 100644
--- a/framework-t/src/android/net/NetworkStateSnapshot.java
+++ b/framework-t/src/android/net/NetworkStateSnapshot.java
@@ -17,6 +17,8 @@
package android.net;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
+import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
+import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -98,12 +100,29 @@ public final class NetworkStateSnapshot implements Parcelable {
return mLinkProperties;
}
- /** Get the Subscriber Id of the network associated with this snapshot. */
+ /**
+ * Get the Subscriber Id of the network associated with this snapshot.
+ * @deprecated Please use #getSubId, which doesn't return personally identifiable
+ * information.
+ */
+ @Deprecated
@Nullable
public String getSubscriberId() {
return mSubscriberId;
}
+ /** Get the subId of the network associated with this snapshot. */
+ public int getSubId() {
+ if (mNetworkCapabilities.hasTransport(TRANSPORT_CELLULAR)) {
+ final NetworkSpecifier spec = mNetworkCapabilities.getNetworkSpecifier();
+ if (spec instanceof TelephonyNetworkSpecifier) {
+ return ((TelephonyNetworkSpecifier) spec).getSubscriptionId();
+ }
+ }
+ return INVALID_SUBSCRIPTION_ID;
+ }
+
+
/**
* Get the legacy type of the network associated with this snapshot.
* @return the legacy network type. See {@code ConnectivityManager#TYPE_*}.