Merge "[Passpoint] New APIs for HomeSP OtherHomePartners"

This commit is contained in:
TreeHugger Robot
2020-10-15 19:54:22 +00:00
committed by Android (Google) Code Review
4 changed files with 70 additions and 5 deletions

View File

@@ -32110,13 +32110,13 @@ package android.net.wifi.hotspot2.pps {
method public String getFriendlyName();
method @Nullable public long[] getMatchAllOis();
method @Nullable public long[] getMatchAnyOis();
method @Nullable public String[] getOtherHomePartners();
method @NonNull public java.util.Collection<java.lang.String> getOtherHomePartnersList();
method public long[] getRoamingConsortiumOis();
method public void setFqdn(String);
method public void setFriendlyName(String);
method public void setMatchAllOis(@Nullable long[]);
method public void setMatchAnyOis(@Nullable long[]);
method public void setOtherHomePartners(@Nullable String[]);
method public void setOtherHomePartnersList(@NonNull java.util.Collection<java.lang.String>);
method public void setRoamingConsortiumOis(long[]);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.hotspot2.pps.HomeSp> CREATOR;

View File

@@ -803,13 +803,13 @@ package android.net.wifi.hotspot2.pps {
method public String getFriendlyName();
method @Nullable public long[] getMatchAllOis();
method @Nullable public long[] getMatchAnyOis();
method @Nullable public String[] getOtherHomePartners();
method @NonNull public java.util.Collection<java.lang.String> getOtherHomePartnersList();
method public long[] getRoamingConsortiumOis();
method public void setFqdn(String);
method public void setFriendlyName(String);
method public void setMatchAllOis(@Nullable long[]);
method public void setMatchAnyOis(@Nullable long[]);
method public void setOtherHomePartners(@Nullable String[]);
method public void setOtherHomePartnersList(@NonNull java.util.Collection<java.lang.String>);
method public void setRoamingConsortiumOis(long[]);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.hotspot2.pps.HomeSp> CREATOR;

View File

@@ -16,6 +16,7 @@
package android.net.wifi.hotspot2.pps;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -24,6 +25,7 @@ import android.util.Log;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -214,22 +216,51 @@ public final class HomeSp implements Parcelable {
*
* @param otherHomePartners Array of Strings containing the FQDNs of other Home partner
* providers
* @hide
*/
public void setOtherHomePartners(@Nullable String[] otherHomePartners) {
mOtherHomePartners = otherHomePartners;
}
/**
* Set the list of FQDN (Fully Qualified Domain Name) of other Home partner providers.
*
* @param otherHomePartners Collection of Strings containing the FQDNs of other Home partner
* providers
*/
public void setOtherHomePartnersList(@NonNull Collection<String> otherHomePartners) {
if (otherHomePartners == null) {
return;
}
mOtherHomePartners = otherHomePartners.toArray(new String[otherHomePartners.size()]);
}
/**
* Get the list of FQDN (Fully Qualified Domain Name) of other Home partner providers set in
* the profile.
*
* @return Array of Strings containing the FQDNs of other Home partner providers set in the
* profile
* @hide
*/
public @Nullable String[] getOtherHomePartners() {
return mOtherHomePartners;
}
/**
* Get the list of FQDN (Fully Qualified Domain Name) of other Home partner providers set in
* the profile.
*
* @return Collection of Strings containing the FQDNs of other Home partner providers set in the
* profile
*/
public @NonNull Collection<String> getOtherHomePartnersList() {
if (mOtherHomePartners == null) {
return Collections.emptyList();
}
return Arrays.asList(mOtherHomePartners);
}
/**
* List of Organization Identifiers (OIs) identifying a roaming consortium of
* which this provider is a member.

View File

@@ -16,6 +16,7 @@
package android.net.wifi.hotspot2.pps;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -26,7 +27,9 @@ import androidx.test.filters.SmallTest;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -35,6 +38,7 @@ import java.util.Map;
*/
@SmallTest
public class HomeSpTest {
private static final String[] OTHER_HOME_PARTNER_LIST = new String[]{"partner1", "partner2"};
/**
* Helper function for creating a map of home network IDs for testing.
@@ -62,7 +66,7 @@ public class HomeSpTest {
homeSp.setHomeNetworkIds(homeNetworkIds);
homeSp.setMatchAllOis(new long[] {0x11L, 0x22L});
homeSp.setMatchAnyOis(new long[] {0x33L, 0x44L});
homeSp.setOtherHomePartners(new String[] {"partner1", "partner2"});
homeSp.setOtherHomePartners(OTHER_HOME_PARTNER_LIST);
homeSp.setRoamingConsortiumOis(new long[] {0x55, 0x66});
return homeSp;
}
@@ -218,4 +222,34 @@ public class HomeSpTest {
HomeSp copySp = new HomeSp(sourceSp);
assertTrue(copySp.equals(sourceSp));
}
/**
* Verify that the getOtherHomePartnersList gets the list of partners as expected.
*
* @throws Exception
*/
@Test
public void validateGetOtherHomePartnersList() throws Exception {
HomeSp homeSp = createHomeSpWithoutHomeNetworkIds();
Collection<String> otherHomePartnersList = homeSp.getOtherHomePartnersList();
assertEquals(2, otherHomePartnersList.size());
assertTrue(Arrays.equals(OTHER_HOME_PARTNER_LIST, otherHomePartnersList.toArray()));
}
/**
* Verify that the setOtherHomePartnersList sets the list of partners as expected.
*
* @throws Exception
*/
@Test
public void validateSetOtherHomePartnersList() throws Exception {
HomeSp homeSp = createHomeSpWithoutHomeNetworkIds();
final Collection<String> homePartners =
new ArrayList<>(Arrays.asList(OTHER_HOME_PARTNER_LIST));
homeSp.setOtherHomePartnersList(homePartners);
assertTrue(Arrays.equals(homeSp.getOtherHomePartners(), OTHER_HOME_PARTNER_LIST));
}
}