Stop using NetworkState internally in ConnectivityService.
NetworkState is used by many methods that take or return legacy
network types. It is used because it contains most of the state
related to a network.
This code is not easy to follow and is more expensive than it
needs to be: most of the methods that construct a NetworkState
only really need one of its members (e.g., LinkProperties, or
NetworkInfo), but constructing a NetworkState requires making
defensive copies of all its other members as well.
- Instead of using NetworkState, use NetworkAgentInfo, which
already contains all the same data.
- Replace calls to getUnfilteredActiveNetworkState with calls to
getNetworkAgentInfoForUid. When getUnfilteredActiveNetworkState
returned NetworkState.EMPTY, return a null nai, which causes
any caller to see return null LinkProperties/NetworkInfo/etc.
- Rename filterNetworkStateForUid to getFilteredNetworkInfo,
because that's the only thing it actually filters.
- Rename getFilteredNetworkInfo to getFilteredNetworkInfoForType
to avoid having two methods with the same name perform two
different operations. That method was only introduced recently
in aosp/1552503, so it's probably fine to rename it.
Bug: 174123988
Test: passes existing ConnectivityServiceTest
Change-Id: Idfb5e149967266a442b268de6f13a521884dbb8f
1 file changed