ConnectivityManager: release all requests mapping to a callback.
This patch changes how callback unregistration works in order to be consistent with undocumented use cases currently de-facto supported by the API (although in a buggy way): - callback recycling: releasing then reregistering a callback again. - multiple request registrations with the same callback. The second use case is not desirable but needs to be taken into account for now for the purpose of correctly releasing NetworkRequests registered in ConnectivityService. In order to support request release in both use cases with minimal amount of complexity for the time being the following changes are done: - request to callback unmapping is done synchronously at callback release time. - all requests associated to a callback are unmapped at callback release time. This fixes the following issues: - a callback stops being triggered as soon as it is released. Otherwise when recycling the callback immediately, it is possible the previous request associated with it triggers it, confusing the app. - when a callback is registered multiple times, the requests are not leaked. - when a callback is registered multiple times and then released, the N-1 first registrations do not trigger the callback anymore. In the future it would be desirable to enforce the intended 1:1 mapping between callbacks and requests at registration time. Bug: 35921499, 35955593, 20701525 Test: - added new tests in ConnectivityManagerTest to test releasing, recycling, and a disabled test for no multiple regristration. - new tests catch regression causing b/35921499, b/35955593. Change-Id: Ia0917ac322fc049f76adb4743bc745989fed6d26
Loading
Please register or sign in to comment