Remove getFilteredNetworkState and add @NonNull in NetworkState.
getFilteredNetworkState is only used in two places, both of which use only small parts of the NetworkState that is returned to them. Remove the method and replace it with inline code in the two callers. NetworkState is a fairly expensive object, and this removes the need to perform lots of defensive copies of data that the caller does not need. Also remove the only call to the NetworkState constructor in ConnectivityService. That leaves only one caller to the NetworkState constructor, the one in NetworkAgentInfo. This constructor is called with defensive copies of NetworkInfo, LinkProperties, and NetworkCapabilities, so mark these three parameters as @NonNull. It's also called with a non-null Network, because NetworkAgentInfo is only constructed with non-null Networks, so mark the network parameter @NonNull as well. In order to make the arguments in the NetworkState constructor @NonNull, introduce a new constructor that sets everything to null and make NetworkState.EMPTY call it. Test: atest FrameworksNetTests Change-Id: Idcc9e32c53533b0cf61494517e62d4c184fa7610
Loading
Please register or sign in to comment