Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4962134 authored by Cody Kesting's avatar Cody Kesting Committed by Automerger Merge Worker
Browse files

Merge "Forward unknown Data Stall types to Connectivity Diagnostics." am:...

Merge "Forward unknown Data Stall types to Connectivity Diagnostics." am: 54d9df0f am: 3e089515 am: a4b2c9a6

Change-Id: I33a89a56431f168f7bfeb72e2eabef9010685940
parents ef5df706 a4b2c9a6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ public class ConnectivityDiagnosticsManager {
         */
        private long mReportTimestamp;

        /** The detection method used to identify the suspected data stall */
        /** A bitmask of the detection methods used to identify the suspected data stall */
        @DetectionMethod private final int mDetectionMethod;

        /** LinkProperties available on the Network at the reported timestamp */
@@ -499,9 +499,9 @@ public class ConnectivityDiagnosticsManager {
        }

        /**
         * Returns the detection method used to identify this suspected data stall.
         * Returns the bitmask of detection methods used to identify this suspected data stall.
         *
         * @return The detection method used to identify the suspected data stall
         * @return The bitmask of detection methods used to identify the suspected data stall
         */
        public int getDetectionMethod() {
            return mDetectionMethod;
+31 −20
Original line number Diff line number Diff line
@@ -3103,30 +3103,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
    }

    private void notifyDataStallSuspected(DataStallReportParcelable p, int netId) {
        log("Data stall detected with methods: " + p.detectionMethod);

        final PersistableBundle extras = new PersistableBundle();
        switch (p.detectionMethod) {
            case DETECTION_METHOD_DNS_EVENTS:
        int detectionMethod = 0;
        if (hasDataStallDetectionMethod(p, DETECTION_METHOD_DNS_EVENTS)) {
            extras.putInt(KEY_DNS_CONSECUTIVE_TIMEOUTS, p.dnsConsecutiveTimeouts);
                break;
            case DETECTION_METHOD_TCP_METRICS:
            detectionMethod |= DETECTION_METHOD_DNS_EVENTS;
        }
        if (hasDataStallDetectionMethod(p, 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);
            detectionMethod |= DETECTION_METHOD_TCP_METRICS;
        }

    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);
                p.timestampMillis);
        msg.setData(new Bundle(extras));

        // NetworkStateTrackerHandler currently doesn't take any actions based on data
@@ -3135,6 +3129,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
        mConnectivityDiagnosticsHandler.sendMessage(msg);
    }

    private boolean hasDataStallDetectionMethod(DataStallReportParcelable p, int detectionMethod) {
        return (p.detectionMethod & detectionMethod) != 0;
    }

    private boolean networkRequiresPrivateDnsValidation(NetworkAgentInfo nai) {
        return isPrivateDnsValidationRequired(nai.networkCapabilities);
    }
@@ -8194,6 +8192,19 @@ public class ConnectivityService extends IConnectivityManager.Stub
                + "creators");
        }

        notifyDataStallSuspected(detectionMethod, network.netId, timestampMillis, extras);
        final DataStallReportParcelable p = new DataStallReportParcelable();
        p.timestampMillis = timestampMillis;
        p.detectionMethod = detectionMethod;

        if (hasDataStallDetectionMethod(p, DETECTION_METHOD_DNS_EVENTS)) {
            p.dnsConsecutiveTimeouts = extras.getInt(KEY_DNS_CONSECUTIVE_TIMEOUTS);
        }
        if (hasDataStallDetectionMethod(p, DETECTION_METHOD_TCP_METRICS)) {
            p.tcpPacketFailRate = extras.getInt(KEY_TCP_PACKET_FAIL_RATE);
            p.tcpMetricsCollectionPeriodMillis = extras.getInt(
                    KEY_TCP_METRICS_COLLECTION_PERIOD_MILLIS);
        }

        notifyDataStallSuspected(p, network.netId);
    }
}