Remove "when" usage in ConnectivityServiceTest
"when" is not thread-safe, as it relies on global state to find which
mock was called with the method to mock in its parameters.
This causes flakes where non-test code that interacts with the mock may
be called from another thread between the contents of "when" and the
"when" method another thread, causing UnfinishedStubbingExceptions or
other test errors. In particular
ConnectivityService#getNetworkCapabilitiesInternal was seen to be
wrongly identified as a mocking site for Dependencies.
Replace all usages with doReturn().when(mock).method() syntax, which has
better thread safety since global state is not necessary to tie the
mock, mocked method and return value.
Bug: 195626111
Test: atest ConnectivityServiceTest
Change-Id: I57c5ffb3b3f799fc59c3af4ccb323fb5d6794fad
1 file changed