Merge "Mark several NetworkAgentInfo members @NonNull and address TODO."
This commit is contained in:
@@ -6597,7 +6597,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't modify caller's NetworkCapabilities.
|
// Don't modify caller's NetworkCapabilities.
|
||||||
NetworkCapabilities newNc = new NetworkCapabilities(nc);
|
final NetworkCapabilities newNc = new NetworkCapabilities(nc);
|
||||||
if (nai.lastValidated) {
|
if (nai.lastValidated) {
|
||||||
newNc.addCapability(NET_CAPABILITY_VALIDATED);
|
newNc.addCapability(NET_CAPABILITY_VALIDATED);
|
||||||
} else {
|
} else {
|
||||||
@@ -6685,26 +6685,21 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_CAP_CHANGED);
|
notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_CAP_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : static analysis indicates that prevNc can't be null here (getAndSetNetworkCaps
|
final boolean oldMetered = prevNc.isMetered();
|
||||||
// never returns null), so mark the relevant members and functions in nai as @NonNull and
|
final boolean newMetered = newNc.isMetered();
|
||||||
// remove this test
|
final boolean meteredChanged = oldMetered != newMetered;
|
||||||
if (prevNc != null) {
|
|
||||||
final boolean oldMetered = prevNc.isMetered();
|
|
||||||
final boolean newMetered = newNc.isMetered();
|
|
||||||
final boolean meteredChanged = oldMetered != newMetered;
|
|
||||||
|
|
||||||
if (meteredChanged) {
|
if (meteredChanged) {
|
||||||
maybeNotifyNetworkBlocked(nai, oldMetered, newMetered, mRestrictBackground,
|
maybeNotifyNetworkBlocked(nai, oldMetered, newMetered, mRestrictBackground,
|
||||||
mRestrictBackground, mVpnBlockedUidRanges, mVpnBlockedUidRanges);
|
mRestrictBackground, mVpnBlockedUidRanges, mVpnBlockedUidRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean roamingChanged = prevNc.hasCapability(NET_CAPABILITY_NOT_ROAMING) !=
|
final boolean roamingChanged = prevNc.hasCapability(NET_CAPABILITY_NOT_ROAMING)
|
||||||
newNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
|
!= newNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
|
||||||
|
|
||||||
// Report changes that are interesting for network statistics tracking.
|
// Report changes that are interesting for network statistics tracking.
|
||||||
if (meteredChanged || roamingChanged) {
|
if (meteredChanged || roamingChanged) {
|
||||||
notifyIfacesChangedForNetworkStats();
|
notifyIfacesChangedForNetworkStats();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This network might have been underlying another network. Propagate its capabilities.
|
// This network might have been underlying another network. Propagate its capabilities.
|
||||||
|
|||||||
@@ -136,12 +136,12 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
// This Network object should always be used if possible, so as to encourage reuse of the
|
// This Network object should always be used if possible, so as to encourage reuse of the
|
||||||
// enclosed socket factory and connection pool. Avoid creating other Network objects.
|
// enclosed socket factory and connection pool. Avoid creating other Network objects.
|
||||||
// This Network object is always valid.
|
// This Network object is always valid.
|
||||||
public final Network network;
|
@NonNull public final Network network;
|
||||||
public LinkProperties linkProperties;
|
@NonNull public LinkProperties linkProperties;
|
||||||
// This should only be modified by ConnectivityService, via setNetworkCapabilities().
|
// This should only be modified by ConnectivityService, via setNetworkCapabilities().
|
||||||
// TODO: make this private with a getter.
|
// TODO: make this private with a getter.
|
||||||
public NetworkCapabilities networkCapabilities;
|
@NonNull public NetworkCapabilities networkCapabilities;
|
||||||
public final NetworkAgentConfig networkAgentConfig;
|
@NonNull public final NetworkAgentConfig networkAgentConfig;
|
||||||
|
|
||||||
// Underlying networks declared by the agent. Only set if supportsUnderlyingNetworks is true.
|
// Underlying networks declared by the agent. Only set if supportsUnderlyingNetworks is true.
|
||||||
// The networks in this list might be declared by a VPN app using setUnderlyingNetworks and are
|
// The networks in this list might be declared by a VPN app using setUnderlyingNetworks and are
|
||||||
@@ -603,7 +603,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
*
|
*
|
||||||
* @return the old capabilities of this network.
|
* @return the old capabilities of this network.
|
||||||
*/
|
*/
|
||||||
public synchronized NetworkCapabilities getAndSetNetworkCapabilities(
|
@NonNull public synchronized NetworkCapabilities getAndSetNetworkCapabilities(
|
||||||
@NonNull final NetworkCapabilities nc) {
|
@NonNull final NetworkCapabilities nc) {
|
||||||
final NetworkCapabilities oldNc = networkCapabilities;
|
final NetworkCapabilities oldNc = networkCapabilities;
|
||||||
networkCapabilities = nc;
|
networkCapabilities = nc;
|
||||||
|
|||||||
Reference in New Issue
Block a user