summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorlesl <lesl@google.com>2019-12-24 00:03:53 +0800
committerlesl <lesl@google.com>2019-12-26 15:59:16 +0800
commit55d0d5e904c52afaabc90fdb0a50e825c7c984ed (patch)
tree7de1b0020bc06b85b85145f453461eb2052bbb64 /service
parent9859a4b6d2455f2aabd6a15f9b8f9cd2ba6d9337 (diff)
wifi: Read hotspot feature support from overlay config
Add features support into SoftApCapability. Bug: 142752869 Test: atest frameworks/opt/net/wifi/tests/wifitests/ Change-Id: I9a296652a39887ad16f4095aac802421330e64fb
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java60
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java16
-rw-r--r--service/java/com/android/server/wifi/util/ApConfigUtil.java31
-rw-r--r--service/res/values/config.xml3
-rw-r--r--service/res/values/overlayable.xml1
5 files changed, 68 insertions, 43 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 656373036..fc015ee8f 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -369,8 +369,9 @@ public class SoftApManager implements ActiveModeManager {
// Make a copy of configuration for updating AP band and channel.
SoftApConfiguration.Builder localConfigBuilder = new SoftApConfiguration.Builder(config);
- boolean acsEnabled = mContext.getResources()
- .getBoolean(R.bool.config_wifi_softap_acs_supported);
+ boolean acsEnabled = mCurrentSoftApCapability.isFeatureSupported(
+ SoftApCapability.SOFTAP_FEATURE_ACS_OFFLOAD);
+
result = ApConfigUtil.updateApChannelConfig(
mWifiNative, mCountryCode,
mWifiApConfigStore.getAllowed2GChannel(), localConfigBuilder, config, acsEnabled);
@@ -384,18 +385,18 @@ public class SoftApManager implements ActiveModeManager {
Log.d(TAG, "SoftAP is a hidden network");
}
+ if (config.getMaxNumberOfClients() != 0
+ && !mCurrentSoftApCapability.isFeatureSupported(
+ SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT)) {
+ Log.d(TAG, "Error, Max Client control need HAL support");
+ return ERROR_UNSUPPORTED_CONFIGURATION;
+ }
+
if (!mWifiNative.startSoftAp(mApInterfaceName,
localConfigBuilder.build(), mSoftApListener)) {
Log.e(TAG, "Soft AP start failed");
return ERROR_GENERIC;
}
- // TODO: b/140172237, it needs to check feature support or not from SoftApCapability
- /*
- if (config.getMaxNumberOfClients() != 0) {
- Log.d(TAG, "Error, Max Client control need HAL support");
- return ERROR_UNSUPPORTED_CONFIGURATION;
- }
- */
mWifiDiagnostics.startLogging(mApInterfaceName);
mStartTimestamp = FORMATTER.format(new Date(System.currentTimeMillis()));
@@ -420,12 +421,14 @@ public class SoftApManager implements ActiveModeManager {
maxConfig = Math.min(maxConfig, config.getMaxNumberOfClients());
}
if (mConnectedClients.size() == maxConfig) {
- // TODO: b/140172237, it needs to check feature support or not from SoftApCapability
- Log.i(TAG, "No more room for new client, current HAL support: ");
- Log.d(TAG, "Force disconnect for client: " + newClient);
- mWifiNative.forceClientDisconnect(
- mApInterfaceName, newClient.getMacAddress(),
- ApConfigUtil.DISCONNECT_REASON_CODE_NO_MORE_STAS);
+ Log.i(TAG, "No more room for new client:" + newClient);
+ if (mCurrentSoftApCapability.isFeatureSupported(
+ SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT)) {
+ Log.d(TAG, "Force disconnect for client: " + newClient);
+ mWifiNative.forceClientDisconnect(
+ mApInterfaceName, newClient.getMacAddress(),
+ ApConfigUtil.DISCONNECT_REASON_CODE_NO_MORE_STAS);
+ }
isAllow = false;
}
return isAllow;
@@ -609,31 +612,30 @@ public class SoftApManager implements ActiveModeManager {
* configuration.
*/
private void updateClientConnection() {
- final int maxAllowedClientsByHardwareAndCarrierg =
+ final int maxAllowedClientsByHardwareAndCarrier =
mCurrentSoftApCapability.getMaxSupportedClients();
final int userApConfigMaxClientCount =
mApConfig.getSoftApConfiguration().getMaxNumberOfClients();
- int finalMaxClientCount = maxAllowedClientsByHardwareAndCarrierg;
+ int finalMaxClientCount = maxAllowedClientsByHardwareAndCarrier;
if (userApConfigMaxClientCount > 0) {
finalMaxClientCount = Math.min(userApConfigMaxClientCount,
- maxAllowedClientsByHardwareAndCarrierg);
+ maxAllowedClientsByHardwareAndCarrier);
}
if (mConnectedClients.size() > finalMaxClientCount) {
Log.d(TAG, "Capability Changed, update connected client");
Iterator<WifiClient> iterator = mConnectedClients.iterator();
int remove_count = mConnectedClients.size() - finalMaxClientCount;
- // TODO: b/140172237, it needs to check feature support or not from
- // SoftApCapability
- while (iterator.hasNext()) {
- if (remove_count == 0) {
- break;
+ if (mCurrentSoftApCapability.isFeatureSupported(
+ SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT)) {
+ while (iterator.hasNext()) {
+ if (remove_count == 0) break;
+ WifiClient client = iterator.next();
+ Log.d(TAG, "Force disconnect for client: " + client);
+ mWifiNative.forceClientDisconnect(
+ mApInterfaceName, client.getMacAddress(),
+ ApConfigUtil.DISCONNECT_REASON_CODE_NO_MORE_STAS);
+ remove_count--;
}
- WifiClient client = iterator.next();
- Log.d(TAG, "Force disconnect for client: " + client);
- mWifiNative.forceClientDisconnect(
- mApInterfaceName, client.getMacAddress(),
- ApConfigUtil.DISCONNECT_REASON_CODE_NO_MORE_STAS);
- remove_count--;
}
}
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index ba6173fa0..8b3a3213f 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -970,13 +970,7 @@ public class WifiServiceImpl extends BaseWifiService {
public SoftApCapability getSoftApCapability() {
synchronized (mLock) {
if (mTetheredSoftApCapability == null) {
- mTetheredSoftApCapability = new SoftApCapability();
- int hardwareSupportedMaxClient = mContext.getResources().getInteger(
- R.integer.config_wifi_hardware_soft_ap_max_client_count);
- if (hardwareSupportedMaxClient <= 0) {
- Log.e(TAG, "Error, Hardware maximum_client should be positive number");
- }
- mTetheredSoftApCapability.setMaxSupportedClients(hardwareSupportedMaxClient);
+ mTetheredSoftApCapability = ApConfigUtil.updateCapabilityFromResource(mContext);
}
return mTetheredSoftApCapability;
}
@@ -1162,13 +1156,7 @@ public class WifiServiceImpl extends BaseWifiService {
public SoftApCapability getSoftApCapability() {
if (mLohsSoftApCapability == null) {
- mLohsSoftApCapability = new SoftApCapability();
- int hardwareSupportedMaxClient = mContext.getResources().getInteger(
- R.integer.config_wifi_hardware_soft_ap_max_client_count);
- if (hardwareSupportedMaxClient <= 0) {
- Log.e(TAG, "Error, Hardware maximum_client should be positive number");
- }
- mLohsSoftApCapability.setMaxSupportedClients(hardwareSupportedMaxClient);
+ mLohsSoftApCapability = ApConfigUtil.updateCapabilityFromResource(mContext);
}
return mLohsSoftApCapability;
}
diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java
index c1f75ff3a..f36ba0935 100644
--- a/service/java/com/android/server/wifi/util/ApConfigUtil.java
+++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java
@@ -17,7 +17,9 @@
package com.android.server.wifi.util;
import android.annotation.NonNull;
+import android.content.Context;
import android.net.MacAddress;
+import android.net.wifi.SoftApCapability;
import android.net.wifi.SoftApConfiguration;
import android.net.wifi.SoftApConfiguration.BandType;
import android.net.wifi.WifiConfiguration;
@@ -25,6 +27,7 @@ import android.net.wifi.WifiScanner;
import android.util.Log;
import com.android.server.wifi.WifiNative;
+import com.android.wifi.resources.R;
import java.util.ArrayList;
import java.util.Random;
@@ -369,4 +372,32 @@ public class ApConfigUtil {
}
return configBuilder.build();
}
+
+ /**
+ * Helper function to creating SoftApCapability instance with initial field from resource file.
+ */
+ @NonNull
+ public static SoftApCapability updateCapabilityFromResource(@NonNull Context context) {
+ int features = 0;
+ if (context.getResources().getBoolean(
+ R.bool.config_wifi_softap_acs_supported)) {
+ Log.d(TAG, "Update Softap capability, add acs feature support");
+ features |= SoftApCapability.SOFTAP_FEATURE_ACS_OFFLOAD;
+ }
+
+ if (context.getResources().getBoolean(
+ R.bool.config_wifi_sofap_client_force_disconnect_supported)) {
+ Log.d(TAG, "Update Softap capability, add client control feature support");
+ features |= SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT;
+ }
+ SoftApCapability capability = new SoftApCapability(features);
+ int hardwareSupportedMaxClient = context.getResources().getInteger(
+ R.integer.config_wifi_hardware_soft_ap_max_client_count);
+ if (hardwareSupportedMaxClient > 0) {
+ Log.d(TAG, "Update Softap capability, max client = " + hardwareSupportedMaxClient);
+ capability.setMaxSupportedClients(hardwareSupportedMaxClient);
+ }
+
+ return capability;
+ }
}
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index 97124718b..ec8da0e50 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -155,6 +155,9 @@
power limit for meeting SAR requirements -->
<bool translatable="false" name="config_wifi_framework_enable_soft_ap_sar_tx_power_limit">false</bool>
+ <!-- Wifi Hal supports force client disconnect for softap -->
+ <bool translatable="false" name="config_wifi_sofap_client_force_disconnect_supported">true</bool>
+
<!-- Wifi driver supports Automatic channel selection (ACS) for softap -->
<bool translatable="false" name="config_wifi_softap_acs_supported">false</bool>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 8466aef16..e7b82ce64 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -66,6 +66,7 @@
<item type="bool" name="config_wifi_only_link_same_credential_configurations" />
<item type="bool" name="config_wifi_framework_enable_sar_tx_power_limit" />
<item type="bool" name="config_wifi_framework_enable_soft_ap_sar_tx_power_limit" />
+ <item type="bool" name="config_wifi_sofap_client_force_disconnect_supported" />
<item type="bool" name="config_wifi_softap_acs_supported" />
<item type="string" name="config_wifi_softap_acs_supported_channel_list" />
<item type="bool" name="config_wifi_softap_ieee80211ac_supported" />