Merge "[DU04-2]Appropriate changes to the NetworkPolicyManager API" am: 73c476d79d am: 8c4e592d2e

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2007132

Change-Id: I289823436cda3561d76f4c1421201315e0b26638
This commit is contained in:
Frank Li
2022-03-16 13:19:34 +00:00
committed by Automerger Merge Worker
3 changed files with 15 additions and 7 deletions

View File

@@ -26,6 +26,7 @@ import android.net.NetworkStats;
oneway interface INetworkStatsProviderCallback { oneway interface INetworkStatsProviderCallback {
void notifyStatsUpdated(int token, in NetworkStats ifaceStats, in NetworkStats uidStats); void notifyStatsUpdated(int token, in NetworkStats ifaceStats, in NetworkStats uidStats);
void notifyAlertReached(); void notifyAlertReached();
void notifyWarningOrLimitReached(); void notifyWarningReached();
void notifyLimitReached();
void unregister(); void unregister();
} }

View File

@@ -152,19 +152,19 @@ public abstract class NetworkStatsProvider {
try { try {
// Reuse the code path to notify warning reached with limit reached // Reuse the code path to notify warning reached with limit reached
// since framework handles them in the same way. // since framework handles them in the same way.
getProviderCallbackBinderOrThrow().notifyWarningOrLimitReached(); getProviderCallbackBinderOrThrow().notifyWarningReached();
} catch (RemoteException e) { } catch (RemoteException e) {
e.rethrowAsRuntimeException(); e.rethrowAsRuntimeException();
} }
} }
/** /**
* Notify system that the quota set by {@link #onSetLimit} or limit set by * Notify system that the limit set by {@link #onSetLimit} or limit set by
* {@link #onSetWarningAndLimit} has been reached. * {@link #onSetWarningAndLimit} has been reached.
*/ */
public void notifyLimitReached() { public void notifyLimitReached() {
try { try {
getProviderCallbackBinderOrThrow().notifyWarningOrLimitReached(); getProviderCallbackBinderOrThrow().notifyLimitReached();
} catch (RemoteException e) { } catch (RemoteException e) {
e.rethrowAsRuntimeException(); e.rethrowAsRuntimeException();
} }

View File

@@ -2393,10 +2393,17 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
} }
@Override @Override
public void notifyWarningOrLimitReached() { public void notifyWarningReached() {
Log.d(TAG, mTag + ": notifyWarningOrLimitReached"); Log.d(TAG, mTag + ": notifyWarningReached");
BinderUtils.withCleanCallingIdentity(() -> BinderUtils.withCleanCallingIdentity(() ->
mNetworkPolicyManager.notifyStatsProviderWarningOrLimitReached()); mNetworkPolicyManager.notifyStatsProviderWarningReached());
}
@Override
public void notifyLimitReached() {
Log.d(TAG, mTag + ": notifyLimitReached");
BinderUtils.withCleanCallingIdentity(() ->
mNetworkPolicyManager.notifyStatsProviderLimitReached());
} }
@Override @Override