Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 128e25ce authored by Vinit Deshpande's avatar Vinit Deshpande
Browse files

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

merged from partner/m-wireless-wifi-dev
d51b9525 Do not provide 5GHz option for softap if there is no country code available
parents 2797429b d51b9525
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
@@ -62,6 +63,8 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
    private RadioButton mChannel5G;

    WifiConfiguration mWifiConfig;
    WifiManager mWifiManager;

    private static final String TAG = "WifiApDialog";

    public WifiApDialog(Context context, DialogInterface.OnClickListener listener,
@@ -72,6 +75,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
        if (wifiConfig != null) {
            mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig);
        }
        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    }

    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);
        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(DialogInterface.BUTTON_NEGATIVE,
        context.getString(R.string.wifi_cancel), mListener);