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

Commit e14a0909 authored by lesl's avatar lesl
Browse files

wifi: Add SoftAp Max Client control support

1. SoftAp Max Client parameter in SoftApConfiguration
2. Add new field in CarrierConfigManager to get carrier max client
setting.
3. Add new Callback: onCapabilityChanged to notify Settings to know
current supported maximum client number from carrier req and chip limit.

Bug: 142752869
Test: atest frameworks/base/wifi/tests/
Change-Id: I03366e22055233b9f77e0c1808e54a473569c9c7
parent 4a0eafa3
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -5608,11 +5608,19 @@ package android.net.wifi {
    field public static final int KEY_MGMT_WAPI_PSK = 13; // 0xd
  }
  public final class SoftApCapability implements android.os.Parcelable {
    method public int describeContents();
    method public int getMaxSupportedClients();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.SoftApCapability> CREATOR;
  }
  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 getMaxNumberOfClients();
    method public int getSecurityType();
    method @Nullable public String getSsid();
    method @Nullable public String getWpa2Passphrase();
@@ -5635,6 +5643,7 @@ package android.net.wifi {
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setBssid(@Nullable android.net.MacAddress);
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setChannel(int, int);
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setHiddenSsid(boolean);
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setMaxNumberOfClients(int);
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setSsid(@Nullable String);
    method @NonNull public android.net.wifi.SoftApConfiguration.Builder setWpa2Passphrase(@Nullable String);
  }
@@ -5868,6 +5877,7 @@ package android.net.wifi {
    field public static final int PASSPOINT_ROAMING_NETWORK = 1; // 0x1
    field public static final int SAP_START_FAILURE_GENERAL = 0; // 0x0
    field public static final int SAP_START_FAILURE_NO_CHANNEL = 1; // 0x1
    field public static final int SAP_START_FAILURE_UNSUPPORTED_CONFIGURATION = 2; // 0x2
    field public static final String WIFI_AP_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_AP_STATE_CHANGED";
    field public static final int WIFI_AP_STATE_DISABLED = 11; // 0xb
    field public static final int WIFI_AP_STATE_DISABLING = 10; // 0xa
@@ -5906,6 +5916,7 @@ package android.net.wifi {
  }
  public static interface WifiManager.SoftApCallback {
    method public default void onCapabilityChanged(@NonNull android.net.wifi.SoftApCapability);
    method public default void onConnectedClientsChanged(@NonNull java.util.List<android.net.wifi.WifiClient>);
    method public default void onInfoChanged(@NonNull android.net.wifi.SoftApInfo);
    method public default void onStateChanged(int, int);
@@ -8908,6 +8919,11 @@ package android.telephony {
    field public static final String KEY_SUPPORT_CDMA_1X_VOICE_CALLS_BOOL = "support_cdma_1x_voice_calls_bool";
  }
  public static final class CarrierConfigManager.Wifi {
    field public static final String KEY_HOTSPOT_MAX_CLIENT_COUNT = "wifi.hotspot_maximum_client_count";
    field public static final String KEY_PREFIX = "wifi.";
  }
  public final class CarrierRestrictionRules implements android.os.Parcelable {
    method @NonNull public java.util.List<java.lang.Boolean> areCarrierIdentifiersAllowed(@NonNull java.util.List<android.service.carrier.CarrierIdentifier>);
    method public int describeContents();
+26 −0
Original line number Diff line number Diff line
@@ -3932,6 +3932,32 @@ public class CarrierConfigManager {
        sDefaults.putLong(KEY_DATA_SWITCH_VALIDATION_TIMEOUT_LONG, 2000);
        sDefaults.putInt(KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT,
                CellSignalStrengthLte.USE_RSRP | CellSignalStrengthLte.USE_RSSNR);
        // Default wifi configurations.
        sDefaults.putAll(Wifi.getDefaults());
    }

    /**
     * Wi-Fi configs used in WiFi Module.
     *
     * @hide
     */
    @SystemApi
    public static final class Wifi {
        /** Prefix of all Wifi.KEY_* constants. */
        public static final String KEY_PREFIX = "wifi.";
        /**
        * It contains the maximum client count definition that the carrier owns.
        */
        public static final String KEY_HOTSPOT_MAX_CLIENT_COUNT =
                KEY_PREFIX + "hotspot_maximum_client_count";

        private static PersistableBundle getDefaults() {
            PersistableBundle defaults = new PersistableBundle();
            defaults.putInt(KEY_HOTSPOT_MAX_CLIENT_COUNT, 0);
            return defaults;
        }

        private Wifi() {}
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

package android.net.wifi;
import android.net.wifi.SoftApCapability;
import android.net.wifi.SoftApInfo;

import android.net.wifi.WifiClient;
@@ -51,4 +52,12 @@ oneway interface ISoftApCallback
     * @param softApInfo is the softap information. {@link SoftApInfo}
     */
    void onInfoChanged(in SoftApInfo softApInfo);


    /**
     * Service to manager callback providing information of softap.
     *
     * @param capability is the softap capability. {@link SoftApCapability}
     */
    void onCapabilityChanged(in SoftApCapability capability);
}
+19 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.wifi;

parcelable SoftApCapability;
+114 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.wifi;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * A class representing capability of the SoftAp.
 * {@see WifiManager}
 *
 * @hide
 */
@SystemApi
public final class SoftApCapability implements Parcelable {

    private int mMaximumSupportedClientNumber;

    /**
     * Get the maximum supported client numbers which AP resides on.
     */
    public int getMaxSupportedClients() {
        return mMaximumSupportedClientNumber;
    }

    /**
     * Set the maximum supported client numbers which AP resides on.
     * @hide
     */
    public void setMaxSupportedClients(int maxClient) {
        mMaximumSupportedClientNumber = maxClient;
    }

    /**
     * @hide
     */
    public SoftApCapability(@Nullable SoftApCapability source) {
        if (source != null) {
            mMaximumSupportedClientNumber = source.mMaximumSupportedClientNumber;
        }
    }

    /**
     * @hide
     */
    public SoftApCapability() {
    }

    @Override
    /** Implement the Parcelable interface. */
    public int describeContents() {
        return 0;
    }

    @Override
    /** Implement the Parcelable interface */
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mMaximumSupportedClientNumber);
    }

    @NonNull
    /** Implement the Parcelable interface */
    public static final Creator<SoftApCapability> CREATOR = new Creator<SoftApCapability>() {
        public SoftApCapability createFromParcel(Parcel in) {
            SoftApCapability capability = new SoftApCapability();
            capability.mMaximumSupportedClientNumber = in.readInt();
            return capability;
        }

        public SoftApCapability[] newArray(int size) {
            return new SoftApCapability[size];
        }
    };

    @NonNull
    @Override
    public String toString() {
        StringBuilder sbuf = new StringBuilder();
        sbuf.append("MaximumSupportedClientNumber=").append(mMaximumSupportedClientNumber);
        return sbuf.toString();
    }

    @Override
    public boolean equals(@NonNull Object o) {
        if (this == o) return true;
        if (!(o instanceof SoftApCapability)) return false;
        SoftApCapability capability = (SoftApCapability) o;
        return mMaximumSupportedClientNumber == capability.mMaximumSupportedClientNumber;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mMaximumSupportedClientNumber);
    }
}
Loading