From c01caad3c9e684a4665561309ccefc625595411e Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Wed, 14 Oct 2020 18:21:52 -0700 Subject: [Passpoint] New APIs for HomeSP OtherHomePartners Following feedback from API council, modified the OtherHomePartners get/set APIs back to be hidden, and created new APIs that use a Collection instaed of an array. Updated CTS tests. Bug: 169330230 Test: atest HomeSpTest PasspointConfigurationTest Change-Id: I454679196dabebdf0649a544b9b0c135800f5941 --- api/current.txt | 4 +-- wifi/api/current.txt | 4 +-- .../java/android/net/wifi/hotspot2/pps/HomeSp.java | 31 +++++++++++++++++++ .../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 8b62fc43c8e3..0e8febd4f4e4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -32004,13 +32004,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 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); method public void setRoamingConsortiumOis(long[]); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; diff --git a/wifi/api/current.txt b/wifi/api/current.txt index 1c297e7058dd..b54d084fcdc2 100644 --- a/wifi/api/current.txt +++ b/wifi/api/current.txt @@ -800,13 +800,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 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); method public void setRoamingConsortiumOis(long[]); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator 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,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 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 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 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 homePartners = + new ArrayList<>(Arrays.asList(OTHER_HOME_PARTNER_LIST)); + + homeSp.setOtherHomePartnersList(homePartners); + assertTrue(Arrays.equals(homeSp.getOtherHomePartners(), OTHER_HOME_PARTNER_LIST)); + } } -- cgit v1.2.3-59-g8ed1b