From 39b6acbb55b037ba6dbeb092eb93caddd277a2cd Mon Sep 17 00:00:00 2001 From: Rhed Jao Date: Mon, 7 Dec 2020 17:58:26 +0800 Subject: Fixes an error handling in BugreportProgressService Calls onError function when bugreport is finished and file is empty. Bug: 174314124 Bug: 175287931 Test: atest BugreportReceiverTest Change-Id: I4542568fd2d2ad1c75c7c3b223accca4995938a3 Merged-In: I4542568fd2d2ad1c75c7c3b223accca4995938a3 --- .../Shell/src/com/android/shell/BugreportProgressService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'packages/Shell/src') diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index f7b1c5bf9c5b..2b71892ee8a5 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -380,6 +380,11 @@ public class BugreportProgressService extends Service { public void onFinished() { mInfo.renameBugreportFile(); mInfo.renameScreenshots(); + if (mInfo.bugreportFile.length() == 0) { + Log.e(TAG, "Bugreport file empty. File path = " + mInfo.bugreportFile); + onError(BUGREPORT_ERROR_RUNTIME); + return; + } synchronized (mLock) { sendBugreportFinishedBroadcastLocked(); mMainThreadHandler.post(() -> mInfoDialog.onBugreportFinished(mInfo)); @@ -408,10 +413,6 @@ public class BugreportProgressService extends Service { @GuardedBy("mLock") private void sendBugreportFinishedBroadcastLocked() { final String bugreportFilePath = mInfo.bugreportFile.getAbsolutePath(); - if (mInfo.bugreportFile.length() == 0) { - Log.e(TAG, "Bugreport file empty. File path = " + bugreportFilePath); - return; - } if (mInfo.type == BugreportParams.BUGREPORT_MODE_REMOTE) { sendRemoteBugreportFinishedBroadcast(mContext, bugreportFilePath, mInfo.bugreportFile); -- cgit v1.2.3-59-g8ed1b