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

Commit f03958c2 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 63b6611f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -827,6 +827,15 @@ public class WifiService extends IWifiManager.Stub {
        mWifiStateMachine.setCountryCode(countryCode, persist);
        mWifiStateMachine.setCountryCode(countryCode, persist);
    }
    }



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

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


    void setCountryCode(String country, boolean persist);
    void setCountryCode(String country, boolean persist);


    String getCountryCode();

    void setFrequencyBand(int band, boolean persist);
    void setFrequencyBand(int band, boolean persist);


    int getFrequencyBand();
    int getFrequencyBand();
+12 −0
Original line number Original line Diff line number Diff line
@@ -792,6 +792,18 @@ public class WifiManager {
        } catch (RemoteException e) { }
        } 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.
     * Set the operational frequency band.
     * @param band  One of
     * @param band  One of
+13 −1
Original line number Original line Diff line number Diff line
@@ -214,6 +214,9 @@ public class WifiStateMachine extends StateMachine {
    /* Tracks current frequency mode */
    /* Tracks current frequency mode */
    private AtomicInteger mFrequencyBand = new AtomicInteger(WifiManager.WIFI_FREQUENCY_BAND_AUTO);
    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. */
    /* Tracks if we are filtering Multicast v4 packets. Default is to filter. */
    private AtomicBoolean mFilteringMulticastV4Packets = new AtomicBoolean(true);
    private AtomicBoolean mFilteringMulticastV4Packets = new AtomicBoolean(true);


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


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

    /**
    /**
     * Set the operational frequency band
     * Set the operational frequency band
     * @param band
     * @param band
@@ -2686,7 +2696,9 @@ public class WifiStateMachine extends StateMachine {
                case CMD_SET_COUNTRY_CODE:
                case CMD_SET_COUNTRY_CODE:
                    String country = (String) message.obj;
                    String country = (String) message.obj;
                    if (DBG) log("set country code " + country);
                    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);
                        loge("Failed to set country code " + country);
                    }
                    }
                    break;
                    break;