Home | History | Annotate | Download | only in net
      1 /*
      2  * Copyright (C) 2011 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;
     18 
     19 import android.net.DataUsageRequest;
     20 import android.net.INetworkStatsSession;
     21 import android.net.Network;
     22 import android.net.NetworkStats;
     23 import android.net.NetworkStatsHistory;
     24 import android.net.NetworkTemplate;
     25 import android.os.IBinder;
     26 import android.os.Messenger;
     27 
     28 /** {@hide} */
     29 interface INetworkStatsService {
     30 
     31     /** Start a statistics query session. */
     32     INetworkStatsSession openSession();
     33 
     34     /** Start a statistics query session. If calling package is profile or device owner then it is
     35      *  granted automatic access if apiLevel is NetworkStatsManager.API_LEVEL_DPC_ALLOWED. If
     36      *  apiLevel is at least NetworkStatsManager.API_LEVEL_REQUIRES_PACKAGE_USAGE_STATS then
     37      *  PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
     38      *  READ_NETWORK_USAGE_STATS is checked for.
     39      */
     40     INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage);
     41 
     42     /** Return data layer snapshot of UID network usage. */
     43     NetworkStats getDataLayerSnapshotForUid(int uid);
     44 
     45     /** Get a detailed snapshot of stats since boot for all UIDs.
     46     *
     47     * <p>Results will not always be limited to stats on requiredIfaces when specified: stats for
     48     * interfaces stacked on the specified interfaces, or for interfaces on which the specified
     49     * interfaces are stacked on, will also be included.
     50     * @param requiredIfaces Interface names to get data for, or {@link NetworkStats#INTERFACES_ALL}.
     51     */
     52     NetworkStats getDetailedUidStats(in String[] requiredIfaces);
     53 
     54     /** Return set of any ifaces associated with mobile networks since boot. */
     55     String[] getMobileIfaces();
     56 
     57     /** Increment data layer count of operations performed for UID and tag. */
     58     void incrementOperationCount(int uid, int tag, int operationCount);
     59 
     60     /** Force update of ifaces. */
     61     void forceUpdateIfaces(in Network[] defaultNetworks);
     62     /** Force update of statistics. */
     63     void forceUpdate();
     64 
     65     /** Registers a callback on data usage. */
     66     DataUsageRequest registerUsageCallback(String callingPackage,
     67             in DataUsageRequest request, in Messenger messenger, in IBinder binder);
     68 
     69     /** Unregisters a callback on data usage. */
     70     void unregisterUsageRequest(in DataUsageRequest request);
     71 
     72     /** Get the uid stats information since boot */
     73     long getUidStats(int uid, int type);
     74 
     75     /** Get the iface stats information since boot */
     76     long getIfaceStats(String iface, int type);
     77 
     78     /** Get the total network stats information since boot */
     79     long getTotalStats(int type);
     80 
     81 }
     82