From c3b87926fbbfd2164991725553ae8d676e94de0d Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 13 Sep 2019 10:20:13 -0700 Subject: [PATCH] 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 --- wifi/java/android/net/wifi/IWifiManager.aidl | 2 -- wifi/java/android/net/wifi/WifiManager.java | 19 ------------------- .../android/server/wifi/BaseWifiService.java | 2 +- .../src/android/net/wifi/WifiManagerTest.java | 19 ------------------- 4 files changed, 1 insertion(+), 41 deletions(-) diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index c755c0f00469..a97a5a5ec593 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -108,8 +108,6 @@ interface IWifiManager int getWifiEnabledState(); - void setCountryCode(String country); - String getCountryCode(); boolean isDualBandSupported(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 61cad4827344..00895e846e82 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -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. diff --git a/wifi/java/com/android/server/wifi/BaseWifiService.java b/wifi/java/com/android/server/wifi/BaseWifiService.java index 032a13ec826d..2e82f4e8c23b 100644 --- a/wifi/java/com/android/server/wifi/BaseWifiService.java +++ b/wifi/java/com/android/server/wifi/BaseWifiService.java @@ -205,7 +205,7 @@ public class BaseWifiService extends IWifiManager.Stub { throw new UnsupportedOperationException(); } - @Override + /** @removed */ public void setCountryCode(String country) { throw new UnsupportedOperationException(); } diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java index 8beee5708f1d..7e7f00281529 100644 --- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java @@ -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.