Loading wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java +21 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,27 @@ public final class PasspointConfiguration implements Parcelable { public HomeSP homeSp = null; public Credential credential = null; /** * Constructor for creating PasspointConfiguration with default values. */ public PasspointConfiguration() {} /** * Copy constructor. * * @param source The source to copy from */ public PasspointConfiguration(PasspointConfiguration source) { if (source != null) { if (source.homeSp != null) { homeSp = new HomeSP(source.homeSp); } if (source.credential != null) { credential = new Credential(source.credential); } } } @Override public int describeContents() { return 0; Loading wifi/java/android/net/wifi/hotspot2/pps/Credential.java +87 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,25 @@ public final class Credential implements Parcelable { */ public String nonEapInnerMethod = null; /** * Constructor for creating UserCredential with default values. */ public UserCredential() {} /** * Copy constructor. * * @param source The source to copy from */ public UserCredential(UserCredential source) { if (source != null) { username = source.username; password = source.password; eapType = source.eapType; nonEapInnerMethod = source.nonEapInnerMethod; } } @Override public int describeContents() { return 0; Loading Loading @@ -221,6 +240,26 @@ public final class Credential implements Parcelable { */ public byte[] certSha256FingerPrint = null; /** * Constructor for creating CertificateCredential with default values. */ public CertificateCredential() {} /** * Copy constructor. * * @param source The source to copy from */ public CertificateCredential(CertificateCredential source) { if (source != null) { certType = source.certType; if (source.certSha256FingerPrint != null) { certSha256FingerPrint = Arrays.copyOf(source.certSha256FingerPrint, source.certSha256FingerPrint.length); } } } @Override public int describeContents() { return 0; Loading Loading @@ -307,6 +346,23 @@ public final class Credential implements Parcelable { */ public int eapType = Integer.MIN_VALUE; /** * Constructor for creating SimCredential with default values. */ public SimCredential() {} /** * Copy constructor * * @param source The source to copy from */ public SimCredential(SimCredential source) { if (source != null) { imsi = source.imsi; eapType = source.eapType; } } @Override public int describeContents() { return 0; Loading Loading @@ -422,6 +478,37 @@ public final class Credential implements Parcelable { */ public PrivateKey clientPrivateKey = null; /** * Constructor for creating Credential with default values. */ public Credential() {} /** * Copy constructor. * * @param source The source to copy from */ public Credential(Credential source) { if (source != null) { realm = source.realm; if (source.userCredential != null) { userCredential = new UserCredential(source.userCredential); } if (source.certCredential != null) { certCredential = new CertificateCredential(source.certCredential); } if (source.simCredential != null) { simCredential = new SimCredential(source.simCredential); } if (source.clientCertificateChain != null) { clientCertificateChain = Arrays.copyOf(source.clientCertificateChain, source.clientCertificateChain.length); } caCertificate = source.caCertificate; clientPrivateKey = source.clientPrivateKey; } } @Override public int describeContents() { return 0; Loading wifi/java/android/net/wifi/hotspot2/pps/HomeSP.java +21 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,27 @@ public final class HomeSP implements Parcelable { */ public long[] roamingConsortiumOIs = null; /** * Constructor for creating HomeSP with default values. */ public HomeSP() {} /** * Copy constructor. * * @param source The source to copy from */ public HomeSP(HomeSP source) { if (source != null) { fqdn = source.fqdn; friendlyName = source.friendlyName; if (source.roamingConsortiumOIs != null) { roamingConsortiumOIs = Arrays.copyOf(source.roamingConsortiumOIs, source.roamingConsortiumOIs.length); } } } @Override public int describeContents() { return 0; Loading wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java +44 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ import org.junit.Test; @SmallTest public class PasspointConfigurationTest { /** * Utility function for creating a {@link android.net.wifi.hotspot2.pps.HomeSP}. * * @return {@link android.net.wifi.hotspot2.pps.HomeSP} */ private static HomeSP createHomeSp() { HomeSP homeSp = new HomeSP(); homeSp.fqdn = "fqdn"; Loading @@ -41,6 +46,11 @@ public class PasspointConfigurationTest { return homeSp; } /** * Utility function for creating a {@link android.net.wifi.hotspot2.pps.Credential}. * * @return {@link android.net.wifi.hotspot2.pps.Credential} */ private static Credential createCredential() { Credential cred = new Credential(); cred.realm = "realm"; Loading @@ -55,6 +65,12 @@ public class PasspointConfigurationTest { return cred; } /** * Verify parcel write and read consistency for the given configuration. * * @param writeConfig The configuration to verify * @throws Exception */ private static void verifyParcel(PasspointConfiguration writeConfig) throws Exception { Parcel parcel = Parcel.obtain(); writeConfig.writeToParcel(parcel, 0); Loading @@ -77,6 +93,7 @@ public class PasspointConfigurationTest { /** * Verify parcel read/write for a configuration that contained both HomeSP and Credential. * * @throws Exception */ @Test Loading Loading @@ -158,4 +175,30 @@ public class PasspointConfigurationTest { config.credential = createCredential(); assertTrue(config.validate()); } /** * Verify that copy constructor works when pass in a null source. * * @throws Exception */ @Test public void validateCopyConstructorWithNullSource() throws Exception { PasspointConfiguration copyConfig = new PasspointConfiguration(null); PasspointConfiguration defaultConfig = new PasspointConfiguration(); assertTrue(copyConfig.equals(defaultConfig)); } /** * Verify that copy constructor works when pass in a valid source. * * @throws Exception */ @Test public void validateCopyConstructorWithValidSource() throws Exception { PasspointConfiguration sourceConfig = new PasspointConfiguration(); sourceConfig.homeSp = createHomeSp(); sourceConfig.credential = createCredential(); PasspointConfiguration copyConfig = new PasspointConfiguration(sourceConfig); assertTrue(copyConfig.equals(sourceConfig)); } } wifi/tests/src/android/net/wifi/hotspot2/pps/CredentialTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -470,4 +470,52 @@ public class CredentialTest { cred.simCredential.eapType = EAPConstants.EAP_SIM; assertFalse(cred.validate()); } /** * Verify that copy constructor works when pass in a null source. * * @throws Exception */ @Test public void validateCopyConstructorWithNullSource() throws Exception { Credential copyCred = new Credential(null); Credential defaultCred = new Credential(); assertTrue(copyCred.equals(defaultCred)); } /** * Verify that copy constructor works when pass in a source with user credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithUserCred() throws Exception { Credential sourceCred = createCredentialWithUserCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } /** * Verify that copy constructor works when pass in a source with certificate credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithCertCred() throws Exception { Credential sourceCred = createCredentialWithCertificateCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } /** * Verify that copy constructor works when pass in a source with SIM credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithSimCred() throws Exception { Credential sourceCred = createCredentialWithSimCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } } No newline at end of file Loading
wifi/java/android/net/wifi/hotspot2/PasspointConfiguration.java +21 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,27 @@ public final class PasspointConfiguration implements Parcelable { public HomeSP homeSp = null; public Credential credential = null; /** * Constructor for creating PasspointConfiguration with default values. */ public PasspointConfiguration() {} /** * Copy constructor. * * @param source The source to copy from */ public PasspointConfiguration(PasspointConfiguration source) { if (source != null) { if (source.homeSp != null) { homeSp = new HomeSP(source.homeSp); } if (source.credential != null) { credential = new Credential(source.credential); } } } @Override public int describeContents() { return 0; Loading
wifi/java/android/net/wifi/hotspot2/pps/Credential.java +87 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,25 @@ public final class Credential implements Parcelable { */ public String nonEapInnerMethod = null; /** * Constructor for creating UserCredential with default values. */ public UserCredential() {} /** * Copy constructor. * * @param source The source to copy from */ public UserCredential(UserCredential source) { if (source != null) { username = source.username; password = source.password; eapType = source.eapType; nonEapInnerMethod = source.nonEapInnerMethod; } } @Override public int describeContents() { return 0; Loading Loading @@ -221,6 +240,26 @@ public final class Credential implements Parcelable { */ public byte[] certSha256FingerPrint = null; /** * Constructor for creating CertificateCredential with default values. */ public CertificateCredential() {} /** * Copy constructor. * * @param source The source to copy from */ public CertificateCredential(CertificateCredential source) { if (source != null) { certType = source.certType; if (source.certSha256FingerPrint != null) { certSha256FingerPrint = Arrays.copyOf(source.certSha256FingerPrint, source.certSha256FingerPrint.length); } } } @Override public int describeContents() { return 0; Loading Loading @@ -307,6 +346,23 @@ public final class Credential implements Parcelable { */ public int eapType = Integer.MIN_VALUE; /** * Constructor for creating SimCredential with default values. */ public SimCredential() {} /** * Copy constructor * * @param source The source to copy from */ public SimCredential(SimCredential source) { if (source != null) { imsi = source.imsi; eapType = source.eapType; } } @Override public int describeContents() { return 0; Loading Loading @@ -422,6 +478,37 @@ public final class Credential implements Parcelable { */ public PrivateKey clientPrivateKey = null; /** * Constructor for creating Credential with default values. */ public Credential() {} /** * Copy constructor. * * @param source The source to copy from */ public Credential(Credential source) { if (source != null) { realm = source.realm; if (source.userCredential != null) { userCredential = new UserCredential(source.userCredential); } if (source.certCredential != null) { certCredential = new CertificateCredential(source.certCredential); } if (source.simCredential != null) { simCredential = new SimCredential(source.simCredential); } if (source.clientCertificateChain != null) { clientCertificateChain = Arrays.copyOf(source.clientCertificateChain, source.clientCertificateChain.length); } caCertificate = source.caCertificate; clientPrivateKey = source.clientPrivateKey; } } @Override public int describeContents() { return 0; Loading
wifi/java/android/net/wifi/hotspot2/pps/HomeSP.java +21 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,27 @@ public final class HomeSP implements Parcelable { */ public long[] roamingConsortiumOIs = null; /** * Constructor for creating HomeSP with default values. */ public HomeSP() {} /** * Copy constructor. * * @param source The source to copy from */ public HomeSP(HomeSP source) { if (source != null) { fqdn = source.fqdn; friendlyName = source.friendlyName; if (source.roamingConsortiumOIs != null) { roamingConsortiumOIs = Arrays.copyOf(source.roamingConsortiumOIs, source.roamingConsortiumOIs.length); } } } @Override public int describeContents() { return 0; Loading
wifi/tests/src/android/net/wifi/hotspot2/PasspointConfigurationTest.java +44 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ import org.junit.Test; @SmallTest public class PasspointConfigurationTest { /** * Utility function for creating a {@link android.net.wifi.hotspot2.pps.HomeSP}. * * @return {@link android.net.wifi.hotspot2.pps.HomeSP} */ private static HomeSP createHomeSp() { HomeSP homeSp = new HomeSP(); homeSp.fqdn = "fqdn"; Loading @@ -41,6 +46,11 @@ public class PasspointConfigurationTest { return homeSp; } /** * Utility function for creating a {@link android.net.wifi.hotspot2.pps.Credential}. * * @return {@link android.net.wifi.hotspot2.pps.Credential} */ private static Credential createCredential() { Credential cred = new Credential(); cred.realm = "realm"; Loading @@ -55,6 +65,12 @@ public class PasspointConfigurationTest { return cred; } /** * Verify parcel write and read consistency for the given configuration. * * @param writeConfig The configuration to verify * @throws Exception */ private static void verifyParcel(PasspointConfiguration writeConfig) throws Exception { Parcel parcel = Parcel.obtain(); writeConfig.writeToParcel(parcel, 0); Loading @@ -77,6 +93,7 @@ public class PasspointConfigurationTest { /** * Verify parcel read/write for a configuration that contained both HomeSP and Credential. * * @throws Exception */ @Test Loading Loading @@ -158,4 +175,30 @@ public class PasspointConfigurationTest { config.credential = createCredential(); assertTrue(config.validate()); } /** * Verify that copy constructor works when pass in a null source. * * @throws Exception */ @Test public void validateCopyConstructorWithNullSource() throws Exception { PasspointConfiguration copyConfig = new PasspointConfiguration(null); PasspointConfiguration defaultConfig = new PasspointConfiguration(); assertTrue(copyConfig.equals(defaultConfig)); } /** * Verify that copy constructor works when pass in a valid source. * * @throws Exception */ @Test public void validateCopyConstructorWithValidSource() throws Exception { PasspointConfiguration sourceConfig = new PasspointConfiguration(); sourceConfig.homeSp = createHomeSp(); sourceConfig.credential = createCredential(); PasspointConfiguration copyConfig = new PasspointConfiguration(sourceConfig); assertTrue(copyConfig.equals(sourceConfig)); } }
wifi/tests/src/android/net/wifi/hotspot2/pps/CredentialTest.java +48 −0 Original line number Diff line number Diff line Loading @@ -470,4 +470,52 @@ public class CredentialTest { cred.simCredential.eapType = EAPConstants.EAP_SIM; assertFalse(cred.validate()); } /** * Verify that copy constructor works when pass in a null source. * * @throws Exception */ @Test public void validateCopyConstructorWithNullSource() throws Exception { Credential copyCred = new Credential(null); Credential defaultCred = new Credential(); assertTrue(copyCred.equals(defaultCred)); } /** * Verify that copy constructor works when pass in a source with user credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithUserCred() throws Exception { Credential sourceCred = createCredentialWithUserCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } /** * Verify that copy constructor works when pass in a source with certificate credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithCertCred() throws Exception { Credential sourceCred = createCredentialWithCertificateCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } /** * Verify that copy constructor works when pass in a source with SIM credential. * * @throws Exception */ @Test public void validateCopyConstructorWithSourceWithSimCred() throws Exception { Credential sourceCred = createCredentialWithSimCredential(); Credential copyCred = new Credential(sourceCred); assertTrue(copyCred.equals(sourceCred)); } } No newline at end of file