Merge "ConnectivityService: safer locking" into oc-dev
am: 6120db5990 Change-Id: I1c22edc7a247d83d860e7016fe7edab1537c5bb7
This commit is contained in:
@@ -1261,14 +1261,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
@Override
|
@Override
|
||||||
public LinkProperties getLinkProperties(Network network) {
|
public LinkProperties getLinkProperties(Network network) {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
return getLinkProperties(getNetworkAgentInfoForNetwork(network));
|
||||||
if (nai != null) {
|
}
|
||||||
|
|
||||||
|
private LinkProperties getLinkProperties(NetworkAgentInfo nai) {
|
||||||
|
if (nai == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
synchronized (nai) {
|
synchronized (nai) {
|
||||||
return new LinkProperties(nai.linkProperties);
|
return new LinkProperties(nai.linkProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NetworkCapabilities getNetworkCapabilitiesInternal(NetworkAgentInfo nai) {
|
private NetworkCapabilities getNetworkCapabilitiesInternal(NetworkAgentInfo nai) {
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
@@ -3017,7 +3020,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
enforceInternetPermission();
|
enforceInternetPermission();
|
||||||
|
|
||||||
NetworkAgentInfo nai;
|
// TODO: execute this logic on ConnectivityService handler.
|
||||||
|
final NetworkAgentInfo nai;
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
nai = getDefaultNetwork();
|
nai = getDefaultNetwork();
|
||||||
} else {
|
} else {
|
||||||
@@ -3028,21 +3032,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Revalidate if the app report does not match our current validated state.
|
// Revalidate if the app report does not match our current validated state.
|
||||||
if (hasConnectivity == nai.lastValidated) return;
|
if (hasConnectivity == nai.lastValidated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int uid = Binder.getCallingUid();
|
final int uid = Binder.getCallingUid();
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("reportNetworkConnectivity(" + nai.network.netId + ", " + hasConnectivity +
|
log("reportNetworkConnectivity(" + nai.network.netId + ", " + hasConnectivity +
|
||||||
") by " + uid);
|
") by " + uid);
|
||||||
}
|
}
|
||||||
synchronized (nai) {
|
|
||||||
// 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
|
||||||
// rematchNetworkAndRequests() which is not meant to work on such networks.
|
// rematchNetworkAndRequests() which is not meant to work on such networks.
|
||||||
if (!nai.everConnected) return;
|
if (!nai.everConnected) {
|
||||||
|
return;
|
||||||
if (isNetworkWithLinkPropertiesBlocked(nai.linkProperties, uid, false)) return;
|
|
||||||
|
|
||||||
nai.networkMonitor.sendMessage(NetworkMonitor.CMD_FORCE_REEVALUATION, uid);
|
|
||||||
}
|
}
|
||||||
|
LinkProperties lp = getLinkProperties(nai);
|
||||||
|
if (isNetworkWithLinkPropertiesBlocked(lp, uid, false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nai.networkMonitor.sendMessage(NetworkMonitor.CMD_FORCE_REEVALUATION, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProxyInfo getDefaultProxy() {
|
private ProxyInfo getDefaultProxy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user