Merge changes from topics "mergedNetwork", "wifiInfoSubId"
* changes: Add API to get Subscription Id [Suggestion] API to set carrier merged network
This commit is contained in:
@@ -31894,6 +31894,7 @@ package android.net.wifi {
|
||||
method @Nullable public String getSsid();
|
||||
method public int getSubscriptionId();
|
||||
method public boolean isAppInteractionRequired();
|
||||
method public boolean isCarrierMerged();
|
||||
method public boolean isCredentialSharedWithUser();
|
||||
method public boolean isEnhancedOpen();
|
||||
method public boolean isHiddenSsid();
|
||||
@@ -31909,6 +31910,7 @@ package android.net.wifi {
|
||||
ctor public WifiNetworkSuggestion.Builder();
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion build();
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setBssid(@NonNull android.net.MacAddress);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setCarrierMerged(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setCredentialSharedWithUser(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsAppInteractionRequired(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsEnhancedMacRandomizationEnabled(boolean);
|
||||
|
||||
@@ -505,6 +505,7 @@ package android.net.wifi {
|
||||
method @Nullable public String getSsid();
|
||||
method public int getSubscriptionId();
|
||||
method public boolean isAppInteractionRequired();
|
||||
method public boolean isCarrierMerged();
|
||||
method public boolean isCredentialSharedWithUser();
|
||||
method public boolean isEnhancedOpen();
|
||||
method public boolean isHiddenSsid();
|
||||
@@ -520,6 +521,7 @@ package android.net.wifi {
|
||||
ctor public WifiNetworkSuggestion.Builder();
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion build();
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setBssid(@NonNull android.net.MacAddress);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setCarrierMerged(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setCredentialSharedWithUser(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsAppInteractionRequired(boolean);
|
||||
method @NonNull public android.net.wifi.WifiNetworkSuggestion.Builder setIsEnhancedMacRandomizationEnabled(boolean);
|
||||
|
||||
@@ -345,6 +345,7 @@ package android.net.wifi {
|
||||
field @Deprecated public static final int RECENT_FAILURE_REFUSED_TEMPORARILY = 1002; // 0x3ea
|
||||
field @Deprecated public boolean allowAutojoin;
|
||||
field @Deprecated public int carrierId;
|
||||
field @Deprecated public boolean carrierMerged;
|
||||
field @Deprecated public String creatorName;
|
||||
field @Deprecated public int creatorUid;
|
||||
field @Deprecated public boolean fromWifiNetworkSpecifier;
|
||||
@@ -426,8 +427,10 @@ package android.net.wifi {
|
||||
method @Nullable public String getRequestingPackageName();
|
||||
method public double getRetriedTxPacketsPerSecond();
|
||||
method public int getScore();
|
||||
method public int getSubscriptionId();
|
||||
method public double getSuccessfulRxPacketsPerSecond();
|
||||
method public double getSuccessfulTxPacketsPerSecond();
|
||||
method public boolean isCarrierMerged();
|
||||
method public boolean isEphemeral();
|
||||
method public boolean isOemPaid();
|
||||
method public boolean isOemPrivate();
|
||||
|
||||
@@ -7,5 +7,7 @@ MissingNullability: android.net.wifi.rtt.RangingRequest.Builder#addResponder(and
|
||||
|
||||
|
||||
|
||||
MutableBareField: android.net.wifi.WifiConfiguration#carrierMerged:
|
||||
|
||||
MutableBareField: android.net.wifi.WifiConfiguration#subscriptionId:
|
||||
Bare field subscriptionId must be marked final, or moved behind accessors if mutable
|
||||
|
||||
@@ -1052,6 +1052,15 @@ public class WifiConfiguration implements Parcelable {
|
||||
*/
|
||||
public boolean oemPrivate;
|
||||
|
||||
/**
|
||||
* Indicate whether or not the network is a carrier merged network.
|
||||
* This bit can only be used by suggestion network, see
|
||||
* {@link WifiNetworkSuggestion.Builder#setCarrierMerged(boolean)}
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean carrierMerged;
|
||||
|
||||
/**
|
||||
* True if this Wifi configuration is created from a {@link WifiNetworkSuggestion},
|
||||
* false otherwise.
|
||||
@@ -2283,6 +2292,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
trusted = true; // Networks are considered trusted by default.
|
||||
oemPaid = false;
|
||||
oemPrivate = false;
|
||||
carrierMerged = false;
|
||||
fromWifiNetworkSuggestion = false;
|
||||
fromWifiNetworkSpecifier = false;
|
||||
meteredHint = false;
|
||||
@@ -2407,12 +2417,13 @@ public class WifiConfiguration implements Parcelable {
|
||||
if (this.trusted) sbuf.append(" trusted");
|
||||
if (this.oemPaid) sbuf.append(" oemPaid");
|
||||
if (this.oemPrivate) sbuf.append(" oemPrivate");
|
||||
if (this.carrierMerged) sbuf.append(" carrierMerged");
|
||||
if (this.fromWifiNetworkSuggestion) sbuf.append(" fromWifiNetworkSuggestion");
|
||||
if (this.fromWifiNetworkSpecifier) sbuf.append(" fromWifiNetworkSpecifier");
|
||||
if (this.meteredHint) sbuf.append(" meteredHint");
|
||||
if (this.useExternalScores) sbuf.append(" useExternalScores");
|
||||
if (this.validatedInternetAccess || this.ephemeral || this.trusted || this.oemPaid
|
||||
|| this.oemPrivate || this.fromWifiNetworkSuggestion
|
||||
|| this.oemPrivate || this.carrierMerged || this.fromWifiNetworkSuggestion
|
||||
|| this.fromWifiNetworkSpecifier || this.meteredHint || this.useExternalScores) {
|
||||
sbuf.append("\n");
|
||||
}
|
||||
@@ -2980,6 +2991,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
trusted = source.trusted;
|
||||
oemPaid = source.oemPaid;
|
||||
oemPrivate = source.oemPrivate;
|
||||
carrierMerged = source.carrierMerged;
|
||||
fromWifiNetworkSuggestion = source.fromWifiNetworkSuggestion;
|
||||
fromWifiNetworkSpecifier = source.fromWifiNetworkSpecifier;
|
||||
meteredHint = source.meteredHint;
|
||||
@@ -3062,6 +3074,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
dest.writeInt(trusted ? 1 : 0);
|
||||
dest.writeInt(oemPaid ? 1 : 0);
|
||||
dest.writeInt(oemPrivate ? 1 : 0);
|
||||
dest.writeInt(carrierMerged ? 1 : 0);
|
||||
dest.writeInt(fromWifiNetworkSuggestion ? 1 : 0);
|
||||
dest.writeInt(fromWifiNetworkSpecifier ? 1 : 0);
|
||||
dest.writeInt(meteredHint ? 1 : 0);
|
||||
@@ -3141,6 +3154,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
config.trusted = in.readInt() != 0;
|
||||
config.oemPaid = in.readInt() != 0;
|
||||
config.oemPrivate = in.readInt() != 0;
|
||||
config.carrierMerged = in.readInt() != 0;
|
||||
config.fromWifiNetworkSuggestion = in.readInt() != 0;
|
||||
config.fromWifiNetworkSpecifier = in.readInt() != 0;
|
||||
config.meteredHint = in.readInt() != 0;
|
||||
|
||||
@@ -25,8 +25,10 @@ import android.net.NetworkInfo.DetailedState;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.module.util.Inet4AddressUtils;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
@@ -168,6 +170,11 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
private boolean mOemPrivate;
|
||||
|
||||
/**
|
||||
* Whether the network is a carrier merged network.
|
||||
*/
|
||||
private boolean mCarrierMerged;
|
||||
|
||||
/**
|
||||
* OSU (Online Sign Up) AP for Passpoint R2.
|
||||
*/
|
||||
@@ -189,6 +196,11 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
private String mRequestingPackageName;
|
||||
|
||||
/**
|
||||
* Identify which Telephony subscription provides this network.
|
||||
*/
|
||||
private int mSubscriptionId;
|
||||
|
||||
/**
|
||||
* Running total count of lost (not ACKed) transmitted unicast data packets.
|
||||
* @hide
|
||||
@@ -315,6 +327,7 @@ public class WifiInfo implements Parcelable {
|
||||
mRssi = INVALID_RSSI;
|
||||
mLinkSpeed = LINK_SPEED_UNKNOWN;
|
||||
mFrequency = -1;
|
||||
mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -335,11 +348,13 @@ public class WifiInfo implements Parcelable {
|
||||
setTrusted(false);
|
||||
setOemPaid(false);
|
||||
setOemPrivate(false);
|
||||
setCarrierMerged(false);
|
||||
setOsuAp(false);
|
||||
setRequestingPackageName(null);
|
||||
setFQDN(null);
|
||||
setProviderFriendlyName(null);
|
||||
setPasspointUniqueId(null);
|
||||
setSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
txBad = 0;
|
||||
txSuccess = 0;
|
||||
rxSuccess = 0;
|
||||
@@ -373,11 +388,13 @@ public class WifiInfo implements Parcelable {
|
||||
mTrusted = source.mTrusted;
|
||||
mOemPaid = source.mOemPaid;
|
||||
mOemPrivate = source.mOemPrivate;
|
||||
mCarrierMerged = source.mCarrierMerged;
|
||||
mRequestingPackageName =
|
||||
source.mRequestingPackageName;
|
||||
mOsuAp = source.mOsuAp;
|
||||
mFqdn = source.mFqdn;
|
||||
mProviderFriendlyName = source.mProviderFriendlyName;
|
||||
mSubscriptionId = source.mSubscriptionId;
|
||||
txBad = source.txBad;
|
||||
txRetries = source.txRetries;
|
||||
txSuccess = source.txSuccess;
|
||||
@@ -753,6 +770,9 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean isOemPaid() {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return mOemPaid;
|
||||
}
|
||||
|
||||
@@ -768,9 +788,33 @@ public class WifiInfo implements Parcelable {
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean isOemPrivate() {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return mOemPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
public void setCarrierMerged(boolean carrierMerged) {
|
||||
mCarrierMerged = carrierMerged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current Wifi network is a carrier merged network, false otherwise.
|
||||
* @see WifiNetworkSuggestion.Builder#setCarrierMerged(boolean).
|
||||
* {@hide}
|
||||
*/
|
||||
@SystemApi
|
||||
public boolean isCarrierMerged() {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return mCarrierMerged;
|
||||
}
|
||||
|
||||
|
||||
/** {@hide} */
|
||||
public void setOsuAp(boolean osuAp) {
|
||||
mOsuAp = osuAp;
|
||||
@@ -839,6 +883,28 @@ public class WifiInfo implements Parcelable {
|
||||
return mRequestingPackageName;
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public void setSubscriptionId(int subId) {
|
||||
mSubscriptionId = subId;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this network is provisioned by a carrier, returns subscription Id corresponding to the
|
||||
* associated SIM on the device. If this network is not provisioned by a carrier, returns
|
||||
* {@link android.telephony.SubscriptionManager#INVALID_SUBSCRIPTION_ID}
|
||||
*
|
||||
* @see WifiNetworkSuggestion.Builder#setSubscriptionId(int)
|
||||
* @see android.telephony.SubscriptionInfo#getSubscriptionId()
|
||||
* {@hide}
|
||||
*/
|
||||
@SystemApi
|
||||
public int getSubscriptionId() {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return mSubscriptionId;
|
||||
}
|
||||
|
||||
|
||||
/** @hide */
|
||||
@UnsupportedAppUsage
|
||||
@@ -1010,6 +1076,7 @@ public class WifiInfo implements Parcelable {
|
||||
dest.writeInt(mTrusted ? 1 : 0);
|
||||
dest.writeInt(mOemPaid ? 1 : 0);
|
||||
dest.writeInt(mOemPrivate ? 1 : 0);
|
||||
dest.writeInt(mCarrierMerged ? 1 : 0);
|
||||
dest.writeInt(score);
|
||||
dest.writeLong(txSuccess);
|
||||
dest.writeDouble(mSuccessfulTxPacketsPerSecond);
|
||||
@@ -1028,6 +1095,7 @@ public class WifiInfo implements Parcelable {
|
||||
dest.writeInt(mMaxSupportedTxLinkSpeed);
|
||||
dest.writeInt(mMaxSupportedRxLinkSpeed);
|
||||
dest.writeString(mPasspointUniqueId);
|
||||
dest.writeInt(mSubscriptionId);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -1057,6 +1125,7 @@ public class WifiInfo implements Parcelable {
|
||||
info.mTrusted = in.readInt() != 0;
|
||||
info.mOemPaid = in.readInt() != 0;
|
||||
info.mOemPrivate = in.readInt() != 0;
|
||||
info.mCarrierMerged = in.readInt() != 0;
|
||||
info.score = in.readInt();
|
||||
info.txSuccess = in.readLong();
|
||||
info.mSuccessfulTxPacketsPerSecond = in.readDouble();
|
||||
@@ -1075,6 +1144,7 @@ public class WifiInfo implements Parcelable {
|
||||
info.mMaxSupportedTxLinkSpeed = in.readInt();
|
||||
info.mMaxSupportedRxLinkSpeed = in.readInt();
|
||||
info.mPasspointUniqueId = in.readString();
|
||||
info.mSubscriptionId = in.readInt();
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,11 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
*/
|
||||
private boolean mIsNetworkOemPrivate;
|
||||
|
||||
/**
|
||||
* Whether this network is a carrier merged network.
|
||||
*/
|
||||
private boolean mIsCarrierMerged;
|
||||
|
||||
/**
|
||||
* Whether this network will use enhanced MAC randomization.
|
||||
*/
|
||||
@@ -214,6 +219,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
mIsNetworkUntrusted = false;
|
||||
mIsNetworkOemPaid = false;
|
||||
mIsNetworkOemPrivate = false;
|
||||
mIsCarrierMerged = false;
|
||||
mPriorityGroup = 0;
|
||||
mIsEnhancedMacRandomizationEnabled = false;
|
||||
mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
@@ -775,6 +781,34 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the suggestion represents a carrier merged network. A carrier merged
|
||||
* Wi-Fi network is treated as part of the mobile carrier network. Such configuration may
|
||||
* impact the user interface and data usage accounting.
|
||||
* <p>
|
||||
* <li>A suggestion marked as carrier merged must be metered enterprise network with a valid
|
||||
* subscription Id set.
|
||||
* @see #setIsMetered(boolean)
|
||||
* @see #setSubscriptionId(int)
|
||||
* @see #setWpa2EnterpriseConfig(WifiEnterpriseConfig)
|
||||
* @see #setWpa3Enterprise192BitModeConfig(WifiEnterpriseConfig)
|
||||
* @see #setWpa3EnterpriseStandardModeConfig(WifiEnterpriseConfig)
|
||||
* @see #setPasspointConfig(PasspointConfiguration)
|
||||
* </li>
|
||||
* <li>If not set, defaults to false (i.e. not a carrier merged network.)</li>
|
||||
* </p>
|
||||
* @param isCarrierMerged Boolean indicating whether the network is treated a carrier
|
||||
* merged network (if true) or non-merged network (if false);
|
||||
* @return Instance of {@link Builder} to enable chaining of the builder method.
|
||||
*/
|
||||
public @NonNull Builder setCarrierMerged(boolean isCarrierMerged) {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
mIsCarrierMerged = isCarrierMerged;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setSecurityParamsInWifiConfiguration(
|
||||
@NonNull WifiConfiguration configuration) {
|
||||
if (!TextUtils.isEmpty(mWpa2PskPassphrase)) { // WPA-PSK network.
|
||||
@@ -843,6 +877,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
wifiConfiguration.trusted = !mIsNetworkUntrusted;
|
||||
wifiConfiguration.oemPaid = mIsNetworkOemPaid;
|
||||
wifiConfiguration.oemPrivate = mIsNetworkOemPrivate;
|
||||
wifiConfiguration.carrierMerged = mIsCarrierMerged;
|
||||
wifiConfiguration.macRandomizationSetting = mIsEnhancedMacRandomizationEnabled
|
||||
? WifiConfiguration.RANDOMIZATION_ENHANCED
|
||||
: WifiConfiguration.RANDOMIZATION_PERSISTENT;
|
||||
@@ -877,6 +912,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
wifiConfiguration.trusted = !mIsNetworkUntrusted;
|
||||
wifiConfiguration.oemPaid = mIsNetworkOemPaid;
|
||||
wifiConfiguration.oemPrivate = mIsNetworkOemPrivate;
|
||||
wifiConfiguration.carrierMerged = mIsCarrierMerged;
|
||||
wifiConfiguration.subscriptionId = mSubscriptionId;
|
||||
mPasspointConfiguration.setCarrierId(mCarrierId);
|
||||
mPasspointConfiguration.setSubscriptionId(mSubscriptionId);
|
||||
@@ -1004,6 +1040,14 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
}
|
||||
mIsSharedWithUser = false;
|
||||
}
|
||||
if (mIsCarrierMerged) {
|
||||
if (mSubscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
||||
|| mMeteredOverride != WifiConfiguration.METERED_OVERRIDE_METERED
|
||||
|| !isEnterpriseSuggestion()) {
|
||||
throw new IllegalStateException("A carrier merged network must be a metered, "
|
||||
+ "enterprise network with valid subscription Id");
|
||||
}
|
||||
}
|
||||
return new WifiNetworkSuggestion(
|
||||
wifiConfiguration,
|
||||
mPasspointConfiguration,
|
||||
@@ -1013,8 +1057,15 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
mIsInitialAutojoinEnabled,
|
||||
mPriorityGroup);
|
||||
}
|
||||
|
||||
private boolean isEnterpriseSuggestion() {
|
||||
return !(mWpa2EnterpriseConfig == null && mWpa3EnterpriseConfig == null
|
||||
&& mWapiEnterpriseConfig == null && mPasspointConfiguration == null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Network configuration for the provided network.
|
||||
* @hide
|
||||
@@ -1172,6 +1223,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
.append(", isUnTrusted=").append(!wifiConfiguration.trusted)
|
||||
.append(", isOemPaid=").append(wifiConfiguration.oemPaid)
|
||||
.append(", isOemPrivate=").append(wifiConfiguration.oemPrivate)
|
||||
.append(", isCarrierMerged").append(wifiConfiguration.carrierMerged)
|
||||
.append(", priorityGroup=").append(priorityGroup)
|
||||
.append(" ]");
|
||||
return sb.toString();
|
||||
@@ -1290,6 +1342,16 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
return wifiConfiguration.oemPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Builder#setCarrierMerged(boolean)
|
||||
*/
|
||||
public boolean isCarrierMerged() {
|
||||
if (!SdkLevel.isAtLeastS()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return wifiConfiguration.carrierMerged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WifiEnterpriseConfig, or null if unset.
|
||||
* @see Builder#setWapiEnterpriseConfig(WifiEnterpriseConfig)
|
||||
|
||||
@@ -75,6 +75,7 @@ public class WifiConfigurationTest {
|
||||
config.trusted = false;
|
||||
config.oemPaid = true;
|
||||
config.oemPrivate = true;
|
||||
config.carrierMerged = true;
|
||||
config.updateIdentifier = "1234";
|
||||
config.fromWifiNetworkSpecifier = true;
|
||||
config.fromWifiNetworkSuggestion = true;
|
||||
@@ -101,6 +102,7 @@ public class WifiConfigurationTest {
|
||||
assertTrue(reconfig.fromWifiNetworkSuggestion);
|
||||
assertTrue(reconfig.oemPaid);
|
||||
assertTrue(reconfig.oemPrivate);
|
||||
assertTrue(reconfig.carrierMerged);
|
||||
|
||||
Parcel parcelWW = Parcel.obtain();
|
||||
reconfig.writeToParcel(parcelWW, 0);
|
||||
@@ -116,6 +118,7 @@ public class WifiConfigurationTest {
|
||||
config.trusted = false;
|
||||
config.oemPaid = true;
|
||||
config.oemPrivate = true;
|
||||
config.carrierMerged = true;
|
||||
config.updateIdentifier = "1234";
|
||||
config.fromWifiNetworkSpecifier = true;
|
||||
config.fromWifiNetworkSuggestion = true;
|
||||
@@ -134,6 +137,7 @@ public class WifiConfigurationTest {
|
||||
assertTrue(reconfig.fromWifiNetworkSuggestion);
|
||||
assertTrue(reconfig.oemPaid);
|
||||
assertTrue(reconfig.oemPrivate);
|
||||
assertTrue(reconfig.carrierMerged);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -50,6 +51,7 @@ public class WifiInfoTest {
|
||||
private static final int TEST_RSSI = -60;
|
||||
private static final int TEST_NETWORK_ID = 5;
|
||||
private static final int TEST_NETWORK_ID2 = 6;
|
||||
private static final int TEST_SUB_ID = 1;
|
||||
|
||||
/**
|
||||
* Verify parcel write/read with WifiInfo.
|
||||
@@ -64,6 +66,7 @@ public class WifiInfoTest {
|
||||
writeWifiInfo.setTrusted(true);
|
||||
writeWifiInfo.setOemPaid(true);
|
||||
writeWifiInfo.setOemPrivate(true);
|
||||
writeWifiInfo.setCarrierMerged(true);
|
||||
writeWifiInfo.setOsuAp(true);
|
||||
writeWifiInfo.setFQDN(TEST_FQDN);
|
||||
writeWifiInfo.setProviderFriendlyName(TEST_PROVIDER_NAME);
|
||||
@@ -71,6 +74,7 @@ public class WifiInfoTest {
|
||||
writeWifiInfo.setWifiStandard(TEST_WIFI_STANDARD);
|
||||
writeWifiInfo.setMaxSupportedTxLinkSpeedMbps(TEST_MAX_SUPPORTED_TX_LINK_SPEED_MBPS);
|
||||
writeWifiInfo.setMaxSupportedRxLinkSpeedMbps(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS);
|
||||
writeWifiInfo.setSubscriptionId(TEST_SUB_ID);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
writeWifiInfo.writeToParcel(parcel, 0);
|
||||
@@ -86,6 +90,7 @@ public class WifiInfoTest {
|
||||
assertTrue(readWifiInfo.isTrusted());
|
||||
assertTrue(readWifiInfo.isOemPaid());
|
||||
assertTrue(readWifiInfo.isOemPrivate());
|
||||
assertTrue(readWifiInfo.isCarrierMerged());
|
||||
assertTrue(readWifiInfo.isOsuAp());
|
||||
assertTrue(readWifiInfo.isPasspointAp());
|
||||
assertEquals(TEST_PACKAGE_NAME, readWifiInfo.getRequestingPackageName());
|
||||
@@ -96,6 +101,7 @@ public class WifiInfoTest {
|
||||
readWifiInfo.getMaxSupportedTxLinkSpeedMbps());
|
||||
assertEquals(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS,
|
||||
readWifiInfo.getMaxSupportedRxLinkSpeedMbps());
|
||||
assertEquals(TEST_SUB_ID, readWifiInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,6 +114,7 @@ public class WifiInfoTest {
|
||||
writeWifiInfo.setTrusted(true);
|
||||
writeWifiInfo.setOemPaid(true);
|
||||
writeWifiInfo.setOemPrivate(true);
|
||||
writeWifiInfo.setCarrierMerged(true);
|
||||
writeWifiInfo.setOsuAp(true);
|
||||
writeWifiInfo.setFQDN(TEST_FQDN);
|
||||
writeWifiInfo.setProviderFriendlyName(TEST_PROVIDER_NAME);
|
||||
@@ -115,6 +122,7 @@ public class WifiInfoTest {
|
||||
writeWifiInfo.setWifiStandard(TEST_WIFI_STANDARD);
|
||||
writeWifiInfo.setMaxSupportedTxLinkSpeedMbps(TEST_MAX_SUPPORTED_TX_LINK_SPEED_MBPS);
|
||||
writeWifiInfo.setMaxSupportedRxLinkSpeedMbps(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS);
|
||||
writeWifiInfo.setSubscriptionId(TEST_SUB_ID);
|
||||
|
||||
WifiInfo readWifiInfo = new WifiInfo(writeWifiInfo);
|
||||
|
||||
@@ -125,6 +133,7 @@ public class WifiInfoTest {
|
||||
assertTrue(readWifiInfo.isTrusted());
|
||||
assertTrue(readWifiInfo.isOemPaid());
|
||||
assertTrue(readWifiInfo.isOemPrivate());
|
||||
assertTrue(readWifiInfo.isCarrierMerged());
|
||||
assertTrue(readWifiInfo.isOsuAp());
|
||||
assertTrue(readWifiInfo.isPasspointAp());
|
||||
assertEquals(TEST_PACKAGE_NAME, readWifiInfo.getRequestingPackageName());
|
||||
@@ -135,6 +144,7 @@ public class WifiInfoTest {
|
||||
readWifiInfo.getMaxSupportedTxLinkSpeedMbps());
|
||||
assertEquals(TEST_MAX_SUPPORTED_RX_LINK_SPEED_MBPS,
|
||||
readWifiInfo.getMaxSupportedRxLinkSpeedMbps());
|
||||
assertEquals(TEST_SUB_ID, readWifiInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,6 +164,8 @@ public class WifiInfoTest {
|
||||
assertEquals(-1, wifiInfo.getNetworkId());
|
||||
assertFalse(wifiInfo.isOemPaid());
|
||||
assertFalse(wifiInfo.isOemPrivate());
|
||||
assertFalse(wifiInfo.isCarrierMerged());
|
||||
assertEquals(SubscriptionManager.INVALID_SUBSCRIPTION_ID, wifiInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1414,4 +1414,90 @@ public class WifiNetworkSuggestionTest {
|
||||
.setIsInitialAutojoinEnabled(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate {@link WifiNetworkSuggestion.Builder#setCarrierMerged(boolean)} (boolean)} set the
|
||||
* correct value to the WifiConfiguration.
|
||||
*/
|
||||
@Test
|
||||
public void testSetCarrierMergedNetwork() {
|
||||
assumeTrue(SdkLevel.isAtLeastS());
|
||||
|
||||
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
|
||||
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
|
||||
enterpriseConfig.setCaCertificate(FakeKeys.CA_CERT0);
|
||||
enterpriseConfig.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH);
|
||||
WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion.Builder()
|
||||
.setSsid(TEST_SSID)
|
||||
.setSubscriptionId(1)
|
||||
.setWpa2EnterpriseConfig(enterpriseConfig)
|
||||
.setCarrierMerged(true)
|
||||
.setIsMetered(true)
|
||||
.build();
|
||||
assertTrue(suggestion.isCarrierMerged());
|
||||
assertTrue(suggestion.wifiConfiguration.carrierMerged);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
|
||||
* when set both {@link WifiNetworkSuggestion.Builder#setCarrierMerged(boolean)} (boolean)}
|
||||
* to true on a network is not metered.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSetCarrierMergedNetworkOnUnmeteredNetworkFail() {
|
||||
assumeTrue(SdkLevel.isAtLeastS());
|
||||
|
||||
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
|
||||
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
|
||||
enterpriseConfig.setCaCertificate(FakeKeys.CA_CERT0);
|
||||
enterpriseConfig.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH);
|
||||
new WifiNetworkSuggestion.Builder()
|
||||
.setSsid(TEST_SSID)
|
||||
.setSubscriptionId(1)
|
||||
.setWpa2EnterpriseConfig(enterpriseConfig)
|
||||
.setCarrierMerged(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
|
||||
* when set both {@link WifiNetworkSuggestion.Builder#setCarrierMerged(boolean)} (boolean)}
|
||||
* to true on a network which {@link WifiNetworkSuggestion.Builder#setSubscriptionId(int)}
|
||||
* is not set with a valid sub id.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSetCarrierMergedNetworkWithoutValidSubscriptionIdFail() {
|
||||
assumeTrue(SdkLevel.isAtLeastS());
|
||||
|
||||
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
|
||||
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
|
||||
enterpriseConfig.setCaCertificate(FakeKeys.CA_CERT0);
|
||||
enterpriseConfig.setDomainSuffixMatch(TEST_DOMAIN_SUFFIX_MATCH);
|
||||
WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion.Builder()
|
||||
.setSsid(TEST_SSID)
|
||||
.setWpa2EnterpriseConfig(enterpriseConfig)
|
||||
.setCarrierMerged(true)
|
||||
.setIsMetered(true)
|
||||
.build();
|
||||
assertTrue(suggestion.isCarrierMerged());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure {@link WifiNetworkSuggestion.Builder#build()} throws an exception
|
||||
* when set both {@link WifiNetworkSuggestion.Builder#setCarrierMerged(boolean)} (boolean)}
|
||||
* to true on a non enterprise network.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSetCarrierMergedNetworkWithNonEnterpriseNetworkFail() {
|
||||
assumeTrue(SdkLevel.isAtLeastS());
|
||||
|
||||
WifiNetworkSuggestion suggestion = new WifiNetworkSuggestion.Builder()
|
||||
.setSsid(TEST_SSID)
|
||||
.setSubscriptionId(1)
|
||||
.setWpa2Passphrase(TEST_PRESHARED_KEY)
|
||||
.setCarrierMerged(true)
|
||||
.setIsMetered(true)
|
||||
.build();
|
||||
assertTrue(suggestion.isCarrierMerged());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user