diff options
| -rw-r--r-- | api/current.txt | 4 | ||||
| -rw-r--r-- | wifi/api/current.txt | 4 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java | 31 | ||||
| -rw-r--r-- | wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java | 36 |
4 files changed, 70 insertions, 5 deletions
diff --git a/api/current.txt b/api/current.txt index 97e5f4e5d4b0..c8419c58c4ae 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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; diff --git a/wifi/api/current.txt b/wifi/api/current.txt index 2d48a8325d6e..f7061181b72b 100644 --- a/wifi/api/current.txt +++ b/wifi/api/current.txt @@ -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; diff --git a/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java b/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java index 35a8ff6095e0..64aad613c8b2 100644 --- a/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java +++ b/wifi/java/android/net/wifi/hotspot2/pps/HomeSp.java @@ -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,23 +216,52 @@ 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. */ diff --git a/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java b/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java index 93d471ab6b81..fe889fc31ed4 100644 --- a/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java +++ b/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java @@ -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)); + } } |