blob: 41efc5040885f4f09053e0d93923ac6d81870c50 [file] [log] [blame]
Jeff Sharkey75279902011-05-24 18:39:45 -07001/*
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
17package android.net;
18
Antonio Cansadocd42acd2016-02-17 13:03:38 -080019import android.net.DataUsageRequest;
Jeff Sharkeyb52e3e52012-04-06 11:12:08 -070020import android.net.INetworkStatsSession;
Lorenzo Colittic78da292018-01-19 00:50:48 +090021import android.net.Network;
Varun Anand02c50ef2019-02-07 14:13:13 -080022import android.net.NetworkState;
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070023import android.net.NetworkStats;
Jeff Sharkey75279902011-05-24 18:39:45 -070024import android.net.NetworkStatsHistory;
Jeff Sharkey1b5a2a92011-06-18 18:34:16 -070025import android.net.NetworkTemplate;
Antonio Cansadocd42acd2016-02-17 13:03:38 -080026import android.os.IBinder;
27import android.os.Messenger;
Varun Anand02c50ef2019-02-07 14:13:13 -080028import com.android.internal.net.VpnInfo;
Jeff Sharkey75279902011-05-24 18:39:45 -070029
30/** {@hide} */
31interface INetworkStatsService {
32
Jeff Sharkeyb52e3e52012-04-06 11:12:08 -070033 /** Start a statistics query session. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000034 @UnsupportedAppUsage
Jeff Sharkeyb52e3e52012-04-06 11:12:08 -070035 INetworkStatsSession openSession();
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070036
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +000037 /** Start a statistics query session. If calling package is profile or device owner then it is
38 * granted automatic access if apiLevel is NetworkStatsManager.API_LEVEL_DPC_ALLOWED. If
39 * apiLevel is at least NetworkStatsManager.API_LEVEL_REQUIRES_PACKAGE_USAGE_STATS then
40 * PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
41 * READ_NETWORK_USAGE_STATS is checked for.
42 */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000043 @UnsupportedAppUsage
Jeff Sharkeyf4de2942017-08-29 15:32:13 -060044 INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage);
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +000045
Jeff Sharkeya63ba592011-07-19 23:47:12 -070046 /** Return data layer snapshot of UID network usage. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000047 @UnsupportedAppUsage
Jeff Sharkeya63ba592011-07-19 23:47:12 -070048 NetworkStats getDataLayerSnapshotForUid(int uid);
Remi NGUYEN VAN088ff682018-03-06 12:36:54 +090049
50 /** Get a detailed snapshot of stats since boot for all UIDs.
51 *
52 * <p>Results will not always be limited to stats on requiredIfaces when specified: stats for
53 * interfaces stacked on the specified interfaces, or for interfaces on which the specified
54 * interfaces are stacked on, will also be included.
55 * @param requiredIfaces Interface names to get data for, or {@link NetworkStats#INTERFACES_ALL}.
56 */
57 NetworkStats getDetailedUidStats(in String[] requiredIfaces);
58
Jeff Sharkey234766a2012-04-10 19:48:07 -070059 /** Return set of any ifaces associated with mobile networks since boot. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000060 @UnsupportedAppUsage
Jeff Sharkey234766a2012-04-10 19:48:07 -070061 String[] getMobileIfaces();
62
Jeff Sharkeya63ba592011-07-19 23:47:12 -070063 /** Increment data layer count of operations performed for UID and tag. */
64 void incrementOperationCount(int uid, int tag, int operationCount);
65
Jeff Sharkey69736342014-12-08 14:50:12 -080066 /** Force update of ifaces. */
Varun Anand02c50ef2019-02-07 14:13:13 -080067 void forceUpdateIfaces(
68 in Network[] defaultNetworks,
69 in VpnInfo[] vpnArray,
70 in NetworkState[] networkStates,
71 in String activeIface);
Jeff Sharkey350083e2011-06-29 10:45:16 -070072 /** Force update of statistics. */
Andrei Onea9a8b6bf2019-02-25 13:25:32 +000073 @UnsupportedAppUsage
Jeff Sharkey350083e2011-06-29 10:45:16 -070074 void forceUpdate();
Jeff Sharkey69736342014-12-08 14:50:12 -080075
Antonio Cansadocd42acd2016-02-17 13:03:38 -080076 /** Registers a callback on data usage. */
Antonio Cansado6965c182016-03-30 11:37:18 -070077 DataUsageRequest registerUsageCallback(String callingPackage,
Antonio Cansadocd42acd2016-02-17 13:03:38 -080078 in DataUsageRequest request, in Messenger messenger, in IBinder binder);
79
80 /** Unregisters a callback on data usage. */
Antonio Cansado6965c182016-03-30 11:37:18 -070081 void unregisterUsageRequest(in DataUsageRequest request);
Antonio Cansadocd42acd2016-02-17 13:03:38 -080082
Chenbo Fengd3d9c4e2017-11-14 17:54:17 -080083 /** Get the uid stats information since boot */
84 long getUidStats(int uid, int type);
85
86 /** Get the iface stats information since boot */
87 long getIfaceStats(String iface, int type);
88
89 /** Get the total network stats information since boot */
90 long getTotalStats(int type);
91
Jeff Sharkey75279902011-05-24 18:39:45 -070092}