summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-10-15 16:06:07 +0900
committerLorenzo Colitti <lorenzo@google.com>2014-10-16 01:16:50 +0900
commit0cb7903ddedbbb8a8171926e4460b74af589369d (patch)
treebfce69bec50b73a671b4acc4434f6dead4187fd0 /services
parent5873c3e862b83fb0c64b52b86bdd8f26ff8ffb5f (diff)
downloadframeworks_base-0cb7903ddedbbb8a8171926e4460b74af589369d.zip
frameworks_base-0cb7903ddedbbb8a8171926e4460b74af589369d.tar.gz
frameworks_base-0cb7903ddedbbb8a8171926e4460b74af589369d.tar.bz2
Propagate network state changes to the LockdownVpnTracker.
Bug: 17695048 Change-Id: I10378df0ab545729a6a315fd1bc8870cd98f47b3
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java21
-rw-r--r--services/core/java/com/android/server/net/LockdownVpnTracker.java13
2 files changed, 26 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index b29cdf4..6a6dcaf 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -2001,9 +2001,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} else if (state == NetworkInfo.State.CONNECTED) {
// handleConnect(info);
}
- if (mLockdownTracker != null) {
- mLockdownTracker.onNetworkInfoChanged(info);
- }
+ notifyLockdownVpn(null);
break;
}
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED: {
@@ -2126,6 +2124,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (nai.networkRequests.get(mDefaultRequest.requestId) != null) {
removeDataActivityTracking(nai);
mActiveDefaultNetwork = ConnectivityManager.TYPE_NONE;
+ notifyLockdownVpn(nai);
requestNetworkTransitionWakelock(nai.name());
}
for (NetworkAgentInfo networkToActivate : toActivate) {
@@ -3801,6 +3800,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} catch (Exception e) {
loge("Exception setting default network :" + e);
}
+ notifyLockdownVpn(newNetwork);
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
updateTcpBufferSizes(newNetwork);
}
@@ -3916,6 +3916,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
mDefaultInetConditionPublished = newNetwork.validated ? 100 : 0;
mLegacyTypeTracker.add(newNetwork.networkInfo.getType(), newNetwork);
+ notifyLockdownVpn(newNetwork);
}
}
}
@@ -4035,6 +4036,16 @@ public class ConnectivityService extends IConnectivityManager.Stub {
sendInetConditionBroadcast(nai.networkInfo);
}
+ private void notifyLockdownVpn(NetworkAgentInfo nai) {
+ if (mLockdownTracker != null) {
+ if (nai != null && nai.isVPN()) {
+ mLockdownTracker.onVpnStateChanged(nai.networkInfo);
+ } else {
+ mLockdownTracker.onNetworkInfoChanged();
+ }
+ }
+ }
+
private void updateNetworkInfo(NetworkAgentInfo networkAgent, NetworkInfo newInfo) {
NetworkInfo.State state = newInfo.getState();
NetworkInfo oldInfo = null;
@@ -4042,9 +4053,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
oldInfo = networkAgent.networkInfo;
networkAgent.networkInfo = newInfo;
}
- if (networkAgent.isVPN() && mLockdownTracker != null) {
- mLockdownTracker.onVpnStateChanged(newInfo);
- }
+ notifyLockdownVpn(networkAgent);
if (oldInfo != null && oldInfo.getState() == state) {
if (VDBG) log("ignoring duplicate network state non-change");
diff --git a/services/core/java/com/android/server/net/LockdownVpnTracker.java b/services/core/java/com/android/server/net/LockdownVpnTracker.java
index 04df3e7..e9c7751 100644
--- a/services/core/java/com/android/server/net/LockdownVpnTracker.java
+++ b/services/core/java/com/android/server/net/LockdownVpnTracker.java
@@ -25,6 +25,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.LinkAddress;
import android.net.NetworkInfo;
@@ -113,7 +114,6 @@ public class LockdownVpnTracker {
* connection when ready, or setting firewall rules once VPN is connected.
*/
private void handleStateChangedLocked() {
- Slog.d(TAG, "handleStateChanged()");
final NetworkInfo egressInfo = mConnService.getActiveNetworkInfoUnfiltered();
final LinkProperties egressProp = mConnService.getActiveLinkProperties();
@@ -126,6 +126,14 @@ public class LockdownVpnTracker {
|| State.DISCONNECTED.equals(egressInfo.getState());
final boolean egressChanged = egressProp == null
|| !TextUtils.equals(mAcceptedEgressIface, egressProp.getInterfaceName());
+
+ final String egressTypeName = (egressInfo == null) ?
+ null : ConnectivityManager.getNetworkTypeName(egressInfo.getType());
+ final String egressIface = (egressProp == null) ?
+ null : egressProp.getInterfaceName();
+ Slog.d(TAG, "handleStateChanged: egress=" + egressTypeName +
+ " " + mAcceptedEgressIface + "->" + egressIface);
+
if (egressDisconnected || egressChanged) {
clearSourceRulesLocked();
mAcceptedEgressIface = null;
@@ -252,6 +260,7 @@ public class LockdownVpnTracker {
}
public void reset() {
+ Slog.d(TAG, "reset()");
synchronized (mStateLock) {
// cycle tracker, reset error count, and trigger retry
shutdownLocked();
@@ -277,7 +286,7 @@ public class LockdownVpnTracker {
}
}
- public void onNetworkInfoChanged(NetworkInfo info) {
+ public void onNetworkInfoChanged() {
synchronized (mStateLock) {
handleStateChangedLocked();
}