Do not provide 5GHz option for softap if there is no country code available

Bug:19414134
Change-Id: I3899d9daa33eca5d2c5528c2e4da97b02d019160
This commit is contained in:
xinhe
2015-02-23 17:10:08 -08:00
parent 82ff3d5c56
commit d51b9525c9

View File

@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.AuthAlgorithm; import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiManager;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
@@ -62,6 +63,8 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
private RadioButton mChannel5G; private RadioButton mChannel5G;
WifiConfiguration mWifiConfig; WifiConfiguration mWifiConfig;
WifiManager mWifiManager;
private static final String TAG = "WifiApDialog"; private static final String TAG = "WifiApDialog";
public WifiApDialog(Context context, DialogInterface.OnClickListener listener, public WifiApDialog(Context context, DialogInterface.OnClickListener listener,
@@ -72,6 +75,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
if (wifiConfig != null) { if (wifiConfig != null) {
mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig); mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig);
} }
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
} }
public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) { public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) {
@@ -140,6 +144,17 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band); mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band);
mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band); mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band);
String countryCode = mWifiManager.getCountryCode();
if (!mWifiManager.is5GHzBandSupported() || countryCode == null) {
//If no country code, 5GHz AP is forbidden
Log.e(TAG," NO country code, forbid 5GHz");
mChannel5G.setVisibility(View.INVISIBLE);
mWifiConfig.apBand = 0;
} else {
mChannel5G.setVisibility(View.VISIBLE);
}
setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener); setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener);
setButton(DialogInterface.BUTTON_NEGATIVE, setButton(DialogInterface.BUTTON_NEGATIVE,
context.getString(R.string.wifi_cancel), mListener); context.getString(R.string.wifi_cancel), mListener);