Move Data Stall logic to CS from NetworkMonitorCallbacks.

This change moves the logic for handling Data Stall notifications from
NetworkMonitorCallbacks to ConnectivityService. This avoids duplicate
logic for managing data stall simulation requests from
ConnectivityManager. This also puts all of the logic for proxying Data
Stall notifications to the ConnectivityDiagnosticsHandler into one
place.

Bug: 148032944
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: Ie2f6a1a2376c5c452750ab417cb5e8c24fc44fc3
Merged-In: Ie2f6a1a2376c5c452750ab417cb5e8c24fc44fc3
(cherry picked from commit 745eaa39a3c9bcaaa61671f66d8c1180195c84c4)
This commit is contained in:
Cody Kesting
2020-05-18 18:57:14 +00:00
parent 8ed33c51f1
commit 15eb17c2fc

View File

@@ -3087,23 +3087,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@Override
public void notifyDataStallSuspected(DataStallReportParcelable p) {
final PersistableBundle extras = new PersistableBundle();
switch (p.detectionMethod) {
case DETECTION_METHOD_DNS_EVENTS:
extras.putInt(KEY_DNS_CONSECUTIVE_TIMEOUTS, p.dnsConsecutiveTimeouts);
break;
case DETECTION_METHOD_TCP_METRICS:
extras.putInt(KEY_TCP_PACKET_FAIL_RATE, p.tcpPacketFailRate);
extras.putInt(KEY_TCP_METRICS_COLLECTION_PERIOD_MILLIS,
p.tcpMetricsCollectionPeriodMillis);
break;
default:
log("Unknown data stall detection method, ignoring: " + p.detectionMethod);
return;
}
proxyDataStallToConnectivityDiagnosticsHandler(
p.detectionMethod, mNetId, p.timestampMillis, extras);
ConnectivityService.this.notifyDataStallSuspected(p, mNetId);
}
@Override
@@ -3117,11 +3101,31 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
private void proxyDataStallToConnectivityDiagnosticsHandler(int detectionMethod, int netId,
long timestampMillis, @NonNull PersistableBundle extras) {
private void notifyDataStallSuspected(DataStallReportParcelable p, int netId) {
final PersistableBundle extras = new PersistableBundle();
switch (p.detectionMethod) {
case DETECTION_METHOD_DNS_EVENTS:
extras.putInt(KEY_DNS_CONSECUTIVE_TIMEOUTS, p.dnsConsecutiveTimeouts);
break;
case DETECTION_METHOD_TCP_METRICS:
extras.putInt(KEY_TCP_PACKET_FAIL_RATE, p.tcpPacketFailRate);
extras.putInt(KEY_TCP_METRICS_COLLECTION_PERIOD_MILLIS,
p.tcpMetricsCollectionPeriodMillis);
break;
default:
// TODO(b/156294356): update for new data stall detection methods
log("Unknown data stall detection method, ignoring: " + p.detectionMethod);
return;
}
notifyDataStallSuspected(p.detectionMethod, netId, p.timestampMillis, extras);
}
private void notifyDataStallSuspected(int detectionMethod, int netId, long timestampMillis,
@NonNull PersistableBundle extras) {
final Message msg = mConnectivityDiagnosticsHandler.obtainMessage(
ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED,
detectionMethod, netId, timestampMillis);
ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED, detectionMethod, netId,
timestampMillis);
msg.setData(new Bundle(extras));
// NetworkStateTrackerHandler currently doesn't take any actions based on data
@@ -8177,7 +8181,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
+ "creators");
}
proxyDataStallToConnectivityDiagnosticsHandler(
detectionMethod, network.netId, timestampMillis, extras);
notifyDataStallSuspected(detectionMethod, network.netId, timestampMillis, extras);
}
}