Refresh Wifi AP Config display when config changes

Change-Id: I6fe284355223cbcedd82f95d6415c4d6b660f39f
Fixes: 64757839
Test: robotests
Test: rerun ACTS WifiTetheringTest:test_change_wifi_hotspot_ssid_when_hotspot_enabled
This commit is contained in:
Fan Zhang
2017-09-01 11:10:37 -07:00
parent fe18f8e876
commit 5a8b70d3da
8 changed files with 102 additions and 30 deletions

View File

@@ -23,12 +23,13 @@ import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import com.android.settings.R;
public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferenceController {
private static final String TAG = "WifiTetherApBandPref";
private static final String PREF_KEY = "wifi_tether_network_ap_band";
private static final String[] BAND_VALUES =
{String.valueOf(AP_BAND_2GHZ), String.valueOf(AP_BAND_5GHZ)};
@@ -40,21 +41,23 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
OnTetherConfigUpdateListener listener) {
super(context, listener);
mBandEntries = mContext.getResources().getStringArray(R.array.wifi_ap_band_config_full);
}
@Override
public void updateDisplay() {
final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
if (config == null) {
mBandIndex = 0;
Log.d(TAG, "Updating band index to 0 because no config");
} else if (is5GhzBandSupported()) {
mBandIndex = config.apBand;
Log.d(TAG, "Updating band index to " + mBandIndex);
} else {
config.apBand = 0;
mWifiManager.setWifiApConfiguration(config);
mBandIndex = config.apBand;
Log.d(TAG, "5Ghz not supported, updating band index to " + mBandIndex);
}
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
ListPreference preference = (ListPreference) mPreference;
if (!is5GhzBandSupported()) {
preference.setEnabled(false);