diff options
author | Paul Jensen <pauljensen@google.com> | 2015-05-13 14:05:12 -0400 |
---|---|---|
committer | Paul Jensen <pauljensen@google.com> | 2015-06-04 09:09:36 -0400 |
commit | d7b6ca91e9ecac15949a4484d560cfab5833a431 (patch) | |
tree | 72a4c8698a7bdf1c2a28ebf7e90988235bf38703 /services/core/java/com/android/server/connectivity/NetworkMonitor.java | |
parent | e247cdec6db549035b67bb21fa08a4c6c73897d3 (diff) | |
download | frameworks_base-d7b6ca91e9ecac15949a4484d560cfab5833a431.zip frameworks_base-d7b6ca91e9ecac15949a4484d560cfab5833a431.tar.gz frameworks_base-d7b6ca91e9ecac15949a4484d560cfab5833a431.tar.bz2 |
Revive ConnectivityServiceTest and add some tests.
Change-Id: I44740a7b21cff18ac2a67d09c4d0e597add19ee0
Diffstat (limited to 'services/core/java/com/android/server/connectivity/NetworkMonitor.java')
-rw-r--r-- | services/core/java/com/android/server/connectivity/NetworkMonitor.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java index bf896a5..fc50e2c 100644 --- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java +++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java @@ -32,6 +32,7 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Message; +import android.os.Process; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; @@ -48,6 +49,7 @@ import android.telephony.CellInfoWcdma; import android.telephony.TelephonyManager; import android.util.Log; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Protocol; import com.android.internal.util.State; import com.android.internal.util.StateMachine; @@ -177,8 +179,8 @@ public class NetworkMonitor extends StateMachine { private static final int CMD_LAUNCH_CAPTIVE_PORTAL_APP = BASE + 11; private static final String LINGER_DELAY_PROPERTY = "persist.netmon.linger"; - // Default to 30s linger time-out. - private static final int DEFAULT_LINGER_DELAY_MS = 30000; + // Default to 30s linger time-out. Modifyable only for testing. + private static int DEFAULT_LINGER_DELAY_MS = 30000; private final int mLingerDelayMs; private int mLingerToken = 0; @@ -771,4 +773,13 @@ public class NetworkMonitor extends StateMachine { mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT, PERMISSION_ACCESS_NETWORK_CONDITIONS); } + + // Allow tests to override linger time. + @VisibleForTesting + public static void SetDefaultLingerTime(int time_ms) { + if (Process.myUid() == Process.SYSTEM_UID) { + throw new SecurityException("SetDefaultLingerTime only for internal testing."); + } + DEFAULT_LINGER_DELAY_MS = time_ms; + } } |