[NS D05] Rework how to tear down networks
Networks are torn down if they don't satisfy requests but only if
they are found unable to ever do so. This is important because
general-purpose networks typically turn up unvalidated, which
means they would get torn down immediately in the presence of
some worse network that is already validated.
Note that functionally it's the same as before for the existing
scores, except that
• An exiting network that doesn't satisfy any request is always
torn down immediately – this is WAI
• An unmetered network is never torn down when compared to a
metered network – this is a bugfix (previously the platform
would tear down an unmetered cellular on grounds that it
could not beat the performance of a metered Ethernet, but
that's wrong ; the bug was never realized because Android
always thinks Ethernet is unmetered)
• An unvalidated network will not be torn down if the current
satisfier is also unvalidated, even if the satisfier is much
faster. This is the reason for the change in the test. It's
wrong to tear down in this case because even if much slower
the slower network should win if it validates and the other
doesn't.
Test: ConnectivityServiceTest
Change-Id: Ic9a3d336306a25d1272976ce467aa7c908af7bef
3 files changed