Merge "Remove mSubscriberIdMatchRule from NetworkTemplate" am: b97fbbf5e0 am: 1972c16a3d

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2241257

Change-Id: I61f8a7c51ffcdbb2c06a1a4996049f2aaaa9f562
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Aaron Huang
2023-01-03 03:07:06 +00:00
committed by Automerger Merge Worker
3 changed files with 42 additions and 75 deletions

View File

@@ -52,7 +52,6 @@ import android.util.ArraySet;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.net.module.util.CollectionUtils; import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.NetworkIdentityUtils; import com.android.net.module.util.NetworkIdentityUtils;
import com.android.net.module.util.NetworkStatsUtils;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@@ -280,23 +279,21 @@ public final class NetworkTemplate implements Parcelable {
private final int mRoaming; private final int mRoaming;
private final int mDefaultNetwork; private final int mDefaultNetwork;
private final int mRatType; 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_*}. // Bitfield containing OEM network properties{@code NetworkIdentity#OEM_*}.
private final int mOemManaged; private final int mOemManaged;
private static void checkValidSubscriberIdMatchRule(int matchRule, int subscriberIdMatchRule) { private static void checkValidMatchSubscriberIds(int matchRule, String[] matchSubscriberIds) {
switch (matchRule) { switch (matchRule) {
case MATCH_MOBILE: case MATCH_MOBILE:
case MATCH_CARRIER: case MATCH_CARRIER:
// MOBILE and CARRIER templates must always specify a subscriber ID. // MOBILE and CARRIER templates must always specify a subscriber ID.
if (subscriberIdMatchRule == NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL) { if (matchSubscriberIds.length == 0) {
throw new IllegalArgumentException("Invalid SubscriberIdMatchRule " throw new IllegalArgumentException("checkValidMatchSubscriberIds with empty"
+ "on match rule: " + getMatchRuleName(matchRule)); + " 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; return;
default: default:
@@ -312,28 +309,21 @@ public final class NetworkTemplate implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
publicAlternatives = "Use {@code Builder} instead.") publicAlternatives = "Use {@code Builder} instead.")
public NetworkTemplate(int matchRule, String subscriberId, String wifiNetworkKey) { 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 // 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 // to metered networks. It is now possible to match mobile with any meteredness, but
// in order to preserve backward compatibility of @UnsupportedAppUsage methods, this // in order to preserve backward compatibility of @UnsupportedAppUsage methods, this
//constructor passes METERED_YES for these types. //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], wifiNetworkKey != null ? new String[] { wifiNetworkKey } : new String[0],
(matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD (matchRule == MATCH_MOBILE || matchRule == MATCH_MOBILE_WILDCARD
|| matchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL, || matchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL,
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
OEM_MANAGED_ALL, NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT);
} }
/** @hide */ /** @hide */
public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds, public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds,
String[] matchWifiNetworkKeys, int metered, int roaming, 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(matchWifiNetworkKeys);
Objects.requireNonNull(matchSubscriberIds); Objects.requireNonNull(matchSubscriberIds);
mMatchRule = matchRule; mMatchRule = matchRule;
@@ -345,8 +335,7 @@ public final class NetworkTemplate implements Parcelable {
mDefaultNetwork = defaultNetwork; mDefaultNetwork = defaultNetwork;
mRatType = ratType; mRatType = ratType;
mOemManaged = oemManaged; mOemManaged = oemManaged;
mSubscriberIdMatchRule = subscriberIdMatchRule; checkValidMatchSubscriberIds(matchRule, matchSubscriberIds);
checkValidSubscriberIdMatchRule(matchRule, subscriberIdMatchRule);
if (!isKnownMatchRule(matchRule)) { if (!isKnownMatchRule(matchRule)) {
throw new IllegalArgumentException("Unknown network template rule " + matchRule throw new IllegalArgumentException("Unknown network template rule " + matchRule
+ " will not match any identity."); + " will not match any identity.");
@@ -363,7 +352,6 @@ public final class NetworkTemplate implements Parcelable {
mDefaultNetwork = in.readInt(); mDefaultNetwork = in.readInt();
mRatType = in.readInt(); mRatType = in.readInt();
mOemManaged = in.readInt(); mOemManaged = in.readInt();
mSubscriberIdMatchRule = in.readInt();
} }
@Override @Override
@@ -377,7 +365,6 @@ public final class NetworkTemplate implements Parcelable {
dest.writeInt(mDefaultNetwork); dest.writeInt(mDefaultNetwork);
dest.writeInt(mRatType); dest.writeInt(mRatType);
dest.writeInt(mOemManaged); dest.writeInt(mOemManaged);
dest.writeInt(mSubscriberIdMatchRule);
} }
@Override @Override
@@ -414,15 +401,13 @@ public final class NetworkTemplate implements Parcelable {
if (mOemManaged != OEM_MANAGED_ALL) { if (mOemManaged != OEM_MANAGED_ALL) {
builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged)); builder.append(", oemManaged=").append(getOemManagedNames(mOemManaged));
} }
builder.append(", subscriberIdMatchRule=")
.append(subscriberIdMatchRuleToString(mSubscriberIdMatchRule));
return builder.toString(); return builder.toString();
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mMatchRule, mSubscriberId, Arrays.hashCode(mMatchWifiNetworkKeys), return Objects.hash(mMatchRule, mSubscriberId, Arrays.hashCode(mMatchWifiNetworkKeys),
mMetered, mRoaming, mDefaultNetwork, mRatType, mOemManaged, mSubscriberIdMatchRule); mMetered, mRoaming, mDefaultNetwork, mRatType, mOemManaged);
} }
@Override @Override
@@ -436,23 +421,11 @@ public final class NetworkTemplate implements Parcelable {
&& mDefaultNetwork == other.mDefaultNetwork && mDefaultNetwork == other.mDefaultNetwork
&& mRatType == other.mRatType && mRatType == other.mRatType
&& mOemManaged == other.mOemManaged && mOemManaged == other.mOemManaged
&& mSubscriberIdMatchRule == other.mSubscriberIdMatchRule
&& Arrays.equals(mMatchWifiNetworkKeys, other.mMatchWifiNetworkKeys); && Arrays.equals(mMatchWifiNetworkKeys, other.mMatchWifiNetworkKeys);
} }
return false; 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 */ /** @hide */
public boolean isMatchRuleMobile() { public boolean isMatchRuleMobile() {
switch (mMatchRule) { switch (mMatchRule) {
@@ -627,13 +600,13 @@ public final class NetworkTemplate implements Parcelable {
/** /**
* Check if this template matches {@code subscriberId}. Returns true if this * Check if this template matches {@code subscriberId}. Returns true if this
* template was created with {@code SUBSCRIBER_ID_MATCH_RULE_ALL}, or with a * template was created with a {@code mMatchSubscriberIds} array that contains
* {@code mMatchSubscriberIds} array that contains {@code subscriberId}. * {@code subscriberId} or if {@code mMatchSubscriberIds} is empty.
* *
* @hide * @hide
*/ */
public boolean matchesSubscriberId(@Nullable String subscriberId) { public boolean matchesSubscriberId(@Nullable String subscriberId) {
return mSubscriberIdMatchRule == NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL return mMatchSubscriberIds.length == 0
|| CollectionUtils.contains(mMatchSubscriberIds, subscriberId); || CollectionUtils.contains(mMatchSubscriberIds, subscriberId);
} }
@@ -812,7 +785,11 @@ public final class NetworkTemplate implements Parcelable {
// could handle incompatible subscriberIds. See b/217805241. // could handle incompatible subscriberIds. See b/217805241.
return new NetworkTemplate(template.mMatchRule, merged[0], merged, return new NetworkTemplate(template.mMatchRule, merged[0], merged,
CollectionUtils.isEmpty(matchWifiNetworkKeys) 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; return template;
@@ -1024,14 +1001,11 @@ public final class NetworkTemplate implements Parcelable {
@NonNull @NonNull
public NetworkTemplate build() { public NetworkTemplate build() {
assertRequestableParameters(); assertRequestableParameters();
final int subscriberIdMatchRule = mMatchSubscriberIds.isEmpty()
? NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_ALL
: NetworkStatsUtils.SUBSCRIBER_ID_MATCH_RULE_EXACT;
return new NetworkTemplate(getWildcardDeducedMatchRule(), return new NetworkTemplate(getWildcardDeducedMatchRule(),
mMatchSubscriberIds.isEmpty() ? null : mMatchSubscriberIds.iterator().next(), mMatchSubscriberIds.isEmpty() ? null : mMatchSubscriberIds.iterator().next(),
mMatchSubscriberIds.toArray(new String[0]), mMatchSubscriberIds.toArray(new String[0]),
mMatchWifiNetworkKeys.toArray(new String[0]), mMetered, mRoaming, mMatchWifiNetworkKeys.toArray(new String[0]), mMetered, mRoaming,
mDefaultNetwork, mRatType, mOemManaged, subscriberIdMatchRule); mDefaultNetwork, mRatType, mOemManaged);
} }
} }
} }

View File

@@ -19,8 +19,8 @@ package android.net.netstats
import android.net.NetworkStats.DEFAULT_NETWORK_ALL import android.net.NetworkStats.DEFAULT_NETWORK_ALL
import android.net.NetworkStats.METERED_ALL import android.net.NetworkStats.METERED_ALL
import android.net.NetworkStats.METERED_YES import android.net.NetworkStats.METERED_YES
import android.net.NetworkStats.ROAMING_YES
import android.net.NetworkStats.ROAMING_ALL import android.net.NetworkStats.ROAMING_ALL
import android.net.NetworkStats.ROAMING_YES
import android.net.NetworkTemplate import android.net.NetworkTemplate
import android.net.NetworkTemplate.MATCH_BLUETOOTH import android.net.NetworkTemplate.MATCH_BLUETOOTH
import android.net.NetworkTemplate.MATCH_CARRIER import android.net.NetworkTemplate.MATCH_CARRIER
@@ -33,8 +33,6 @@ import android.net.NetworkTemplate.MATCH_WIFI_WILDCARD
import android.net.NetworkTemplate.NETWORK_TYPE_ALL import android.net.NetworkTemplate.NETWORK_TYPE_ALL
import android.net.NetworkTemplate.OEM_MANAGED_ALL import android.net.NetworkTemplate.OEM_MANAGED_ALL
import android.telephony.TelephonyManager 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.ConnectivityModuleTest
import com.android.testutils.DevSdkIgnoreRule import com.android.testutils.DevSdkIgnoreRule
import com.android.testutils.SC_V2 import com.android.testutils.SC_V2
@@ -80,7 +78,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1, val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES, arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
} }
@@ -93,7 +91,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1, val expectedTemplate = NetworkTemplate(matchRule, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES, arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_YES, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, ROAMING_YES, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
} }
@@ -109,7 +107,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_MOBILE_WILDCARD, null /*subscriberId*/, val expectedTemplate = NetworkTemplate(MATCH_MOBILE_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
@@ -121,7 +119,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1, val expectedTemplate = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1,
arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES, arrayOf(TEST_IMSI1), emptyArray<String>(), METERED_YES,
ROAMING_ALL, DEFAULT_NETWORK_ALL, TelephonyManager.NETWORK_TYPE_UMTS, ROAMING_ALL, DEFAULT_NETWORK_ALL, TelephonyManager.NETWORK_TYPE_UMTS,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
@@ -131,7 +129,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/, val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
@@ -141,7 +139,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_WIFI, null /*subscriberId*/, val expectedTemplate = NetworkTemplate(MATCH_WIFI, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, arrayOf(TEST_WIFI_KEY1), emptyArray<String>() /*subscriberIds*/, arrayOf(TEST_WIFI_KEY1),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
@@ -152,7 +150,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_WIFI, TEST_IMSI1, val expectedTemplate = NetworkTemplate(MATCH_WIFI, TEST_IMSI1,
arrayOf(TEST_IMSI1), arrayOf(TEST_WIFI_KEY1), arrayOf(TEST_IMSI1), arrayOf(TEST_WIFI_KEY1),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
@@ -163,7 +161,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(matchRule, null /*subscriberId*/, val expectedTemplate = NetworkTemplate(matchRule, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
} }
@@ -198,7 +196,7 @@ class NetworkTemplateTest {
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/, val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD, null /*subscriberId*/,
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), emptyArray<String>() /*subscriberIds*/, emptyArray<String>(),
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_ALL) OEM_MANAGED_ALL)
assertEquals(expectedTemplate, it) assertEquals(expectedTemplate, it)
} }
} }

View File

@@ -49,7 +49,6 @@ import android.net.NetworkTemplate.normalize
import android.net.wifi.WifiInfo import android.net.wifi.WifiInfo
import android.os.Build import android.os.Build
import android.telephony.TelephonyManager 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.DevSdkIgnoreRule
import com.android.testutils.DevSdkIgnoreRunner import com.android.testutils.DevSdkIgnoreRunner
import com.android.testutils.assertParcelSane import com.android.testutils.assertParcelSane
@@ -448,19 +447,18 @@ class NetworkTemplateTest {
@Test @Test
fun testParcelUnparcel() { 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, emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
TelephonyManager.NETWORK_TYPE_LTE, OEM_MANAGED_ALL, TelephonyManager.NETWORK_TYPE_LTE, OEM_MANAGED_ALL)
SUBSCRIBER_ID_MATCH_RULE_EXACT)
val templateWifi = NetworkTemplate(MATCH_WIFI, null, emptyArray<String>(), val templateWifi = NetworkTemplate(MATCH_WIFI, null, emptyArray<String>(),
arrayOf(TEST_WIFI_KEY1), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, arrayOf(TEST_WIFI_KEY1), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0,
OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_ALL)
val templateOem = NetworkTemplate(MATCH_MOBILE, null, emptyArray<String>(), val templateOem = NetworkTemplate(MATCH_MOBILE_WILDCARD, null, emptyArray<String>(),
emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, 0,
OEM_MANAGED_YES, SUBSCRIBER_ID_MATCH_RULE_EXACT) OEM_MANAGED_YES)
assertParcelSane(templateMobile, 10) assertParcelSane(templateMobile, 9)
assertParcelSane(templateWifi, 10) assertParcelSane(templateWifi, 9)
assertParcelSane(templateOem, 10) assertParcelSane(templateOem, 9)
} }
// Verify NETWORK_TYPE_* constants in NetworkTemplate do not conflict with // Verify NETWORK_TYPE_* constants in NetworkTemplate do not conflict with
@@ -514,12 +512,10 @@ class NetworkTemplateTest {
val templateOemYes = NetworkTemplate(matchType, subscriberId, matchSubscriberIds, val templateOemYes = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL, matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES)
SUBSCRIBER_ID_MATCH_RULE_EXACT)
val templateOemAll = NetworkTemplate(matchType, subscriberId, matchSubscriberIds, val templateOemAll = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL, matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL)
SUBSCRIBER_ID_MATCH_RULE_EXACT)
for (identityOemManagedState in oemManagedStates) { for (identityOemManagedState in oemManagedStates) {
val ident = buildNetworkIdentity(mockContext, buildNetworkState(networkType, val ident = buildNetworkIdentity(mockContext, buildNetworkState(networkType,
@@ -530,8 +526,7 @@ class NetworkTemplateTest {
for (templateOemManagedState in oemManagedStates) { for (templateOemManagedState in oemManagedStates) {
val template = NetworkTemplate(matchType, subscriberId, matchSubscriberIds, val template = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL, matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, templateOemManagedState, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, templateOemManagedState)
SUBSCRIBER_ID_MATCH_RULE_EXACT)
if (identityOemManagedState == templateOemManagedState) { if (identityOemManagedState == templateOemManagedState) {
template.assertMatches(ident) template.assertMatches(ident)
} else { } else {