blob: e693009c33774a452b2c2c9c57dac28a7da6604b [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;
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070021import android.net.NetworkStats;
Jeff Sharkey75279902011-05-24 18:39:45 -070022import android.net.NetworkStatsHistory;
Jeff Sharkey1b5a2a92011-06-18 18:34:16 -070023import android.net.NetworkTemplate;
Antonio Cansadocd42acd2016-02-17 13:03:38 -080024import android.os.IBinder;
25import android.os.Messenger;
Jeff Sharkey75279902011-05-24 18:39:45 -070026
27/** {@hide} */
28interface INetworkStatsService {
29
Jeff Sharkeyb52e3e52012-04-06 11:12:08 -070030 /** Start a statistics query session. */
31 INetworkStatsSession openSession();
Jeff Sharkeyd2a45872011-05-28 20:56:34 -070032
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +000033 /** Start a statistics query session. If calling package is profile or device owner then it is
34 * granted automatic access if apiLevel is NetworkStatsManager.API_LEVEL_DPC_ALLOWED. If
35 * apiLevel is at least NetworkStatsManager.API_LEVEL_REQUIRES_PACKAGE_USAGE_STATS then
36 * PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
37 * READ_NETWORK_USAGE_STATS is checked for.
38 */
39 INetworkStatsSession openSessionForUsageStats(String callingPackage);
40
Jeff Sharkeyb52e3e52012-04-06 11:12:08 -070041 /** Return network layer usage total for traffic that matches template. */
42 long getNetworkTotalBytes(in NetworkTemplate template, long start, long end);
Jeff Sharkey75279902011-05-24 18:39:45 -070043
Jeff Sharkeya63ba592011-07-19 23:47:12 -070044 /** Return data layer snapshot of UID network usage. */
45 NetworkStats getDataLayerSnapshotForUid(int uid);
Jeff Sharkey234766a2012-04-10 19:48:07 -070046 /** Return set of any ifaces associated with mobile networks since boot. */
47 String[] getMobileIfaces();
48
Jeff Sharkeya63ba592011-07-19 23:47:12 -070049 /** Increment data layer count of operations performed for UID and tag. */
50 void incrementOperationCount(int uid, int tag, int operationCount);
51
Jeff Sharkeyb5d55e32011-08-10 17:53:27 -070052 /** Mark given UID as being in foreground for stats purposes. */
53 void setUidForeground(int uid, boolean uidForeground);
Jeff Sharkey69736342014-12-08 14:50:12 -080054
55 /** Force update of ifaces. */
56 void forceUpdateIfaces();
Jeff Sharkey350083e2011-06-29 10:45:16 -070057 /** Force update of statistics. */
58 void forceUpdate();
Jeff Sharkey69736342014-12-08 14:50:12 -080059
Jeff Sharkeyac3fcb12012-05-02 18:11:52 -070060 /** Advise persistance threshold; may be overridden internally. */
61 void advisePersistThreshold(long thresholdBytes);
Jeff Sharkey350083e2011-06-29 10:45:16 -070062
Antonio Cansadocd42acd2016-02-17 13:03:38 -080063 /** Registers a callback on data usage. */
Antonio Cansado6965c182016-03-30 11:37:18 -070064 DataUsageRequest registerUsageCallback(String callingPackage,
Antonio Cansadocd42acd2016-02-17 13:03:38 -080065 in DataUsageRequest request, in Messenger messenger, in IBinder binder);
66
67 /** Unregisters a callback on data usage. */
Antonio Cansado6965c182016-03-30 11:37:18 -070068 void unregisterUsageRequest(in DataUsageRequest request);
Antonio Cansadocd42acd2016-02-17 13:03:38 -080069
Jeff Sharkey75279902011-05-24 18:39:45 -070070}