Loading core/java/com/android/internal/os/KernelWakelockReader.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.internal.annotations.VisibleForTesting; import java.io.File; import java.io.File; import java.io.FileInputStream; import java.io.FileInputStream; import java.util.Arrays; import java.util.Iterator; import java.util.Iterator; /** /** Loading Loading @@ -66,6 +67,7 @@ public class KernelWakelockReader { private final String[] mProcWakelocksName = new String[3]; private final String[] mProcWakelocksName = new String[3]; private final long[] mProcWakelocksData = new long[3]; private final long[] mProcWakelocksData = new long[3]; private ISuspendControlService mSuspendControlService = null; private ISuspendControlService mSuspendControlService = null; private byte[] mKernelWakelockBuffer = new byte[32 * 1024]; /** /** * Reads kernel wakelock stats and updates the staleStats with the new information. * Reads kernel wakelock stats and updates the staleStats with the new information. Loading @@ -84,7 +86,7 @@ public class KernelWakelockReader { } } return removeOldStats(staleStats); return removeOldStats(staleStats); } else { } else { byte[] buffer = new byte[32*1024]; Arrays.fill(mKernelWakelockBuffer, (byte) 0); int len = 0; int len = 0; boolean wakeup_sources; boolean wakeup_sources; final long startTime = SystemClock.uptimeMillis(); final long startTime = SystemClock.uptimeMillis(); Loading @@ -107,7 +109,8 @@ public class KernelWakelockReader { } } int cnt; int cnt; while ((cnt = is.read(buffer, len, buffer.length - len)) > 0) { while ((cnt = is.read(mKernelWakelockBuffer, len, mKernelWakelockBuffer.length - len)) > 0) { len += cnt; len += cnt; } } Loading @@ -125,12 +128,13 @@ public class KernelWakelockReader { } } if (len > 0) { if (len > 0) { if (len >= buffer.length) { if (len >= mKernelWakelockBuffer.length) { Slog.wtf(TAG, "Kernel wake locks exceeded buffer size " + buffer.length); Slog.wtf(TAG, "Kernel wake locks exceeded mKernelWakelockBuffer size " + mKernelWakelockBuffer.length); } } int i; int i; for (i=0; i<len; i++) { for (i=0; i<len; i++) { if (buffer[i] == '\0') { if (mKernelWakelockBuffer[i] == '\0') { len = i; len = i; break; break; } } Loading @@ -143,7 +147,7 @@ public class KernelWakelockReader { Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend"); Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend"); } } // Get kernel wakelock stats // Get kernel wakelock stats parseProcWakelocks(buffer, len, wakeup_sources, staleStats); parseProcWakelocks(mKernelWakelockBuffer, len, wakeup_sources, staleStats); return removeOldStats(staleStats); return removeOldStats(staleStats); } } } } Loading Loading
core/java/com/android/internal/os/KernelWakelockReader.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.internal.annotations.VisibleForTesting; import java.io.File; import java.io.File; import java.io.FileInputStream; import java.io.FileInputStream; import java.util.Arrays; import java.util.Iterator; import java.util.Iterator; /** /** Loading Loading @@ -66,6 +67,7 @@ public class KernelWakelockReader { private final String[] mProcWakelocksName = new String[3]; private final String[] mProcWakelocksName = new String[3]; private final long[] mProcWakelocksData = new long[3]; private final long[] mProcWakelocksData = new long[3]; private ISuspendControlService mSuspendControlService = null; private ISuspendControlService mSuspendControlService = null; private byte[] mKernelWakelockBuffer = new byte[32 * 1024]; /** /** * Reads kernel wakelock stats and updates the staleStats with the new information. * Reads kernel wakelock stats and updates the staleStats with the new information. Loading @@ -84,7 +86,7 @@ public class KernelWakelockReader { } } return removeOldStats(staleStats); return removeOldStats(staleStats); } else { } else { byte[] buffer = new byte[32*1024]; Arrays.fill(mKernelWakelockBuffer, (byte) 0); int len = 0; int len = 0; boolean wakeup_sources; boolean wakeup_sources; final long startTime = SystemClock.uptimeMillis(); final long startTime = SystemClock.uptimeMillis(); Loading @@ -107,7 +109,8 @@ public class KernelWakelockReader { } } int cnt; int cnt; while ((cnt = is.read(buffer, len, buffer.length - len)) > 0) { while ((cnt = is.read(mKernelWakelockBuffer, len, mKernelWakelockBuffer.length - len)) > 0) { len += cnt; len += cnt; } } Loading @@ -125,12 +128,13 @@ public class KernelWakelockReader { } } if (len > 0) { if (len > 0) { if (len >= buffer.length) { if (len >= mKernelWakelockBuffer.length) { Slog.wtf(TAG, "Kernel wake locks exceeded buffer size " + buffer.length); Slog.wtf(TAG, "Kernel wake locks exceeded mKernelWakelockBuffer size " + mKernelWakelockBuffer.length); } } int i; int i; for (i=0; i<len; i++) { for (i=0; i<len; i++) { if (buffer[i] == '\0') { if (mKernelWakelockBuffer[i] == '\0') { len = i; len = i; break; break; } } Loading @@ -143,7 +147,7 @@ public class KernelWakelockReader { Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend"); Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend"); } } // Get kernel wakelock stats // Get kernel wakelock stats parseProcWakelocks(buffer, len, wakeup_sources, staleStats); parseProcWakelocks(mKernelWakelockBuffer, len, wakeup_sources, staleStats); return removeOldStats(staleStats); return removeOldStats(staleStats); } } } } Loading