diff options
| author | 2017-09-05 07:57:00 +0000 | |
|---|---|---|
| committer | 2017-09-05 07:57:00 +0000 | |
| commit | 2dac2cce5a2f28ae368e7e6af6fb4e49ac22c5b4 (patch) | |
| tree | 3f015c76d25d47e5e6560d5d7e1750526a44981b | |
| parent | 10070c635625bcdfda441d9655e57dbaf19bb7f6 (diff) | |
| parent | 26bcfa19d01758c86a8f43a5b39673cd5866d2f3 (diff) | |
Merge "ConnectivityService: improve wakelock logging" into oc-mr1-dev
| -rw-r--r-- | services/core/java/com/android/server/ConnectivityService.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index adf536bbf487..4546bfbfbce2 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -456,6 +456,11 @@ public class ConnectivityService extends IConnectivityManager.Stub private static final int MAX_WAKELOCK_LOGS = 20; private final LocalLog mWakelockLogs = new LocalLog(MAX_WAKELOCK_LOGS); + private int mTotalWakelockAcquisitions = 0; + private int mTotalWakelockReleases = 0; + private long mTotalWakelockDurationMs = 0; + private long mMaxWakelockDurationMs = 0; + private long mLastWakeLockAcquireTimestamp = 0; // Array of <Network,ReadOnlyLocalLogs> tracking network validation and results private static final int MAX_VALIDATION_LOGS = 10; @@ -1947,6 +1952,14 @@ public class ConnectivityService extends IConnectivityManager.Stub pw.println(); pw.println("NetTransition WakeLock activity (most recent first):"); pw.increaseIndent(); + pw.println("total acquisitions: " + mTotalWakelockAcquisitions); + pw.println("total releases: " + mTotalWakelockReleases); + pw.println("cumulative duration: " + (mTotalWakelockDurationMs / 1000) + "s"); + pw.println("longest duration: " + (mMaxWakelockDurationMs / 1000) + "s"); + if (mTotalWakelockAcquisitions > mTotalWakelockReleases) { + long duration = SystemClock.elapsedRealtime() - mLastWakeLockAcquireTimestamp; + pw.println("currently holding WakeLock for: " + (duration / 1000) + "s"); + } mWakelockLogs.reverseDump(fd, pw, args); pw.decreaseIndent(); } @@ -3014,6 +3027,8 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } mNetTransitionWakeLock.acquire(); + mLastWakeLockAcquireTimestamp = SystemClock.elapsedRealtime(); + mTotalWakelockAcquisitions++; } mWakelockLogs.log("ACQUIRE for " + forWhom); Message msg = mHandler.obtainMessage(EVENT_EXPIRE_NET_TRANSITION_WAKELOCK); @@ -3046,6 +3061,10 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } mNetTransitionWakeLock.release(); + long lockDuration = SystemClock.elapsedRealtime() - mLastWakeLockAcquireTimestamp; + mTotalWakelockDurationMs += lockDuration; + mMaxWakelockDurationMs = Math.max(mMaxWakelockDurationMs, lockDuration); + mTotalWakelockReleases++; } mWakelockLogs.log(String.format("RELEASE (%s)", event)); } |