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.NetworkStats; 22 import android.net.NetworkStatsHistory; 23 import android.net.NetworkTemplate; 24 import android.os.IBinder; 25 import android.os.Messenger; 26 27 /** {@hide} */ 28 interface INetworkStatsService { 29 30 /** Start a statistics query session. */ openSession()31 INetworkStatsSession openSession(); 32 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 */ openSessionForUsageStats(String callingPackage)39 INetworkStatsSession openSessionForUsageStats(String callingPackage); 40 41 /** Return network layer usage total for traffic that matches template. */ getNetworkTotalBytes(in NetworkTemplate template, long start, long end)42 long getNetworkTotalBytes(in NetworkTemplate template, long start, long end); 43 44 /** Return data layer snapshot of UID network usage. */ getDataLayerSnapshotForUid(int uid)45 NetworkStats getDataLayerSnapshotForUid(int uid); 46 /** Return set of any ifaces associated with mobile networks since boot. */ getMobileIfaces()47 String[] getMobileIfaces(); 48 49 /** Increment data layer count of operations performed for UID and tag. */ incrementOperationCount(int uid, int tag, int operationCount)50 void incrementOperationCount(int uid, int tag, int operationCount); 51 52 /** Mark given UID as being in foreground for stats purposes. */ setUidForeground(int uid, boolean uidForeground)53 void setUidForeground(int uid, boolean uidForeground); 54 55 /** Force update of ifaces. */ forceUpdateIfaces()56 void forceUpdateIfaces(); 57 /** Force update of statistics. */ forceUpdate()58 void forceUpdate(); 59 60 /** Advise persistance threshold; may be overridden internally. */ advisePersistThreshold(long thresholdBytes)61 void advisePersistThreshold(long thresholdBytes); 62 63 /** Registers a callback on data usage. */ registerUsageCallback(String callingPackage, in DataUsageRequest request, in Messenger messenger, in IBinder binder)64 DataUsageRequest registerUsageCallback(String callingPackage, 65 in DataUsageRequest request, in Messenger messenger, in IBinder binder); 66 67 /** Unregisters a callback on data usage. */ unregisterUsageRequest(in DataUsageRequest request)68 void unregisterUsageRequest(in DataUsageRequest request); 69 70 } 71