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

Commit b59555ca authored by Svetoslav's avatar Svetoslav Committed by Svetoslav Ganov
Browse files

Print to PDF putting a pring job in a wrong state.

When printing to a PDF file we get a Uri from the storage APIs
and write the content. Once the file is written to storage the
print job is completed and there is print service involved. Th
spooler was wrongly putting the job in a failed state instead
of a complete state.

bug:16522267

Change-Id: I4741c9b9eb763e118e7dfb2c7c502bd7fc13f7a1
parent e138eb58
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
    private static final int STATE_CREATE_FILE_FAILED = 4;
    private static final int STATE_PRINTER_UNAVAILABLE = 5;
    private static final int STATE_UPDATE_SLOW = 6;
    private static final int STATE_PRINT_COMPLETED = 7;

    private static final int UI_STATE_PREVIEW = 0;
    private static final int UI_STATE_ERROR = 1;
@@ -304,6 +305,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
                    spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_QUEUED, null);
                } break;

                case STATE_PRINT_COMPLETED: {
                    spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_COMPLETED, null);
                } break;

                case STATE_CREATE_FILE_FAILED: {
                    spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_FAILED,
                            getString(R.string.print_write_error_message));
@@ -539,6 +544,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat

    private void onStartCreateDocumentActivityResult(int resultCode, Intent data) {
        if (resultCode == RESULT_OK && data != null) {
            setState(STATE_PRINT_COMPLETED);
            updateOptionsUi();
            Uri uri = data.getData();
            mPrintedDocument.writeContent(getContentResolver(), uri);
            // Calling finish here does not invoke lifecycle callbacks but we
@@ -706,7 +713,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat

    private static boolean isFinalState(int state) {
        return state == STATE_PRINT_CONFIRMED
                || state == STATE_PRINT_CANCELED;
                || state == STATE_PRINT_CANCELED
                || state == STATE_PRINT_COMPLETED;
    }

    private void updateSelectedPagesFromPreview() {
@@ -1060,6 +1068,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
        }

        if (mState == STATE_PRINT_CONFIRMED
                || mState == STATE_PRINT_COMPLETED
                || mState == STATE_PRINT_CANCELED
                || mState == STATE_UPDATE_FAILED
                || mState == STATE_CREATE_FILE_FAILED