Isolate an ad-hoc legacy API codepath.

The legacy API getNetworkInfo(int type) is expected to return
NetworkInfo objects for all network types supported by the device
even when those network types are not connected.

This requires a lot of fabrication because all the data
structures in ConnectivityService store information about
connected networks, not networks that don't exist.

Worse, the current behaviour is to return BLOCKED instead of
DISCONNECTED if background data is restricted. This obviously
makes no sense, because a disconnected network cannot be
blocked, and because if that network type did connect and was
unmetered (e.g., Wi-Fi), it would no longer be BLOCKED.
This complicates the code, forcing several methods to deal with
a special case of null NetworkCapabilities, no NetworkAgentInfo,
etc.

Fix this by isolating this outlandish behaviour to its own
method. This allows the main codepaths not to have to support
this unusual and not very useful edge case.

Bug: 174123988
Test: pure refactoring, passes existing tests
Change-Id: Ia52b24c59024c8f6e63e584b864e0225cb572090
1 file changed
tree: 7c8f1392067cf11ba6ca67253d399293b0b063e6
  1. core/
  2. framework/
  3. service/
  4. services/
  5. tests/
  6. OWNERS