Merge "[DU03-1]Remove INetworkStatsService from BatteryStatsImpl" am: acd0aef603 am: 18bf9f8d10 am: df8a07ce41 am: 85d620386f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1948496 Change-Id: Ie58903de1d88367bced48dd4e79c51cfd49701b8
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package android.app.usage;
|
||||
|
||||
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
@@ -55,7 +57,6 @@ import com.android.net.module.util.NetworkIdentityUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provides access to network usage history and statistics. Usage data is collected in
|
||||
@@ -670,26 +671,49 @@ public class NetworkStatsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Query realtime network usage statistics details with interfaces constrains.
|
||||
* Return snapshot of current UID statistics, including any {@link TrafficStats#UID_TETHERING},
|
||||
* video calling data usage and count of network operations that set by
|
||||
* {@link TrafficStats#incrementOperationCount}. The returned data doesn't include any
|
||||
* statistics that is reported by {@link NetworkStatsProvider}.
|
||||
* Query realtime mobile network usage statistics.
|
||||
*
|
||||
* @param requiredIfaces A list of interfaces the stats should be restricted to, or
|
||||
* {@link NetworkStats#INTERFACES_ALL}.
|
||||
* Return a snapshot of current UID network statistics, as it applies
|
||||
* to the mobile radios of the device. The snapshot will include any
|
||||
* tethering traffic, video calling data usage and count of
|
||||
* network operations set by {@link TrafficStats#incrementOperationCount}
|
||||
* made over a mobile radio.
|
||||
* The snapshot will not include any statistics that cannot be seen by
|
||||
* the kernel, e.g. statistics reported by {@link NetworkStatsProvider}s.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
//@SystemApi
|
||||
@SystemApi
|
||||
@RequiresPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK)
|
||||
@NonNull public android.net.NetworkStats getDetailedUidStats(
|
||||
@NonNull Set<String> requiredIfaces) {
|
||||
Objects.requireNonNull(requiredIfaces, "requiredIfaces cannot be null");
|
||||
@NonNull public android.net.NetworkStats getMobileUidStats() {
|
||||
try {
|
||||
return mService.getDetailedUidStats(requiredIfaces.toArray(new String[0]));
|
||||
return mService.getUidStatsForTransport(TRANSPORT_CELLULAR);
|
||||
} catch (RemoteException e) {
|
||||
if (DBG) Log.d(TAG, "Remote exception when get detailed uid stats");
|
||||
if (DBG) Log.d(TAG, "Remote exception when get Mobile uid stats");
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query realtime Wi-Fi network usage statistics.
|
||||
*
|
||||
* Return a snapshot of current UID network statistics, as it applies
|
||||
* to the Wi-Fi radios of the device. The snapshot will include any
|
||||
* tethering traffic, video calling data usage and count of
|
||||
* network operations set by {@link TrafficStats#incrementOperationCount}
|
||||
* made over a Wi-Fi radio.
|
||||
* The snapshot will not include any statistics that cannot be seen by
|
||||
* the kernel, e.g. statistics reported by {@link NetworkStatsProvider}s.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK)
|
||||
@NonNull public android.net.NetworkStats getWifiUidStats() {
|
||||
try {
|
||||
return mService.getUidStatsForTransport(TRANSPORT_WIFI);
|
||||
} catch (RemoteException e) {
|
||||
if (DBG) Log.d(TAG, "Remote exception when get WiFi uid stats");
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,14 +49,8 @@ interface INetworkStatsService {
|
||||
@UnsupportedAppUsage
|
||||
NetworkStats getDataLayerSnapshotForUid(int uid);
|
||||
|
||||
/** Get a detailed snapshot of stats since boot for all UIDs.
|
||||
*
|
||||
* <p>Results will not always be limited to stats on requiredIfaces when specified: stats for
|
||||
* interfaces stacked on the specified interfaces, or for interfaces on which the specified
|
||||
* interfaces are stacked on, will also be included.
|
||||
* @param requiredIfaces Interface names to get data for, or {@link NetworkStats#INTERFACES_ALL}.
|
||||
*/
|
||||
NetworkStats getDetailedUidStats(in String[] requiredIfaces);
|
||||
/** Get the transport NetworkStats for all UIDs since boot. */
|
||||
NetworkStats getUidStatsForTransport(int transport);
|
||||
|
||||
/** Return set of any ifaces associated with mobile networks since boot. */
|
||||
@UnsupportedAppUsage
|
||||
|
||||
Reference in New Issue
Block a user