diff options
| author | 2010-09-02 22:29:05 -0700 | |
|---|---|---|
| committer | 2010-09-02 22:29:05 -0700 | |
| commit | fb79b7dab3ccaf490e8cbb18c9feed7080e4b54f (patch) | |
| tree | f589e50bb367519557c54e4695e8aa551c186708 | |
| parent | ea16e72bff350c0b6e2a00a82b934d1a2fc0fa2d (diff) | |
| parent | 12da9d7472ae87b841575d5358e19f143d12f900 (diff) | |
am 12da9d74: Fix buffer compacting in NativeDaemonConnector
Merge commit '12da9d7472ae87b841575d5358e19f143d12f900' into gingerbread-plus-aosp
* commit '12da9d7472ae87b841575d5358e19f143d12f900':
Fix buffer compacting in NativeDaemonConnector
| -rw-r--r-- | services/java/com/android/server/NativeDaemonConnector.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/services/java/com/android/server/NativeDaemonConnector.java b/services/java/com/android/server/NativeDaemonConnector.java index c45259064c45..f3cb9b782806 100644 --- a/services/java/com/android/server/NativeDaemonConnector.java +++ b/services/java/com/android/server/NativeDaemonConnector.java @@ -109,6 +109,10 @@ final class NativeDaemonConnector implements Runnable { int count = inputStream.read(buffer, start, BUFFER_SIZE - start); if (count < 0) break; + // Add our starting point to the count and reset the start. + count += start; + start = 0; + for (int i = 0; i < count; i++) { if (buffer[i] == 0) { String event = new String(buffer, start, i - start); @@ -140,6 +144,9 @@ final class NativeDaemonConnector implements Runnable { start = i + 1; } } + + // We should end at the amount we read. If not, compact then + // buffer and read again. if (start != count) { final int remaining = BUFFER_SIZE - start; System.arraycopy(buffer, start, buffer, 0, remaining); |