Merge "Work on issue #29042642: Watchdog going off" into nyc-dev

am: 5a6cf3ac9a

* commit '5a6cf3ac9a3945c2d1f0e5e28ffda9e52124eb15':
  Work on issue #29042642: Watchdog going off

Change-Id: I2a3b120648aef7401bb6d4c2460f868cdc16c1a0
This commit is contained in:
Dianne Hackborn
2016-06-02 18:50:24 +00:00
committed by android-build-merger

View File

@@ -1,5 +1,6 @@
package com.android.internal.util; package com.android.internal.util;
import android.util.Log;
import android.util.Printer; import android.util.Printer;
import java.io.IOException; import java.io.IOException;
@@ -328,11 +329,13 @@ public class FastPrintWriter extends PrintWriter {
} }
private void flushBytesLocked() throws IOException { private void flushBytesLocked() throws IOException {
int position; if (!mIoError) {
if ((position = mBytes.position()) > 0) { int position;
mBytes.flip(); if ((position = mBytes.position()) > 0) {
mOutputStream.write(mBytes.array(), 0, position); mBytes.flip();
mBytes.clear(); mOutputStream.write(mBytes.array(), 0, position);
mBytes.clear();
}
} }
} }
@@ -352,11 +355,15 @@ public class FastPrintWriter extends PrintWriter {
} }
break; break;
} }
flushBytesLocked(); if (!mIoError) {
mOutputStream.flush(); flushBytesLocked();
mOutputStream.flush();
}
} else if (mWriter != null) { } else if (mWriter != null) {
mWriter.write(mText, 0, mPos); if (!mIoError) {
mWriter.flush(); mWriter.write(mText, 0, mPos);
mWriter.flush();
}
} else { } else {
int nonEolOff = 0; int nonEolOff = 0;
final int sepLen = mSeparator.length(); final int sepLen = mSeparator.length();
@@ -385,12 +392,15 @@ public class FastPrintWriter extends PrintWriter {
synchronized (lock) { synchronized (lock) {
try { try {
flushLocked(); flushLocked();
if (mOutputStream != null) { if (!mIoError) {
mOutputStream.flush(); if (mOutputStream != null) {
} else if (mWriter != null) { mOutputStream.flush();
mWriter.flush(); } else if (mWriter != null) {
mWriter.flush();
}
} }
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError(); setError();
} }
} }
@@ -407,6 +417,7 @@ public class FastPrintWriter extends PrintWriter {
mWriter.close(); mWriter.close();
} }
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError(); setError();
} }
} }
@@ -425,6 +436,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(charArray, 0, charArray.length); appendLocked(charArray, 0, charArray.length);
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }
@@ -442,6 +455,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(ch); appendLocked(ch);
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }
@@ -465,6 +480,7 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(str, 0, str.length()); appendLocked(str, 0, str.length());
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError(); setError();
} }
} }
@@ -500,6 +516,7 @@ public class FastPrintWriter extends PrintWriter {
flushLocked(); flushLocked();
} }
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError(); setError();
} }
} }
@@ -564,6 +581,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(buf, offset, count); appendLocked(buf, offset, count);
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }
@@ -584,6 +603,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked((char) oneChar); appendLocked((char) oneChar);
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }
@@ -600,6 +621,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(str, 0, str.length()); appendLocked(str, 0, str.length());
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }
@@ -624,6 +647,8 @@ public class FastPrintWriter extends PrintWriter {
try { try {
appendLocked(str, offset, count); appendLocked(str, offset, count);
} catch (IOException e) { } catch (IOException e) {
Log.w("FastPrintWriter", "Write failure", e);
setError();
} }
} }
} }