diff options
author | Hai Shalom <haishalom@google.com> | 2020-02-19 20:17:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-19 20:17:42 +0000 |
commit | da4585593fa357905133553d1b42c924b63124b4 (patch) | |
tree | 291dfc1ac746df86782f03ae4a7344026c116ae3 | |
parent | f2dc70b4b77826f3f890c38ecb8d72da26d3630e (diff) | |
parent | efc940ff3fe1559d00f44586cd6274f2789e9ad0 (diff) |
Merge "[Passpoint] Remove throws IllegalStateException form getUniqueId API"
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java | 9 | ||||
-rw-r--r-- | wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java | 20 |
3 files changed, 11 insertions, 20 deletions
diff --git a/api/current.txt b/api/current.txt index 20933e4ad762..993db4a6a4ad 100644 --- a/api/current.txt +++ b/api/current.txt @@ -31745,7 +31745,7 @@ package android.net.wifi.hotspot2 { method public android.net.wifi.hotspot2.pps.Credential getCredential(); method public android.net.wifi.hotspot2.pps.HomeSp getHomeSp(); method public long getSubscriptionExpirationTimeMillis(); - method @NonNull public String getUniqueId() throws java.lang.IllegalStateException; + method @NonNull public String getUniqueId(); method public boolean isOsuProvisioned(); method public void setCredential(android.net.wifi.hotspot2.pps.Credential); method public void setHomeSp(android.net.wifi.hotspot2.pps.HomeSp); diff --git a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java index 7d9bdba81a76..4507cc2707d4 100644 --- a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java +++ b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java @@ -900,12 +900,15 @@ public final class PasspointConfiguration implements Parcelable { } /** - * Get a unique identifier for a PasspointConfiguration object. + * Get a unique identifier for a PasspointConfiguration object. The identifier depends on the + * configuration that identify the service provider under the HomeSp subtree, and on the + * credential configuration under the Credential subtree. + * The method throws an {@link IllegalStateException} if the configuration under HomeSp subtree + * or the configuration under Credential subtree are not initialized. * * @return A unique identifier - * @throws IllegalStateException if Credential or HomeSP nodes are not initialized */ - public @NonNull String getUniqueId() throws IllegalStateException { + public @NonNull String getUniqueId() { if (mCredential == null || mHomeSp == null || TextUtils.isEmpty(mHomeSp.getFqdn())) { throw new IllegalStateException("Credential or HomeSP are not initialized"); } diff --git a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java index 8f6beb19091b..638efb9f14ee 100644 --- a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java +++ b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java @@ -426,17 +426,11 @@ public class PasspointConfigurationTest { * * @throws Exception */ - @Test + @Test (expected = IllegalStateException.class) public void validateUniqueIdExceptionWithEmptyHomeSp() throws Exception { PasspointConfiguration config = PasspointTestUtils.createConfig(); config.setHomeSp(null); - boolean exceptionCaught = false; - try { - String uniqueId = config.getUniqueId(); - } catch (IllegalStateException e) { - exceptionCaught = true; - } - assertTrue(exceptionCaught); + String uniqueId = config.getUniqueId(); } /** @@ -445,16 +439,10 @@ public class PasspointConfigurationTest { * * @throws Exception */ - @Test + @Test (expected = IllegalStateException.class) public void validateUniqueIdExceptionWithEmptyCredential() throws Exception { PasspointConfiguration config = PasspointTestUtils.createConfig(); config.setCredential(null); - boolean exceptionCaught = false; - try { - String uniqueId = config.getUniqueId(); - } catch (IllegalStateException e) { - exceptionCaught = true; - } - assertTrue(exceptionCaught); + String uniqueId = config.getUniqueId(); } } |