Merge changes If51b6676,Ia6863a70,I802d2316

* changes:
  [MS37] Replace NetworkStatsManagerInternal usages in NPMS
  [MS36] Remove unused getNetwork[Total|Uid]Bytes
  [MS35] Remove getNetwork[Total|Uid]Bytes dependencies from NPMS
This commit is contained in:
Junyu Lai
2022-01-17 08:15:14 +00:00
committed by Gerrit Code Review
3 changed files with 109 additions and 55 deletions

View File

@@ -142,7 +142,15 @@ public class NetworkStatsManager {
setAugmentWithSubscriptionPlan(true);
}
/** @hide */
/**
* Set poll on open flag to indicate the poll is needed before service gets statistics
* result. This is default enabled. However, for any non-privileged caller, the poll might
* be omitted in case of rate limiting.
*
* @param pollOnOpen true if poll is needed.
* @hide
*/
// @SystemApi(client = MODULE_LIBRARIES)
public void setPollOnOpen(boolean pollOnOpen) {
if (pollOnOpen) {
mFlags |= FLAG_POLL_ON_OPEN;
@@ -863,4 +871,74 @@ public class NetworkStatsManager {
return msg.getData().getParcelable(key);
}
}
/**
* Mark given UID as being in foreground for stats purposes.
*
* @hide
*/
// @SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK})
public void setUidForeground(int uid, boolean uidForeground) {
try {
mService.setUidForeground(uid, uidForeground);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Advise persistence threshold; may be overridden internally.
*
* @hide
*/
// @SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK})
public void advisePersistThreshold(long thresholdBytes) {
try {
mService.advisePersistThreshold(thresholdBytes);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Force update of statistics.
*
* @hide
*/
// @SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK})
public void forceUpdate() {
try {
mService.forceUpdate();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Set the warning and limit to all registered custom network stats providers.
* Note that invocation of any interface will be sent to all providers.
*
* @hide
*/
// @SystemApi
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK})
public void setStatsProviderWarningAndLimitAsync(@NonNull String iface, long warning,
long limit) {
try {
mService.setStatsProviderWarningAndLimitAsync(iface, warning, limit);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -94,4 +94,16 @@ interface INetworkStatsService {
/** Registers a network stats provider */
INetworkStatsProviderCallback registerNetworkStatsProvider(String tag,
in INetworkStatsProvider provider);
/** Mark given UID as being in foreground for stats purposes. */
void setUidForeground(int uid, boolean uidForeground);
/** Advise persistence threshold; may be overridden internally. */
void advisePersistThreshold(long thresholdBytes);
/**
* Set the warning and limit to all registered custom network stats providers.
* Note that invocation of any interface will be sent to all providers.
*/
void setStatsProviderWarningAndLimitAsync(String iface, long warning, long limit);
}