Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76ac95e9 authored by Rhed Jao's avatar Rhed Jao Committed by Automerger Merge Worker
Browse files

Fixes an error handling in BugreportProgressService am: 39b6acbb

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532904

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I51ae9156cbb4148ce1b1c97e8d06fa23a4bccf8f
parents dfa52cd6 39b6acbb
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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);
+14 −1
Original line number Diff line number Diff line
@@ -512,6 +512,17 @@ public class BugreportReceiverTest {
        assertEquals("Didn't change state", STATE_HIDE, newState);
    }

    @Test
    public void testBugreportFinished_withEmptyBugreportFile() throws Exception {
        sendBugreportStarted();

        IoUtils.closeQuietly(mBugreportFd);
        mBugreportFd = null;
        sendBugreportFinished();

        assertServiceNotRunning();
    }

    @Test
    public void testShareBugreportAfterServiceDies() throws Exception {
        sendBugreportStarted();
@@ -647,7 +658,9 @@ public class BugreportReceiverTest {
     * Callbacks to service to finish the bugreport.
     */
    private void sendBugreportFinished() throws Exception {
        if (mBugreportFd != null) {
            writeZipFile(mBugreportFd, BUGREPORT_FILE, BUGREPORT_CONTENT);
        }
        if (mScreenshotFd != null) {
            writeScreenshotFile(mScreenshotFd, SCREENSHOT_CONTENT);
        }