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

Commit e34357d1 authored by Andrew Dodd's avatar Andrew Dodd
Browse files

wifi: Allow Settings to retrieve country code

This makes getCountryCode behave like getFrequencyBand

This allows Settings to get/set country code like
it can for frequency band.

Change-Id: Id9f00d3a678642c6c142fd1511af820d729507a7
parent 24a86e7b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -887,6 +887,15 @@ public class WifiService extends IWifiManager.Stub {
        mWifiStateMachine.setCountryCode(countryCode, persist);
    }


    /**
     * Get the operational country code
     */
    public String getCountryCode() {
        enforceAccessPermission();
        return mWifiStateMachine.getCountryCode();
    }

    /**
     * Set the operational frequency band
     * @param band One of
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ interface IWifiManager

    void setCountryCode(String country, boolean persist);

    String getCountryCode();

    void setFrequencyBand(int band, boolean persist);

    int getFrequencyBand();
+12 −0
Original line number Diff line number Diff line
@@ -809,6 +809,18 @@ public class WifiManager {
        } catch (RemoteException e) { }
    }

    /**
     * Get the operational country code.
     * @hide
     */
    public String getCountryCode() {
        try {
            return mService.getCountryCode();
        } catch (RemoteException e) {
            return null;
        }
    }

    /**
     * Set the operational frequency band.
     * @param band  One of
+13 −1
Original line number Diff line number Diff line
@@ -209,6 +209,9 @@ public class WifiStateMachine extends StateMachine {
    /* Tracks current frequency mode */
    private AtomicInteger mFrequencyBand = new AtomicInteger(WifiManager.WIFI_FREQUENCY_BAND_AUTO);

    /* Tracks current country code */
    private String mCountryCode = "GB";

    /* Tracks if we are filtering Multicast v4 packets. Default is to filter. */
    private AtomicBoolean mFilteringMulticastV4Packets = new AtomicBoolean(true);

@@ -1078,6 +1081,13 @@ public class WifiStateMachine extends StateMachine {
        sendMessage(obtainMessage(CMD_SET_COUNTRY_CODE, countryCode));
    }

    /**
     * Returns the operational country code
     */
    public String getCountryCode() {
        return mCountryCode;
    }

    /**
     * Set the operational frequency band
     * @param band
@@ -2792,7 +2802,9 @@ 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())) {
                    if (mWifiNative.setCountryCode(country.toUpperCase())) {
                        mCountryCode = country;
                    } else {
                        loge("Failed to set country code " + country);
                    }
                    break;