a75740531ea4ebc545deefabe3296d10fd1288cc
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
Description
android_packages_modules_Connectivity
Languages
Java
81.4%
Kotlin
7.7%
AIDL
4.5%
C++
4.5%
C
1.7%
Other
0.1%