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

merged from partner/m-wireless-wifi-dev
d51b952 Do not provide 5GHz option for softap if there is no country code available
This commit is contained in:
Vinit Deshpande
2015-03-06 13:56:02 -08:00

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);