Merge "Stop bugreportd if binder call fails"
am: 8cf74c36c0

Change-Id: Ife5c3c7090423b084b829c16f1d7d4a931c1936e
diff --git a/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java b/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java
index 5c0874d..c98a79a 100644
--- a/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java
+++ b/services/core/java/com/android/server/os/BugreportManagerServiceImpl.java
@@ -174,7 +174,11 @@
             ds.startBugreport(callingUid, callingPackage,
                     bugreportFd, screenshotFd, bugreportMode, myListener);
         } catch (RemoteException e) {
-            reportError(listener, IDumpstateListener.BUGREPORT_ERROR_RUNTIME_ERROR);
+            // bugreportd service is already started now. We need to kill it to manage the
+            // lifecycle correctly. If we don't subsequent callers will get
+            // BUGREPORT_ERROR_ANOTHER_REPORT_IN_PROGRESS error.
+            // Note that listener will be notified by the death recipient below.
+            cancelBugreport();
         }
     }