From f032537ceacbc1834883ac34a4c3e81e0308fe81 Mon Sep 17 00:00:00 2001 From: songjinshi Date: Mon, 30 May 2016 20:58:18 +0800 Subject: [PATCH] Fixes the system server hang forever issue caused by the monkey not read completed the sync pipe. - Incorrect exception handle. When no space left on the device the write will occurs an I/O exception, so we needed to catch it and continue to read the data of the sync pipe to aviod the bugreport hang forever. https://code.google.com/p/android/issues/detail?id=211970 Change-Id: I80c6548434587bcc17b50f0c246a5887cdd339cf Signed-off-by: songjinshi --- .../src/com/android/commands/monkey/Monkey.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java index 93bfcf0bb..81d63c68b 100644 --- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java +++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java @@ -433,8 +433,18 @@ public class Monkey { String s; while ((s = inBuffer.readLine()) != null) { if (mRequestBugreport) { - logOutput.write(s); - logOutput.write("\n"); + try { + // When no space left on the device the write will + // occurs an I/O exception, so we needed to catch it + // and continue to read the data of the sync pipe to + // aviod the bugreport hang forever. + logOutput.write(s); + logOutput.write("\n"); + } catch (IOException e) { + while(inBuffer.readLine() != null) {} + System.err.println(e.toString()); + break; + } } else { System.err.println(s); }