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

Commit c3b87926 authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiManager: Remove setCountryCode API

Wifi stack will instead call existing public Telephony API/broadcast
to get the country code.

Bug: 140744935
Test: Manual tests
Test: atest android.net.wifi
Change-Id: I83be57123630c510e121f49ceadb30644e26c29c
parent 641a6834
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ interface IWifiManager

    int getWifiEnabledState();

    void setCountryCode(String country);

    String getCountryCode();

    boolean isDualBandSupported();
+0 −19
Original line number Diff line number Diff line
@@ -2489,25 +2489,6 @@ public class WifiManager {
        return false;
    }

    /**
     * Set the country code.
     * @param countryCode country code in ISO 3166 format.
     *
     * @hide
     */
    public void setCountryCode(@NonNull String country) {
        try {
            IWifiManager iWifiManager = getIWifiManager();
            if (iWifiManager == null) {
                if (TextUtils.isEmpty(country)) return;
                throw new RemoteException("Wifi service is not running");
            }
            iWifiManager.setCountryCode(country);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    * get the country code.
    * @return the country code in ISO 3166 format.
+1 −1
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ public class BaseWifiService extends IWifiManager.Stub {
        throw new UnsupportedOperationException();
    }

    @Override
    /** @removed */
    public void setCountryCode(String country) {
        throw new UnsupportedOperationException();
    }
+0 −19
Original line number Diff line number Diff line
@@ -972,25 +972,6 @@ public class WifiManagerTest {
        verify(mWifiService).stopWatchLocalOnlyHotspot();
    }

    /**
     * Verify that calls WifiServiceImpl to set country code when no exception happens.
     */
    @Test
    public void testSetWifiCountryCode() throws Exception {
        mWifiManager.setCountryCode(TEST_COUNTRY_CODE);
        verify(mWifiService).setCountryCode(TEST_COUNTRY_CODE);
    }

    /**
     * Verify that WifiManager.setCountryCode() rethrows exceptions if caller does not
     * have necessary permissions.
     */
    @Test(expected = SecurityException.class)
    public void testSetWifiCountryCodeFailedOnSecurityException() throws Exception {
        doThrow(new SecurityException()).when(mWifiService).setCountryCode(anyString());
        mWifiManager.setCountryCode(TEST_COUNTRY_CODE);
    }

    /**
     * Test that calls to get the current WPS config token return null and do not have any
     * interactions with WifiServiceImpl.