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; |
Lorenzo Colitti | c78da29 | 2018-01-19 00:50:48 +0900 | [diff] [blame] | 21 | import android.net.Network; |
Varun Anand | 02c50ef | 2019-02-07 14:13:13 -0800 | [diff] [blame] | 22 | import android.net.NetworkState; |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 23 | import android.net.NetworkStats; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 24 | import android.net.NetworkStatsHistory; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 25 | import android.net.NetworkTemplate; |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 26 | import android.os.IBinder; |
| 27 | import android.os.Messenger; |
Varun Anand | 02c50ef | 2019-02-07 14:13:13 -0800 | [diff] [blame] | 28 | import com.android.internal.net.VpnInfo; |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 29 | |
| 30 | /** {@hide} */ |
| 31 | interface INetworkStatsService { |
| 32 | |
Jeff Sharkey | b52e3e5 | 2012-04-06 11:12:08 -0700 | [diff] [blame] | 33 | /** Start a statistics query session. */ |
Andrei Onea | 9a8b6bf | 2019-02-25 13:25:32 +0000 | [diff] [blame] | 34 | @UnsupportedAppUsage |
Jeff Sharkey | b52e3e5 | 2012-04-06 11:12:08 -0700 | [diff] [blame] | 35 | INetworkStatsSession openSession(); |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 36 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 37 | /** 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 Onea | 9a8b6bf | 2019-02-25 13:25:32 +0000 | [diff] [blame] | 43 | @UnsupportedAppUsage |
Jeff Sharkey | f4de294 | 2017-08-29 15:32:13 -0600 | [diff] [blame] | 44 | INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage); |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 45 | |
Jeff Sharkey | a63ba59 | 2011-07-19 23:47:12 -0700 | [diff] [blame] | 46 | /** Return data layer snapshot of UID network usage. */ |
Andrei Onea | 9a8b6bf | 2019-02-25 13:25:32 +0000 | [diff] [blame] | 47 | @UnsupportedAppUsage |
Jeff Sharkey | a63ba59 | 2011-07-19 23:47:12 -0700 | [diff] [blame] | 48 | NetworkStats getDataLayerSnapshotForUid(int uid); |
Remi NGUYEN VAN | 088ff68 | 2018-03-06 12:36:54 +0900 | [diff] [blame] | 49 | |
| 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 Sharkey | 234766a | 2012-04-10 19:48:07 -0700 | [diff] [blame] | 59 | /** Return set of any ifaces associated with mobile networks since boot. */ |
Andrei Onea | 9a8b6bf | 2019-02-25 13:25:32 +0000 | [diff] [blame] | 60 | @UnsupportedAppUsage |
Jeff Sharkey | 234766a | 2012-04-10 19:48:07 -0700 | [diff] [blame] | 61 | String[] getMobileIfaces(); |
| 62 | |
Jeff Sharkey | a63ba59 | 2011-07-19 23:47:12 -0700 | [diff] [blame] | 63 | /** Increment data layer count of operations performed for UID and tag. */ |
| 64 | void incrementOperationCount(int uid, int tag, int operationCount); |
| 65 | |
Jeff Sharkey | 6973634 | 2014-12-08 14:50:12 -0800 | [diff] [blame] | 66 | /** Force update of ifaces. */ |
Varun Anand | 02c50ef | 2019-02-07 14:13:13 -0800 | [diff] [blame] | 67 | void forceUpdateIfaces( |
| 68 | in Network[] defaultNetworks, |
| 69 | in VpnInfo[] vpnArray, |
| 70 | in NetworkState[] networkStates, |
| 71 | in String activeIface); |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 72 | /** Force update of statistics. */ |
Andrei Onea | 9a8b6bf | 2019-02-25 13:25:32 +0000 | [diff] [blame] | 73 | @UnsupportedAppUsage |
Jeff Sharkey | 350083e | 2011-06-29 10:45:16 -0700 | [diff] [blame] | 74 | void forceUpdate(); |
Jeff Sharkey | 6973634 | 2014-12-08 14:50:12 -0800 | [diff] [blame] | 75 | |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 76 | /** Registers a callback on data usage. */ |
Antonio Cansado | 6965c18 | 2016-03-30 11:37:18 -0700 | [diff] [blame] | 77 | DataUsageRequest registerUsageCallback(String callingPackage, |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 78 | in DataUsageRequest request, in Messenger messenger, in IBinder binder); |
| 79 | |
| 80 | /** Unregisters a callback on data usage. */ |
Antonio Cansado | 6965c18 | 2016-03-30 11:37:18 -0700 | [diff] [blame] | 81 | void unregisterUsageRequest(in DataUsageRequest request); |
Antonio Cansado | cd42acd | 2016-02-17 13:03:38 -0800 | [diff] [blame] | 82 | |
Chenbo Feng | d3d9c4e | 2017-11-14 17:54:17 -0800 | [diff] [blame] | 83 | /** 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 Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 92 | } |