Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c64b68c3 authored by Les Lee's avatar Les Lee Committed by Android (Google) Code Review
Browse files

Merge changes from topic "lohs_sap_config"

* changes:
  wifi: Fix java doc error, use @code instead of @link
  softap: Update LOHS API usage
  SoftAp: Public SoftApConfiguration to replace WifiConfiguration
parents 83512d58 f272d502
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -30508,6 +30508,21 @@ package android.net.wifi {
    field public CharSequence venueName;
  }
  public final class SoftApConfiguration implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.net.MacAddress getBssid();
    method @Nullable public String getPassphrase();
    method public int getSecurityType();
    method @Nullable public String getSsid();
    method public boolean isHiddenSsid();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    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
    field public static final int SECURITY_TYPE_WPA3_SAE = 3; // 0x3
    field public static final int SECURITY_TYPE_WPA3_SAE_TRANSITION = 2; // 0x2
  }
  public enum SupplicantState implements android.os.Parcelable {
    method public int describeContents();
    method public static boolean isValidState(android.net.wifi.SupplicantState);
@@ -30842,7 +30857,8 @@ package android.net.wifi {
  public class WifiManager.LocalOnlyHotspotReservation implements java.lang.AutoCloseable {
    method public void close();
    method public android.net.wifi.WifiConfiguration getWifiConfiguration();
    method @NonNull public android.net.wifi.SoftApConfiguration getSoftApConfiguration();
    method @Deprecated @Nullable public android.net.wifi.WifiConfiguration getWifiConfiguration();
  }
  public class WifiManager.MulticastLock {
+0 −12
Original line number Diff line number Diff line
@@ -6113,29 +6113,17 @@ package android.net.wifi {
  }
  public final class SoftApConfiguration implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<android.net.MacAddress> getAllowedClientList();
    method public int getBand();
    method @NonNull public java.util.List<android.net.MacAddress> getBlockedClientList();
    method @Nullable public android.net.MacAddress getBssid();
    method public int getChannel();
    method public int getMaxNumberOfClients();
    method @Nullable public String getPassphrase();
    method public int getSecurityType();
    method public int getShutdownTimeoutMillis();
    method @Nullable public String getSsid();
    method public boolean isClientControlByUserEnabled();
    method public boolean isHiddenSsid();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int BAND_2GHZ = 1; // 0x1
    field public static final int BAND_5GHZ = 2; // 0x2
    field public static final int BAND_6GHZ = 4; // 0x4
    field public static final int BAND_ANY = 7; // 0x7
    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
    field public static final int SECURITY_TYPE_WPA3_SAE = 3; // 0x3
    field public static final int SECURITY_TYPE_WPA3_SAE_TRANSITION = 2; // 0x2
  }
  public static final class SoftApConfiguration.Builder {
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.net.wifi;

import android.net.wifi.WifiConfiguration;
import android.net.wifi.SoftApConfiguration;

/**
 * Communicates LOHS status back to the application process.
@@ -24,7 +24,7 @@ import android.net.wifi.WifiConfiguration;
 * @hide
 */
oneway interface ILocalOnlyHotspotCallback {
    void onHotspotStarted(in WifiConfiguration config);
    void onHotspotStarted(in SoftApConfiguration config);
    void onHotspotStopped();
    void onHotspotFailed(int reason);
}
+41 −17
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;

/**
 * Configuration for a soft access point (a.k.a. Soft AP, SAP, Hotspot).
@@ -45,22 +44,21 @@ import java.util.concurrent.Executor;
 * framework how it should configure a hotspot.
 *
 * System apps can use this to configure a tethered hotspot using
 * {@link WifiManager#startTetheredHotspot(SoftApConfiguration)} and
 * {@link WifiManager#setSoftApConfiguration(SoftApConfiguration)}
 * {@code WifiManager#startTetheredHotspot(SoftApConfiguration)} and
 * {@code WifiManager#setSoftApConfiguration(SoftApConfiguration)}
 * or local-only hotspot using
 * {@link WifiManager#startLocalOnlyHotspot(SoftApConfiguration, Executor,
 * {@code WifiManager#startLocalOnlyHotspot(SoftApConfiguration, Executor,
 * WifiManager.LocalOnlyHotspotCallback)}.
 *
 * Instances of this class are immutable; use {@link SoftApConfiguration.Builder} and its methods to
 * create a new instance.
 *
 * @hide
 */
@SystemApi
public final class SoftApConfiguration implements Parcelable {

    @VisibleForTesting
    static final int PSK_MIN_LEN = 8;

    @VisibleForTesting
    static final int PSK_MAX_LEN = 63;

@@ -207,22 +205,24 @@ public final class SoftApConfiguration implements Parcelable {
    private final int mShutdownTimeoutMillis;

    /**
     * Security types we support.
     * THe definition of security type OPEN.
     */
    /** @hide */
    @SystemApi
    public static final int SECURITY_TYPE_OPEN = 0;

    /** @hide */
    @SystemApi

    /**
     * The definition of security type WPA2-PSK.
     */
    public static final int SECURITY_TYPE_WPA2_PSK = 1;

    /** @hide */
    @SystemApi
    /**
     * The definition of security type WPA3-SAE Transition mode.
     */
    public static final int SECURITY_TYPE_WPA3_SAE_TRANSITION = 2;

    /** @hide */
    @SystemApi
    /**
     * The definition of security type WPA3-SAE.
     */
    public static final int SECURITY_TYPE_WPA3_SAE = 3;

    /** @hide */
@@ -346,7 +346,7 @@ public final class SoftApConfiguration implements Parcelable {

    /**
     * Return String set to be the SSID for the AP.
     * {@link #setSsid(String)}.
     * {@link Builder#setSsid(String)}.
     */
    @Nullable
    public String getSsid() {
@@ -364,7 +364,7 @@ public final class SoftApConfiguration implements Parcelable {

    /**
     * Returns String set to be passphrase for current AP.
     * {@link #setPassphrase(String, @SecurityType int)}.
     * {@link Builder#setPassphrase(String, int)}.
     */
    @Nullable
    public String getPassphrase() {
@@ -383,7 +383,10 @@ public final class SoftApConfiguration implements Parcelable {
    /**
     * Returns {@link BandType} set to be the band for the AP.
     * {@link Builder#setBand(@BandType int)}.
     *
     * @hide
     */
    @SystemApi
    public @BandType int getBand() {
        return mBand;
    }
@@ -391,7 +394,10 @@ public final class SoftApConfiguration implements Parcelable {
    /**
     * Returns Integer set to be the channel for the AP.
     * {@link Builder#setChannel(int)}.
     *
     * @hide
     */
    @SystemApi
    public int getChannel() {
        return mChannel;
    }
@@ -408,7 +414,10 @@ public final class SoftApConfiguration implements Parcelable {
    /**
     * Returns the maximum number of clients that can associate to the AP.
     * {@link Builder#setMaxNumberOfClients(int)}.
     *
     * @hide
     */
    @SystemApi
    public int getMaxNumberOfClients() {
        return mMaxNumberOfClients;
    }
@@ -417,7 +426,10 @@ public final class SoftApConfiguration implements Parcelable {
     * Returns the shutdown timeout in milliseconds.
     * The Soft AP will shutdown when there are no devices associated to it for
     * the timeout duration. See {@link Builder#setShutdownTimeoutMillis(int)}.
     *
     * @hide
     */
    @SystemApi
    public int getShutdownTimeoutMillis() {
        return mShutdownTimeoutMillis;
    }
@@ -426,7 +438,10 @@ public final class SoftApConfiguration implements Parcelable {
     * Returns a flag indicating whether clients need to be pre-approved by the user.
     * (true: authorization required) or not (false: not required).
     * {@link Builder#enableClientControlByUser(Boolean)}.
     *
     * @hide
     */
    @SystemApi
    public boolean isClientControlByUserEnabled() {
        return mClientControlByUser;
    }
@@ -435,8 +450,11 @@ public final class SoftApConfiguration implements Parcelable {
     * Returns List of clients which aren't allowed to associate to the AP.
     *
     * Clients are configured using {@link Builder#setClientList(List, List)}
     *
     * @hide
     */
    @NonNull
    @SystemApi
    public List<MacAddress> getBlockedClientList() {
        return mBlockedClientList;
    }
@@ -444,8 +462,11 @@ public final class SoftApConfiguration implements Parcelable {
    /**
     * List of clients which are allowed to associate to the AP.
     * Clients are configured using {@link Builder#setClientList(List, List)}
     *
     * @hide
     */
    @NonNull
    @SystemApi
    public List<MacAddress> getAllowedClientList() {
        return mAllowedClientList;
    }
@@ -456,7 +477,10 @@ public final class SoftApConfiguration implements Parcelable {
     *
     * All fields are optional. By default, SSID and BSSID are automatically chosen by the
     * framework, and an open network is created.
     *
     * @hide
     */
    @SystemApi
    public static final class Builder {
        private String mSsid;
        private MacAddress mBssid;
+60 −9
Original line number Diff line number Diff line
@@ -2971,7 +2971,7 @@ public class WifiManager {
     * Each application can make a single active call to this method. The {@link
     * LocalOnlyHotspotCallback#onStarted(LocalOnlyHotspotReservation)} callback supplies the
     * requestor with a {@link LocalOnlyHotspotReservation} that contains a
     * {@link WifiConfiguration} with the SSID, security type and credentials needed to connect
     * {@link SoftApConfiguration} with the SSID, security type and credentials needed to connect
     * to the hotspot.  Communicating this information is up to the application.
     * <p>
     * If the LocalOnlyHotspot cannot be created, the {@link LocalOnlyHotspotCallback#onFailed(int)}
@@ -3136,7 +3136,7 @@ public class WifiManager {
     * Allow callers (Settings UI) to watch LocalOnlyHotspot state changes.  Callers will
     * receive a {@link LocalOnlyHotspotSubscription} object as a parameter of the
     * {@link LocalOnlyHotspotObserver#onRegistered(LocalOnlyHotspotSubscription)}. The registered
     * callers will receive the {@link LocalOnlyHotspotObserver#onStarted(WifiConfiguration)} and
     * callers will receive the {@link LocalOnlyHotspotObserver#onStarted(SoftApConfiguration)} and
     * {@link LocalOnlyHotspotObserver#onStopped()} callbacks.
     * <p>
     * Applications should have the
@@ -3711,13 +3711,13 @@ public class WifiManager {
    }

    /**
     * LocalOnlyHotspotReservation that contains the {@link WifiConfiguration} for the active
     * LocalOnlyHotspotReservation that contains the {@link SoftApConfiguration} for the active
     * LocalOnlyHotspot request.
     * <p>
     * Applications requesting LocalOnlyHotspot for sharing will receive an instance of the
     * LocalOnlyHotspotReservation in the
     * {@link LocalOnlyHotspotCallback#onStarted(LocalOnlyHotspotReservation)} call.  This
     * reservation contains the relevant {@link WifiConfiguration}.
     * reservation contains the relevant {@link SoftApConfiguration}.
     * When an application is done with the LocalOnlyHotspot, they should call {@link
     * LocalOnlyHotspotReservation#close()}.  Once this happens, the application will not receive
     * any further callbacks. If the LocalOnlyHotspot is stopped due to a
@@ -3727,20 +3727,71 @@ public class WifiManager {
    public class LocalOnlyHotspotReservation implements AutoCloseable {

        private final CloseGuard mCloseGuard = new CloseGuard();
        private final WifiConfiguration mConfig;
        private final SoftApConfiguration mConfig;
        private boolean mClosed = false;

        /** @hide */
        @VisibleForTesting
        public LocalOnlyHotspotReservation(WifiConfiguration config) {
        public LocalOnlyHotspotReservation(SoftApConfiguration config) {
            mConfig = config;
            mCloseGuard.open("close");
        }

        /**
         * Returns the {@link WifiConfiguration} of the current Local Only Hotspot (LOHS).
         * May be null if hotspot enabled and security type is not
         * {@code WifiConfiguration.KeyMgmt.None} or {@code WifiConfiguration.KeyMgmt.WPA2_PSK}.
         *
         * @deprecated Use {@code WifiManager#getSoftApConfiguration()} to get the
         * LOHS configuration.
         */
        @Deprecated
        @Nullable
        public WifiConfiguration getWifiConfiguration() {
            return convertToWifiConfiguration(mConfig);
        }

        /**
         * Returns the {@link SoftApConfiguration} of the current Local Only Hotspot (LOHS).
         */
        @NonNull
        public SoftApConfiguration getSoftApConfiguration() {
            return mConfig;
        }

        /**
         * Convert to WifiConfiguration from SoftApConfuration.
         *
         * Copy to the filed which is public and used by SoftAp.
         */
        private WifiConfiguration convertToWifiConfiguration(SoftApConfiguration softApConfig) {
            if (softApConfig == null) return null;

            WifiConfiguration wifiConfig = new WifiConfiguration();
            wifiConfig.networkId = WifiConfiguration.LOCAL_ONLY_NETWORK_ID;
            wifiConfig.SSID = softApConfig.getSsid();
            if (softApConfig.getBssid() != null) {
                wifiConfig.BSSID = softApConfig.getBssid().toString();
            }
            wifiConfig.preSharedKey = softApConfig.getPassphrase();
            wifiConfig.hiddenSSID = softApConfig.isHiddenSsid();
            int authType = softApConfig.getSecurityType();
            switch (authType) {
                case SoftApConfiguration.SECURITY_TYPE_OPEN:
                    authType = WifiConfiguration.KeyMgmt.NONE;
                    wifiConfig.allowedKeyManagement.set(authType);
                    break;
                case SoftApConfiguration.SECURITY_TYPE_WPA2_PSK:
                    authType = WifiConfiguration.KeyMgmt.WPA2_PSK;
                    wifiConfig.allowedKeyManagement.set(authType);
                    break;
                default:
                    wifiConfig = null;
                    break;
            }
            return wifiConfig;
        }

        @Override
        public void close() {
            try {
@@ -3835,7 +3886,7 @@ public class WifiManager {
        }

        @Override
        public void onHotspotStarted(WifiConfiguration config) {
        public void onHotspotStarted(SoftApConfiguration config) {
            WifiManager manager = mWifiManager.get();
            if (manager == null) return;

@@ -3927,7 +3978,7 @@ public class WifiManager {
        /**
         * LocalOnlyHotspot started with the supplied config.
         */
        public void onStarted(WifiConfiguration config) {};
        public void onStarted(SoftApConfiguration config) {};

        /**
         * LocalOnlyHotspot stopped.
@@ -3967,7 +4018,7 @@ public class WifiManager {
        }

        @Override
        public void onHotspotStarted(WifiConfiguration config) {
        public void onHotspotStarted(SoftApConfiguration config) {
            WifiManager manager = mWifiManager.get();
            if (manager == null) return;

Loading