Merge "Remove *_WILDCARD constants from NetworkTemplate"
This commit is contained in:
@@ -88,18 +88,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
public static final int MATCH_WIFI = 4;
|
public static final int MATCH_WIFI = 4;
|
||||||
/** Match rule to match ethernet networks. */
|
/** Match rule to match ethernet networks. */
|
||||||
public static final int MATCH_ETHERNET = 5;
|
public static final int MATCH_ETHERNET = 5;
|
||||||
/**
|
|
||||||
* Match rule to match all cellular networks.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static final int MATCH_MOBILE_WILDCARD = 6;
|
|
||||||
/**
|
|
||||||
* Match rule to match all wifi networks.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static final int MATCH_WIFI_WILDCARD = 7;
|
|
||||||
/** Match rule to match bluetooth networks. */
|
/** Match rule to match bluetooth networks. */
|
||||||
public static final int MATCH_BLUETOOTH = 8;
|
public static final int MATCH_BLUETOOTH = 8;
|
||||||
/**
|
/**
|
||||||
@@ -177,8 +165,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
case MATCH_MOBILE:
|
case MATCH_MOBILE:
|
||||||
case MATCH_WIFI:
|
case MATCH_WIFI:
|
||||||
case MATCH_ETHERNET:
|
case MATCH_ETHERNET:
|
||||||
case MATCH_MOBILE_WILDCARD:
|
|
||||||
case MATCH_WIFI_WILDCARD:
|
|
||||||
case MATCH_BLUETOOTH:
|
case MATCH_BLUETOOTH:
|
||||||
case MATCH_PROXY:
|
case MATCH_PROXY:
|
||||||
case MATCH_CARRIER:
|
case MATCH_CARRIER:
|
||||||
@@ -284,9 +270,8 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
|
|
||||||
private static void checkValidMatchSubscriberIds(int matchRule, String[] matchSubscriberIds) {
|
private static void checkValidMatchSubscriberIds(int matchRule, String[] matchSubscriberIds) {
|
||||||
switch (matchRule) {
|
switch (matchRule) {
|
||||||
case MATCH_MOBILE:
|
|
||||||
case MATCH_CARRIER:
|
case MATCH_CARRIER:
|
||||||
// MOBILE and CARRIER templates must always specify a subscriber ID.
|
// CARRIER templates must always specify a valid subscriber ID.
|
||||||
if (matchSubscriberIds.length == 0) {
|
if (matchSubscriberIds.length == 0) {
|
||||||
throw new IllegalArgumentException("checkValidMatchSubscriberIds with empty"
|
throw new IllegalArgumentException("checkValidMatchSubscriberIds with empty"
|
||||||
+ " list of ids for rule" + getMatchRuleName(matchRule));
|
+ " list of ids for rule" + getMatchRuleName(matchRule));
|
||||||
@@ -314,9 +299,9 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
//constructor passes METERED_YES for these types.
|
//constructor passes METERED_YES for these types.
|
||||||
this(matchRule, new String[] { subscriberId },
|
this(matchRule, 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_CARRIER)
|
||||||
|| matchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL,
|
? METERED_YES : METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
|
||||||
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
|
NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -417,43 +402,23 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public boolean isMatchRuleMobile() {
|
|
||||||
switch (mMatchRule) {
|
|
||||||
case MATCH_MOBILE:
|
|
||||||
case MATCH_MOBILE_WILDCARD:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get match rule of the template. See {@code MATCH_*}.
|
* Get match rule of the template. See {@code MATCH_*}.
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
|
||||||
public int getMatchRule() {
|
public int getMatchRule() {
|
||||||
// Wildcard rules are not exposed. For external callers, convert wildcard rules to
|
return mMatchRule;
|
||||||
// exposed rules before returning.
|
|
||||||
switch (mMatchRule) {
|
|
||||||
case MATCH_MOBILE_WILDCARD:
|
|
||||||
return MATCH_MOBILE;
|
|
||||||
case MATCH_WIFI_WILDCARD:
|
|
||||||
return MATCH_WIFI;
|
|
||||||
default:
|
|
||||||
return mMatchRule;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subscriber Id of the template.
|
* Get subscriber Id of the template.
|
||||||
*
|
*
|
||||||
* @deprecated User should get a subscriberId by {@link #getSubscriberIds} instead.
|
* @deprecated User should use {@link #getSubscriberIds} instead.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Nullable
|
@Nullable
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
|
||||||
|
publicAlternatives = "Caller should use {@code getSubscriberIds} instead.")
|
||||||
public String getSubscriberId() {
|
public String getSubscriberId() {
|
||||||
return CollectionUtils.isEmpty(mMatchSubscriberIds) ? null : mMatchSubscriberIds[0];
|
return CollectionUtils.isEmpty(mMatchSubscriberIds) ? null : mMatchSubscriberIds[0];
|
||||||
}
|
}
|
||||||
@@ -542,10 +507,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
return matchesWifi(ident);
|
return matchesWifi(ident);
|
||||||
case MATCH_ETHERNET:
|
case MATCH_ETHERNET:
|
||||||
return matchesEthernet(ident);
|
return matchesEthernet(ident);
|
||||||
case MATCH_MOBILE_WILDCARD:
|
|
||||||
return matchesMobileWildcard(ident);
|
|
||||||
case MATCH_WIFI_WILDCARD:
|
|
||||||
return matchesWifiWildcard(ident);
|
|
||||||
case MATCH_BLUETOOTH:
|
case MATCH_BLUETOOTH:
|
||||||
return matchesBluetooth(ident);
|
return matchesBluetooth(ident);
|
||||||
case MATCH_PROXY:
|
case MATCH_PROXY:
|
||||||
@@ -626,9 +587,9 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
// TODO: consider matching against WiMAX subscriber identity
|
// TODO: consider matching against WiMAX subscriber identity
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ident.mType == TYPE_MOBILE && !CollectionUtils.isEmpty(mMatchSubscriberIds)
|
return (CollectionUtils.isEmpty(mMatchSubscriberIds)
|
||||||
&& CollectionUtils.contains(mMatchSubscriberIds, ident.mSubscriberId)
|
|| CollectionUtils.contains(mMatchSubscriberIds, ident.mSubscriberId))
|
||||||
&& matchesCollapsedRatType(ident);
|
&& (ident.mType == TYPE_MOBILE && matchesCollapsedRatType(ident));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,6 +601,8 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
case TYPE_WIFI:
|
case TYPE_WIFI:
|
||||||
return matchesSubscriberId(ident.mSubscriberId)
|
return matchesSubscriberId(ident.mSubscriberId)
|
||||||
&& matchesWifiNetworkKey(ident.mWifiNetworkKey);
|
&& matchesWifiNetworkKey(ident.mWifiNetworkKey);
|
||||||
|
case TYPE_WIFI_P2P:
|
||||||
|
return CollectionUtils.isEmpty(mMatchWifiNetworkKeys);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -675,24 +638,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
|| CollectionUtils.contains(mMatchWifiNetworkKeys, ident.mWifiNetworkKey)));
|
|| CollectionUtils.contains(mMatchWifiNetworkKeys, ident.mWifiNetworkKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesMobileWildcard(NetworkIdentity ident) {
|
|
||||||
if (ident.mType == TYPE_WIMAX) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return ident.mType == TYPE_MOBILE && matchesCollapsedRatType(ident);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean matchesWifiWildcard(NetworkIdentity ident) {
|
|
||||||
switch (ident.mType) {
|
|
||||||
case TYPE_WIFI:
|
|
||||||
case TYPE_WIFI_P2P:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if matches Bluetooth network template.
|
* Check if matches Bluetooth network template.
|
||||||
*/
|
*/
|
||||||
@@ -718,10 +663,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
return "WIFI";
|
return "WIFI";
|
||||||
case MATCH_ETHERNET:
|
case MATCH_ETHERNET:
|
||||||
return "ETHERNET";
|
return "ETHERNET";
|
||||||
case MATCH_MOBILE_WILDCARD:
|
|
||||||
return "MOBILE_WILDCARD";
|
|
||||||
case MATCH_WIFI_WILDCARD:
|
|
||||||
return "WIFI_WILDCARD";
|
|
||||||
case MATCH_BLUETOOTH:
|
case MATCH_BLUETOOTH:
|
||||||
return "BLUETOOTH";
|
return "BLUETOOTH";
|
||||||
case MATCH_PROXY:
|
case MATCH_PROXY:
|
||||||
@@ -781,9 +722,8 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
return new NetworkTemplate(template.mMatchRule, merged,
|
return new NetworkTemplate(template.mMatchRule, merged,
|
||||||
CollectionUtils.isEmpty(matchWifiNetworkKeys)
|
CollectionUtils.isEmpty(matchWifiNetworkKeys)
|
||||||
? new String[0] : new String[] { matchWifiNetworkKeys[0] },
|
? new String[0] : new String[] { matchWifiNetworkKeys[0] },
|
||||||
(template.mMatchRule == MATCH_MOBILE
|
(template.mMatchRule == MATCH_MOBILE || template.mMatchRule == MATCH_CARRIER)
|
||||||
|| template.mMatchRule == MATCH_MOBILE_WILDCARD
|
? METERED_YES : METERED_ALL,
|
||||||
|| template.mMatchRule == MATCH_CARRIER) ? METERED_YES : METERED_ALL,
|
|
||||||
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
|
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,10 +891,7 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
* @param matchRule the target match rule to be checked.
|
* @param matchRule the target match rule to be checked.
|
||||||
*/
|
*/
|
||||||
private static void assertRequestableMatchRule(final int matchRule) {
|
private static void assertRequestableMatchRule(final int matchRule) {
|
||||||
if (!isKnownMatchRule(matchRule)
|
if (!isKnownMatchRule(matchRule) || matchRule == MATCH_PROXY) {
|
||||||
|| matchRule == MATCH_PROXY
|
|
||||||
|| matchRule == MATCH_MOBILE_WILDCARD
|
|
||||||
|| matchRule == MATCH_WIFI_WILDCARD) {
|
|
||||||
throw new IllegalArgumentException("Invalid match rule: "
|
throw new IllegalArgumentException("Invalid match rule: "
|
||||||
+ getMatchRuleName(matchRule));
|
+ getMatchRuleName(matchRule));
|
||||||
}
|
}
|
||||||
@@ -974,20 +911,6 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* For backward compatibility, deduce match rule to a wildcard match rule
|
|
||||||
* if the Subscriber Ids are empty.
|
|
||||||
*/
|
|
||||||
private int getWildcardDeducedMatchRule() {
|
|
||||||
if (mMatchRule == MATCH_MOBILE && mMatchSubscriberIds.isEmpty()) {
|
|
||||||
return MATCH_MOBILE_WILDCARD;
|
|
||||||
} else if (mMatchRule == MATCH_WIFI && mMatchSubscriberIds.isEmpty()
|
|
||||||
&& mMatchWifiNetworkKeys.isEmpty()) {
|
|
||||||
return MATCH_WIFI_WILDCARD;
|
|
||||||
}
|
|
||||||
return mMatchRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the instance of the NetworkTemplate.
|
* Builds the instance of the NetworkTemplate.
|
||||||
*
|
*
|
||||||
@@ -996,7 +919,7 @@ public final class NetworkTemplate implements Parcelable {
|
|||||||
@NonNull
|
@NonNull
|
||||||
public NetworkTemplate build() {
|
public NetworkTemplate build() {
|
||||||
assertRequestableParameters();
|
assertRequestableParameters();
|
||||||
return new NetworkTemplate(getWildcardDeducedMatchRule(),
|
return new NetworkTemplate(mMatchRule,
|
||||||
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);
|
mDefaultNetwork, mRatType, mOemManaged);
|
||||||
|
|||||||
@@ -26,10 +26,8 @@ import android.net.NetworkTemplate.MATCH_BLUETOOTH
|
|||||||
import android.net.NetworkTemplate.MATCH_CARRIER
|
import android.net.NetworkTemplate.MATCH_CARRIER
|
||||||
import android.net.NetworkTemplate.MATCH_ETHERNET
|
import android.net.NetworkTemplate.MATCH_ETHERNET
|
||||||
import android.net.NetworkTemplate.MATCH_MOBILE
|
import android.net.NetworkTemplate.MATCH_MOBILE
|
||||||
import android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD
|
|
||||||
import android.net.NetworkTemplate.MATCH_PROXY
|
import android.net.NetworkTemplate.MATCH_PROXY
|
||||||
import android.net.NetworkTemplate.MATCH_WIFI
|
import android.net.NetworkTemplate.MATCH_WIFI
|
||||||
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
|
||||||
@@ -64,10 +62,8 @@ class NetworkTemplateTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify hidden match rules cannot construct templates.
|
// Verify hidden match rules cannot construct templates.
|
||||||
listOf(MATCH_WIFI_WILDCARD, MATCH_MOBILE_WILDCARD, MATCH_PROXY).forEach {
|
assertFailsWith<IllegalArgumentException> {
|
||||||
assertFailsWith<IllegalArgumentException> {
|
NetworkTemplate.Builder(MATCH_PROXY).build()
|
||||||
NetworkTemplate.Builder(it).build()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify template which matches metered cellular and carrier networks with
|
// Verify template which matches metered cellular and carrier networks with
|
||||||
@@ -102,7 +98,7 @@ class NetworkTemplateTest {
|
|||||||
// Verify template which matches metered cellular networks,
|
// Verify template which matches metered cellular networks,
|
||||||
// regardless of IMSI. See buildTemplateMobileWildcard.
|
// regardless of IMSI. See buildTemplateMobileWildcard.
|
||||||
NetworkTemplate.Builder(MATCH_MOBILE).setMeteredness(METERED_YES).build().let {
|
NetworkTemplate.Builder(MATCH_MOBILE).setMeteredness(METERED_YES).build().let {
|
||||||
val expectedTemplate = NetworkTemplate(MATCH_MOBILE_WILDCARD,
|
val expectedTemplate = NetworkTemplate(MATCH_MOBILE,
|
||||||
emptyArray<String>() /*subscriberIds*/, emptyArray<String>() /*wifiNetworkKey*/,
|
emptyArray<String>() /*subscriberIds*/, emptyArray<String>() /*wifiNetworkKey*/,
|
||||||
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
|
METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
|
||||||
OEM_MANAGED_ALL)
|
OEM_MANAGED_ALL)
|
||||||
@@ -110,7 +106,6 @@ class NetworkTemplateTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify template which matches metered cellular networks and ratType.
|
// Verify template which matches metered cellular networks and ratType.
|
||||||
// See NetworkTemplate#buildTemplateMobileWithRatType.
|
|
||||||
NetworkTemplate.Builder(MATCH_MOBILE).setSubscriberIds(setOf(TEST_IMSI1))
|
NetworkTemplate.Builder(MATCH_MOBILE).setSubscriberIds(setOf(TEST_IMSI1))
|
||||||
.setMeteredness(METERED_YES).setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
|
.setMeteredness(METERED_YES).setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
|
||||||
.build().let {
|
.build().let {
|
||||||
@@ -123,7 +118,7 @@ class NetworkTemplateTest {
|
|||||||
// Verify template which matches all wifi networks,
|
// Verify template which matches all wifi networks,
|
||||||
// regardless of Wifi Network Key. See buildTemplateWifiWildcard and buildTemplateWifi.
|
// regardless of Wifi Network Key. See buildTemplateWifiWildcard and buildTemplateWifi.
|
||||||
NetworkTemplate.Builder(MATCH_WIFI).build().let {
|
NetworkTemplate.Builder(MATCH_WIFI).build().let {
|
||||||
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD,
|
val expectedTemplate = NetworkTemplate(MATCH_WIFI,
|
||||||
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), METERED_ALL,
|
emptyArray<String>() /*subscriberIds*/, emptyArray<String>(), METERED_ALL,
|
||||||
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL)
|
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_ALL)
|
||||||
assertEquals(expectedTemplate, it)
|
assertEquals(expectedTemplate, it)
|
||||||
@@ -188,7 +183,7 @@ class NetworkTemplateTest {
|
|||||||
|
|
||||||
// Verify template which matches wifi wildcard with the given empty key set.
|
// Verify template which matches wifi wildcard with the given empty key set.
|
||||||
NetworkTemplate.Builder(MATCH_WIFI).setWifiNetworkKeys(setOf<String>()).build().let {
|
NetworkTemplate.Builder(MATCH_WIFI).setWifiNetworkKeys(setOf<String>()).build().let {
|
||||||
val expectedTemplate = NetworkTemplate(MATCH_WIFI_WILDCARD,
|
val expectedTemplate = NetworkTemplate(MATCH_WIFI,
|
||||||
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)
|
OEM_MANAGED_ALL)
|
||||||
|
|||||||
@@ -34,10 +34,8 @@ import android.net.NetworkStats.METERED_YES
|
|||||||
import android.net.NetworkStats.ROAMING_ALL
|
import android.net.NetworkStats.ROAMING_ALL
|
||||||
import android.net.NetworkTemplate.MATCH_CARRIER
|
import android.net.NetworkTemplate.MATCH_CARRIER
|
||||||
import android.net.NetworkTemplate.MATCH_MOBILE
|
import android.net.NetworkTemplate.MATCH_MOBILE
|
||||||
import android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD
|
|
||||||
import android.net.NetworkTemplate.MATCH_TEST
|
import android.net.NetworkTemplate.MATCH_TEST
|
||||||
import android.net.NetworkTemplate.MATCH_WIFI
|
import android.net.NetworkTemplate.MATCH_WIFI
|
||||||
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.net.NetworkTemplate.OEM_MANAGED_NO
|
import android.net.NetworkTemplate.OEM_MANAGED_NO
|
||||||
@@ -231,7 +229,6 @@ class NetworkTemplateTest {
|
|||||||
val templateMobileWildcard = buildTemplateMobileWildcard()
|
val templateMobileWildcard = buildTemplateMobileWildcard()
|
||||||
val templateMobileNullImsiWithRatType = NetworkTemplate.Builder(MATCH_MOBILE)
|
val templateMobileNullImsiWithRatType = NetworkTemplate.Builder(MATCH_MOBILE)
|
||||||
.setRatType(TelephonyManager.NETWORK_TYPE_UMTS).build()
|
.setRatType(TelephonyManager.NETWORK_TYPE_UMTS).build()
|
||||||
|
|
||||||
val mobileImsi1 = buildMobileNetworkState(TEST_IMSI1)
|
val mobileImsi1 = buildMobileNetworkState(TEST_IMSI1)
|
||||||
val identMobile1 = buildNetworkIdentity(mockContext, mobileImsi1,
|
val identMobile1 = buildNetworkIdentity(mockContext, mobileImsi1,
|
||||||
false /* defaultNetwork */, TelephonyManager.NETWORK_TYPE_UMTS)
|
false /* defaultNetwork */, TelephonyManager.NETWORK_TYPE_UMTS)
|
||||||
@@ -453,7 +450,7 @@ class NetworkTemplateTest {
|
|||||||
val templateWifi = NetworkTemplate(MATCH_WIFI, emptyArray<String>(),
|
val templateWifi = NetworkTemplate(MATCH_WIFI, 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)
|
OEM_MANAGED_ALL)
|
||||||
val templateOem = NetworkTemplate(MATCH_MOBILE_WILDCARD, emptyArray<String>(),
|
val templateOem = NetworkTemplate(MATCH_MOBILE, 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)
|
OEM_MANAGED_YES)
|
||||||
assertParcelSane(templateMobile, 8)
|
assertParcelSane(templateMobile, 8)
|
||||||
@@ -491,13 +488,14 @@ class NetworkTemplateTest {
|
|||||||
* @param matchType A match rule from {@code NetworkTemplate.MATCH_*} corresponding to the
|
* @param matchType A match rule from {@code NetworkTemplate.MATCH_*} corresponding to the
|
||||||
* networkType.
|
* networkType.
|
||||||
* @param subscriberId To be populated with {@code TEST_IMSI*} only if networkType is
|
* @param subscriberId To be populated with {@code TEST_IMSI*} only if networkType is
|
||||||
* {@code TYPE_MOBILE}. May be left as null when matchType is
|
* {@code TYPE_MOBILE}. Note that {@code MATCH_MOBILE} with an empty subscriberId list
|
||||||
* {@link NetworkTemplate.MATCH_MOBILE_WILDCARD}.
|
* will match any subscriber ID.
|
||||||
* @param templateWifiKey Top be populated with {@code TEST_WIFI_KEY*} only if networkType is
|
* @param templateWifiKey To be populated with {@code TEST_WIFI_KEY*} only if networkType is
|
||||||
* {@code TYPE_WIFI}. May be left as null when matchType is
|
* {@code TYPE_WIFI}. Note that {@code MATCH_WIFI} with both an empty subscriberId list
|
||||||
* {@link NetworkTemplate.MATCH_WIFI_WILDCARD}.
|
* and an empty wifiNetworkKey list will match any subscriber ID and/or any wifi network
|
||||||
* @param identWifiKey If networkType is {@code TYPE_WIFI}, this value must *NOT* be null. Provide
|
* key.
|
||||||
* one of {@code TEST_WIFI_KEY*}.
|
* @param identWifiKey If networkType is {@code TYPE_WIFI}, this value must *NOT* be null.
|
||||||
|
* Provide one of {@code TEST_WIFI_KEY*}.
|
||||||
*/
|
*/
|
||||||
private fun matchOemManagedIdent(
|
private fun matchOemManagedIdent(
|
||||||
networkType: Int,
|
networkType: Int,
|
||||||
@@ -507,8 +505,10 @@ class NetworkTemplateTest {
|
|||||||
identWifiKey: String? = null
|
identWifiKey: String? = null
|
||||||
) {
|
) {
|
||||||
val oemManagedStates = arrayOf(OEM_NONE, OEM_PAID, OEM_PRIVATE, OEM_PAID or OEM_PRIVATE)
|
val oemManagedStates = arrayOf(OEM_NONE, OEM_PAID, OEM_PRIVATE, OEM_PAID or OEM_PRIVATE)
|
||||||
val matchSubscriberIds = arrayOf(subscriberId)
|
val matchSubscriberIds =
|
||||||
val matchWifiNetworkKeys = arrayOf(templateWifiKey)
|
if (subscriberId == null) emptyArray<String>() else arrayOf(subscriberId)
|
||||||
|
val matchWifiNetworkKeys =
|
||||||
|
if (templateWifiKey == null) emptyArray<String>() else arrayOf(templateWifiKey)
|
||||||
|
|
||||||
val templateOemYes = NetworkTemplate(matchType, matchSubscriberIds,
|
val templateOemYes = NetworkTemplate(matchType, matchSubscriberIds,
|
||||||
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
|
matchWifiNetworkKeys, METERED_ALL, ROAMING_ALL,
|
||||||
@@ -547,11 +547,10 @@ class NetworkTemplateTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testOemManagedMatchesIdent() {
|
fun testOemManagedMatchesIdent() {
|
||||||
matchOemManagedIdent(TYPE_MOBILE, MATCH_MOBILE, subscriberId = TEST_IMSI1)
|
matchOemManagedIdent(TYPE_MOBILE, MATCH_MOBILE, subscriberId = TEST_IMSI1)
|
||||||
matchOemManagedIdent(TYPE_MOBILE, MATCH_MOBILE_WILDCARD)
|
matchOemManagedIdent(TYPE_MOBILE, MATCH_MOBILE)
|
||||||
matchOemManagedIdent(TYPE_WIFI, MATCH_WIFI, templateWifiKey = TEST_WIFI_KEY1,
|
matchOemManagedIdent(TYPE_WIFI, MATCH_WIFI, templateWifiKey = TEST_WIFI_KEY1,
|
||||||
identWifiKey = TEST_WIFI_KEY1)
|
identWifiKey = TEST_WIFI_KEY1)
|
||||||
matchOemManagedIdent(TYPE_WIFI, MATCH_WIFI_WILDCARD,
|
matchOemManagedIdent(TYPE_WIFI, MATCH_WIFI, identWifiKey = TEST_WIFI_KEY1)
|
||||||
identWifiKey = TEST_WIFI_KEY1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user