Wifi Setting: Use SoftApConfiguration for Tether Setting
Bug: 145578449 Test: Manual Test: make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest Change-Id: I02b4dcbb7b6e29b67ecc7356200f3fc3a1007562
This commit is contained in:
@@ -18,7 +18,7 @@ package com.android.settings.wifi.tether;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.SoftApConfiguration;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -46,17 +46,17 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
|
||||
@Override
|
||||
public void updateDisplay() {
|
||||
final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
|
||||
final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
|
||||
if (config == null) {
|
||||
mBandIndex = 0;
|
||||
Log.d(TAG, "Updating band index to 0 because no config");
|
||||
} else if (is5GhzBandSupported()) {
|
||||
mBandIndex = validateSelection(config.apBand);
|
||||
mBandIndex = validateSelection(config.getBand());
|
||||
Log.d(TAG, "Updating band index to " + mBandIndex);
|
||||
} else {
|
||||
config.apBand = 0;
|
||||
mWifiManager.setWifiApConfiguration(config);
|
||||
mBandIndex = config.apBand;
|
||||
mWifiManager.setSoftApConfiguration(
|
||||
new SoftApConfiguration.Builder(config).setBand(0).build());
|
||||
mBandIndex = config.getBand();
|
||||
Log.d(TAG, "5Ghz not supported, updating band index to " + mBandIndex);
|
||||
}
|
||||
ListPreference preference =
|
||||
@@ -68,13 +68,13 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
preference.setEnabled(false);
|
||||
preference.setSummary(R.string.wifi_ap_choose_2G);
|
||||
} else {
|
||||
preference.setValue(Integer.toString(config.apBand));
|
||||
preference.setValue(Integer.toString(config.getBand()));
|
||||
preference.setSummary(getConfigSummary());
|
||||
}
|
||||
}
|
||||
|
||||
String getConfigSummary() {
|
||||
if (mBandIndex == WifiConfiguration.AP_BAND_ANY) {
|
||||
if (mBandIndex == SoftApConfiguration.BAND_ANY) {
|
||||
return mContext.getString(R.string.wifi_ap_prefer_5G);
|
||||
}
|
||||
return mBandSummaries[mBandIndex];
|
||||
@@ -102,12 +102,12 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
// 1: no dual mode means we can't have AP_BAND_ANY - default to 5GHZ
|
||||
// 2: no 5 GHZ support means we can't have AP_BAND_5GHZ - default to 2GHZ
|
||||
// 3: With Dual mode support we can't have AP_BAND_5GHZ - default to ANY
|
||||
if (!isDualMode && WifiConfiguration.AP_BAND_ANY == band) {
|
||||
return WifiConfiguration.AP_BAND_5GHZ;
|
||||
} else if (!is5GhzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) {
|
||||
return WifiConfiguration.AP_BAND_2GHZ;
|
||||
} else if (isDualMode && WifiConfiguration.AP_BAND_5GHZ == band) {
|
||||
return WifiConfiguration.AP_BAND_ANY;
|
||||
if (!isDualMode && SoftApConfiguration.BAND_ANY == band) {
|
||||
return SoftApConfiguration.BAND_5GHZ;
|
||||
} else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
|
||||
return SoftApConfiguration.BAND_2GHZ;
|
||||
} else if (isDualMode && SoftApConfiguration.BAND_5GHZ == band) {
|
||||
return SoftApConfiguration.BAND_ANY;
|
||||
}
|
||||
|
||||
return band;
|
||||
|
Reference in New Issue
Block a user