Add carrier ID field for WifiConfiguration and PasspointConfiguration
This is only for the load and save Carrier ID field. Bug: 130875004 Test: build, bootup, unit test Change-Id: Id48587ca26fc9dc0f7678b5a449e2d39a2e90dae
This commit is contained in:
@@ -4746,6 +4746,7 @@ package android.net.wifi {
|
||||
method @Deprecated public boolean isEphemeral();
|
||||
method @Deprecated public boolean isNoInternetAccessExpected();
|
||||
field @Deprecated public boolean allowAutojoin;
|
||||
field @Deprecated public int carrierId;
|
||||
field @Deprecated public String creatorName;
|
||||
field @Deprecated public int creatorUid;
|
||||
field @Deprecated public String lastUpdateName;
|
||||
@@ -4852,6 +4853,10 @@ package android.net.wifi {
|
||||
field public int numUsage;
|
||||
}
|
||||
|
||||
public static final class WifiNetworkSuggestion.Builder {
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_CARRIER_PROVISIONING) public android.net.wifi.WifiNetworkSuggestion.Builder setCarrierId(int);
|
||||
}
|
||||
|
||||
public class WifiScanner {
|
||||
method @Deprecated public void configureWifiChange(int, int, int, int, int, android.net.wifi.WifiScanner.BssidInfo[]);
|
||||
method @Deprecated public void configureWifiChange(android.net.wifi.WifiScanner.WifiChangeSettings);
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.BackupUtils;
|
||||
import android.util.Log;
|
||||
@@ -729,6 +730,14 @@ public class WifiConfiguration implements Parcelable {
|
||||
@SystemApi
|
||||
public String lastUpdateName;
|
||||
|
||||
/**
|
||||
* The carrier ID identifies the operator who provides this network configuration.
|
||||
* see {@link TelephonyManager#getSimCarrierId()}
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public int carrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Status of user approval for connection
|
||||
@@ -1850,6 +1859,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
.append(" PRIO: ").append(this.priority)
|
||||
.append(" HIDDEN: ").append(this.hiddenSSID)
|
||||
.append(" PMF: ").append(this.requirePMF)
|
||||
.append("CarrierId: ").append(this.carrierId)
|
||||
.append('\n');
|
||||
|
||||
|
||||
@@ -2443,6 +2453,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
randomizedMacExpirationTimeMs = source.randomizedMacExpirationTimeMs;
|
||||
requirePMF = source.requirePMF;
|
||||
updateIdentifier = source.updateIdentifier;
|
||||
carrierId = source.carrierId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2517,6 +2528,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
dest.writeInt(macRandomizationSetting);
|
||||
dest.writeInt(osu ? 1 : 0);
|
||||
dest.writeLong(randomizedMacExpirationTimeMs);
|
||||
dest.writeInt(carrierId);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@@ -2593,6 +2605,7 @@ public class WifiConfiguration implements Parcelable {
|
||||
config.macRandomizationSetting = in.readInt();
|
||||
config.osu = in.readInt() != 0;
|
||||
config.randomizedMacExpirationTimeMs = in.readLong();
|
||||
config.carrierId = in.readInt();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -1263,4 +1263,23 @@ public class WifiEnterpriseConfig implements Parcelable {
|
||||
public @Ocsp int getOcsp() {
|
||||
return mOcsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current authentication method needs SIM card.
|
||||
* @return true if the credential information require SIM card for current authentication
|
||||
* method, otherwise it returns false.
|
||||
* @hide
|
||||
*/
|
||||
public boolean requireSimCredential() {
|
||||
if (mEapMethod == Eap.SIM || mEapMethod == Eap.AKA || mEapMethod == Eap.AKA_PRIME) {
|
||||
return true;
|
||||
}
|
||||
if (mEapMethod == Eap.PEAP) {
|
||||
if (mPhase2Method == Phase2.SIM || mPhase2Method == Phase2.AKA
|
||||
|| mPhase2Method == Phase2.AKA_PRIME) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,15 @@ import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityThread;
|
||||
import android.net.MacAddress;
|
||||
import android.net.wifi.hotspot2.PasspointConfiguration;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
@@ -107,6 +110,12 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
*/
|
||||
private int mPriority;
|
||||
|
||||
/**
|
||||
* The carrier ID identifies the operator who provides this network configuration.
|
||||
* see {@link TelephonyManager#getSimCarrierId()}
|
||||
*/
|
||||
private int mCarrierId;
|
||||
|
||||
public Builder() {
|
||||
mSsid = null;
|
||||
mBssid = null;
|
||||
@@ -121,6 +130,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
mIsUserInteractionRequired = false;
|
||||
mIsMetered = false;
|
||||
mPriority = UNASSIGNED_PRIORITY;
|
||||
mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,6 +267,23 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the carrier ID of the network operator. The carrier ID associates a Suggested
|
||||
* network with a specific carrier (and therefore SIM). The carrier ID must be provided
|
||||
* for any network which uses the SIM-based authentication: e.g. EAP-SIM, EAP-AKA,
|
||||
* EAP-AKA', and EAP-PEAP with SIM-based phase 2 authentication.
|
||||
* @param carrierId see {@link TelephonyManager#getSimCarrierId()}.
|
||||
* @return Instance of {@link Builder} to enable chaining of the builder method.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.NETWORK_CARRIER_PROVISIONING)
|
||||
public @NonNull Builder setCarrierId(int carrierId) {
|
||||
mCarrierId = carrierId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether this represents a hidden network.
|
||||
* <p>
|
||||
@@ -380,6 +407,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
wifiConfiguration.meteredOverride =
|
||||
mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED
|
||||
: WifiConfiguration.METERED_OVERRIDE_NONE;
|
||||
wifiConfiguration.carrierId = mCarrierId;
|
||||
return wifiConfiguration;
|
||||
}
|
||||
|
||||
@@ -405,6 +433,7 @@ public final class WifiNetworkSuggestion implements Parcelable {
|
||||
wifiConfiguration.meteredOverride =
|
||||
mIsMetered ? WifiConfiguration.METERED_OVERRIDE_METERED
|
||||
: WifiConfiguration.METERED_OVERRIDE_NONE;
|
||||
mPasspointConfiguration.setCarrierId(mCarrierId);
|
||||
return wifiConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.net.wifi.hotspot2.pps.UpdateParameter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -397,6 +398,30 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
return mServiceFriendlyNames.get(mServiceFriendlyNames.keySet().stream().findFirst().get());
|
||||
}
|
||||
|
||||
/**
|
||||
* The carrier ID identifies the operator who provides this network configuration.
|
||||
* see {@link TelephonyManager#getSimCarrierId()}
|
||||
*/
|
||||
private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
|
||||
|
||||
/**
|
||||
* Set the carrier ID associated with current configuration.
|
||||
* @param carrierId {@code mCarrierId}
|
||||
* @hide
|
||||
*/
|
||||
public void setCarrierId(int carrierId) {
|
||||
this.mCarrierId = carrierId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the carrier ID associated with current configuration.
|
||||
* @return {@code mCarrierId}
|
||||
* @hide
|
||||
*/
|
||||
public int getCarrierId() {
|
||||
return mCarrierId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for creating PasspointConfiguration with default values.
|
||||
*/
|
||||
@@ -438,6 +463,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
mUsageLimitUsageTimePeriodInMinutes = source.mUsageLimitUsageTimePeriodInMinutes;
|
||||
mServiceFriendlyNames = source.mServiceFriendlyNames;
|
||||
mAaaServerTrustedNames = source.mAaaServerTrustedNames;
|
||||
mCarrierId = source.mCarrierId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -466,6 +492,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
bundle.putSerializable("serviceFriendlyNames",
|
||||
(HashMap<String, String>) mServiceFriendlyNames);
|
||||
dest.writeBundle(bundle);
|
||||
dest.writeInt(mCarrierId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -495,6 +522,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
&& mUsageLimitStartTimeInMillis == that.mUsageLimitStartTimeInMillis
|
||||
&& mUsageLimitDataLimit == that.mUsageLimitDataLimit
|
||||
&& mUsageLimitTimeLimitInMinutes == that.mUsageLimitTimeLimitInMinutes
|
||||
&& mCarrierId == that.mCarrierId
|
||||
&& (mServiceFriendlyNames == null ? that.mServiceFriendlyNames == null
|
||||
: mServiceFriendlyNames.equals(that.mServiceFriendlyNames));
|
||||
}
|
||||
@@ -505,7 +533,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
mUpdateIdentifier, mCredentialPriority, mSubscriptionCreationTimeInMillis,
|
||||
mSubscriptionExpirationTimeInMillis, mUsageLimitUsageTimePeriodInMinutes,
|
||||
mUsageLimitStartTimeInMillis, mUsageLimitDataLimit, mUsageLimitTimeLimitInMinutes,
|
||||
mServiceFriendlyNames);
|
||||
mServiceFriendlyNames, mCarrierId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -558,6 +586,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
if (mServiceFriendlyNames != null) {
|
||||
builder.append("ServiceFriendlyNames: ").append(mServiceFriendlyNames);
|
||||
}
|
||||
builder.append("CarrierId:" + mCarrierId);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -662,6 +691,7 @@ public final class PasspointConfiguration implements Parcelable {
|
||||
Map<String, String> friendlyNamesMap = (HashMap) bundle.getSerializable(
|
||||
"serviceFriendlyNames");
|
||||
config.setServiceFriendlyNames(friendlyNamesMap);
|
||||
config.mCarrierId = in.readInt();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user