Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit dafed3d0 authored by Hugo Benichi's avatar Hugo Benichi
Browse files

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
parent 9ea45b61
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment