Search in sources :

Example 61 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project platform_frameworks_base by android.

the class IpConnectivityEventBuilderTest method testApfProgramEventSerialization.

public void testApfProgramEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(ApfProgramEvent.class), aLong(200), anInt(7), anInt(9), anInt(2048), anInt(3));
    String want = joinLines("dropped_events: 0", "events <", "  apf_program_event <", "    current_ras: 9", "    drop_multicast: true", "    filtered_ras: 7", "    has_ipv4_addr: true", "    lifetime: 200", "    program_length: 2048", "  >", "  time_ms: 1", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : ApfProgramEvent(android.net.metrics.ApfProgramEvent) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString)

Example 62 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project platform_frameworks_base by android.

the class IpConnectivityMetricsTest method testLoggingEventsWithMultipleCallers.

public void testLoggingEventsWithMultipleCallers() throws Exception {
    IpConnectivityLog logger = new IpConnectivityLog(mMockService);
    final int nCallers = 10;
    final int nEvents = 10;
    for (int n = 0; n < nCallers; n++) {
        final int i = n;
        new Thread() {

            public void run() {
                for (int j = 0; j < nEvents; j++) {
                    assertTrue(logger.log(i * 100 + j, FAKE_EV));
                }
            }
        }.start();
    }
    List<ConnectivityMetricsEvent> got = verifyEvents(nCallers * nEvents, 100);
    Collections.sort(got, EVENT_COMPARATOR);
    Iterator<ConnectivityMetricsEvent> iter = got.iterator();
    for (int i = 0; i < nCallers; i++) {
        for (int j = 0; j < nEvents; j++) {
            int expectedTimestamp = i * 100 + j;
            assertEventsEqual(expectedEvent(expectedTimestamp), iter.next());
        }
    }
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent)

Example 63 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class IpConnectivityEventBuilder method toProto.

public static List<IpConnectivityEvent> toProto(List<ConnectivityMetricsEvent> eventsIn) {
    final ArrayList<IpConnectivityEvent> eventsOut = new ArrayList<>(eventsIn.size());
    for (ConnectivityMetricsEvent in : eventsIn) {
        final IpConnectivityEvent out = toProto(in);
        if (out == null) {
            continue;
        }
        eventsOut.add(out);
    }
    return eventsOut;
}
Also used : IpConnectivityEvent(com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent) ArrayList(java.util.ArrayList) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent)

Aggregations

ConnectivityMetricsEvent (android.net.ConnectivityMetricsEvent)63 MetricsTestUtil.aString (com.android.server.connectivity.MetricsTestUtil.aString)44 SmallTest (android.test.suitebuilder.annotation.SmallTest)39 DefaultNetworkEvent (android.net.metrics.DefaultNetworkEvent)8 IpConnectivityLog (android.net.metrics.IpConnectivityLog)8 Reference (android.net.ConnectivityMetricsEvent.Reference)6 IpConnectivityEvent (com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent)5 ArrayList (java.util.ArrayList)5 ApfProgramEvent (android.net.metrics.ApfProgramEvent)4 ApfStats (android.net.metrics.ApfStats)4 DhcpClientEvent (android.net.metrics.DhcpClientEvent)4 DhcpErrorEvent (android.net.metrics.DhcpErrorEvent)4 DnsEvent (android.net.metrics.DnsEvent)4 IpManagerEvent (android.net.metrics.IpManagerEvent)4 IpReachabilityEvent (android.net.metrics.IpReachabilityEvent)4 NetworkEvent (android.net.metrics.NetworkEvent)4 RaEvent (android.net.metrics.RaEvent)4 ValidationProbeEvent (android.net.metrics.ValidationProbeEvent)4 FileDescriptor (java.io.FileDescriptor)3 FileOutputStream (java.io.FileOutputStream)3