• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.NetworkStateSnapshot;
23 import android.net.NetworkStats;
24 import android.net.NetworkStatsHistory;
25 import android.net.NetworkTemplate;
26 import android.net.UnderlyingNetworkInfo;
27 import android.net.netstats.provider.INetworkStatsProvider;
28 import android.net.netstats.provider.INetworkStatsProviderCallback;
29 import android.os.IBinder;
30 import android.os.Messenger;
31 
32 /** {@hide} */
33 interface INetworkStatsService {
34 
35     /** Start a statistics query session. */
36     @UnsupportedAppUsage
openSession()37     INetworkStatsSession openSession();
38 
39     /** Start a statistics query session. If calling package is profile or device owner then it is
40      *  granted automatic access if apiLevel is NetworkStatsManager.API_LEVEL_DPC_ALLOWED. If
41      *  apiLevel is at least NetworkStatsManager.API_LEVEL_REQUIRES_PACKAGE_USAGE_STATS then
42      *  PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
43      *  READ_NETWORK_USAGE_STATS is checked for.
44      */
45     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
openSessionForUsageStats(int flags, String callingPackage)46     INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage);
47 
48     /** Return data layer snapshot of UID network usage. */
49     @UnsupportedAppUsage
getDataLayerSnapshotForUid(int uid)50     NetworkStats getDataLayerSnapshotForUid(int uid);
51 
52     /** Get a detailed snapshot of stats since boot for all UIDs.
53     *
54     * <p>Results will not always be limited to stats on requiredIfaces when specified: stats for
55     * interfaces stacked on the specified interfaces, or for interfaces on which the specified
56     * interfaces are stacked on, will also be included.
57     * @param requiredIfaces Interface names to get data for, or {@link NetworkStats#INTERFACES_ALL}.
58     */
getDetailedUidStats(in String[] requiredIfaces)59     NetworkStats getDetailedUidStats(in String[] requiredIfaces);
60 
61     /** Return set of any ifaces associated with mobile networks since boot. */
62     @UnsupportedAppUsage
getMobileIfaces()63     String[] getMobileIfaces();
64 
65     /** Increment data layer count of operations performed for UID and tag. */
incrementOperationCount(int uid, int tag, int operationCount)66     void incrementOperationCount(int uid, int tag, int operationCount);
67 
68     /**  Notify {@code NetworkStatsService} about network status changed. */
notifyNetworkStatus( in Network[] defaultNetworks, in NetworkStateSnapshot[] snapshots, in String activeIface, in UnderlyingNetworkInfo[] underlyingNetworkInfos)69     void notifyNetworkStatus(
70          in Network[] defaultNetworks,
71          in NetworkStateSnapshot[] snapshots,
72          in String activeIface,
73          in UnderlyingNetworkInfo[] underlyingNetworkInfos);
74     /** Force update of statistics. */
75     @UnsupportedAppUsage
forceUpdate()76     void forceUpdate();
77 
78     /** Registers a callback on data usage. */
registerUsageCallback(String callingPackage, in DataUsageRequest request, in Messenger messenger, in IBinder binder)79     DataUsageRequest registerUsageCallback(String callingPackage,
80             in DataUsageRequest request, in Messenger messenger, in IBinder binder);
81 
82     /** Unregisters a callback on data usage. */
unregisterUsageRequest(in DataUsageRequest request)83     void unregisterUsageRequest(in DataUsageRequest request);
84 
85     /** Get the uid stats information since boot */
getUidStats(int uid, int type)86     long getUidStats(int uid, int type);
87 
88     /** Get the iface stats information since boot */
getIfaceStats(String iface, int type)89     long getIfaceStats(String iface, int type);
90 
91     /** Get the total network stats information since boot */
getTotalStats(int type)92     long getTotalStats(int type);
93 
94     /** Registers a network stats provider */
registerNetworkStatsProvider(String tag, in INetworkStatsProvider provider)95     INetworkStatsProviderCallback registerNetworkStatsProvider(String tag,
96             in INetworkStatsProvider provider);
97 }
98