[MS37] Replace NetworkStatsManagerInternal usages in NPMS
This is done by: 1. Add NetworkStatsManagerInternal APIs directly from NetworkStatsManager, these APIs are needed by NPMS. 2. Replace all usages with these APIs. 3. Delete NetworkStatsManagerInternal implementation. Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest Bug: 204830222 CTS-Coverage-Bug: 213124616 Change-Id: If51b6676915e3a0a8a9f95221d735306911442fc
This commit is contained in:
@@ -871,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user