[CS] Unregister callback as part of onUnavailable dispatch

The onUnavailable semantics promise that it is equivalent to calling
the unregister callback method. But - it doesn't unregister the callback
allowing it to be reused. Fixed.

Additionally, modified the unregisterNetworkCallback method to not fail
on duplicate unregistration (since a callback could now self
unregister). Instead simply print a log.

Bug: 130651445
Test: atest ConnectivityServiceTest
Change-Id: I4c54b003a733eb0b1e4fd8674ed13081b1bef8e3
This commit is contained in:
Etan Cohen
2019-04-16 15:07:55 -07:00
parent c586bdf976
commit 6cb6599ddd
2 changed files with 11 additions and 2 deletions

View File

@@ -3854,6 +3854,9 @@ public class ConnectivityServiceTest {
networkCallback.expectCallback(CallbackState.UNAVAILABLE, null);
testFactory.waitForRequests();
// unregister network callback - a no-op, but should not fail
mCm.unregisterNetworkCallback(networkCallback);
testFactory.unregister();
handlerThread.quit();
}