summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ningyuan Wang <nywang@google.com> 2017-09-20 14:00:17 -0700
committer Ningyuan Wang <nywang@google.com> 2017-11-14 13:01:37 -0800
commit557875dcc0b6dd3aa4fe46b6cff8eb83b2c8eea8 (patch)
tree618b55852a70db777a94aa77dbb23ebc73ca515f
parentd3fe8f09c8c83bf191df548cd09728993a34ca03 (diff)
Remove persist option for WifiManager.setCountryCode()
Bug: 29353903 Test: compile, unit tests Change-Id: I67e495035c3c47d884f16c190eeb4f708cbb5b2e
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl2
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java6
-rw-r--r--wifi/tests/src/android/net/wifi/WifiManagerTest.java20
3 files changed, 24 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 26a2bdde40fc..c2f11d96b9f2 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -102,7 +102,7 @@ interface IWifiManager
int getWifiEnabledState();
- void setCountryCode(String country, boolean persist);
+ void setCountryCode(String country);
String getCountryCode();
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 68e6203867b6..66fabf33ddbb 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -16,6 +16,7 @@
package android.net.wifi;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
@@ -1748,13 +1749,12 @@ public class WifiManager {
/**
* Set the country code.
* @param countryCode country code in ISO 3166 format.
- * @param persist {@code true} if this needs to be remembered
*
* @hide
*/
- public void setCountryCode(String country, boolean persist) {
+ public void setCountryCode(@NonNull String country) {
try {
- mService.setCountryCode(country, persist);
+ mService.setCountryCode(country);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index 1364224c443d..3cad59053308 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -59,6 +59,7 @@ public class WifiManagerTest {
private static final int ERROR_NOT_SET = -1;
private static final int ERROR_TEST_REASON = 5;
private static final String TEST_PACKAGE_NAME = "TestPackage";
+ private static final String TEST_COUNTRY_CODE = "US";
@Mock Context mContext;
@Mock IWifiManager mWifiService;
@@ -777,4 +778,23 @@ public class WifiManagerTest {
mWifiManager.unregisterLocalOnlyHotspotObserver();
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);
+ }
}