summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCody Kesting <ckesting@google.com>2020-01-06 15:51:59 -0800
committerCody Kesting <ckesting@google.com>2020-02-05 11:49:33 -0800
commit782cbfa3fb32bbfe42288c3767ee262c187b04d2 (patch)
tree918e81aaa35d3585ad2d7eb26676c8ee67d284c0 /src
parent33f2e3bc19a9d33f244939f8d04dc006b83aed1e (diff)
Define callback for suspected data stall.
Currently, NetworkStack does not notify ConnectivityService explicitly when it detects a potential data stall. This adds a new method notifyDataStallSuspected() to INetworkMonitorCallbacks for notifying ConnectivityService. ConstantsShim is defined for using constants from the Android platform that are introduced after the NetworkStack mainline module was defined. Bug: 143187964 Test: compiles Test: atest NetworkStackTests Change-Id: Ie3b5b4e71e4a4b15a5a84f761eaead3acf6fc807 Merged-In: Ie3b5b4e71e4a4b15a5a84f761eaead3acf6fc807
Diffstat (limited to 'src')
-rw-r--r--src/com/android/server/connectivity/NetworkMonitor.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java
index a4f934f..3a3f95c 100644
--- a/src/com/android/server/connectivity/NetworkMonitor.java
+++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -68,6 +68,8 @@ import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USE_HTTPS;
import static android.net.util.NetworkStackUtils.isEmpty;
import static android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY;
+import static com.android.networkstack.apishim.ConstantsShim.DETECTION_METHOD_DNS_EVENTS;
+import static com.android.networkstack.apishim.ConstantsShim.DETECTION_METHOD_TCP_METRICS;
import static com.android.networkstack.util.DnsUtils.PRIVATE_DNS_PROBE_HOST_SUFFIX;
import static com.android.networkstack.util.DnsUtils.TYPE_ADDRCONFIG;
@@ -103,6 +105,7 @@ import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
+import android.os.PersistableBundle;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -613,6 +616,15 @@ public class NetworkMonitor extends StateMachine {
}
}
+ private void notifyDataStallSuspected(int detectionMethod, PersistableBundle extras) {
+ try {
+ mCallback.notifyDataStallSuspected(
+ SystemClock.elapsedRealtime(), detectionMethod, extras);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error sending notification for suspected data stall", e);
+ }
+ }
+
// DefaultState is the parent of all States. It exists only to handle CMD_* messages but
// does not entail any real state (hence no enter() or exit() routines).
private class DefaultState extends State {
@@ -2275,6 +2287,9 @@ public class NetworkMonitor extends StateMachine {
result = false;
} else if (tst.isDataStallSuspected()) {
result = true;
+
+ // TODO(b/147249364): add metrics to PersistableBundle once keys are defined
+ notifyDataStallSuspected(DETECTION_METHOD_TCP_METRICS, PersistableBundle.EMPTY);
}
if (DBG || VDBG_STALL) {
msg.add("tcp packets received=" + tst.getLatestReceivedCount())
@@ -2292,6 +2307,9 @@ public class NetworkMonitor extends StateMachine {
mDataStallValidDnsTimeThreshold)) {
result = true;
logNetworkEvent(NetworkEvent.NETWORK_CONSECUTIVE_DNS_TIMEOUT_FOUND);
+
+ // TODO(b/147249364): add metrics to PersistableBundle once keys are defined
+ notifyDataStallSuspected(DETECTION_METHOD_DNS_EVENTS, PersistableBundle.EMPTY);
}
if (DBG || VDBG_STALL) {
msg.add("consecutive dns timeout count=" + dsd.getConsecutiveTimeoutCount());