summaryrefslogtreecommitdiff
path: root/framework-t/src/android/net/NetworkIdentity.java
diff options
context:
space:
mode:
authorLes Lee <lesl@google.com>2021-12-23 11:45:02 +0800
committerLes Lee <lesl@google.com>2022-01-03 15:13:00 +0800
commit03bc7820312a293a80fa02ed6c58fe6ff9f42bb0 (patch)
tree8dfe571645a9d18d4e278163a3893a384238c26b /framework-t/src/android/net/NetworkIdentity.java
parent4aaf65aa86fe1b2c6fe10c30525ee18edd41eef3 (diff)
wifi data usage: replaced Wi-Fi SSID with a Wi-Fi network key
1. Used SSID to be a wifi network identity can't separate wifi data usage when there are two different network with same SSID. Use a new usage key from WifiInfo to replace wifi SSID to solve this issue. 2. To support to query wifi usage per configured Wifi network. Adding matchWifiNetworkKeys in NetworkTemplate to support querying multi networkKeys wifi data usage since each configured Wifi network configuration might be used to connect different Wifi network. (Replace mNetworkId with mMatchWifiNetworkKeys) 3. Updated callers who were using NetworkTemplate constructor. 4. Fixed SortedSet null order case. The null subscriberId is a valid input for matchSubscriberIds. 5. Replaced ArrayUtils with CollectionUtils. Bug: 197520752 Bug: 126299427 Test: atest -c NetworkTemplateTest Test: atest -c NetworkStatsServiceTest Test: atest -c NetworkPolicyManagerServiceTest Test: atest -c NetworkPolicyTest Change-Id: Ie20e7fb56597817901be4ce1d2a7afcbc9ded0c6
Diffstat (limited to 'framework-t/src/android/net/NetworkIdentity.java')
-rw-r--r--framework-t/src/android/net/NetworkIdentity.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/framework-t/src/android/net/NetworkIdentity.java b/framework-t/src/android/net/NetworkIdentity.java
index eb8f43e3d0..8f1115e065 100644
--- a/framework-t/src/android/net/NetworkIdentity.java
+++ b/framework-t/src/android/net/NetworkIdentity.java
@@ -21,7 +21,6 @@ import static android.net.ConnectivityManager.TYPE_WIFI;
import android.annotation.Nullable;
import android.content.Context;
import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
import android.service.NetworkIdentityProto;
import android.telephony.Annotation.NetworkType;
import android.util.proto.ProtoOutputStream;
@@ -228,11 +227,11 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
final int oemManaged = getOemBitfield(snapshot.getNetworkCapabilities());
if (legacyType == TYPE_WIFI) {
- networkId = snapshot.getNetworkCapabilities().getSsid();
- if (networkId == null) {
- final WifiManager wifi = context.getSystemService(WifiManager.class);
- final WifiInfo info = wifi.getConnectionInfo();
- networkId = info != null ? info.getSSID() : null;
+ final TransportInfo transportInfo = snapshot.getNetworkCapabilities()
+ .getTransportInfo();
+ if (transportInfo instanceof WifiInfo) {
+ final WifiInfo info = (WifiInfo) transportInfo;
+ networkId = info != null ? info.getCurrentNetworkKey() : null;
}
}