Merge changes I8fe85295,I74ada04d

* changes:
  [WPA3] Restore @hide to WifiConfiguration#SuiteBCipher
  [Passpoint] Create an API to get a unique identifier
This commit is contained in:
Hai Shalom
2020-01-31 18:31:40 +00:00
committed by Android (Google) Code Review
4 changed files with 70 additions and 7 deletions

View File

@@ -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);

View File

@@ -373,6 +373,7 @@ public class WifiConfiguration implements Parcelable {
* ECDHE_ECDSA
* ECDHE_RSA
* </pre>
* @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;

View File

@@ -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();
}
}

View File

@@ -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);
}
}