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,6 +329,7 @@ public class FastPrintWriter extends PrintWriter {
} }
private void flushBytesLocked() throws IOException { private void flushBytesLocked() throws IOException {
if (!mIoError) {
int position; int position;
if ((position = mBytes.position()) > 0) { if ((position = mBytes.position()) > 0) {
mBytes.flip(); mBytes.flip();
@@ -335,6 +337,7 @@ public class FastPrintWriter extends PrintWriter {
mBytes.clear(); mBytes.clear();
} }
} }
}
private void flushLocked() throws IOException { private void flushLocked() throws IOException {
//Log.i("PackageManager", "flush mPos=" + mPos); //Log.i("PackageManager", "flush mPos=" + mPos);
@@ -352,11 +355,15 @@ public class FastPrintWriter extends PrintWriter {
} }
break; break;
} }
if (!mIoError) {
flushBytesLocked(); flushBytesLocked();
mOutputStream.flush(); mOutputStream.flush();
}
} else if (mWriter != null) { } else if (mWriter != null) {
if (!mIoError) {
mWriter.write(mText, 0, mPos); mWriter.write(mText, 0, mPos);
mWriter.flush(); 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 (!mIoError) {
if (mOutputStream != null) { if (mOutputStream != null) {
mOutputStream.flush(); mOutputStream.flush();
} else if (mWriter != null) { } else if (mWriter != null) {
mWriter.flush(); 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();
} }
} }
} }