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

Commit 24369cda authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Gerrit Code Review
Browse files

Wi-Fi: Ping the driver for wifi-only devices

Wifi-only devices are not capable to find APs with hidden SSID unless a DRIVER COUNTRY command
will send to wifi driver. This change has:

- Send DRIVER COUNTRY command to ping the driver (to correct the seek of hiddens SSIDs)
- Save mCountryCode as uppercase because the wifi_countrycode_values array is in uppercase.
  Otherwise the preference will not be found.

Patchset 7: Rebase
            Do not set mCountryCode if country is null

Change-Id: Ie0f838aef07eaf683b713f7f0e46ff3c751523ab
parent 056a2699
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -360,6 +360,10 @@ public class WifiNative {
    }

    public boolean setCountryCode(String countryCode) {
        if (countryCode == null) {
            // Ping the driver
            return doBooleanCommand("DRIVER COUNTRY");
        }
        return doBooleanCommand("DRIVER COUNTRY " + countryCode);
    }

+14 −3
Original line number Diff line number Diff line
@@ -1346,7 +1346,15 @@ public class WifiStateMachine extends StateMachine {
        if (countryCode != null && !countryCode.isEmpty()) {
            setCountryCode(countryCode, false);
        } else {
            //use driver default
            // On wifi-only devices, some drivers don't find hidden SSIDs unless DRIVER COUNTRY
            // is called. Pinging the wifi driver without country code resolves this issue.
            ConnectivityManager cm =
                    (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            if (!cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
                setCountryCode(null, false);
            }

            // In other case, mmc tables from carrier do the trick of starting up the wifi driver
        }
    }

@@ -2804,8 +2812,11 @@ public class WifiStateMachine extends StateMachine {
                case CMD_SET_COUNTRY_CODE:
                    String country = (String) message.obj;
                    if (DBG) log("set country code " + country);
                    if (mWifiNative.setCountryCode(country.toUpperCase())) {
                        mCountryCode = country;
                    String countryCode = country != null ? country.toUpperCase() : null;
                    if (mWifiNative.setCountryCode(countryCode)) {
                        if (countryCode != null) {
                            mCountryCode = countryCode;
                        }
                    } else {
                        loge("Failed to set country code " + country);
                    }