Potential fix for bug: 2564824 : Device runtime restart in BatteryService

Look for corrupted bytes and replace with ?

If the problem is in the parsing code, then this will not help.

Change-Id: If33643f126a4099d4113e37760c6ef74683fe97e
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 24275ec..833c01b 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -895,9 +895,15 @@
 
                 String[] nameStringArray = mProcWakelocksName;
                 long[] wlData = mProcWakelocksData;
+                // Stomp out any bad characters since this is from a circular buffer
+                // A corruption is seen sometimes that results in the vm crashing
+                // This should prevent crashes and the line will probably fail to parse
+                for (int j = startIndex; j < endIndex; j++) {
+                    if ((wlBuffer[j] & 0x80) != 0) wlBuffer[j] = (byte) '?';
+                }
                 boolean parsed = Process.parseProcLine(wlBuffer, startIndex, endIndex,
                         PROC_WAKELOCKS_FORMAT, nameStringArray, wlData, null);
-                
+
                 name = nameStringArray[0];
                 count = (int) wlData[1];
                 // convert nanoseconds to microseconds with rounding.