[Mainline] Network netId to getNetId() migration
Bug: 175085315 Test: atest Change-Id: I3d7366ba1e60be3ff7c6dd6c589db760b182136b
This commit is contained in:
@@ -1287,7 +1287,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (network == null) {
|
if (network == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return getNetworkAgentInfoForNetId(network.netId);
|
return getNetworkAgentInfoForNetId(network.getNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetworkAgentInfo getNetworkAgentInfoForNetId(int netId) {
|
private NetworkAgentInfo getNetworkAgentInfoForNetId(int netId) {
|
||||||
@@ -1378,7 +1378,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
final String action = blocked ? "BLOCKED" : "UNBLOCKED";
|
final String action = blocked ? "BLOCKED" : "UNBLOCKED";
|
||||||
mNetworkInfoBlockingLogs.log(String.format(
|
mNetworkInfoBlockingLogs.log(String.format(
|
||||||
"%s %d(%d) on netId %d", action, nri.mUid, nri.request.requestId, net.netId));
|
"%s %d(%d) on netId %d", action, nri.mUid, nri.request.requestId, net.getNetId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1890,7 +1890,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
int netId;
|
int netId;
|
||||||
synchronized (nai) {
|
synchronized (nai) {
|
||||||
lp = nai.linkProperties;
|
lp = nai.linkProperties;
|
||||||
netId = nai.network.netId;
|
netId = nai.network.getNetId();
|
||||||
}
|
}
|
||||||
boolean ok = addLegacyRouteToHost(lp, addr, netId, uid);
|
boolean ok = addLegacyRouteToHost(lp, addr, netId, uid);
|
||||||
if (DBG) log("requestRouteToHostAddress ok=" + ok);
|
if (DBG) log("requestRouteToHostAddress ok=" + ok);
|
||||||
@@ -2553,7 +2553,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (defaultNai == null) {
|
if (defaultNai == null) {
|
||||||
pw.println("none");
|
pw.println("none");
|
||||||
} else {
|
} else {
|
||||||
pw.println(defaultNai.network.netId);
|
pw.println(defaultNai.network.getNetId());
|
||||||
}
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
@@ -2690,7 +2690,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private NetworkAgentInfo[] networksSortedById() {
|
private NetworkAgentInfo[] networksSortedById() {
|
||||||
NetworkAgentInfo[] networks = new NetworkAgentInfo[0];
|
NetworkAgentInfo[] networks = new NetworkAgentInfo[0];
|
||||||
networks = mNetworkAgentInfos.values().toArray(networks);
|
networks = mNetworkAgentInfos.values().toArray(networks);
|
||||||
Arrays.sort(networks, Comparator.comparingInt(nai -> nai.network.netId));
|
Arrays.sort(networks, Comparator.comparingInt(nai -> nai.network.getNetId()));
|
||||||
return networks;
|
return networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2974,13 +2974,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
handleFreshlyValidatedNetwork(nai);
|
handleFreshlyValidatedNetwork(nai);
|
||||||
// Clear NO_INTERNET, PRIVATE_DNS_BROKEN, PARTIAL_CONNECTIVITY and
|
// Clear NO_INTERNET, PRIVATE_DNS_BROKEN, PARTIAL_CONNECTIVITY and
|
||||||
// LOST_INTERNET notifications if network becomes valid.
|
// LOST_INTERNET notifications if network becomes valid.
|
||||||
mNotifier.clearNotification(nai.network.netId,
|
mNotifier.clearNotification(nai.network.getNetId(),
|
||||||
NotificationType.NO_INTERNET);
|
NotificationType.NO_INTERNET);
|
||||||
mNotifier.clearNotification(nai.network.netId,
|
mNotifier.clearNotification(nai.network.getNetId(),
|
||||||
NotificationType.LOST_INTERNET);
|
NotificationType.LOST_INTERNET);
|
||||||
mNotifier.clearNotification(nai.network.netId,
|
mNotifier.clearNotification(nai.network.getNetId(),
|
||||||
NotificationType.PARTIAL_CONNECTIVITY);
|
NotificationType.PARTIAL_CONNECTIVITY);
|
||||||
mNotifier.clearNotification(nai.network.netId,
|
mNotifier.clearNotification(nai.network.getNetId(),
|
||||||
NotificationType.PRIVATE_DNS_BROKEN);
|
NotificationType.PRIVATE_DNS_BROKEN);
|
||||||
// If network becomes valid, the hasShownBroken should be reset for
|
// If network becomes valid, the hasShownBroken should be reset for
|
||||||
// that network so that the notification will be fired when the private
|
// that network so that the notification will be fired when the private
|
||||||
@@ -3051,7 +3051,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private final AutodestructReference<NetworkAgentInfo> mNai;
|
private final AutodestructReference<NetworkAgentInfo> mNai;
|
||||||
|
|
||||||
private NetworkMonitorCallbacks(NetworkAgentInfo nai) {
|
private NetworkMonitorCallbacks(NetworkAgentInfo nai) {
|
||||||
mNetId = nai.network.netId;
|
mNetId = nai.network.getNetId();
|
||||||
mNai = new AutodestructReference<>(nai);
|
mNai = new AutodestructReference<>(nai);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3201,7 +3201,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// in order to restart a validation pass from within netd.
|
// in order to restart a validation pass from within netd.
|
||||||
final PrivateDnsConfig cfg = mDnsManager.getPrivateDnsConfig();
|
final PrivateDnsConfig cfg = mDnsManager.getPrivateDnsConfig();
|
||||||
if (cfg.useTls && TextUtils.isEmpty(cfg.hostname)) {
|
if (cfg.useTls && TextUtils.isEmpty(cfg.hostname)) {
|
||||||
updateDnses(nai.linkProperties, null, nai.network.netId);
|
updateDnses(nai.linkProperties, null, nai.network.getNetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3234,7 +3234,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private void updatePrivateDns(NetworkAgentInfo nai, PrivateDnsConfig newCfg) {
|
private void updatePrivateDns(NetworkAgentInfo nai, PrivateDnsConfig newCfg) {
|
||||||
mDnsManager.updatePrivateDns(nai.network, newCfg);
|
mDnsManager.updatePrivateDns(nai.network, newCfg);
|
||||||
updateDnses(nai.linkProperties, null, nai.network.netId);
|
updateDnses(nai.linkProperties, null, nai.network.getNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePrivateDnsValidationUpdate(PrivateDnsValidationUpdate update) {
|
private void handlePrivateDnsValidationUpdate(PrivateDnsValidationUpdate update) {
|
||||||
@@ -3330,9 +3330,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
final boolean wasDefault = isDefaultNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
mNetworkForNetId.remove(nai.network.netId);
|
mNetworkForNetId.remove(nai.network.getNetId());
|
||||||
}
|
}
|
||||||
mNetIdManager.releaseNetId(nai.network.netId);
|
mNetIdManager.releaseNetId(nai.network.getNetId());
|
||||||
// Just in case.
|
// Just in case.
|
||||||
mLegacyTypeTracker.remove(nai, wasDefault);
|
mLegacyTypeTracker.remove(nai, wasDefault);
|
||||||
}
|
}
|
||||||
@@ -3362,7 +3362,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
log(nai.toShortString() + " disconnected, was satisfying " + nai.numNetworkRequests());
|
log(nai.toShortString() + " disconnected, was satisfying " + nai.numNetworkRequests());
|
||||||
}
|
}
|
||||||
// Clear all notifications of this network.
|
// Clear all notifications of this network.
|
||||||
mNotifier.clearNotification(nai.network.netId);
|
mNotifier.clearNotification(nai.network.getNetId());
|
||||||
// A network agent has disconnected.
|
// A network agent has disconnected.
|
||||||
// TODO - if we move the logic to the network agent (have them disconnect
|
// TODO - if we move the logic to the network agent (have them disconnect
|
||||||
// because they lost all their requests or because their score isn't good)
|
// because they lost all their requests or because their score isn't good)
|
||||||
@@ -3399,14 +3399,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
// Remove the NetworkAgent, but don't mark the netId as
|
// Remove the NetworkAgent, but don't mark the netId as
|
||||||
// available until we've told netd to delete it below.
|
// available until we've told netd to delete it below.
|
||||||
mNetworkForNetId.remove(nai.network.netId);
|
mNetworkForNetId.remove(nai.network.getNetId());
|
||||||
}
|
}
|
||||||
// Remove all previously satisfied requests.
|
// Remove all previously satisfied requests.
|
||||||
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
for (int i = 0; i < nai.numNetworkRequests(); i++) {
|
||||||
NetworkRequest request = nai.requestAt(i);
|
NetworkRequest request = nai.requestAt(i);
|
||||||
final NetworkRequestInfo nri = mNetworkRequests.get(request);
|
final NetworkRequestInfo nri = mNetworkRequests.get(request);
|
||||||
final NetworkAgentInfo currentNetwork = nri.mSatisfier;
|
final NetworkAgentInfo currentNetwork = nri.mSatisfier;
|
||||||
if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) {
|
if (currentNetwork != null
|
||||||
|
&& currentNetwork.network.getNetId() == nai.network.getNetId()) {
|
||||||
nri.mSatisfier = null;
|
nri.mSatisfier = null;
|
||||||
sendUpdatedScoreToFactories(request, null);
|
sendUpdatedScoreToFactories(request, null);
|
||||||
}
|
}
|
||||||
@@ -3436,26 +3437,26 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
destroyNativeNetwork(nai);
|
destroyNativeNetwork(nai);
|
||||||
mDnsManager.removeNetwork(nai.network);
|
mDnsManager.removeNetwork(nai.network);
|
||||||
}
|
}
|
||||||
mNetIdManager.releaseNetId(nai.network.netId);
|
mNetIdManager.releaseNetId(nai.network.getNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
private boolean createNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
||||||
try {
|
try {
|
||||||
// This should never fail. Specifying an already in use NetID will cause failure.
|
// This should never fail. Specifying an already in use NetID will cause failure.
|
||||||
if (networkAgent.isVPN()) {
|
if (networkAgent.isVPN()) {
|
||||||
mNetd.networkCreateVpn(networkAgent.network.netId,
|
mNetd.networkCreateVpn(networkAgent.network.getNetId(),
|
||||||
(networkAgent.networkAgentConfig == null
|
(networkAgent.networkAgentConfig == null
|
||||||
|| !networkAgent.networkAgentConfig.allowBypass));
|
|| !networkAgent.networkAgentConfig.allowBypass));
|
||||||
} else {
|
} else {
|
||||||
mNetd.networkCreatePhysical(networkAgent.network.netId,
|
mNetd.networkCreatePhysical(networkAgent.network.getNetId(),
|
||||||
getNetworkPermission(networkAgent.networkCapabilities));
|
getNetworkPermission(networkAgent.networkCapabilities));
|
||||||
}
|
}
|
||||||
mDnsResolver.createNetworkCache(networkAgent.network.netId);
|
mDnsResolver.createNetworkCache(networkAgent.network.getNetId());
|
||||||
mDnsManager.updateTransportsForNetwork(networkAgent.network.netId,
|
mDnsManager.updateTransportsForNetwork(networkAgent.network.getNetId(),
|
||||||
networkAgent.networkCapabilities.getTransportTypes());
|
networkAgent.networkCapabilities.getTransportTypes());
|
||||||
return true;
|
return true;
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
loge("Error creating network " + networkAgent.network.netId + ": "
|
loge("Error creating network " + networkAgent.network.getNetId() + ": "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3463,8 +3464,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private void destroyNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
private void destroyNativeNetwork(@NonNull NetworkAgentInfo networkAgent) {
|
||||||
try {
|
try {
|
||||||
mNetd.networkDestroy(networkAgent.network.netId);
|
mNetd.networkDestroy(networkAgent.network.getNetId());
|
||||||
mDnsResolver.destroyNetworkCache(networkAgent.network.netId);
|
mDnsResolver.destroyNetworkCache(networkAgent.network.getNetId());
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
loge("Exception destroying network: " + e);
|
loge("Exception destroying network: " + e);
|
||||||
}
|
}
|
||||||
@@ -4026,7 +4027,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
Intent intent = new Intent(action);
|
Intent intent = new Intent(action);
|
||||||
if (type != NotificationType.PRIVATE_DNS_BROKEN) {
|
if (type != NotificationType.PRIVATE_DNS_BROKEN) {
|
||||||
intent.setData(Uri.fromParts("netId", Integer.toString(nai.network.netId), null));
|
intent.setData(Uri.fromParts("netId", Integer.toString(nai.network.getNetId()), null));
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
// Some OEMs have their own Settings package. Thus, need to get the current using
|
// Some OEMs have their own Settings package. Thus, need to get the current using
|
||||||
// Settings package name instead of just use default name "com.android.settings".
|
// Settings package name instead of just use default name "com.android.settings".
|
||||||
@@ -4041,7 +4042,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
intent,
|
intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
|
||||||
mNotifier.showNotification(nai.network.netId, type, nai, null, pendingIntent, highPriority);
|
mNotifier.showNotification(
|
||||||
|
nai.network.getNetId(), type, nai, null, pendingIntent, highPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldPromptUnvalidated(NetworkAgentInfo nai) {
|
private boolean shouldPromptUnvalidated(NetworkAgentInfo nai) {
|
||||||
@@ -4407,7 +4409,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
int netid = nai.network.netId;
|
int netid = nai.network.getNetId();
|
||||||
log("reportNetworkConnectivity(" + netid + ", " + hasConnectivity + ") by " + uid);
|
log("reportNetworkConnectivity(" + netid + ", " + hasConnectivity + ") by " + uid);
|
||||||
}
|
}
|
||||||
// Validating a network that has not yet connected could result in a call to
|
// Validating a network that has not yet connected could result in a call to
|
||||||
@@ -4442,7 +4444,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return getLinkPropertiesProxyInfo(activeNetwork);
|
return getLinkPropertiesProxyInfo(activeNetwork);
|
||||||
} else if (mDeps.queryUserAccess(Binder.getCallingUid(), network.netId)) {
|
} else if (mDeps.queryUserAccess(Binder.getCallingUid(), network.getNetId())) {
|
||||||
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
|
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
|
||||||
// caller may not have.
|
// caller may not have.
|
||||||
return getLinkPropertiesProxyInfo(network);
|
return getLinkPropertiesProxyInfo(network);
|
||||||
@@ -5653,7 +5655,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
nai = mNetworkForNetId.get(network.netId);
|
nai = mNetworkForNetId.get(network.getNetId());
|
||||||
}
|
}
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
nai.asyncChannel.sendMessage(android.net.NetworkAgent.CMD_REQUEST_BANDWIDTH_UPDATE);
|
nai.asyncChannel.sendMessage(android.net.NetworkAgent.CMD_REQUEST_BANDWIDTH_UPDATE);
|
||||||
@@ -6033,7 +6035,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (VDBG) log("Got NetworkAgent Messenger");
|
if (VDBG) log("Got NetworkAgent Messenger");
|
||||||
mNetworkAgentInfos.put(nai.messenger, nai);
|
mNetworkAgentInfos.put(nai.messenger, nai);
|
||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
mNetworkForNetId.put(nai.network.netId, nai);
|
mNetworkForNetId.put(nai.network.getNetId(), nai);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -6061,7 +6063,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private void updateLinkProperties(NetworkAgentInfo networkAgent, LinkProperties newLp,
|
private void updateLinkProperties(NetworkAgentInfo networkAgent, LinkProperties newLp,
|
||||||
@NonNull LinkProperties oldLp) {
|
@NonNull LinkProperties oldLp) {
|
||||||
int netId = networkAgent.network.netId;
|
int netId = networkAgent.network.getNetId();
|
||||||
|
|
||||||
// The NetworkAgent does not know whether clatd is running on its network or not, or whether
|
// The NetworkAgent does not know whether clatd is running on its network or not, or whether
|
||||||
// a NAT64 prefix was discovered by the DNS resolver. Before we do anything else, make sure
|
// a NAT64 prefix was discovered by the DNS resolver. Before we do anything else, make sure
|
||||||
@@ -6342,7 +6344,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
final int newPermission = getNetworkPermission(newNc);
|
final int newPermission = getNetworkPermission(newNc);
|
||||||
if (oldPermission != newPermission && nai.created && !nai.isVPN()) {
|
if (oldPermission != newPermission && nai.created && !nai.isVPN()) {
|
||||||
try {
|
try {
|
||||||
mNetd.networkSetPermissionForNetwork(nai.network.netId, newPermission);
|
mNetd.networkSetPermissionForNetwork(nai.network.getNetId(), newPermission);
|
||||||
} catch (RemoteException | ServiceSpecificException e) {
|
} catch (RemoteException | ServiceSpecificException e) {
|
||||||
loge("Exception in networkSetPermissionForNetwork: " + e);
|
loge("Exception in networkSetPermissionForNetwork: " + e);
|
||||||
}
|
}
|
||||||
@@ -6567,7 +6569,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!newNc.equalsTransportTypes(prevNc)) {
|
if (!newNc.equalsTransportTypes(prevNc)) {
|
||||||
mDnsManager.updateTransportsForNetwork(nai.network.netId, newNc.getTransportTypes());
|
mDnsManager.updateTransportsForNetwork(
|
||||||
|
nai.network.getNetId(), newNc.getTransportTypes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6621,12 +6624,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (!newRanges.isEmpty()) {
|
if (!newRanges.isEmpty()) {
|
||||||
final UidRange[] addedRangesArray = new UidRange[newRanges.size()];
|
final UidRange[] addedRangesArray = new UidRange[newRanges.size()];
|
||||||
newRanges.toArray(addedRangesArray);
|
newRanges.toArray(addedRangesArray);
|
||||||
mNMS.addVpnUidRanges(nai.network.netId, addedRangesArray);
|
mNMS.addVpnUidRanges(nai.network.getNetId(), addedRangesArray);
|
||||||
}
|
}
|
||||||
if (!prevRanges.isEmpty()) {
|
if (!prevRanges.isEmpty()) {
|
||||||
final UidRange[] removedRangesArray = new UidRange[prevRanges.size()];
|
final UidRange[] removedRangesArray = new UidRange[prevRanges.size()];
|
||||||
prevRanges.toArray(removedRangesArray);
|
prevRanges.toArray(removedRangesArray);
|
||||||
mNMS.removeVpnUidRanges(nai.network.netId, removedRangesArray);
|
mNMS.removeVpnUidRanges(nai.network.getNetId(), removedRangesArray);
|
||||||
}
|
}
|
||||||
final boolean wasFiltering = requiresVpnIsolation(nai, prevNc, nai.linkProperties);
|
final boolean wasFiltering = requiresVpnIsolation(nai, prevNc, nai.linkProperties);
|
||||||
final boolean shouldFilter = requiresVpnIsolation(nai, newNc, nai.linkProperties);
|
final boolean shouldFilter = requiresVpnIsolation(nai, newNc, nai.linkProperties);
|
||||||
@@ -6657,7 +6660,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
public void handleUpdateLinkProperties(NetworkAgentInfo nai, LinkProperties newLp) {
|
public void handleUpdateLinkProperties(NetworkAgentInfo nai, LinkProperties newLp) {
|
||||||
ensureRunningOnConnectivityServiceThread();
|
ensureRunningOnConnectivityServiceThread();
|
||||||
|
|
||||||
if (getNetworkAgentInfoForNetId(nai.network.netId) != nai) {
|
if (getNetworkAgentInfoForNetId(nai.network.getNetId()) != nai) {
|
||||||
// Ignore updates for disconnected networks
|
// Ignore updates for disconnected networks
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -6868,7 +6871,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (null != newNetwork) {
|
if (null != newNetwork) {
|
||||||
mNetd.networkSetDefault(newNetwork.network.netId);
|
mNetd.networkSetDefault(newNetwork.network.getNetId());
|
||||||
} else {
|
} else {
|
||||||
mNetd.networkClearDefault();
|
mNetd.networkClearDefault();
|
||||||
}
|
}
|
||||||
@@ -6931,8 +6934,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return mRequest.mRequests.get(0).requestId + " : "
|
return mRequest.mRequests.get(0).requestId + " : "
|
||||||
+ (null != mOldNetwork ? mOldNetwork.network.netId : "null")
|
+ (null != mOldNetwork ? mOldNetwork.network.getNetId() : "null")
|
||||||
+ " → " + (null != mNewNetwork ? mNewNetwork.network.netId : "null");
|
+ " → " + (null != mNewNetwork ? mNewNetwork.network.getNetId() : "null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7796,7 +7799,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
private void logNetworkEvent(NetworkAgentInfo nai, int evtype) {
|
private void logNetworkEvent(NetworkAgentInfo nai, int evtype) {
|
||||||
int[] transports = nai.networkCapabilities.getTransportTypes();
|
int[] transports = nai.networkCapabilities.getTransportTypes();
|
||||||
mMetricsLog.log(nai.network.netId, transports, new NetworkEvent(evtype));
|
mMetricsLog.log(nai.network.getNetId(), transports, new NetworkEvent(evtype));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean toBool(int encodedBoolean) {
|
private static boolean toBool(int encodedBoolean) {
|
||||||
@@ -8418,6 +8421,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
KEY_TCP_METRICS_COLLECTION_PERIOD_MILLIS);
|
KEY_TCP_METRICS_COLLECTION_PERIOD_MILLIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDataStallSuspected(p, network.netId);
|
notifyDataStallSuspected(p, network.getNetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
|||||||
// Has to be in TestNetworkAgent to ensure all teardown codepaths properly clean up
|
// Has to be in TestNetworkAgent to ensure all teardown codepaths properly clean up
|
||||||
// resources, even for binder death or unwanted calls.
|
// resources, even for binder death or unwanted calls.
|
||||||
synchronized (mTestNetworkTracker) {
|
synchronized (mTestNetworkTracker) {
|
||||||
mTestNetworkTracker.remove(getNetwork().netId);
|
mTestNetworkTracker.remove(getNetwork().getNetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
|
|||||||
administratorUids,
|
administratorUids,
|
||||||
binder);
|
binder);
|
||||||
|
|
||||||
mTestNetworkTracker.put(agent.getNetwork().netId, agent);
|
mTestNetworkTracker.put(agent.getNetwork().getNetId(), agent);
|
||||||
}
|
}
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulate the management of DNS settings for networks.
|
* Encapsulate the management of DNS settings for networks.
|
||||||
*
|
*
|
||||||
@@ -266,23 +265,23 @@ public class DnsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeNetwork(Network network) {
|
public void removeNetwork(Network network) {
|
||||||
mPrivateDnsMap.remove(network.netId);
|
mPrivateDnsMap.remove(network.getNetId());
|
||||||
mPrivateDnsValidationMap.remove(network.netId);
|
mPrivateDnsValidationMap.remove(network.getNetId());
|
||||||
mTransportsMap.remove(network.netId);
|
mTransportsMap.remove(network.getNetId());
|
||||||
mLinkPropertiesMap.remove(network.netId);
|
mLinkPropertiesMap.remove(network.getNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is exclusively called by ConnectivityService#dumpNetworkDiagnostics() which
|
// This is exclusively called by ConnectivityService#dumpNetworkDiagnostics() which
|
||||||
// is not on the ConnectivityService handler thread.
|
// is not on the ConnectivityService handler thread.
|
||||||
public PrivateDnsConfig getPrivateDnsConfig(@NonNull Network network) {
|
public PrivateDnsConfig getPrivateDnsConfig(@NonNull Network network) {
|
||||||
return mPrivateDnsMap.getOrDefault(network.netId, PRIVATE_DNS_OFF);
|
return mPrivateDnsMap.getOrDefault(network.getNetId(), PRIVATE_DNS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrivateDnsConfig updatePrivateDns(Network network, PrivateDnsConfig cfg) {
|
public PrivateDnsConfig updatePrivateDns(Network network, PrivateDnsConfig cfg) {
|
||||||
Log.w(TAG, "updatePrivateDns(" + network + ", " + cfg + ")");
|
Log.w(TAG, "updatePrivateDns(" + network + ", " + cfg + ")");
|
||||||
return (cfg != null)
|
return (cfg != null)
|
||||||
? mPrivateDnsMap.put(network.netId, cfg)
|
? mPrivateDnsMap.put(network.getNetId(), cfg)
|
||||||
: mPrivateDnsMap.remove(network.netId);
|
: mPrivateDnsMap.remove(network.getNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrivateDnsStatus(int netId, LinkProperties lp) {
|
public void updatePrivateDnsStatus(int netId, LinkProperties lp) {
|
||||||
@@ -309,8 +308,7 @@ public class DnsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrivateDnsValidation(PrivateDnsValidationUpdate update) {
|
public void updatePrivateDnsValidation(PrivateDnsValidationUpdate update) {
|
||||||
final PrivateDnsValidationStatuses statuses =
|
final PrivateDnsValidationStatuses statuses = mPrivateDnsValidationMap.get(update.netId);
|
||||||
mPrivateDnsValidationMap.get(update.netId);
|
|
||||||
if (statuses == null) return;
|
if (statuses == null) return;
|
||||||
statuses.updateStatus(update);
|
statuses.updateStatus(update);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class LingerMonitor {
|
|||||||
|
|
||||||
private int getNotificationSource(NetworkAgentInfo toNai) {
|
private int getNotificationSource(NetworkAgentInfo toNai) {
|
||||||
for (int i = 0; i < mNotifications.size(); i++) {
|
for (int i = 0; i < mNotifications.size(); i++) {
|
||||||
if (mNotifications.valueAt(i) == toNai.network.netId) {
|
if (mNotifications.valueAt(i) == toNai.network.getNetId()) {
|
||||||
return mNotifications.keyAt(i);
|
return mNotifications.keyAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ public class LingerMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean everNotified(NetworkAgentInfo nai) {
|
private boolean everNotified(NetworkAgentInfo nai) {
|
||||||
return mEverNotified.get(nai.network.netId, false);
|
return mEverNotified.get(nai.network.getNetId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -153,7 +153,7 @@ public class LingerMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showNotification(NetworkAgentInfo fromNai, NetworkAgentInfo toNai) {
|
private void showNotification(NetworkAgentInfo fromNai, NetworkAgentInfo toNai) {
|
||||||
mNotifier.showNotification(fromNai.network.netId, NotificationType.NETWORK_SWITCH,
|
mNotifier.showNotification(fromNai.network.getNetId(), NotificationType.NETWORK_SWITCH,
|
||||||
fromNai, toNai, createNotificationIntent(), true);
|
fromNai, toNai, createNotificationIntent(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,8 +208,8 @@ public class LingerMonitor {
|
|||||||
+ " type=" + sNotifyTypeNames.get(notifyType, "unknown(" + notifyType + ")"));
|
+ " type=" + sNotifyTypeNames.get(notifyType, "unknown(" + notifyType + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mNotifications.put(fromNai.network.netId, toNai.network.netId);
|
mNotifications.put(fromNai.network.getNetId(), toNai.network.getNetId());
|
||||||
mEverNotified.put(fromNai.network.netId, true);
|
mEverNotified.put(fromNai.network.getNetId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,8 +295,8 @@ public class LingerMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void noteDisconnect(NetworkAgentInfo nai) {
|
public void noteDisconnect(NetworkAgentInfo nai) {
|
||||||
mNotifications.delete(nai.network.netId);
|
mNotifications.delete(nai.network.getNetId());
|
||||||
mEverNotified.delete(nai.network.netId);
|
mEverNotified.delete(nai.network.getNetId());
|
||||||
maybeStopNotifying(nai);
|
maybeStopNotifying(nai);
|
||||||
// No need to cancel notifications on nai: NetworkMonitor does that on disconnect.
|
// No need to cancel notifications on nai: NetworkMonitor does that on disconnect.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -528,6 +528,6 @@ public class Nat464Xlat extends BaseNetworkObserver {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected int getNetId() {
|
protected int getNetId() {
|
||||||
return mNetwork.network.netId;
|
return mNetwork.network.getNetId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
if (newExpiry > 0) {
|
if (newExpiry > 0) {
|
||||||
mLingerMessage = new WakeupMessage(
|
mLingerMessage = new WakeupMessage(
|
||||||
mContext, mHandler,
|
mContext, mHandler,
|
||||||
"NETWORK_LINGER_COMPLETE." + network.netId /* cmdName */,
|
"NETWORK_LINGER_COMPLETE." + network.getNetId() /* cmdName */,
|
||||||
EVENT_NETWORK_LINGER_COMPLETE /* cmd */,
|
EVENT_NETWORK_LINGER_COMPLETE /* cmd */,
|
||||||
0 /* arg1 (unused) */, 0 /* arg2 (unused) */,
|
0 /* arg1 (unused) */, 0 /* arg2 (unused) */,
|
||||||
this /* obj (NetworkAgentInfo) */);
|
this /* obj (NetworkAgentInfo) */);
|
||||||
@@ -701,7 +701,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
* This represents the network with something like "[100 WIFI|VPN]" or "[108 MOBILE]".
|
* This represents the network with something like "[100 WIFI|VPN]" or "[108 MOBILE]".
|
||||||
*/
|
*/
|
||||||
public String toShortString() {
|
public String toShortString() {
|
||||||
return "[" + network.netId + " "
|
return "[" + network.getNetId() + " "
|
||||||
+ transportNamesOf(networkCapabilities.getTransportTypes()) + "]";
|
+ transportNamesOf(networkCapabilities.getTransportTypes()) + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user