summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/ConnectivityService.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-08-04 15:24:58 -0700
committerJeff Sharkey <jsharkey@android.com>2012-08-23 16:41:06 -0700
commit899223b97c9b0ae56a8211a46600914c0ecfd854 (patch)
tree19b98a147be6309366dc1652f17e9fe3fe6f6e63 /services/java/com/android/server/ConnectivityService.java
parent2c1dfa29b40a988e3ea8f6922768465743aafddc (diff)
Begin moving VPN to NetworkStateTracker pattern.
Created base tracker that handles common bookkeeping, and move VPN to become a tracker. VPN status is now reflected in NetworkInfo, and is mapped to LegacyVpnInfo. Legacy VPN now "babysits" any init services it starts, watching for when they stop unexpectedly. Bug: 5756357 Change-Id: Iba7ec79da69469f6bd9a970cc39cf6b885b4c9c4
Diffstat (limited to 'services/java/com/android/server/ConnectivityService.java')
-rw-r--r--services/java/com/android/server/ConnectivityService.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index cb6ce4b3b2fb..d0db0d2e0690 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -115,13 +115,15 @@ import java.util.List;
* @hide
*/
public class ConnectivityService extends IConnectivityManager.Stub {
+ private static final String TAG = "ConnectivityService";
private static final boolean DBG = true;
private static final boolean VDBG = false;
- private static final String TAG = "ConnectivityService";
private static final boolean LOGD_RULES = false;
+ // TODO: create better separation between radio types and network types
+
// how long to wait before switching back to a radio's default network
private static final int RESTORE_DEFAULT_NETWORK_DELAY = 1 * 60 * 1000;
// system property that can override the above value
@@ -136,6 +138,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private boolean mTetheringConfigValid = false;
private Vpn mVpn;
+ private VpnCallback mVpnCallback = new VpnCallback();
/** Lock around {@link #mUidRules} and {@link #mMeteredIfaces}. */
private Object mRulesLock = new Object();
@@ -328,7 +331,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
this(context, netd, statsService, policyManager, null);
}
- public ConnectivityService(Context context, INetworkManagementService netd,
+ public ConnectivityService(Context context, INetworkManagementService netManager,
INetworkStatsService statsService, INetworkPolicyManager policyManager,
NetworkFactory netFactory) {
if (DBG) log("ConnectivityService starting up");
@@ -366,7 +369,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
mContext = checkNotNull(context, "missing Context");
- mNetd = checkNotNull(netd, "missing INetworkManagementService");
+ mNetd = checkNotNull(netManager, "missing INetworkManagementService");
mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager");
try {
@@ -506,11 +509,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mTethering.getTetherableBluetoothRegexs().length != 0) &&
mTethering.getUpstreamIfaceTypes().length != 0);
- mVpn = new Vpn(mContext, new VpnCallback());
+ mVpn = new Vpn(mContext, mVpnCallback, mNetd);
+ mVpn.startMonitoring(mContext, mTrackerHandler);
try {
mNetd.registerObserver(mTethering);
- mNetd.registerObserver(mVpn);
mNetd.registerObserver(mDataActivityObserver);
} catch (RemoteException e) {
loge("Error registering observer :" + e);
@@ -2238,9 +2241,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
*/
public void updateNetworkSettings(NetworkStateTracker nt) {
String key = nt.getTcpBufferSizesPropName();
- String bufferSizes = SystemProperties.get(key);
+ String bufferSizes = key == null ? null : SystemProperties.get(key);
- if (bufferSizes.length() == 0) {
+ if (TextUtils.isEmpty(bufferSizes)) {
if (VDBG) log(key + " not found in system properties. Using defaults");
// Setting to default values so we won't be stuck to previous values
@@ -3153,10 +3156,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
* be done whenever a better abstraction is developed.
*/
public class VpnCallback {
-
private VpnCallback() {
}
+ public void onStateChanged(NetworkInfo info) {
+ // TODO: if connected, release delayed broadcast
+ // TODO: if disconnected, consider kicking off reconnect
+ }
+
public void override(List<String> dnsServers, List<String> searchDomains) {
if (dnsServers == null) {
restore();