Added trace on Data Saver-related methods.
BUG: 31389946
Test: m -j32 cts && cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: I4a4299371a529121438db166fe03de8263812323
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 2fd9fe1..dffc7b6 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -2049,25 +2049,30 @@
@Override
public void setRestrictBackground(boolean restrictBackground) {
- mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
- final long token = Binder.clearCallingIdentity();
+ Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "setRestrictBackground");
try {
- maybeRefreshTrustedTime();
- synchronized (mUidRulesFirstLock) {
- if (restrictBackground == mRestrictBackground) {
- // Ideally, UI should never allow this scenario...
- Slog.w(TAG, "setRestrictBackground: already " + restrictBackground);
- return;
+ mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ maybeRefreshTrustedTime();
+ synchronized (mUidRulesFirstLock) {
+ if (restrictBackground == mRestrictBackground) {
+ // Ideally, UI should never allow this scenario...
+ Slog.w(TAG, "setRestrictBackground: already " + restrictBackground);
+ return;
+ }
+ setRestrictBackgroundUL(restrictBackground);
}
- setRestrictBackgroundUL(restrictBackground);
+
+ } finally {
+ Binder.restoreCallingIdentity(token);
}
+ mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_CHANGED, restrictBackground ? 1 : 0, 0)
+ .sendToTarget();
} finally {
- Binder.restoreCallingIdentity(token);
+ Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
}
-
- mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_CHANGED, restrictBackground ? 1 : 0, 0)
- .sendToTarget();
}
private void setRestrictBackgroundUL(boolean restrictBackground) {