Skip to content
Commit 2d23f530 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

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