Home | History | Annotate | Download | only in metrics
      1 /**
      2  * Copyright (c) 2016, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.net.metrics;
     18 
     19 /**
     20  * Logs netd events.
     21  *
     22  * {@hide}
     23  */
     24 oneway interface INetdEventListener {
     25     const int EVENT_GETADDRINFO = 1;
     26     const int EVENT_GETHOSTBYNAME = 2;
     27 
     28     const int REPORTING_LEVEL_NONE = 0;
     29     const int REPORTING_LEVEL_METRICS = 1;
     30     const int REPORTING_LEVEL_FULL = 2;
     31 
     32     // Maximum number of IP addresses logged for DNS lookups before we truncate the full list.
     33     const int DNS_REPORTED_IP_ADDRESSES_LIMIT = 10;
     34 
     35     /**
     36      * Logs a DNS lookup function call (getaddrinfo and gethostbyname).
     37      *
     38      * @param netId the ID of the network the lookup was performed on.
     39      * @param eventType one of the EVENT_* constants in this interface.
     40      * @param returnCode the return value of the function call.
     41      * @param latencyMs the latency of the function call.
     42      * @param hostname the name that was looked up.
     43      * @param ipAddresses (possibly a subset of) the IP addresses returned.
     44      *        At most {@link #DNS_REPORTED_IP_ADDRESSES_LIMIT} addresses are logged.
     45      * @param ipAddressesCount the number of IP addresses returned. May be different from the length
     46      *        of ipAddresses if there were too many addresses to log.
     47      * @param uid the UID of the application that performed the query.
     48      */
     49     void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs, String hostname,
     50             in String[] ipAddresses, int ipAddressesCount, int uid);
     51 
     52     /**
     53      * Logs a single connect library call.
     54      *
     55      * @param netId the ID of the network the connect was performed on.
     56      * @param error 0 if the connect call succeeded, otherwise errno if it failed.
     57      * @param latencyMs the latency of the connect call.
     58      * @param ipAddr destination IP address.
     59      * @param port destination port number.
     60      * @param uid the UID of the application that performed the connection.
     61      */
     62     void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
     63 
     64     /**
     65      * Logs a single RX packet which caused the main CPU to exit sleep state.
     66      * @param prefix arbitrary string provided via wakeupAddInterface()
     67      * @param UID of the destination process or -1 if no UID is available.
     68      * @param GID of the destination process or -1 if no GID is available.
     69      * @param receive timestamp for the offending packet. In units of nanoseconds and
     70      *        synchronized to CLOCK_MONOTONIC.
     71      */
     72     void onWakeupEvent(String prefix, int uid, int gid, long timestampNs);
     73 }
     74