Merge "gn2bp: Remove empty srcs cc_object from blueprint"
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
index e5fe3f8..ace5f15 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
@@ -154,9 +154,9 @@
private static final int INVALID_IFINDEX = 0;
private static final int UPSTREAM_IFINDEX = 1001;
- private static final int UPSTREAM_IFINDEX2 = 1002;
- private static final int DOWNSTREAM_IFINDEX = 1003;
- private static final int DOWNSTREAM_IFINDEX2 = 1004;
+ private static final int UPSTREAM_IFINDEX2 = 1003;
+ private static final int DOWNSTREAM_IFINDEX = 2001;
+ private static final int DOWNSTREAM_IFINDEX2 = 2002;
private static final String UPSTREAM_IFACE = "rmnet0";
private static final String UPSTREAM_IFACE2 = "wlan0";
@@ -2108,7 +2108,7 @@
@Test
public void testIpv6ForwardingRuleToString() throws Exception {
final Ipv6ForwardingRule rule = buildTestForwardingRule(UPSTREAM_IFINDEX, NEIGH_A, MAC_A);
- assertEquals("upstreamIfindex: 1001, downstreamIfindex: 1003, address: 2001:db8::1, "
+ assertEquals("upstreamIfindex: 1001, downstreamIfindex: 2001, address: 2001:db8::1, "
+ "srcMac: 12:34:56:78:90:ab, dstMac: 00:00:00:00:00:0a", rule.toString());
}
diff --git a/bpf_progs/netd.c b/bpf_progs/netd.c
index 3eb4e02..b0246f6 100644
--- a/bpf_progs/netd.c
+++ b/bpf_progs/netd.c
@@ -194,19 +194,38 @@
DEFINE_UPDATE_STATS(stats_map_B, StatsKey)
// both of these return 0 on success or -EFAULT on failure (and zero out the buffer)
-static __always_inline inline int bpf_skb_load_bytes_net(const struct __sk_buff* skb, int off,
- void* to, int len, bool is_4_19) {
- return is_4_19
- ? bpf_skb_load_bytes_relative(skb, off, to, len, BPF_HDR_START_NET)
- : bpf_skb_load_bytes(skb, off, to, len);
+static __always_inline inline int bpf_skb_load_bytes_net(const struct __sk_buff* const skb,
+ const int L3_off,
+ void* const to,
+ const int len,
+ const unsigned kver) {
+ // 'kver' (here and throughout) is the compile time guaranteed minimum kernel version,
+ // ie. we're building (a version of) the bpf program for kver (or newer!) kernels.
+ //
+ // 4.19+ kernels support the 'bpf_skb_load_bytes_relative()' bpf helper function,
+ // so we can use it. On pre-4.19 kernels we cannot use the relative load helper,
+ // and thus will simply get things wrong if there's any L2 (ethernet) header in the skb.
+ //
+ // Luckily, for cellular traffic, there likely isn't any, as cell is usually 'rawip'.
+ //
+ // However, this does mean that wifi (and ethernet) on 4.14 is basically a lost cause:
+ // we'll be making decisions based on the *wrong* bytes (fetched from the wrong offset),
+ // because the 'L3_off' passed to bpf_skb_load_bytes() should be increased by l2_header_size,
+ // which for ethernet is 14 and not 0 like it is for rawip.
+ //
+ // For similar reasons this will fail with non-offloaded VLAN tags on < 4.19 kernels,
+ // since those extend the ethernet header from 14 to 18 bytes.
+ return kver >= KVER(4, 19, 0)
+ ? bpf_skb_load_bytes_relative(skb, L3_off, to, len, BPF_HDR_START_NET)
+ : bpf_skb_load_bytes(skb, L3_off, to, len);
}
-static __always_inline inline bool skip_owner_match(struct __sk_buff* skb, bool is_4_19) {
+static __always_inline inline bool skip_owner_match(struct __sk_buff* skb, const unsigned kver) {
uint32_t flag = 0;
if (skb->protocol == htons(ETH_P_IP)) {
uint8_t proto;
// no need to check for success, proto will be zeroed if bpf_skb_load_bytes_net() fails
- (void)bpf_skb_load_bytes_net(skb, IP_PROTO_OFF, &proto, sizeof(proto), is_4_19);
+ (void)bpf_skb_load_bytes_net(skb, IP_PROTO_OFF, &proto, sizeof(proto), kver);
if (proto == IPPROTO_ESP) return true;
if (proto != IPPROTO_TCP) return false; // handles read failure above
uint8_t ihl;
@@ -215,19 +234,19 @@
// (a little bit deeper in the packet in spite of ihl being zeroed) of the tcp flags
// field will also fail, and that failure we already handle correctly
// (we also don't check that ihl in [0x45,0x4F] nor that ipv4 header checksum is correct)
- (void)bpf_skb_load_bytes_net(skb, IPPROTO_IHL_OFF, &ihl, sizeof(ihl), is_4_19);
+ (void)bpf_skb_load_bytes_net(skb, IPPROTO_IHL_OFF, &ihl, sizeof(ihl), kver);
// if the read below fails, we'll just assume no TCP flags are set, which is fine.
(void)bpf_skb_load_bytes_net(skb, (ihl & 0xF) * 4 + TCP_FLAG32_OFF,
- &flag, sizeof(flag), is_4_19);
+ &flag, sizeof(flag), kver);
} else if (skb->protocol == htons(ETH_P_IPV6)) {
uint8_t proto;
// no need to check for success, proto will be zeroed if bpf_skb_load_bytes_net() fails
- (void)bpf_skb_load_bytes_net(skb, IPV6_PROTO_OFF, &proto, sizeof(proto), is_4_19);
+ (void)bpf_skb_load_bytes_net(skb, IPV6_PROTO_OFF, &proto, sizeof(proto), kver);
if (proto == IPPROTO_ESP) return true;
if (proto != IPPROTO_TCP) return false; // handles read failure above
// if the read below fails, we'll just assume no TCP flags are set, which is fine.
(void)bpf_skb_load_bytes_net(skb, sizeof(struct ipv6hdr) + TCP_FLAG32_OFF,
- &flag, sizeof(flag), is_4_19);
+ &flag, sizeof(flag), kver);
} else {
return false;
}
@@ -250,8 +269,8 @@
#define DROP_IF_UNSET (DOZABLE_MATCH | POWERSAVE_MATCH | RESTRICTED_MATCH | LOW_POWER_STANDBY_MATCH)
static __always_inline inline int bpf_owner_match(struct __sk_buff* skb, uint32_t uid,
- bool egress, bool is_4_19) {
- if (skip_owner_match(skb, is_4_19)) return PASS;
+ bool egress, const unsigned kver) {
+ if (skip_owner_match(skb, kver)) return PASS;
if (is_system_uid(uid)) return PASS;
@@ -288,13 +307,13 @@
StatsKey* key, uint32_t selectedMap) {
if (selectedMap == SELECT_MAP_A) {
update_stats_map_A(skb, egress, key);
- } else if (selectedMap == SELECT_MAP_B) {
+ } else {
update_stats_map_B(skb, egress, key);
}
}
static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, bool egress,
- bool is_4_19) {
+ const unsigned kver) {
uint32_t sock_uid = bpf_get_socket_uid(skb);
uint64_t cookie = bpf_get_socket_cookie(skb);
UidTagValue* utag = bpf_cookie_tag_map_lookup_elem(&cookie);
@@ -314,7 +333,7 @@
return PASS;
}
- int match = bpf_owner_match(skb, sock_uid, egress, is_4_19);
+ int match = bpf_owner_match(skb, sock_uid, egress, kver);
if (egress && (match == DROP)) {
// If an outbound packet is going to be dropped, we do not count that
// traffic.
@@ -362,25 +381,25 @@
DEFINE_NETD_BPF_PROG_KVER_RANGE("cgroupskb/ingress/stats$4_19", AID_ROOT, AID_SYSTEM,
bpf_cgroup_ingress_4_19, KVER(4, 19, 0), KVER_INF)
(struct __sk_buff* skb) {
- return bpf_traffic_account(skb, INGRESS, /* is_4_19 */ true);
+ return bpf_traffic_account(skb, INGRESS, KVER(4, 19, 0));
}
DEFINE_NETD_BPF_PROG_KVER_RANGE("cgroupskb/ingress/stats$4_14", AID_ROOT, AID_SYSTEM,
bpf_cgroup_ingress_4_14, KVER_NONE, KVER(4, 19, 0))
(struct __sk_buff* skb) {
- return bpf_traffic_account(skb, INGRESS, /* is_4_19 */ false);
+ return bpf_traffic_account(skb, INGRESS, KVER_NONE);
}
DEFINE_NETD_BPF_PROG_KVER_RANGE("cgroupskb/egress/stats$4_19", AID_ROOT, AID_SYSTEM,
bpf_cgroup_egress_4_19, KVER(4, 19, 0), KVER_INF)
(struct __sk_buff* skb) {
- return bpf_traffic_account(skb, EGRESS, /* is_4_19 */ true);
+ return bpf_traffic_account(skb, EGRESS, KVER(4, 19, 0));
}
DEFINE_NETD_BPF_PROG_KVER_RANGE("cgroupskb/egress/stats$4_14", AID_ROOT, AID_SYSTEM,
bpf_cgroup_egress_4_14, KVER_NONE, KVER(4, 19, 0))
(struct __sk_buff* skb) {
- return bpf_traffic_account(skb, EGRESS, /* is_4_19 */ false);
+ return bpf_traffic_account(skb, EGRESS, KVER_NONE);
}
// WARNING: Android T's non-updatable netd depends on the name of this program.
diff --git a/framework-t/src/android/net/NetworkTemplate.java b/framework-t/src/android/net/NetworkTemplate.java
index c0ae822..b2da371 100644
--- a/framework-t/src/android/net/NetworkTemplate.java
+++ b/framework-t/src/android/net/NetworkTemplate.java
@@ -52,7 +52,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.NetworkIdentityUtils;
-import com.android.net.module.util.NetworkStatsUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -280,23 +279,21 @@
private final int mRoaming;
private final int mDefaultNetwork;
private final int mRatType;
- /**
- * The subscriber Id match rule defines how the template should match networks with
- * specific subscriberId(s). See NetworkTemplate#SUBSCRIBER_ID_MATCH_RULE_* for more detail.
- */
- private final int mSubscriberIdMatchRule;
// Bitfield containing OEM network properties{@code NetworkIdentity#OEM_*}.
private final int mOemManaged;
- private static void checkValidSubscriberIdMatchRule(int matchRule, int subscriberIdMatchRule) {
+ private static void checkValidMatchSubscriberIds(int matchRule, String[] matchSubscriberIds) {
switch (matchRule) {
case MATCH_MOBILE:
case MATCH_CARRIER:
// MOBILE and CARRIER templates must always specify a subscriber ID.
- if (subscriberIdMatchRule == NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL) {
- throw new IllegalArgumentException("Invalid SubscriberIdMatchRule "
- + "on match rule: " + getMatchRuleName(matchRule));
+ if (matchSubscriberIds.length == 0) {
+ throw new IllegalArgumentException("checkValidMatchSubscriberIds with empty"
+ + " list of ids for rule" + getMatchRuleName(matchRule));
+ } else if (CollectionUtils.contains(matchSubscriberIds, null)) {
+ throw new IllegalArgumentException("checkValidMatchSubscriberIds list of ids"
+ + " may not contain null for rule " + getMatchRuleName(matchRule));
}
return;
default:
@@ -312,28 +309,21 @@
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
publicAlternatives = "Use {@code Builder} instead.")
public NetworkTemplate(int matchRule, String subscriberId, String wifiNetworkKey) {
- this(matchRule, subscriberId, new String[] { subscriberId }, wifiNetworkKey);
- }
-
- /** @hide */
- public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds,
- String wifiNetworkKey) {
// Older versions used to only match MATCH_MOBILE and MATCH_MOBILE_WILDCARD templates
// to metered networks. It is now possible to match mobile with any meteredness, but
// in order to preserve backward compatibility of @UnsupportedAppUsage methods, this
//constructor passes METERED_YES for these types.
- this(matchRule, subscriberId, matchSubscriberIds,
+ this(matchRule, subscriberId, new String[] { subscriberId },
wifiNetworkKey != null ? new String[] { wifiNetworkKey } : new String[0],
(matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD
|| matchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL,
- ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT);
+ ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
}
/** @hide */
public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds,
String[] matchWifiNetworkKeys, int metered, int roaming,
- int defaultNetwork, int ratType, int oemManaged, int subscriberIdMatchRule) {
+ int defaultNetwork, int ratType, int oemManaged) {
Objects.requireNonNull(matchWifiNetworkKeys);
Objects.requireNonNull(matchSubscriberIds);
mMatchRule = matchRule;
@@ -345,8 +335,7 @@
mDefaultNetwork = defaultNetwork;
mRatType = ratType;
mOemManaged = oemManaged;
- mSubscriberIdMatchRule = subscriberIdMatchRule;
- checkValidSubscriberIdMatchRule(matchRule, subscriberIdMatchRule);
+ checkValidMatchSubscriberIds(matchRule, matchSubscriberIds);
if (!isKnownMatchRule(matchRule)) {
throw new IllegalArgumentException("Unknown network template rule " + matchRule
+ " will not match any identity.");
@@ -363,7 +352,6 @@
mDefaultNetwork = in.readInt();
mRatType = in.readInt();
mOemManaged = in.readInt();
- mSubscriberIdMatchRule = in.readInt();
}
@Override
@@ -377,7 +365,6 @@
dest.writeInt(mDefaultNetwork);
dest.writeInt(mRatType);
dest.writeInt(mOemManaged);
- dest.writeInt(mSubscriberIdMatchRule);
}
@Override
@@ -414,15 +401,13 @@
if (mOemManaged != OEM_MANAGED_ALL) {
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
}
- builder.append(", subscriberIdMatchRule=")
- .append(subscriberIdMatchRuleToString(mSubscriberIdMatchRule));
return builder.toString();
}
@Override
public int hashCode() {
return Objects.hash(mMatchRule, mSubscriberId, Arrays.hashCode(mMatchWifiNetworkKeys),
- mMetered, mRoaming, mDefaultNetwork, mRatType, mOemManaged, mSubscriberIdMatchRule);
+ mMetered, mRoaming, mDefaultNetwork, mRatType, mOemManaged);
}
@Override
@@ -436,23 +421,11 @@
&& mDefaultNetwork == other.mDefaultNetwork
&& mRatType == other.mRatType
&& mOemManaged == other.mOemManaged
- && mSubscriberIdMatchRule == other.mSubscriberIdMatchRule
&& Arrays.equals(mMatchWifiNetworkKeys, other.mMatchWifiNetworkKeys);
}
return false;
}
- private static String subscriberIdMatchRuleToString(int rule) {
- switch (rule) {
- case NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT:
- return "EXACT_MATCH";
- case NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL:
- return "ALL";
- default:
- return "Unknown rule " + rule;
- }
- }
-
/** @hide */
public boolean isMatchRuleMobile() {
switch (mMatchRule) {
@@ -627,13 +600,13 @@
/**
* Check if this template matches {@code subscriberId}. Returns true if this
- * template was created with {@code SUBSCRIBER_ID_MATCH_RULE_ALL}, or with a
- * {@code mMatchSubscriberIds} array that contains {@code subscriberId}.
+ * template was created with a {@code mMatchSubscriberIds} array that contains
+ * {@code subscriberId} or if {@code mMatchSubscriberIds} is empty.
*
* @hide
*/
public boolean matchesSubscriberId(@Nullable String subscriberId) {
- return mSubscriberIdMatchRule == NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL
+ return mMatchSubscriberIds.length == 0
|| CollectionUtils.contains(mMatchSubscriberIds, subscriberId);
}
@@ -812,7 +785,11 @@
// could handle incompatible subscriberIds. See b/217805241.
return new NetworkTemplate(template.mMatchRule, merged[0], merged,
CollectionUtils.isEmpty(matchWifiNetworkKeys)
- ? null : matchWifiNetworkKeys[0]);
+ ? new String[0] : new String[] { matchWifiNetworkKeys[0] },
+ (template.mMatchRule == MATCH_MOBILE
+ || template.mMatchRule == MATCH_MOBILE_WILDCARD
+ || template.mMatchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL,
+ ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
}
return template;
@@ -1024,14 +1001,11 @@
@NonNull
public NetworkTemplate build() {
assertRequestableParameters();
- final int subscriberIdMatchRule = mMatchSubscriberIds.isEmpty()
- ? NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL
- : NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT;
return new NetworkTemplate(getWildcardDeducedMatchRule(),
mMatchSubscriberIds.isEmpty() ? null : mMatchSubscriberIds.iterator().next(),
mMatchSubscriberIds.toArray(new String[0]),
mMatchWifiNetworkKeys.toArray(new String[0]), mMetered, mRoaming,
- mDefaultNetwork, mRatType, mOemManaged, subscriberIdMatchRule);
+ mDefaultNetwork, mRatType, mOemManaged);
}
}
}
diff --git a/tests/common/java/android/net/netstats/NetworkTemplateTest.kt b/tests/common/java/android/net/netstats/NetworkTemplateTest.kt
index cdf32a4..3c2340c 100644
--- a/tests/common/java/android/net/netstats/NetworkTemplateTest.kt
+++ b/tests/common/java/android/net/netstats/NetworkTemplateTest.kt
@@ -19,8 +19,8 @@
import android.net.NetworkStats.DEFAULT_NETWORK_ALL
import android.net.NetworkStats.METERED_ALL
import android.net.NetworkStats.METERED_YES
-import android.net.NetworkStats.ROAMING_YES
import android.net.NetworkStats.ROAMING_ALL
+import android.net.NetworkStats.ROAMING_YES
import android.net.NetworkTemplate
import android.net.NetworkTemplate.MATCH_BLUETOOTH
import android.net.NetworkTemplate.MATCH_CARRIER
@@ -33,8 +33,6 @@
import android.net.NetworkTemplate.NETWORK_TYPE_ALL
import android.net.NetworkTemplate.OEM_MANAGED_ALL
import android.telephony.TelephonyManager
-import com.android.net.module.util.NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL
-import com.android.net.module.util.NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT
import com.android.testutils.ConnectivityModuleTest
import com.android.testutils.DevSdkIgnoreRule
import com.android.testutils.SC_V2
@@ -80,7 +78,7 @@
val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
}
@@ -93,7 +91,7 @@
val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_YES, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
}
@@ -109,7 +107,7 @@
val expectedTemplate = NetworkTemplate(MATCH_MOBILE_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
@@ -121,7 +119,7 @@
val expectedTemplate = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_ALL, DEFAULT_NETWORK_ALL, TelephonyManager.NETWORK_TYPE_UMTS,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
@@ -131,7 +129,7 @@
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
@@ -141,7 +139,7 @@
val expectedTemplate = NetworkTemplate(MATCH_WIFI, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, arrayOf(TEST_WIFI_KEY1),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
@@ -152,7 +150,7 @@
val expectedTemplate = NetworkTemplate(MATCH_WIFI, TEST_IMSI1,
arrayOf(TEST_IMSI1), arrayOf(TEST_WIFI_KEY1),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
@@ -163,7 +161,7 @@
val expectedTemplate = NetworkTemplate(matchRule, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
}
@@ -198,7 +196,7 @@
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL)
+ OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it)
}
}
diff --git a/tests/unit/java/android/net/NetworkTemplateTest.kt b/tests/unit/java/android/net/NetworkTemplateTest.kt
index 3cf0228..c3440c5 100644
--- a/tests/unit/java/android/net/NetworkTemplateTest.kt
+++ b/tests/unit/java/android/net/NetworkTemplateTest.kt
@@ -49,7 +49,6 @@
import android.net.wifi.WifiInfo
import android.os.Build
import android.telephony.TelephonyManager
-import com.android.net.module.util.NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT
import com.android.testutils.DevSdkIgnoreRule
import com.android.testutils.DevSdkIgnoreRunner
import com.android.testutils.assertParcelSane
@@ -448,19 +447,18 @@
@Test
fun testParcelUnparcel() {
- val templateMobile = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1, emptyArray<String>(),
+ val templateMobile = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1, arrayOf(TEST_IMSI1),
emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
- TelephonyManager.NETWORK_TYPE_LTE, OEM_MANAGED_ALL,
- SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ TelephonyManager.NETWORK_TYPE_LTE, OEM_MANAGED_ALL)
val templateWifi = NetworkTemplate(MATCH_WIFI, null, emptyArray<String>(),
arrayOf(TEST_WIFI_KEY1), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0,
- OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
- val templateOem = NetworkTemplate(MATCH_MOBILE, null, emptyArray<String>(),
+ OEM_MANAGED_ALL)
+ val templateOem = NetworkTemplate(MATCH_MOBILE_WILDCARD, null, emptyArray<String>(),
emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0,
- OEM_MANAGED_YES, SUBSCRIBER_ID_MATCH_RULE_EXACT)
- assertParcelSane(templateMobile, 10)
- assertParcelSane(templateWifi, 10)
- assertParcelSane(templateOem, 10)
+ OEM_MANAGED_YES)
+ assertParcelSane(templateMobile, 9)
+ assertParcelSane(templateWifi, 9)
+ assertParcelSane(templateOem, 9)
}
// Verify NETWORK_TYPE_* constants in NetworkTemplate do not conflict with
@@ -514,12 +512,10 @@
val templateOemYes = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
- DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES,
- SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES)
val templateOemAll = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
- DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL,
- SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL)
for (identityOemManagedState in oemManagedStates) {
val ident = buildNetworkIdentity(mockContext, buildNetworkState(networkType,
@@ -530,8 +526,7 @@
for (templateOemManagedState in oemManagedStates) {
val template = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
- DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, templateOemManagedState,
- SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, templateOemManagedState)
if (identityOemManagedState == templateOemManagedState) {
template.assertMatches(ident)
} else {