Use helper function getIndexForValue in MulticastRoutingCoordinator.
The SparseArray.indexOfValue() uses == to compare values, MulticastRoutingCoordinator uses SparseArray with String type values, and the indexOfValue function would sometimes return -1 when looking for a value in the SparseArray. Added a helper function getIndexForValue in CollectionUtils to get index by comparing values with equals, and used this function in MulticastRoutingCoordinator. Updated MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc test case to use copies of interface names when updating the multicast configs, so the test would fail without this fix. Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.CollectionUtilsTest#testGetIndexForValue atest android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc Change-Id: I862242d6be01b8552cdd6af6c9691948a9f0bfe0
This commit is contained in:
parent
9671e9a6d8
commit
4e7baadc71
1 changed files with 52 additions and 6 deletions
|
|
@ -402,15 +402,18 @@ class MulticastRoutingCoordinatorServiceTest {
|
|||
mService.getVirtualInterfaceIndex(mIfName1), oifsUpdate)
|
||||
val mf6cctlDel = createStructMf6cctl(mSourceAddress, mGroupAddressScope5,
|
||||
mService.getVirtualInterfaceIndex(mIfName1), mEmptyOifs)
|
||||
val ifName1Copy = String(mIfName1.toCharArray())
|
||||
val ifName2Copy = String(mIfName2.toCharArray())
|
||||
val ifName3Copy = String(mIfName3.toCharArray())
|
||||
|
||||
verify(mDeps).setsockoptMrt6AddMfc(eq(mFd), eq(mf6cctlAdd))
|
||||
|
||||
applyMulticastForwardNone(mIfName1, mIfName2)
|
||||
applyMulticastForwardNone(ifName1Copy, ifName2Copy)
|
||||
mLooper.dispatchAll()
|
||||
|
||||
verify(mDeps).setsockoptMrt6AddMfc(eq(mFd), eq(mf6cctlUpdate))
|
||||
|
||||
applyMulticastForwardNone(mIfName1, mIfName3)
|
||||
applyMulticastForwardNone(ifName1Copy, ifName3Copy)
|
||||
mLooper.dispatchAll()
|
||||
|
||||
verify(mDeps, timeout(TIMEOUT_MS).times(1)).setsockoptMrt6DelMfc(eq(mFd), eq(mf6cctlDel))
|
||||
|
|
|
|||
Loading…
Reference in a new issue