diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-10-06 03:15:56 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-10-06 03:15:56 +0000 |
commit | cc00c7e2c335359fb786d7bfe941b8c069f0eef5 (patch) | |
tree | b3b1fe10649a7f2e45da5d9efe06ae27eb68dfdd | |
parent | e6d6c9b0b0e523e2ecce02e22e4d55954de0ad65 (diff) | |
parent | c26d2bfdf8ff6f5049bd599349dbd46e5e053fb4 (diff) | |
download | android_frameworks_opt_net_wifi-cc00c7e2c335359fb786d7bfe941b8c069f0eef5.tar.gz android_frameworks_opt_net_wifi-cc00c7e2c335359fb786d7bfe941b8c069f0eef5.tar.bz2 android_frameworks_opt_net_wifi-cc00c7e2c335359fb786d7bfe941b8c069f0eef5.zip |
Snap for 5053079 from c26d2bfdf8ff6f5049bd599349dbd46e5e053fb4 to pi-qpr2-release
Change-Id: Ic0785d3180ccdae0c7b8530cd2127a7cb1908864
4 files changed, 277 insertions, 67 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index f86a938d7..6d09a29ca 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -259,24 +259,32 @@ public class PasspointProvider { */ public PasspointMatch match(Map<ANQPElementType, ANQPElement> anqpElements, RoamingConsortium roamingConsortium) { - PasspointMatch providerMatch = matchProvider(anqpElements, roamingConsortium); + PasspointMatch providerMatch = matchProviderExceptFor3GPP(anqpElements, roamingConsortium); + + // 3GPP Network matching. + if (providerMatch == PasspointMatch.None && ANQPMatcher.matchThreeGPPNetwork( + (ThreeGPPNetworkElement) anqpElements.get(ANQPElementType.ANQP3GPPNetwork), + mImsiParameter, mMatchingSIMImsiList)) { + return PasspointMatch.RoamingProvider; + } // Perform authentication match against the NAI Realm. int authMatch = ANQPMatcher.matchNAIRealm( (NAIRealmElement) anqpElements.get(ANQPElementType.ANQPNAIRealm), mConfig.getCredential().getRealm(), mEAPMethodID, mAuthParam); - // Auth mismatch, demote provider match. + // In case of Auth mismatch, demote provider match. if (authMatch == AuthMatch.NONE) { return PasspointMatch.None; } - // No realm match, return provider match as is. + // In case of no realm match, return provider match as is. if ((authMatch & AuthMatch.REALM) == 0) { return providerMatch; } - // Realm match, promote provider match to roaming if no other provider match is found. + // Promote the provider match to roaming provider if provider match is not found, but NAI + // realm is matched. return providerMatch == PasspointMatch.None ? PasspointMatch.RoamingProvider : providerMatch; } @@ -454,13 +462,14 @@ public class PasspointProvider { } /** - * Perform a provider match based on the given ANQP elements. + * Perform a provider match based on the given ANQP elements except for matching 3GPP Network. * * @param anqpElements List of ANQP elements * @param roamingConsortium Roaming Consortium information element from the AP * @return {@link PasspointMatch} */ - private PasspointMatch matchProvider(Map<ANQPElementType, ANQPElement> anqpElements, + private PasspointMatch matchProviderExceptFor3GPP( + Map<ANQPElementType, ANQPElement> anqpElements, RoamingConsortium roamingConsortium) { // Domain name matching. if (ANQPMatcher.matchDomainName( @@ -489,12 +498,6 @@ public class PasspointProvider { } } - // 3GPP Network matching. - if (ANQPMatcher.matchThreeGPPNetwork( - (ThreeGPPNetworkElement) anqpElements.get(ANQPElementType.ANQP3GPPNetwork), - mImsiParameter, mMatchingSIMImsiList)) { - return PasspointMatch.RoamingProvider; - } return PasspointMatch.None; } diff --git a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java index 75e75aa0f..258bdb67f 100644 --- a/service/java/com/android/server/wifi/rtt/RttServiceImpl.java +++ b/service/java/com/android/server/wifi/rtt/RttServiceImpl.java @@ -1016,8 +1016,14 @@ public class RttServiceImpl extends IWifiRttManager.Stub { RangingRequest.Builder newRequestBuilder = new RangingRequest.Builder(); for (ResponderConfig rttPeer : request.request.mRttPeers) { if (rttPeer.peerHandle != null && rttPeer.macAddress == null) { + byte[] mac = peerIdToMacMap.get(rttPeer.peerHandle.peerId); + if (mac == null || mac.length != 6) { + Log.e(TAG, "processReceivedAwarePeerMacAddresses: received an invalid MAC " + + "address for peerId=" + rttPeer.peerHandle.peerId); + continue; + } newRequestBuilder.addResponder(new ResponderConfig( - MacAddress.fromBytes(peerIdToMacMap.get(rttPeer.peerHandle.peerId)), + MacAddress.fromBytes(mac), rttPeer.peerHandle, rttPeer.responderType, rttPeer.supports80211mc, rttPeer.channelWidth, rttPeer.frequency, rttPeer.centerFreq0, rttPeer.centerFreq1, rttPeer.preamble)); 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 0055fbaaa..58496622f 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java @@ -47,8 +47,8 @@ import com.android.server.wifi.hotspot2.anqp.ThreeGPPNetworkElement; import com.android.server.wifi.hotspot2.anqp.eap.AuthParam; import com.android.server.wifi.hotspot2.anqp.eap.EAPMethod; import com.android.server.wifi.hotspot2.anqp.eap.NonEAPInnerAuth; - import com.android.server.wifi.util.InformationElementUtil.RoamingConsortium; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -447,7 +447,7 @@ public class PasspointProviderTest { * @throws Exception */ @Test - public void match3GPPNetworkDomainName() throws Exception { + public void matchFQDNWith3GPPNetworkDomainName() throws Exception { String testImsi = "1234567890"; // Setup test provider. @@ -472,13 +472,56 @@ public class PasspointProviderTest { } /** + * Verify that a provider is a home provider when its FQDN, roaming consortium OI, and + * IMSI all matched against the ANQP elements, since we prefer matching home provider over + * roaming provider. + * + * @throws Exception + */ + @Test + public void matchFQDNOverRoamingProvider() throws Exception { + // Setup test data. + String testDomain = "test.com"; + String testImsi = "1234567890"; + long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; + Long[] anqpRCOIs = new Long[] {0x1234L, 0x2133L}; + + // Setup test provider. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setFqdn(testDomain); + homeSp.setRoamingConsortiumOis(providerRCOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + Credential.SimCredential simCredential = new Credential.SimCredential(); + simCredential.setImsi(testImsi); + credential.setSimCredential(simCredential); + config.setCredential(credential); + when(mSimAccessor.getMatchingImsis(new IMSIParameter(testImsi, false))) + .thenReturn(Arrays.asList(new String[] {testImsi})); + mProvider = createProvider(config); + + // Setup ANQP elements. + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQPDomName, + createDomainNameElement(new String[] {testDomain})); + anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium, + createRoamingConsortiumElement(anqpRCOIs)); + anqpElementMap.put(ANQPElementType.ANQP3GPPNetwork, + createThreeGPPNetworkElement(new String[] {"123456"})); + + assertEquals(PasspointMatch.HomeProvider, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } + + /** * Verify that a provider is a roaming provider when a roaming consortium OI matches an OI - * in the roaming consortium ANQP element. + * in the roaming consortium ANQP element and no NAI realm is provided. * * @throws Exception */ @Test - public void matchRoamingConsortium() throws Exception { + public void matchRoamingConsortiumWithoutNAIRealm() throws Exception { long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; Long[] anqpRCOIs = new Long[] {0x1234L, 0x2133L}; @@ -505,12 +548,87 @@ public class PasspointProviderTest { /** * Verify that a provider is a roaming provider when a roaming consortium OI matches an OI - * in the roaming consortium information element. + * in the roaming consortium ANQP element and the provider's credential matches the + * NAI realm provided. + * + * @throws Exception + */ + @Test + public void matchRoamingConsortiumWithNAIRealmMatch() throws Exception { + long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; + Long[] anqpRCOIs = new Long[] {0x1234L, 0x2133L}; + String testRealm = "realm.com"; + + // Setup test provider. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setRoamingConsortiumOis(providerRCOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + credential.setRealm(testRealm); + Credential.UserCredential userCredential = new Credential.UserCredential(); + userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); + credential.setUserCredential(userCredential); + config.setCredential(credential); + mProvider = createProvider(config); + + // Setup Roaming Consortium ANQP element. + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium, + createRoamingConsortiumElement(anqpRCOIs)); + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TTLS, + new NonEAPInnerAuth(NonEAPInnerAuth.AUTH_TYPE_MSCHAPV2))); + + assertEquals(PasspointMatch.RoamingProvider, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } + + /** + * Verify that there is no match when a roaming consortium OI matches an OI + * in the roaming consortium ANQP element and but NAI realm is not matched. + * + * @throws Exception + */ + @Test + public void matchRoamingConsortiumWithNAIRealmMisMatch() throws Exception { + long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; + Long[] anqpRCOIs = new Long[] {0x1234L, 0x2133L}; + String testRealm = "realm.com"; + + // Setup test provider. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setRoamingConsortiumOis(providerRCOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + credential.setRealm(testRealm); + Credential.UserCredential userCredential = new Credential.UserCredential(); + userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); + credential.setUserCredential(userCredential); + config.setCredential(credential); + mProvider = createProvider(config); + + // Setup Roaming Consortium ANQP element. + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium, + createRoamingConsortiumElement(anqpRCOIs)); + // Set up NAI with different EAP method + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TLS, null)); + + assertEquals(PasspointMatch.None, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } + + /** + * Verify that a provider is a roaming provider when a roaming consortium OI matches an OI + * in the roaming consortium information element and no NAI realm is provided. * * @throws Exception */ @Test - public void matchRoamingConsortiumIe() throws Exception { + public void matchRoamingConsortiumIeWithoutNAIRealm() throws Exception { long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; long[] ieRCOIs = new long[] {0x1234L, 0x2133L}; @@ -537,7 +655,84 @@ public class PasspointProviderTest { } /** - * Verify that none of matched providers are not found when a roaming consortium OI doesn't + * Verify that a provider is a roaming provider when a roaming consortium OI matches an OI + * in the roaming consortium information element and the provider's credential matches the + * NAI realm provided. + * + * @throws Exception + */ + @Test + public void matchRoamingConsortiumIeWithNAIRealmMatch() throws Exception { + long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; + long[] ieRCOIs = new long[] {0x1234L, 0x2133L}; + String testRealm = "realm.com"; + + // Setup test provider. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setRoamingConsortiumOis(providerRCOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + credential.setRealm(testRealm); + Credential.UserCredential userCredential = new Credential.UserCredential(); + userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); + credential.setUserCredential(userCredential); + config.setCredential(credential); + mProvider = createProvider(config); + + // Setup Roaming Consortium ANQP element. + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + + // Setup Roaming Consortium Information element. + when(mRoamingConsortium.getRoamingConsortiums()).thenReturn(ieRCOIs); + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TTLS, + new NonEAPInnerAuth(NonEAPInnerAuth.AUTH_TYPE_MSCHAPV2))); + + assertEquals(PasspointMatch.RoamingProvider, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } + + /** + * Verify that there is no match when a roaming consortium OI matches an OI + * in the roaming consortium information element, but NAI realm is not matched. + * + * @throws Exception + */ + @Test + public void matchRoamingConsortiumIeWithNAIRealmMismatch() throws Exception { + long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; + long[] ieRCOIs = new long[] {0x1234L, 0x2133L}; + String testRealm = "realm.com"; + + // Setup test provider. + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setRoamingConsortiumOis(providerRCOIs); + config.setHomeSp(homeSp); + Credential credential = new Credential(); + credential.setRealm(testRealm); + Credential.UserCredential userCredential = new Credential.UserCredential(); + userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); + credential.setUserCredential(userCredential); + config.setCredential(credential); + mProvider = createProvider(config); + + // Setup Roaming Consortium ANQP element. + Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + + // Setup Roaming Consortium Information element. + when(mRoamingConsortium.getRoamingConsortiums()).thenReturn(ieRCOIs); + // Set up NAI with different EAP method + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TLS, null)); + + assertEquals(PasspointMatch.None, + mProvider.match(anqpElementMap, mRoamingConsortium)); + } + + /** + * Verify that none of matched providers are found when a roaming consortium OI doesn't * matches an OI in the roaming consortium information element and * none of NAI realms match each other. * @@ -571,15 +766,16 @@ public class PasspointProviderTest { } /** - * Verify that a provider is a roaming provider when the provider's IMSI parameter and an - * IMSI from the SIM card matches a MCC-MNC in the 3GPP Network ANQP element. + * Verify that a provider is a roaming provider when the provider's IMSI parameter and an IMSI + * from the SIM card matches a MCC-MNC in the 3GPP Network ANQP element regardless of NAI realm + * mismatch. * * @throws Exception */ @Test - public void matchThreeGPPNetwork() throws Exception { + public void matchThreeGPPNetworkWithNAIRealmMismatch() throws Exception { String testImsi = "1234567890"; - + String testRealm = "realm.com"; // Setup test provider. PasspointConfiguration config = new PasspointConfiguration(); config.setHomeSp(new HomeSp()); @@ -597,84 +793,84 @@ public class PasspointProviderTest { anqpElementMap.put(ANQPElementType.ANQP3GPPNetwork, createThreeGPPNetworkElement(new String[] {"123456"})); + // Setup NAI Realm ANQP element with different realm. + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TTLS, + new NonEAPInnerAuth(NonEAPInnerAuth.AUTH_TYPE_MSCHAPV2))); + assertEquals(PasspointMatch.RoamingProvider, mProvider.match(anqpElementMap, mRoamingConsortium)); } /** - * Verify that a provider is a roaming provider when its credential matches a NAI realm in - * the NAI Realm ANQP element. + * Verify that a provider is a roaming provider when the provider's IMSI parameter and an IMSI + * from the SIM card matches a MCC-MNC in the 3GPP Network ANQP element regardless of NAI realm + * match. * * @throws Exception */ @Test - public void matchNAIRealm() throws Exception { + public void matchThreeGPPNetworkWithNAIRealmMatch() throws Exception { + String testImsi = "1234567890"; String testRealm = "realm.com"; - // Setup test provider. PasspointConfiguration config = new PasspointConfiguration(); config.setHomeSp(new HomeSp()); Credential credential = new Credential(); - credential.setRealm(testRealm); - Credential.UserCredential userCredential = new Credential.UserCredential(); - userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); - credential.setUserCredential(userCredential); + Credential.SimCredential simCredential = new Credential.SimCredential(); + simCredential.setImsi(testImsi); + credential.setSimCredential(simCredential); config.setCredential(credential); + credential.setRealm(testRealm); + when(mSimAccessor.getMatchingImsis(new IMSIParameter(testImsi, false))) + .thenReturn(Arrays.asList(new String[] {testImsi})); mProvider = createProvider(config); - // Setup NAI Realm ANQP element. + // Setup 3GPP Network ANQP element. Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); + anqpElementMap.put(ANQPElementType.ANQP3GPPNetwork, + createThreeGPPNetworkElement(new String[] {"123456"})); + + // Setup NAI Realm ANQP element with same realm. anqpElementMap.put(ANQPElementType.ANQPNAIRealm, - createNAIRealmElement(testRealm, EAPConstants.EAP_TTLS, - new NonEAPInnerAuth(NonEAPInnerAuth.AUTH_TYPE_MSCHAPV2))); + createNAIRealmElement(testRealm, EAPConstants.EAP_AKA, null)); assertEquals(PasspointMatch.RoamingProvider, - mProvider.match(anqpElementMap, mRoamingConsortium)); + mProvider.match(anqpElementMap, mRoamingConsortium)); } /** - * Verify that a provider is a home provider when its FQDN, roaming consortium OI, and - * IMSI all matched against the ANQP elements, since we prefer matching home provider over - * roaming provider. + * Verify that a provider is a roaming provider when its credential only matches a NAI realm in + * the NAI Realm ANQP element and not match for Domain Name, RoamingConsortium and 3GPP. * * @throws Exception */ @Test - public void matchHomeOverRoamingProvider() throws Exception { - // Setup test data. - String testDomain = "test.com"; - String testImsi = "1234567890"; - long[] providerRCOIs = new long[] {0x1234L, 0x2345L}; - Long[] anqpRCOIs = new Long[] {0x1234L, 0x2133L}; + public void matchOnlyNAIRealmWithOtherInformationMismatch() throws Exception { + String testRealm = "realm.com"; // Setup test provider. PasspointConfiguration config = new PasspointConfiguration(); - HomeSp homeSp = new HomeSp(); - homeSp.setFqdn(testDomain); - homeSp.setRoamingConsortiumOis(providerRCOIs); - config.setHomeSp(homeSp); + config.setHomeSp(new HomeSp()); Credential credential = new Credential(); - Credential.SimCredential simCredential = new Credential.SimCredential(); - simCredential.setImsi(testImsi); - credential.setSimCredential(simCredential); + credential.setRealm(testRealm); + Credential.UserCredential userCredential = new Credential.UserCredential(); + userCredential.setNonEapInnerMethod(Credential.UserCredential.AUTH_METHOD_MSCHAPV2); + credential.setUserCredential(userCredential); config.setCredential(credential); - when(mSimAccessor.getMatchingImsis(new IMSIParameter(testImsi, false))) - .thenReturn(Arrays.asList(new String[] {testImsi})); mProvider = createProvider(config); - // Setup ANQP elements. + // Setup NAI Realm ANQP element. Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>(); - anqpElementMap.put(ANQPElementType.ANQPDomName, - createDomainNameElement(new String[] {testDomain})); - anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium, - createRoamingConsortiumElement(anqpRCOIs)); - anqpElementMap.put(ANQPElementType.ANQP3GPPNetwork, - createThreeGPPNetworkElement(new String[] {"123456"})); + anqpElementMap.put(ANQPElementType.ANQPNAIRealm, + createNAIRealmElement(testRealm, EAPConstants.EAP_TTLS, + new NonEAPInnerAuth(NonEAPInnerAuth.AUTH_TYPE_MSCHAPV2))); - assertEquals(PasspointMatch.HomeProvider, + assertEquals(PasspointMatch.RoamingProvider, mProvider.match(anqpElementMap, mRoamingConsortium)); } + /** * Verify that an expected WifiConfiguration will be returned for a Passpoint provider * with an user credential. diff --git a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java index d1c1b028b..e1f35239f 100644 --- a/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/rtt/RttServiceImplTest.java @@ -305,13 +305,16 @@ public class RttServiceImplTest { RangingRequest request = RttTestUtils.getDummyRangingRequest((byte) 0xA); PeerHandle peerHandle1 = new PeerHandle(1022); PeerHandle peerHandle2 = new PeerHandle(1023); + PeerHandle peerHandle3 = new PeerHandle(1024); request.mRttPeers.add(ResponderConfig.fromWifiAwarePeerHandleWithDefaults(peerHandle1)); request.mRttPeers.add(ResponderConfig.fromWifiAwarePeerHandleWithDefaults(peerHandle2)); + request.mRttPeers.add(ResponderConfig.fromWifiAwarePeerHandleWithDefaults(peerHandle3)); Map<Integer, MacAddress> peerHandleToMacMap = new HashMap<>(); MacAddress macAwarePeer1 = MacAddress.fromString("AA:BB:CC:DD:EE:FF"); MacAddress macAwarePeer2 = MacAddress.fromString("BB:BB:BB:EE:EE:EE"); peerHandleToMacMap.put(peerHandle1.peerId, macAwarePeer1); peerHandleToMacMap.put(peerHandle2.peerId, macAwarePeer2); + peerHandleToMacMap.put(peerHandle3.peerId, null); // bad answer from Aware (expired?) AwareTranslatePeerHandlesToMac answer = new AwareTranslatePeerHandlesToMac(mDefaultUid, peerHandleToMacMap); @@ -327,7 +330,8 @@ public class RttServiceImplTest { RangingRequest finalRequest = mRequestCaptor.getValue(); assertNotEquals("Request to native is not null", null, finalRequest); - assertEquals("Size of request", request.mRttPeers.size(), finalRequest.mRttPeers.size()); + assertEquals("Size of request", request.mRttPeers.size() - 1, + finalRequest.mRttPeers.size()); assertEquals("Aware peer 1 MAC", macAwarePeer1, finalRequest.mRttPeers.get(finalRequest.mRttPeers.size() - 2).macAddress); assertEquals("Aware peer 2 MAC", macAwarePeer2, @@ -1452,12 +1456,13 @@ public class RttServiceImplTest { Map<Integer, byte[]> result = new HashMap<>(); for (Integer peerId: peerIds) { - byte[] mac = mPeerIdToMacMap.get(peerId).toByteArray(); - if (mac == null) { - continue; + byte[] macBytes = null; + MacAddress macAddr = mPeerIdToMacMap.get(peerId); + if (macAddr != null) { + macBytes = macAddr.toByteArray(); } - result.put(peerId, mac); + result.put(peerId, macBytes); } try { |