summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPavel Maltsev <pavelm@google.com>2018-09-13 14:18:28 -0700
committerPavel Maltsev <pavelm@google.com>2018-10-15 17:03:07 -0700
commit14a767ba9fde7daa8d44a6789682341c87dace85 (patch)
treed75c2b53059fecfbbb03e03d1f8bb91075448c8b /service
parent1223e9aa52466139b4de0637c4f9dd3d00b8b20b (diff)
Allow to configure local-only hotspot on 5ghz
Allow OEMs to configure whether local-only hotspot could be started 5Ghz band. This is important for wireless Android Auto projection we require to run hotspot on 5Ghz band. Bug: 115666270 Test: verified that local-only hotspot starts at 5Ghz and Android projection works Test: runtest -x frameworks/opt/net/wifi/tests/wifitests Change-Id: Ib92a8f9369b9014a42594acea9b2124432ec540f
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiApConfigStore.java6
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java36
2 files changed, 31 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java
index 6981618b8..e6eebb9e7 100644
--- a/service/java/com/android/server/wifi/WifiApConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiApConfigStore.java
@@ -350,13 +350,13 @@ public class WifiApConfigStore {
* Generate a temporary WPA2 based configuration for use by the local only hotspot.
* This config is not persisted and will not be stored by the WifiApConfigStore.
*/
- public static WifiConfiguration generateLocalOnlyHotspotConfig(Context context) {
+ public static WifiConfiguration generateLocalOnlyHotspotConfig(Context context, int apBand) {
WifiConfiguration config = new WifiConfiguration();
- // For local only hotspot we only use 2.4Ghz band.
- config.apBand = WifiConfiguration.AP_BAND_2GHZ;
+
config.SSID = context.getResources().getString(
R.string.wifi_localhotspot_configure_ssid_default) + "_"
+ getRandomIntForDefaultSsid();
+ config.apBand = apBand;
config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK);
config.networkId = WifiConfiguration.LOCAL_ONLY_NETWORK_ID;
String randomUUID = UUID.randomUUID().toString();
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index fc7e66481..6206d9b15 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -28,6 +28,7 @@ import static android.net.wifi.WifiManager.SAP_START_FAILURE_NO_CHANNEL;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
+import static android.net.wifi.WifiManager.WIFI_FEATURE_INFRA_5G;
import static com.android.server.wifi.LocalOnlyHotspotRequestInfo.HOTSPOT_NO_ERROR;
import static com.android.server.wifi.WifiController.CMD_AIRPLANE_TOGGLED;
@@ -1382,8 +1383,14 @@ public class WifiServiceImpl extends IWifiManager.Stub {
}
} else if (mLocalOnlyHotspotRequests.isEmpty()) {
// this is the first request, then set up our config and start LOHS
- mLocalOnlyHotspotConfig =
- WifiApConfigStore.generateLocalOnlyHotspotConfig(mContext);
+ boolean is5Ghz = hasAutomotiveFeature(mContext)
+ && mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wifi_local_only_hotspot_5ghz)
+ && is5GhzSupported();
+
+ mLocalOnlyHotspotConfig = WifiApConfigStore.generateLocalOnlyHotspotConfig(mContext,
+ is5Ghz ? WifiConfiguration.AP_BAND_5GHZ : WifiConfiguration.AP_BAND_2GHZ);
+
startSoftApInternal(mLocalOnlyHotspotConfig, WifiManager.IFACE_IP_MODE_LOCAL_ONLY);
}
@@ -1612,12 +1619,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
if (mVerboseLoggingEnabled) {
mLog.info("getSupportedFeatures uid=%").c(Binder.getCallingUid()).flush();
}
- if (mClientModeImplChannel != null) {
- return mClientModeImpl.syncGetSupportedFeatures(mClientModeImplChannel);
- } else {
- Slog.e(TAG, "mClientModeImplChannel is not initialized");
- return 0;
- }
+ return getSupportedFeaturesInternal();
}
@Override
@@ -2870,4 +2872,22 @@ public class WifiServiceImpl extends IWifiManager.Stub {
mTrafficPoller.removeCallback(callbackIdentifier);
});
}
+
+ private boolean is5GhzSupported() {
+ return (getSupportedFeaturesInternal() & WIFI_FEATURE_INFRA_5G) == WIFI_FEATURE_INFRA_5G;
+ }
+
+ private int getSupportedFeaturesInternal() {
+ final AsyncChannel channel = mClientModeImplChannel;
+ if (channel != null) {
+ return mClientModeImpl.syncGetSupportedFeatures(channel);
+ } else {
+ Slog.e(TAG, "mClientModeImplChannel is not initialized");
+ return 0;
+ }
+ }
+
+ private static boolean hasAutomotiveFeature(Context context) {
+ return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
+ }
}