Merge "Fix spurious ANRs involving window shuffling and non-fullscreen activities"
diff --git a/common/java/com/android/common/Base64.java b/common/java/com/android/common/Base64.java
index 772d567..d65e24e 100644
--- a/common/java/com/android/common/Base64.java
+++ b/common/java/com/android/common/Base64.java
@@ -51,6 +51,13 @@
*/
public static final int WEB_SAFE = 8;
+ /**
+ * Flag to pass to Base64OutputStream to indicate that it should
+ * not close the output stream it is wrapping when it itself is
+ * closed.
+ */
+ public static final int NO_CLOSE = 16;
+
// --------------------------------------------------------
// decoding
// --------------------------------------------------------
diff --git a/common/java/com/android/common/Base64OutputStream.java b/common/java/com/android/common/Base64OutputStream.java
index 7c37428..76e1b6a 100644
--- a/common/java/com/android/common/Base64OutputStream.java
+++ b/common/java/com/android/common/Base64OutputStream.java
@@ -29,6 +29,7 @@
private final boolean encode;
private final Base64.EncoderState estate;
private final Base64.DecoderState dstate;
+ private final int flags;
private byte[] buffer = null;
private int bpos = 0;
@@ -59,6 +60,7 @@
*/
public Base64OutputStream(OutputStream out, int flags, boolean encode) {
super(out);
+ this.flags = flags;
this.encode = encode;
if (encode) {
estate = new Base64.EncoderState(flags, null);
@@ -106,7 +108,11 @@
public void close() throws IOException {
flushBuffer();
internalWrite(EMPTY, 0, 0, true);
- out.close();
+ if ((flags & Base64.NO_CLOSE) == 0) {
+ out.close();
+ } else {
+ out.flush();
+ }
}
/**