From b25e55d892f91decd1be0bcbf6fce592a3ea636b Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Thu, 20 Feb 2020 16:39:23 -0800 Subject: [Passpoint] Added support for Other Home Partners matching Added support for matching Other Home Partners as Home network providers. Information is in PPS-MO HomeSP/OtherHomePartners//FQDN node, and is useful when operators become co-home providers. Bug: 149946692 Test: atest PasspointProviderTest Change-Id: I89219c85f366fcbd16c3c59725813174c3a9e439 --- .../android/server/wifi/hotspot2/ANQPMatcher.java | 8 ++++-- .../server/wifi/hotspot2/PasspointProvider.java | 15 ++++++++++ .../wifi/hotspot2/PasspointProviderTest.java | 33 ++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/service/java/com/android/server/wifi/hotspot2/ANQPMatcher.java b/service/java/com/android/server/wifi/hotspot2/ANQPMatcher.java index dd39174df..a920c5ec1 100644 --- a/service/java/com/android/server/wifi/hotspot2/ANQPMatcher.java +++ b/service/java/com/android/server/wifi/hotspot2/ANQPMatcher.java @@ -40,9 +40,9 @@ public class ANQPMatcher { * * @param element The Domain Name ANQP element * @param fqdn The FQDN to compare against - * @param imsiParam The IMSI parameter of the provider + * @param imsiParam The IMSI parameter of the provider (needed only for IMSI matching) * @param simImsi The IMSI from the installed SIM cards that best matched provider's - * IMSI parameter + * IMSI parameter (needed only for IMSI matching) * @return true if a match is found */ public static boolean matchDomainName(DomainNameElement element, String fqdn, @@ -56,6 +56,10 @@ public class ANQPMatcher { return true; } + if (imsiParam == null || simImsi == null) { + continue; + } + // Try to retrieve the MCC-MNC string from the domain (for 3GPP network domain) and // match against the provider's SIM credential. if (matchMccMnc(Utils.getMccMnc(Utils.splitDomain(domain)), imsiParam, simImsi)) { diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index c8de0c499..205c71f78 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -711,6 +711,21 @@ public class PasspointProvider { return PasspointMatch.HomeProvider; } + // Other Home Partners matching. + if (mConfig.getHomeSp().getOtherHomePartners() != null) { + for (String otherHomePartner : mConfig.getHomeSp().getOtherHomePartners()) { + if (ANQPMatcher.matchDomainName( + (DomainNameElement) anqpElements.get(ANQPElementType.ANQPDomName), + otherHomePartner, null, null)) { + if (mVerboseLoggingEnabled) { + Log.d(TAG, "Other Home Partner " + otherHomePartner + + " match: HomeProvider"); + } + return PasspointMatch.HomeProvider; + } + } + } + // ANQP Roaming Consortium OI matching. long[] providerOIs = mConfig.getHomeSp().getRoamingConsortiumOis(); if (ANQPMatcher.matchRoamingConsortium( diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java index c23ea3411..4ebc6bd23 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java @@ -93,6 +93,7 @@ public class PasspointProviderTest extends WifiBaseTest { private static final int TEST_USAGE_LIMIT_DATA_LIMIT = 100; private static final String TEST_FQDN = "test.com"; private static final String TEST_FQDN2 = "test2.com"; + private static final String TEST_FQDN3 = "test3.com"; private static final String TEST_FRIENDLY_NAME = "Friendly Name"; private static final long[] TEST_RC_OIS = new long[] {0x1234L, 0x2345L}; private static final long[] TEST_IE_RC_OIS = new long[] {0x1234L, 0x2133L}; @@ -1392,8 +1393,8 @@ public class PasspointProviderTest extends WifiBaseTest { } /** - * Verify that an expected WifiConfiguration will be returned for a Passpoint provider - * with a user credential. + * Verify that a provider is a home provider when there is a match between Other Home Partners + * in the profile and the Domain Name ANQP element. * * @throws Exception */ @@ -1427,4 +1428,32 @@ public class PasspointProviderTest extends WifiBaseTest { verifyWifiConfigWithTestData(config, createProvider(config).getWifiConfig()); } + + /** + * Verify that an expected WifiConfiguration will be returned for a Passpoint provider + * with a user credential. + * + * @throws Exception + */ + @Test + public void matchOtherPartnersDomainName() throws Exception { + // Setup test provider. + PasspointConfiguration config = generateTestPasspointConfiguration( + CredentialType.USER, false); + + // Configuration was created with TEST_FQDN as the FQDN, add TEST_FQDN3 as other home + // partner. + HomeSp homeSp = config.getHomeSp(); + homeSp.setOtherHomePartners(new String [] {TEST_FQDN3}); + config.setHomeSp(homeSp); + mProvider = createProvider(config); + + // Setup Domain Name ANQP element to TEST_FQDN2 and TEST_FQDN3 + Map anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQPDomName, + createDomainNameElement(new String[] {TEST_FQDN2, TEST_FQDN3})); + + assertEquals(PasspointMatch.HomeProvider, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } } -- cgit v1.2.3