diff --git a/api/current.txt b/api/current.txt index 572867fc94d41..e24df4204af4f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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); diff --git a/wifi/api/current.txt b/wifi/api/current.txt index f418eb6fc74b1..911f2fbc6afa0 100644 --- a/wifi/api/current.txt +++ b/wifi/api/current.txt @@ -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); diff --git a/wifi/api/system-current.txt b/wifi/api/system-current.txt index 5eef6f80ac161..1d2bed8a6fd97 100644 --- a/wifi/api/system-current.txt +++ b/wifi/api/system-current.txt @@ -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(); diff --git a/wifi/api/system-lint-baseline.txt b/wifi/api/system-lint-baseline.txt index a5f3f7c08fa43..9a3b66a304251 100644 --- a/wifi/api/system-lint-baseline.txt +++ b/wifi/api/system-lint-baseline.txt @@ -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 diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index e1e9757e0f6ce..84cd8184289b5 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -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; diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index 774c043136e75..6bd1ce54dc5b1 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -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; } diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java index 61831ea9c5024..bd9a10308bae3 100644 --- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java +++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java @@ -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. + *
+ *