From ddd09dfbe75fff156a11f102ba64246cee3399d5 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 20 Feb 2018 13:36:14 -0700 Subject: [PATCH] Only emit debug logging when requested. Test: builds, boots Bug: 72556865 Change-Id: I69d5d760221ef907eeea38490f56243f0a3b9dcb --- .../java/com/android/server/net/NetworkStatsService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java index 4b80e98f85..32e15c9d9c 100644 --- a/services/core/java/com/android/server/net/NetworkStatsService.java +++ b/services/core/java/com/android/server/net/NetworkStatsService.java @@ -152,7 +152,8 @@ import java.util.List; */ public class NetworkStatsService extends INetworkStatsService.Stub { static final String TAG = "NetworkStats"; - static final boolean LOGV = false; + static final boolean LOGD = Log.isLoggable(TAG, Log.DEBUG); + static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); private static final int MSG_PERFORM_POLL = 1; private static final int MSG_UPDATE_IFACES = 2; @@ -641,14 +642,14 @@ public class NetworkStatsService extends INetworkStatsService.Stub { if ((flags & NetworkStatsManager.FLAG_AUGMENT_WITH_SUBSCRIPTION_PLAN) != 0 && (template.getMatchRule() == NetworkTemplate.MATCH_MOBILE_ALL) && mSettings.getAugmentEnabled()) { - Slog.d(TAG, "Resolving plan for " + template); + if (LOGD) Slog.d(TAG, "Resolving plan for " + template); final long token = Binder.clearCallingIdentity(); try { final SubscriptionManager sm = mContext.getSystemService(SubscriptionManager.class); final TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); for (int subId : sm.getActiveSubscriptionIdList()) { if (template.matchesSubscriberId(tm.getSubscriberId(subId))) { - Slog.d(TAG, "Found active matching subId " + subId); + if (LOGD) Slog.d(TAG, "Found active matching subId " + subId); final List plans = sm.getSubscriptionPlans(subId); if (!plans.isEmpty()) { plan = plans.get(0); @@ -658,7 +659,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { } finally { Binder.restoreCallingIdentity(token); } - Slog.d(TAG, "Resolved to plan " + plan); + if (LOGD) Slog.d(TAG, "Resolved to plan " + plan); } return plan; }