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:
@@ -3087,23 +3087,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyDataStallSuspected(DataStallReportParcelable p) {
|
public void notifyDataStallSuspected(DataStallReportParcelable p) {
|
||||||
final PersistableBundle extras = new PersistableBundle();
|
ConnectivityService.this.notifyDataStallSuspected(p, mNetId);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3117,11 +3101,31 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void proxyDataStallToConnectivityDiagnosticsHandler(int detectionMethod, int netId,
|
private void notifyDataStallSuspected(DataStallReportParcelable p, int netId) {
|
||||||
long timestampMillis, @NonNull PersistableBundle extras) {
|
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(
|
final Message msg = mConnectivityDiagnosticsHandler.obtainMessage(
|
||||||
ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED,
|
ConnectivityDiagnosticsHandler.EVENT_DATA_STALL_SUSPECTED, detectionMethod, netId,
|
||||||
detectionMethod, netId, timestampMillis);
|
timestampMillis);
|
||||||
msg.setData(new Bundle(extras));
|
msg.setData(new Bundle(extras));
|
||||||
|
|
||||||
// NetworkStateTrackerHandler currently doesn't take any actions based on data
|
// NetworkStateTrackerHandler currently doesn't take any actions based on data
|
||||||
@@ -8177,7 +8181,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
+ "creators");
|
+ "creators");
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyDataStallToConnectivityDiagnosticsHandler(
|
notifyDataStallSuspected(detectionMethod, network.netId, timestampMillis, extras);
|
||||||
detectionMethod, network.netId, timestampMillis, extras);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user