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

Commit efc940ff authored by Hai Shalom's avatar Hai Shalom
Browse files

[Passpoint] Remove throws IllegalStateException form getUniqueId API

Following up on feedback from API council:
Remove throws IllegalStateException form PasspointConfiguration#getUniqueId
API. No need to explicitly declare runtime exceptions.

Bug: 149758065
Test: PasspointConfigurationTest
Change-Id: I9022a7c87ef9839c6b60fdfd8394915779fa708b
parent 481cfeaf
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -31736,7 +31736,7 @@ package android.net.wifi.hotspot2 {
    method public android.net.wifi.hotspot2.pps.Credential getCredential();
    method public android.net.wifi.hotspot2.pps.Credential getCredential();
    method public android.net.wifi.hotspot2.pps.HomeSp getHomeSp();
    method public android.net.wifi.hotspot2.pps.HomeSp getHomeSp();
    method public long getSubscriptionExpirationTimeMillis();
    method public long getSubscriptionExpirationTimeMillis();
    method @NonNull public String getUniqueId() throws java.lang.IllegalStateException;
    method @NonNull public String getUniqueId();
    method public boolean isOsuProvisioned();
    method public boolean isOsuProvisioned();
    method public void setCredential(android.net.wifi.hotspot2.pps.Credential);
    method public void setCredential(android.net.wifi.hotspot2.pps.Credential);
    method public void setHomeSp(android.net.wifi.hotspot2.pps.HomeSp);
    method public void setHomeSp(android.net.wifi.hotspot2.pps.HomeSp);
+6 −3
Original line number Original line Diff line number Diff line
@@ -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
     * @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())) {
        if (mCredential == null || mHomeSp == null || TextUtils.isEmpty(mHomeSp.getFqdn())) {
            throw new IllegalStateException("Credential or HomeSP are not initialized");
            throw new IllegalStateException("Credential or HomeSP are not initialized");
        }
        }
+4 −16
Original line number Original line Diff line number Diff line
@@ -426,17 +426,11 @@ public class PasspointConfigurationTest {
     *
     *
     * @throws Exception
     * @throws Exception
     */
     */
    @Test
    @Test (expected = IllegalStateException.class)
    public void validateUniqueIdExceptionWithEmptyHomeSp() throws Exception {
    public void validateUniqueIdExceptionWithEmptyHomeSp() throws Exception {
        PasspointConfiguration config = PasspointTestUtils.createConfig();
        PasspointConfiguration config = PasspointTestUtils.createConfig();
        config.setHomeSp(null);
        config.setHomeSp(null);
        boolean exceptionCaught = false;
        try {
        String uniqueId = config.getUniqueId();
        String uniqueId = config.getUniqueId();
        } catch (IllegalStateException e) {
            exceptionCaught = true;
        }
        assertTrue(exceptionCaught);
    }
    }


    /**
    /**
@@ -445,16 +439,10 @@ public class PasspointConfigurationTest {
     *
     *
     * @throws Exception
     * @throws Exception
     */
     */
    @Test
    @Test (expected = IllegalStateException.class)
    public void validateUniqueIdExceptionWithEmptyCredential() throws Exception {
    public void validateUniqueIdExceptionWithEmptyCredential() throws Exception {
        PasspointConfiguration config = PasspointTestUtils.createConfig();
        PasspointConfiguration config = PasspointTestUtils.createConfig();
        config.setCredential(null);
        config.setCredential(null);
        boolean exceptionCaught = false;
        try {
        String uniqueId = config.getUniqueId();
        String uniqueId = config.getUniqueId();
        } catch (IllegalStateException e) {
            exceptionCaught = true;
        }
        assertTrue(exceptionCaught);
    }
    }
}
}