Loading api/system-current.txt +19 −3 Original line number Diff line number Diff line Loading @@ -5276,18 +5276,30 @@ package android.net.wifi { public final class SoftApConfiguration implements android.os.Parcelable { method public int describeContents(); method public int getBand(); method @Nullable public android.net.MacAddress getBssid(); method public int getChannel(); method public int getSecurityType(); method @Nullable public String getSsid(); method @Nullable public String getWpa2Passphrase(); method public boolean isHiddenSsid(); method public void writeToParcel(@NonNull android.os.Parcel, int); field public static final int BAND_2GHZ = 0; // 0x0 field public static final int BAND_5GHZ = 1; // 0x1 field public static final int BAND_ANY = -1; // 0xffffffff field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.SoftApConfiguration> CREATOR; field public static final int SECURITY_TYPE_OPEN = 0; // 0x0 field public static final int SECURITY_TYPE_WPA2_PSK = 1; // 0x1 } public static final class SoftApConfiguration.Builder { ctor public SoftApConfiguration.Builder(); ctor public SoftApConfiguration.Builder(@NonNull android.net.wifi.SoftApConfiguration); method @NonNull public android.net.wifi.SoftApConfiguration build(); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setBand(int); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setBssid(@Nullable android.net.MacAddress); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setChannel(int); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setHiddenSsid(boolean); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setSsid(@Nullable String); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setWpa2Passphrase(@Nullable String); } Loading Loading @@ -5467,8 +5479,9 @@ package android.net.wifi { method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,java.util.List<android.net.wifi.ScanResult>> getMatchingOsuProviders(@Nullable java.util.List<android.net.wifi.ScanResult>); method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,android.net.wifi.hotspot2.PasspointConfiguration> getMatchingPasspointConfigsForOsuProviders(@NonNull java.util.Set<android.net.wifi.hotspot2.OsuProvider>); method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_WIFI_STATE, android.Manifest.permission.READ_WIFI_CREDENTIAL}) public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks(); method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.SoftApConfiguration getSoftApConfiguration(); method public int getVerboseLoggingLevel(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.WifiConfiguration getWifiApConfiguration(); method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.WifiConfiguration getWifiApConfiguration(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public int getWifiApState(); method public boolean isApMacRandomizationSupported(); method public boolean isConnectedMacRandomizationSupported(); Loading @@ -5486,17 +5499,20 @@ package android.net.wifi { method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerTrafficStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.TrafficStateCallback); method @RequiresPermission(android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE) public void removeOnWifiUsabilityStatsListener(@NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreBackupData(@NonNull byte[]); method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSoftApBackupData(@NonNull byte[]); method @Deprecated @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSupplicantBackupData(@NonNull byte[], @NonNull byte[]); method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveBackupData(); method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveSoftApBackupData(); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void save(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener); method @RequiresPermission(android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE) public void setDeviceMobilityState(int); method @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean setSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration); method @Deprecated @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsConfiguratorInitiator(@NonNull String, int, int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsEnrolleeInitiator(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startLocalOnlyHotspot(@NonNull android.net.wifi.SoftApConfiguration, @Nullable java.util.concurrent.Executor, @Nullable android.net.wifi.WifiManager.LocalOnlyHotspotCallback); method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public boolean startScan(android.os.WorkSource); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startSoftAp(@Nullable android.net.wifi.WifiConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startSubscriptionProvisioning(@NonNull android.net.wifi.hotspot2.OsuProvider, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.hotspot2.ProvisioningCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startTetheredHotspot(@Nullable android.net.wifi.SoftApConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void stopEasyConnectSession(); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean stopSoftAp(); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void unregisterNetworkRequestMatchCallback(@NonNull android.net.wifi.WifiManager.NetworkRequestMatchCallback); Loading wifi/java/android/net/wifi/IWifiManager.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,8 @@ interface IWifiManager boolean startSoftAp(in WifiConfiguration wifiConfig); boolean startTetheredHotspot(in SoftApConfiguration softApConfig); boolean stopSoftAp(); int startLocalOnlyHotspot(in ILocalOnlyHotspotCallback callback, String packageName, Loading @@ -159,8 +161,14 @@ interface IWifiManager @UnsupportedAppUsage WifiConfiguration getWifiApConfiguration(); SoftApConfiguration getSoftApConfiguration(); boolean setWifiApConfiguration(in WifiConfiguration wifiConfig, String packageName); boolean setSoftApConfiguration(in SoftApConfiguration softApConfig, String packageName); void notifyUserOfApBandConversion(String packageName); void enableTdls(String remoteIPAddress, boolean enable); void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable); Loading @@ -184,6 +192,10 @@ interface IWifiManager void restoreBackupData(in byte[] data); byte[] retrieveSoftApBackupData(); void restoreSoftApBackupData(in byte[] data); void restoreSupplicantBackupData(in byte[] supplicantData, in byte[] ipConfigData); void startSubscriptionProvisioning(in OsuProvider provider, in IProvisioningCallback callback); Loading wifi/java/android/net/wifi/SoftApConfiguration.java +262 −14 Original line number Diff line number Diff line Loading @@ -16,28 +16,34 @@ package android.net.wifi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.MacAddress; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.charset.CharsetEncoder; import java.nio.charset.StandardCharsets; import java.util.Objects; import java.util.concurrent.Executor; /** * WiFi configuration for a soft access point (a.k.a. Soft AP, SAP, Hotspot). * Configuration for a soft access point (a.k.a. Soft AP, SAP, Hotspot). * * This is input for the framework provided by a client app, i.e. it exposes knobs to instruct the * framework how it should open a hotspot. It is not meant to describe the network as it will be * seen by clients; this role is currently served by {@link WifiConfiguration} (see * {@link WifiManager.LocalOnlyHotspotReservation#getWifiConfiguration()}). * framework how it should configure a hotspot. * * System apps can use this to configure a local-only hotspot using * System apps can use this to configure a tethered hotspot using * {@link WifiManager#startTetheredHotspot(SoftApConfiguration)} and * {@link WifiManager#setSoftApConfiguration(SoftApConfiguration)} * or local-only hotspot using * {@link WifiManager#startLocalOnlyHotspot(SoftApConfiguration, Executor, * WifiManager.LocalOnlyHotspotCallback)}. * Loading @@ -48,25 +54,106 @@ import java.util.concurrent.Executor; */ @SystemApi public final class SoftApConfiguration implements Parcelable { /** * 2GHz band. * @hide */ @SystemApi public static final int BAND_2GHZ = 0; /** * 5GHz band. * @hide */ @SystemApi public static final int BAND_5GHZ = 1; /** * Device is allowed to choose the optimal band (2Ghz or 5Ghz) based on device capability, * operating country code and current radio conditions. * @hide */ @SystemApi public static final int BAND_ANY = -1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "BAND_TYPE_" }, value = { BAND_2GHZ, BAND_5GHZ, BAND_ANY, }) public @interface BandType {} /** * SSID for the AP, or null for a framework-determined SSID. */ private final @Nullable String mSsid; /** * BSSID for the AP, or null to use a framework-determined BSSID. */ private final @Nullable MacAddress mBssid; /** * Pre-shared key for WPA2-PSK encryption (non-null enables WPA2-PSK). */ private final @Nullable String mWpa2Passphrase; /** * This is a network that does not broadcast its SSID, so an * SSID-specific probe request must be used for scans. */ private final boolean mHiddenSsid; /** * The operating band of the AP. * One of the band types from {@link @BandType}. */ private final @BandType int mBand; /** * The operating channel of the AP. */ private final int mChannel; /** * The operating security type of the AP. * One of the security types from {@link @SecurityType} */ private final @SecurityType int mSecurityType; /** * Security types we support. */ /** @hide */ @SystemApi public static final int SECURITY_TYPE_OPEN = 0; /** @hide */ @SystemApi public static final int SECURITY_TYPE_WPA2_PSK = 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "SECURITY_TYPE" }, value = { SECURITY_TYPE_OPEN, SECURITY_TYPE_WPA2_PSK, }) public @interface SecurityType {} /** Private constructor for Builder and Parcelable implementation. */ private SoftApConfiguration( @Nullable String ssid, @Nullable MacAddress bssid, String wpa2Passphrase) { private SoftApConfiguration(@Nullable String ssid, @Nullable MacAddress bssid, @Nullable String wpa2Passphrase, boolean hiddenSsid, @BandType int band, int channel, @SecurityType int securityType) { mSsid = ssid; mBssid = bssid; mWpa2Passphrase = wpa2Passphrase; mHiddenSsid = hiddenSsid; mBand = band; mChannel = channel; mSecurityType = securityType; } @Override Loading @@ -80,12 +167,31 @@ public final class SoftApConfiguration implements Parcelable { SoftApConfiguration other = (SoftApConfiguration) otherObj; return Objects.equals(mSsid, other.mSsid) && Objects.equals(mBssid, other.mBssid) && Objects.equals(mWpa2Passphrase, other.mWpa2Passphrase); && Objects.equals(mWpa2Passphrase, other.mWpa2Passphrase) && mHiddenSsid == other.mHiddenSsid && mBand == other.mBand && mChannel == other.mChannel && mSecurityType == other.mSecurityType; } @Override public int hashCode() { return Objects.hash(mSsid, mBssid, mWpa2Passphrase); return Objects.hash(mSsid, mBssid, mWpa2Passphrase, mHiddenSsid, mBand, mChannel, mSecurityType); } @Override public String toString() { StringBuilder sbuf = new StringBuilder(); sbuf.append("ssid=").append(mSsid); if (mBssid != null) sbuf.append(" \n bssid=").append(mBssid.toString()); sbuf.append(" \n Wpa2Passphrase =").append( TextUtils.isEmpty(mWpa2Passphrase) ? "<empty>" : "<non-empty>"); sbuf.append(" \n HiddenSsid =").append(mHiddenSsid); sbuf.append(" \n Band =").append(mBand); sbuf.append(" \n Channel =").append(mChannel); sbuf.append(" \n SecurityType=").append(getSecurityType()); return sbuf.toString(); } @Override Loading @@ -93,6 +199,10 @@ public final class SoftApConfiguration implements Parcelable { dest.writeString(mSsid); dest.writeParcelable(mBssid, flags); dest.writeString(mWpa2Passphrase); dest.writeBoolean(mHiddenSsid); dest.writeInt(mBand); dest.writeInt(mChannel); dest.writeInt(mSecurityType); } @Override Loading @@ -107,7 +217,7 @@ public final class SoftApConfiguration implements Parcelable { return new SoftApConfiguration( in.readString(), in.readParcelable(MacAddress.class.getClassLoader()), in.readString()); in.readString(), in.readBoolean(), in.readInt(), in.readInt(), in.readInt()); } @Override Loading @@ -116,21 +226,67 @@ public final class SoftApConfiguration implements Parcelable { } }; /** * Return String set to be the SSID for the AP. * {@link #setSsid(String)}. */ @Nullable public String getSsid() { return mSsid; } /** * Returns MAC address set to be BSSID for the AP. * {@link #setBssid(MacAddress)}. */ @Nullable public MacAddress getBssid() { return mBssid; } /** * Returns String set to be passphrase for the WPA2-PSK AP. * {@link #setWpa2Passphrase(String)}. */ @Nullable public String getWpa2Passphrase() { return mWpa2Passphrase; } /** * Returns Boolean set to be indicate hidden (true: doesn't broadcast its SSID) or * not (false: broadcasts its SSID) for the AP. * {@link #setHiddenSsid(boolean)}. */ public boolean isHiddenSsid() { return mHiddenSsid; } /** * Returns {@link BandType} set to be the band for the AP. * {@link #setBand(@BandType int)}. */ public @BandType int getBand() { return mBand; } /** * Returns Integer set to be the channel for the AP. * {@link #setChannel(int)}. */ public int getChannel() { return mChannel; } /** * Get security type params which depends on which security passphrase to set. * * @return One of the security types from {@link SecurityType}. */ public @SecurityType int getSecurityType() { return mSecurityType; } /** * Builds a {@link SoftApConfiguration}, which allows an app to configure various aspects of a * Soft AP. Loading @@ -142,6 +298,21 @@ public final class SoftApConfiguration implements Parcelable { private String mSsid; private MacAddress mBssid; private String mWpa2Passphrase; private boolean mHiddenSsid; private int mBand; private int mChannel; private int setSecurityType() { int securityType = SECURITY_TYPE_OPEN; if (!TextUtils.isEmpty(mWpa2Passphrase)) { // WPA2-PSK network. securityType = SECURITY_TYPE_WPA2_PSK; } return securityType; } private void clearAllPassphrase() { mWpa2Passphrase = null; } /** * Constructs a Builder with default values (see {@link Builder}). Loading @@ -150,6 +321,9 @@ public final class SoftApConfiguration implements Parcelable { mSsid = null; mBssid = null; mWpa2Passphrase = null; mHiddenSsid = false; mBand = BAND_2GHZ; mChannel = 0; } /** Loading @@ -161,6 +335,9 @@ public final class SoftApConfiguration implements Parcelable { mSsid = other.mSsid; mBssid = other.mBssid; mWpa2Passphrase = other.mWpa2Passphrase; mHiddenSsid = other.mHiddenSsid; mBand = other.mBand; mChannel = other.mChannel; } /** Loading @@ -170,11 +347,16 @@ public final class SoftApConfiguration implements Parcelable { */ @NonNull public SoftApConfiguration build() { return new SoftApConfiguration(mSsid, mBssid, mWpa2Passphrase); return new SoftApConfiguration(mSsid, mBssid, mWpa2Passphrase, mHiddenSsid, mBand, mChannel, setSecurityType()); } /** * Specifies an SSID for the AP. * <p> * Null SSID only support when configure a local-only hotspot. * <p> * <li>If not set, defaults to null.</li> * * @param ssid SSID of valid Unicode characters, or null to have the SSID automatically * chosen by the framework. Loading @@ -193,7 +375,10 @@ public final class SoftApConfiguration implements Parcelable { /** * Specifies a BSSID for the AP. * * <p> * Only supported when configuring a local-only hotspot. * <p> * <li>If not set, defaults to null.</li> * @param bssid BSSID, or null to have the BSSID chosen by the framework. The caller is * responsible for avoiding collisions. * @return Builder for chaining. Loading @@ -211,8 +396,9 @@ public final class SoftApConfiguration implements Parcelable { } /** * Specifies that this AP should use WPA2-PSK with the given passphrase. When set to null * and no other encryption method is configured, an open network is created. * Specifies that this AP should use WPA2-PSK with the given ASCII WPA2 passphrase. * When set to null, an open network is created. * <p> * * @param passphrase The passphrase to use, or null to unset a previously-set WPA2-PSK * configuration. Loading @@ -222,10 +408,72 @@ public final class SoftApConfiguration implements Parcelable { @NonNull public Builder setWpa2Passphrase(@Nullable String passphrase) { if (passphrase != null) { final CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); if (!asciiEncoder.canEncode(passphrase)) { throw new IllegalArgumentException("passphrase not ASCII encodable"); } Preconditions.checkStringNotEmpty(passphrase); } clearAllPassphrase(); mWpa2Passphrase = passphrase; return this; } /** * Specifies whether the AP is hidden (doesn't broadcast its SSID) or * not (broadcasts its SSID). * <p> * <li>If not set, defaults to false (i.e not a hidden network).</li> * * @param hiddenSsid true for a hidden SSID, false otherwise. * @return Builder for chaining. */ @NonNull public Builder setHiddenSsid(boolean hiddenSsid) { mHiddenSsid = hiddenSsid; return this; } /** * Specifies the band for the AP. * <p> * <li>If not set, defaults to BAND_2GHZ {@link @BandType}.</li> * * @param band One of the band types from {@link @BandType}. * @return Builder for chaining. */ @NonNull public Builder setBand(@BandType int band) { switch (band) { case BAND_2GHZ: break; case BAND_5GHZ: break; case BAND_ANY: break; default: throw new IllegalArgumentException("Invalid band type"); } mBand = band; return this; } /** * Specifies the channel for the AP. * * The channel which AP resides on. Valid channels are country dependent. * Use the special channel value 0 to have the framework auto-select a valid channel * from the band configured with {@link #setBand(@BandType int)}. * * <p> * <li>If not set, defaults to 0.</li> * @param channel operating channel of the AP. * @return Builder for chaining. */ @NonNull public Builder setChannel(int channel) { mChannel = channel; return this; } } } wifi/java/android/net/wifi/WifiManager.java +98 −3 File changed.Preview size limit exceeded, changes collapsed. Show changes wifi/java/com/android/server/wifi/BaseWifiService.java +26 −0 Original line number Diff line number Diff line Loading @@ -284,6 +284,11 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public boolean startTetheredHotspot(SoftApConfiguration softApConfig) { throw new UnsupportedOperationException(); } @Override public boolean stopSoftAp() { throw new UnsupportedOperationException(); Loading Loading @@ -320,11 +325,22 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public SoftApConfiguration getSoftApConfiguration() { throw new UnsupportedOperationException(); } @Override public boolean setWifiApConfiguration(WifiConfiguration wifiConfig, String packageName) { throw new UnsupportedOperationException(); } @Override public boolean setSoftApConfiguration(SoftApConfiguration softApConfig, String packageName) { throw new UnsupportedOperationException(); } @Override public void notifyUserOfApBandConversion(String packageName) { throw new UnsupportedOperationException(); } Loading Loading @@ -384,6 +400,16 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public byte[] retrieveSoftApBackupData() { throw new UnsupportedOperationException(); } @Override public void restoreSoftApBackupData(byte[] data) { throw new UnsupportedOperationException(); } @Override public void restoreSupplicantBackupData(byte[] supplicantData, byte[] ipConfigData) { throw new UnsupportedOperationException(); Loading Loading
api/system-current.txt +19 −3 Original line number Diff line number Diff line Loading @@ -5276,18 +5276,30 @@ package android.net.wifi { public final class SoftApConfiguration implements android.os.Parcelable { method public int describeContents(); method public int getBand(); method @Nullable public android.net.MacAddress getBssid(); method public int getChannel(); method public int getSecurityType(); method @Nullable public String getSsid(); method @Nullable public String getWpa2Passphrase(); method public boolean isHiddenSsid(); method public void writeToParcel(@NonNull android.os.Parcel, int); field public static final int BAND_2GHZ = 0; // 0x0 field public static final int BAND_5GHZ = 1; // 0x1 field public static final int BAND_ANY = -1; // 0xffffffff field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.SoftApConfiguration> CREATOR; field public static final int SECURITY_TYPE_OPEN = 0; // 0x0 field public static final int SECURITY_TYPE_WPA2_PSK = 1; // 0x1 } public static final class SoftApConfiguration.Builder { ctor public SoftApConfiguration.Builder(); ctor public SoftApConfiguration.Builder(@NonNull android.net.wifi.SoftApConfiguration); method @NonNull public android.net.wifi.SoftApConfiguration build(); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setBand(int); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setBssid(@Nullable android.net.MacAddress); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setChannel(int); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setHiddenSsid(boolean); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setSsid(@Nullable String); method @NonNull public android.net.wifi.SoftApConfiguration.Builder setWpa2Passphrase(@Nullable String); } Loading Loading @@ -5467,8 +5479,9 @@ package android.net.wifi { method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,java.util.List<android.net.wifi.ScanResult>> getMatchingOsuProviders(@Nullable java.util.List<android.net.wifi.ScanResult>); method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public java.util.Map<android.net.wifi.hotspot2.OsuProvider,android.net.wifi.hotspot2.PasspointConfiguration> getMatchingPasspointConfigsForOsuProviders(@NonNull java.util.Set<android.net.wifi.hotspot2.OsuProvider>); method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_WIFI_STATE, android.Manifest.permission.READ_WIFI_CREDENTIAL}) public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks(); method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.SoftApConfiguration getSoftApConfiguration(); method public int getVerboseLoggingLevel(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.WifiConfiguration getWifiApConfiguration(); method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public android.net.wifi.WifiConfiguration getWifiApConfiguration(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public int getWifiApState(); method public boolean isApMacRandomizationSupported(); method public boolean isConnectedMacRandomizationSupported(); Loading @@ -5486,17 +5499,20 @@ package android.net.wifi { method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerTrafficStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.TrafficStateCallback); method @RequiresPermission(android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE) public void removeOnWifiUsabilityStatsListener(@NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreBackupData(@NonNull byte[]); method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSoftApBackupData(@NonNull byte[]); method @Deprecated @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSupplicantBackupData(@NonNull byte[], @NonNull byte[]); method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveBackupData(); method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveSoftApBackupData(); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void save(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener); method @RequiresPermission(android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE) public void setDeviceMobilityState(int); method @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean setSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration); method @Deprecated @RequiresPermission(android.Manifest.permission.CHANGE_WIFI_STATE) public boolean setWifiApConfiguration(android.net.wifi.WifiConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsConfiguratorInitiator(@NonNull String, int, int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsEnrolleeInitiator(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startLocalOnlyHotspot(@NonNull android.net.wifi.SoftApConfiguration, @Nullable java.util.concurrent.Executor, @Nullable android.net.wifi.WifiManager.LocalOnlyHotspotCallback); method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public boolean startScan(android.os.WorkSource); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startSoftAp(@Nullable android.net.wifi.WifiConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startSubscriptionProvisioning(@NonNull android.net.wifi.hotspot2.OsuProvider, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.hotspot2.ProvisioningCallback); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startTetheredHotspot(@Nullable android.net.wifi.SoftApConfiguration); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void stopEasyConnectSession(); method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean stopSoftAp(); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void unregisterNetworkRequestMatchCallback(@NonNull android.net.wifi.WifiManager.NetworkRequestMatchCallback); Loading
wifi/java/android/net/wifi/IWifiManager.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,8 @@ interface IWifiManager boolean startSoftAp(in WifiConfiguration wifiConfig); boolean startTetheredHotspot(in SoftApConfiguration softApConfig); boolean stopSoftAp(); int startLocalOnlyHotspot(in ILocalOnlyHotspotCallback callback, String packageName, Loading @@ -159,8 +161,14 @@ interface IWifiManager @UnsupportedAppUsage WifiConfiguration getWifiApConfiguration(); SoftApConfiguration getSoftApConfiguration(); boolean setWifiApConfiguration(in WifiConfiguration wifiConfig, String packageName); boolean setSoftApConfiguration(in SoftApConfiguration softApConfig, String packageName); void notifyUserOfApBandConversion(String packageName); void enableTdls(String remoteIPAddress, boolean enable); void enableTdlsWithMacAddress(String remoteMacAddress, boolean enable); Loading @@ -184,6 +192,10 @@ interface IWifiManager void restoreBackupData(in byte[] data); byte[] retrieveSoftApBackupData(); void restoreSoftApBackupData(in byte[] data); void restoreSupplicantBackupData(in byte[] supplicantData, in byte[] ipConfigData); void startSubscriptionProvisioning(in OsuProvider provider, in IProvisioningCallback callback); Loading
wifi/java/android/net/wifi/SoftApConfiguration.java +262 −14 Original line number Diff line number Diff line Loading @@ -16,28 +16,34 @@ package android.net.wifi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.MacAddress; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.charset.CharsetEncoder; import java.nio.charset.StandardCharsets; import java.util.Objects; import java.util.concurrent.Executor; /** * WiFi configuration for a soft access point (a.k.a. Soft AP, SAP, Hotspot). * Configuration for a soft access point (a.k.a. Soft AP, SAP, Hotspot). * * This is input for the framework provided by a client app, i.e. it exposes knobs to instruct the * framework how it should open a hotspot. It is not meant to describe the network as it will be * seen by clients; this role is currently served by {@link WifiConfiguration} (see * {@link WifiManager.LocalOnlyHotspotReservation#getWifiConfiguration()}). * framework how it should configure a hotspot. * * System apps can use this to configure a local-only hotspot using * System apps can use this to configure a tethered hotspot using * {@link WifiManager#startTetheredHotspot(SoftApConfiguration)} and * {@link WifiManager#setSoftApConfiguration(SoftApConfiguration)} * or local-only hotspot using * {@link WifiManager#startLocalOnlyHotspot(SoftApConfiguration, Executor, * WifiManager.LocalOnlyHotspotCallback)}. * Loading @@ -48,25 +54,106 @@ import java.util.concurrent.Executor; */ @SystemApi public final class SoftApConfiguration implements Parcelable { /** * 2GHz band. * @hide */ @SystemApi public static final int BAND_2GHZ = 0; /** * 5GHz band. * @hide */ @SystemApi public static final int BAND_5GHZ = 1; /** * Device is allowed to choose the optimal band (2Ghz or 5Ghz) based on device capability, * operating country code and current radio conditions. * @hide */ @SystemApi public static final int BAND_ANY = -1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "BAND_TYPE_" }, value = { BAND_2GHZ, BAND_5GHZ, BAND_ANY, }) public @interface BandType {} /** * SSID for the AP, or null for a framework-determined SSID. */ private final @Nullable String mSsid; /** * BSSID for the AP, or null to use a framework-determined BSSID. */ private final @Nullable MacAddress mBssid; /** * Pre-shared key for WPA2-PSK encryption (non-null enables WPA2-PSK). */ private final @Nullable String mWpa2Passphrase; /** * This is a network that does not broadcast its SSID, so an * SSID-specific probe request must be used for scans. */ private final boolean mHiddenSsid; /** * The operating band of the AP. * One of the band types from {@link @BandType}. */ private final @BandType int mBand; /** * The operating channel of the AP. */ private final int mChannel; /** * The operating security type of the AP. * One of the security types from {@link @SecurityType} */ private final @SecurityType int mSecurityType; /** * Security types we support. */ /** @hide */ @SystemApi public static final int SECURITY_TYPE_OPEN = 0; /** @hide */ @SystemApi public static final int SECURITY_TYPE_WPA2_PSK = 1; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = { "SECURITY_TYPE" }, value = { SECURITY_TYPE_OPEN, SECURITY_TYPE_WPA2_PSK, }) public @interface SecurityType {} /** Private constructor for Builder and Parcelable implementation. */ private SoftApConfiguration( @Nullable String ssid, @Nullable MacAddress bssid, String wpa2Passphrase) { private SoftApConfiguration(@Nullable String ssid, @Nullable MacAddress bssid, @Nullable String wpa2Passphrase, boolean hiddenSsid, @BandType int band, int channel, @SecurityType int securityType) { mSsid = ssid; mBssid = bssid; mWpa2Passphrase = wpa2Passphrase; mHiddenSsid = hiddenSsid; mBand = band; mChannel = channel; mSecurityType = securityType; } @Override Loading @@ -80,12 +167,31 @@ public final class SoftApConfiguration implements Parcelable { SoftApConfiguration other = (SoftApConfiguration) otherObj; return Objects.equals(mSsid, other.mSsid) && Objects.equals(mBssid, other.mBssid) && Objects.equals(mWpa2Passphrase, other.mWpa2Passphrase); && Objects.equals(mWpa2Passphrase, other.mWpa2Passphrase) && mHiddenSsid == other.mHiddenSsid && mBand == other.mBand && mChannel == other.mChannel && mSecurityType == other.mSecurityType; } @Override public int hashCode() { return Objects.hash(mSsid, mBssid, mWpa2Passphrase); return Objects.hash(mSsid, mBssid, mWpa2Passphrase, mHiddenSsid, mBand, mChannel, mSecurityType); } @Override public String toString() { StringBuilder sbuf = new StringBuilder(); sbuf.append("ssid=").append(mSsid); if (mBssid != null) sbuf.append(" \n bssid=").append(mBssid.toString()); sbuf.append(" \n Wpa2Passphrase =").append( TextUtils.isEmpty(mWpa2Passphrase) ? "<empty>" : "<non-empty>"); sbuf.append(" \n HiddenSsid =").append(mHiddenSsid); sbuf.append(" \n Band =").append(mBand); sbuf.append(" \n Channel =").append(mChannel); sbuf.append(" \n SecurityType=").append(getSecurityType()); return sbuf.toString(); } @Override Loading @@ -93,6 +199,10 @@ public final class SoftApConfiguration implements Parcelable { dest.writeString(mSsid); dest.writeParcelable(mBssid, flags); dest.writeString(mWpa2Passphrase); dest.writeBoolean(mHiddenSsid); dest.writeInt(mBand); dest.writeInt(mChannel); dest.writeInt(mSecurityType); } @Override Loading @@ -107,7 +217,7 @@ public final class SoftApConfiguration implements Parcelable { return new SoftApConfiguration( in.readString(), in.readParcelable(MacAddress.class.getClassLoader()), in.readString()); in.readString(), in.readBoolean(), in.readInt(), in.readInt(), in.readInt()); } @Override Loading @@ -116,21 +226,67 @@ public final class SoftApConfiguration implements Parcelable { } }; /** * Return String set to be the SSID for the AP. * {@link #setSsid(String)}. */ @Nullable public String getSsid() { return mSsid; } /** * Returns MAC address set to be BSSID for the AP. * {@link #setBssid(MacAddress)}. */ @Nullable public MacAddress getBssid() { return mBssid; } /** * Returns String set to be passphrase for the WPA2-PSK AP. * {@link #setWpa2Passphrase(String)}. */ @Nullable public String getWpa2Passphrase() { return mWpa2Passphrase; } /** * Returns Boolean set to be indicate hidden (true: doesn't broadcast its SSID) or * not (false: broadcasts its SSID) for the AP. * {@link #setHiddenSsid(boolean)}. */ public boolean isHiddenSsid() { return mHiddenSsid; } /** * Returns {@link BandType} set to be the band for the AP. * {@link #setBand(@BandType int)}. */ public @BandType int getBand() { return mBand; } /** * Returns Integer set to be the channel for the AP. * {@link #setChannel(int)}. */ public int getChannel() { return mChannel; } /** * Get security type params which depends on which security passphrase to set. * * @return One of the security types from {@link SecurityType}. */ public @SecurityType int getSecurityType() { return mSecurityType; } /** * Builds a {@link SoftApConfiguration}, which allows an app to configure various aspects of a * Soft AP. Loading @@ -142,6 +298,21 @@ public final class SoftApConfiguration implements Parcelable { private String mSsid; private MacAddress mBssid; private String mWpa2Passphrase; private boolean mHiddenSsid; private int mBand; private int mChannel; private int setSecurityType() { int securityType = SECURITY_TYPE_OPEN; if (!TextUtils.isEmpty(mWpa2Passphrase)) { // WPA2-PSK network. securityType = SECURITY_TYPE_WPA2_PSK; } return securityType; } private void clearAllPassphrase() { mWpa2Passphrase = null; } /** * Constructs a Builder with default values (see {@link Builder}). Loading @@ -150,6 +321,9 @@ public final class SoftApConfiguration implements Parcelable { mSsid = null; mBssid = null; mWpa2Passphrase = null; mHiddenSsid = false; mBand = BAND_2GHZ; mChannel = 0; } /** Loading @@ -161,6 +335,9 @@ public final class SoftApConfiguration implements Parcelable { mSsid = other.mSsid; mBssid = other.mBssid; mWpa2Passphrase = other.mWpa2Passphrase; mHiddenSsid = other.mHiddenSsid; mBand = other.mBand; mChannel = other.mChannel; } /** Loading @@ -170,11 +347,16 @@ public final class SoftApConfiguration implements Parcelable { */ @NonNull public SoftApConfiguration build() { return new SoftApConfiguration(mSsid, mBssid, mWpa2Passphrase); return new SoftApConfiguration(mSsid, mBssid, mWpa2Passphrase, mHiddenSsid, mBand, mChannel, setSecurityType()); } /** * Specifies an SSID for the AP. * <p> * Null SSID only support when configure a local-only hotspot. * <p> * <li>If not set, defaults to null.</li> * * @param ssid SSID of valid Unicode characters, or null to have the SSID automatically * chosen by the framework. Loading @@ -193,7 +375,10 @@ public final class SoftApConfiguration implements Parcelable { /** * Specifies a BSSID for the AP. * * <p> * Only supported when configuring a local-only hotspot. * <p> * <li>If not set, defaults to null.</li> * @param bssid BSSID, or null to have the BSSID chosen by the framework. The caller is * responsible for avoiding collisions. * @return Builder for chaining. Loading @@ -211,8 +396,9 @@ public final class SoftApConfiguration implements Parcelable { } /** * Specifies that this AP should use WPA2-PSK with the given passphrase. When set to null * and no other encryption method is configured, an open network is created. * Specifies that this AP should use WPA2-PSK with the given ASCII WPA2 passphrase. * When set to null, an open network is created. * <p> * * @param passphrase The passphrase to use, or null to unset a previously-set WPA2-PSK * configuration. Loading @@ -222,10 +408,72 @@ public final class SoftApConfiguration implements Parcelable { @NonNull public Builder setWpa2Passphrase(@Nullable String passphrase) { if (passphrase != null) { final CharsetEncoder asciiEncoder = StandardCharsets.US_ASCII.newEncoder(); if (!asciiEncoder.canEncode(passphrase)) { throw new IllegalArgumentException("passphrase not ASCII encodable"); } Preconditions.checkStringNotEmpty(passphrase); } clearAllPassphrase(); mWpa2Passphrase = passphrase; return this; } /** * Specifies whether the AP is hidden (doesn't broadcast its SSID) or * not (broadcasts its SSID). * <p> * <li>If not set, defaults to false (i.e not a hidden network).</li> * * @param hiddenSsid true for a hidden SSID, false otherwise. * @return Builder for chaining. */ @NonNull public Builder setHiddenSsid(boolean hiddenSsid) { mHiddenSsid = hiddenSsid; return this; } /** * Specifies the band for the AP. * <p> * <li>If not set, defaults to BAND_2GHZ {@link @BandType}.</li> * * @param band One of the band types from {@link @BandType}. * @return Builder for chaining. */ @NonNull public Builder setBand(@BandType int band) { switch (band) { case BAND_2GHZ: break; case BAND_5GHZ: break; case BAND_ANY: break; default: throw new IllegalArgumentException("Invalid band type"); } mBand = band; return this; } /** * Specifies the channel for the AP. * * The channel which AP resides on. Valid channels are country dependent. * Use the special channel value 0 to have the framework auto-select a valid channel * from the band configured with {@link #setBand(@BandType int)}. * * <p> * <li>If not set, defaults to 0.</li> * @param channel operating channel of the AP. * @return Builder for chaining. */ @NonNull public Builder setChannel(int channel) { mChannel = channel; return this; } } }
wifi/java/android/net/wifi/WifiManager.java +98 −3 File changed.Preview size limit exceeded, changes collapsed. Show changes
wifi/java/com/android/server/wifi/BaseWifiService.java +26 −0 Original line number Diff line number Diff line Loading @@ -284,6 +284,11 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public boolean startTetheredHotspot(SoftApConfiguration softApConfig) { throw new UnsupportedOperationException(); } @Override public boolean stopSoftAp() { throw new UnsupportedOperationException(); Loading Loading @@ -320,11 +325,22 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public SoftApConfiguration getSoftApConfiguration() { throw new UnsupportedOperationException(); } @Override public boolean setWifiApConfiguration(WifiConfiguration wifiConfig, String packageName) { throw new UnsupportedOperationException(); } @Override public boolean setSoftApConfiguration(SoftApConfiguration softApConfig, String packageName) { throw new UnsupportedOperationException(); } @Override public void notifyUserOfApBandConversion(String packageName) { throw new UnsupportedOperationException(); } Loading Loading @@ -384,6 +400,16 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } @Override public byte[] retrieveSoftApBackupData() { throw new UnsupportedOperationException(); } @Override public void restoreSoftApBackupData(byte[] data) { throw new UnsupportedOperationException(); } @Override public void restoreSupplicantBackupData(byte[] supplicantData, byte[] ipConfigData) { throw new UnsupportedOperationException(); Loading