Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 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 | |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 19 | import android.net.DataUsageRequest; |
Jeff Sharkey | b52e3e5 | 2012-04-06 11:12:08 -0700 | [diff] [blame] | 20 | import android.net.INetworkStatsSession; |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 21 | import android.net.NetworkStats; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 22 | import android.net.NetworkStatsHistory; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 23 | import android.net.NetworkTemplate; |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 24 | import android.os.IBinder; |
| 25 | import android.os.Messenger; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 26 | |
| 27 | /** {@hide} */ |
| 28 | interface INetworkStatsService { |
| 29 | |
Jeff Sharkey | b52e3e5 | 2012-04-06 11:12:08 -0700 | [diff] [blame] | 30 | /** Start a statistics query session. */ |
| 31 | INetworkStatsSession openSession(); |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 32 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 33 | /** 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 | */ |
Jeff Sharkey | f4de294 | 2017-08-29 15:32:13 -0600 | [diff] [blame] | 39 | INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage); |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 40 | |
Jeff Sharkey | b52e3e5 | 2012-04-06 11:12:08 -0700 | [diff] [blame] | 41 | /** Return network layer usage total for traffic that matches template. */ |
| 42 | long getNetworkTotalBytes(in NetworkTemplate template, long start, long end); |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 43 | |
Jeff Sharkey | a63ba59 | 2011-07-19 23:47:12 -0700 | [diff] [blame] | 44 | /** Return data layer snapshot of UID network usage. */ |
| 45 | NetworkStats getDataLayerSnapshotForUid(int uid); |
Jeff Sharkey | 234766a | 2012-04-10 19:48:07 -0700 | [diff] [blame] | 46 | /** Return set of any ifaces associated with mobile networks since boot. */ |
| 47 | String[] getMobileIfaces(); |
| 48 | |
Jeff Sharkey | a63ba59 | 2011-07-19 23:47:12 -0700 | [diff] [blame] | 49 | /** Increment data layer count of operations performed for UID and tag. */ |
| 50 | void incrementOperationCount(int uid, int tag, int operationCount); |
| 51 | |
Jeff Sharkey | b5d55e3 | 2011-08-10 17:53:27 -0700 | [diff] [blame] | 52 | /** Mark given UID as being in foreground for stats purposes. */ |
| 53 | void setUidForeground(int uid, boolean uidForeground); |
Jeff Sharkey | 6973634 | 2014-12-08 14:50:12 -0800 | [diff] [blame] | 54 | |
| 55 | /** Force update of ifaces. */ |
| 56 | void forceUpdateIfaces(); |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 57 | /** Force update of statistics. */ |
| 58 | void forceUpdate(); |
Jeff Sharkey | 6973634 | 2014-12-08 14:50:12 -0800 | [diff] [blame] | 59 | |
Jeff Sharkey | ac3fcb1 | 2012-05-02 18:11:52 -0700 | [diff] [blame] | 60 | /** Advise persistance threshold; may be overridden internally. */ |
| 61 | void advisePersistThreshold(long thresholdBytes); |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 62 | |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 63 | /** Registers a callback on data usage. */ |
Antonio Cansado | 6965c18 | 2016-03-30 11:37:18 -0700 | [diff] [blame] | 64 | DataUsageRequest registerUsageCallback(String callingPackage, |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 65 | in DataUsageRequest request, in Messenger messenger, in IBinder binder); |
| 66 | |
| 67 | /** Unregisters a callback on data usage. */ |
Antonio Cansado | 6965c18 | 2016-03-30 11:37:18 -0700 | [diff] [blame] | 68 | void unregisterUsageRequest(in DataUsageRequest request); |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 69 | |
Chenbo Feng | d3d9c4e | 2017-11-14 17:54:17 -0800 | [diff] [blame] | 70 | /** Get the uid stats information since boot */ |
| 71 | long getUidStats(int uid, int type); |
| 72 | |
| 73 | /** Get the iface stats information since boot */ |
| 74 | long getIfaceStats(String iface, int type); |
| 75 | |
| 76 | /** Get the total network stats information since boot */ |
| 77 | long getTotalStats(int type); |
| 78 | |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 79 | } |