diff --git a/api/current.txt b/api/current.txt index 39b52545f1d52..562d47e792ca8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -31129,11 +31129,6 @@ package android.net.wifi { field @Deprecated public static final String[] strings; } - @Deprecated public static class WifiConfiguration.SuiteBCipher { - field @Deprecated public static final int ECDHE_ECDSA = 0; // 0x0 - field @Deprecated public static final int ECDHE_RSA = 1; // 0x1 - } - public class WifiEnterpriseConfig implements android.os.Parcelable { ctor public WifiEnterpriseConfig(); ctor public WifiEnterpriseConfig(android.net.wifi.WifiEnterpriseConfig); @@ -31616,6 +31611,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 getSubscriptionExpirationTimeInMillis(); + method @NonNull public String getUniqueId() throws java.lang.IllegalStateException; 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/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 0ef224a5f8ee7..372af42a3d14e 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -373,6 +373,7 @@ public class WifiConfiguration implements Parcelable { * ECDHE_ECDSA * ECDHE_RSA * + * @hide */ public static class SuiteBCipher { private SuiteBCipher() { } @@ -715,8 +716,8 @@ public class WifiConfiguration implements Parcelable { public BitSet allowedGroupManagementCiphers; /** * The set of SuiteB ciphers supported by this configuration. - * To be used for WPA3-Enterprise mode. - * See {@link SuiteBCipher} for descriptions of the values. + * To be used for WPA3-Enterprise mode. Set automatically by the framework based on the + * certificate type that is used in this configuration. */ @NonNull public BitSet allowedSuiteBCiphers; diff --git a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java index 3a0d080594c87..756d679b8f21c 100644 --- a/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java +++ b/wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java @@ -19,6 +19,7 @@ package android.net.wifi.hotspot2; import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE; import static android.net.wifi.WifiConfiguration.MeteredOverride; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.wifi.hotspot2.pps.Credential; @@ -895,4 +896,18 @@ public final class PasspointConfiguration implements Parcelable { public boolean isOsuProvisioned() { return getUpdateIdentifier() != Integer.MIN_VALUE; } + + /** + * Get a unique identifier for a PasspointConfiguration object. + * + * @return A unique identifier + * @throws IllegalStateException if Credential or HomeSP nodes are not initialized + */ + public @NonNull String getUniqueId() throws IllegalStateException { + if (mCredential == null || mHomeSp == null || TextUtils.isEmpty(mHomeSp.getFqdn())) { + throw new IllegalStateException("Credential or HomeSP are not initialized"); + } + + return mHomeSp.getFqdn(); + } } diff --git a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java index 654154d77b0d4..e78c5bf992f34 100644 --- a/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java +++ b/wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java @@ -18,6 +18,7 @@ package android.net.wifi.hotspot2; import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -364,4 +365,54 @@ public class PasspointConfigurationTest { assertTrue(config.validateForR2()); assertTrue(config.isOsuProvisioned()); } + + /** + * Verify that the unique identifier generated is correct. + * + * @throws Exception + */ + @Test + public void validateUniqueId() throws Exception { + PasspointConfiguration config = PasspointTestUtils.createConfig(); + String uniqueId; + uniqueId = config.getUniqueId(); + assertEquals(uniqueId, config.getHomeSp().getFqdn()); + } + + /** + * Verify that the unique identifier API generates an exception if HomeSP is not initialized. + * + * @throws Exception + */ + @Test + 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); + } + + /** + * Verify that the unique identifier API generates an exception if Credential is not + * initialized. + * + * @throws Exception + */ + @Test + 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); + } }