Loading packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java +4 −4 Original line number Diff line number Diff line Loading @@ -282,12 +282,10 @@ public final class RemotePrintDocument { Log.i(LOG_TAG, "[CALLED] cancel()"); } if (mState == STATE_CANCELING) { return; } mNextCommand = null; if (mState != STATE_UPDATING) { throw new IllegalStateException("Cannot cancel in state:" + stateToString(mState)); return; } mState = STATE_CANCELING; Loading Loading @@ -568,6 +566,8 @@ public final class RemotePrintDocument { Log.w(LOG_TAG, "Error while canceling", re); } } } else if (isCanceling()) { // Nothing to do } else { canceled(); Loading packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +37 −18 Original line number Diff line number Diff line Loading @@ -320,9 +320,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (isFinishing() || (isFinalState(mState) && !mPrintedDocument.isUpdating())) { return; } if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } setState(STATE_PRINT_CANCELED); doFinish(); } Loading Loading @@ -372,12 +370,14 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat spooler.updatePrintJobUserConfigurableOptionsNoPersistence(mPrintJob); switch (mState) { case STATE_PRINT_CONFIRMED: { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_QUEUED, null); } break; case STATE_PRINT_COMPLETED: { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_COMPLETED, null); if (mCurrentPrinter == mDestinationSpinnerAdapter.getPdfPrinter()) { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_COMPLETED, null); } else { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_QUEUED, null); } } break; case STATE_CREATE_FILE_FAILED: { Loading Loading @@ -491,6 +491,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat requestCreatePdfFileOrFinish(); } break; case STATE_CREATE_FILE_FAILED: case STATE_PRINT_COMPLETED: case STATE_PRINT_CANCELED: { doFinish(); } break; Loading Loading @@ -528,8 +530,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat requestCreatePdfFileOrFinish(); } break; case STATE_CREATE_FILE_FAILED: case STATE_PRINT_COMPLETED: case STATE_PRINT_CANCELED: { updateOptionsUi(); doFinish(); } break; default: { Loading @@ -550,6 +556,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mProgressMessageController.cancel(); ensureErrorUiShown(error, PrintErrorFragment.ACTION_RETRY); if (mState == STATE_CREATE_FILE_FAILED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_CANCELED) { doFinish(); } setState(STATE_UPDATE_FAILED); updateOptionsUi(); Loading Loading @@ -644,7 +656,6 @@ 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(); final Uri uri = data.getData(); // Calling finish here does not invoke lifecycle callbacks but we Loading @@ -657,6 +668,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat }); } else if (resultCode == RESULT_CANCELED) { mState = STATE_CONFIGURING; // The previous update might have been canceled updateDocument(false); updateOptionsUi(); } else { setState(STATE_CREATE_FILE_FAILED); Loading Loading @@ -875,9 +890,9 @@ 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_COMPLETED; return state == STATE_PRINT_CANCELED || state == STATE_PRINT_COMPLETED || state == STATE_CREATE_FILE_FAILED; } private void updateSelectedPagesFromPreview() { Loading Loading @@ -998,6 +1013,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } private void requestCreatePdfFileOrFinish() { mPrintedDocument.cancel(); if (mCurrentPrinter == mDestinationSpinnerAdapter.getPdfPrinter()) { startCreateDocumentActivity(); } else { Loading Loading @@ -1113,9 +1130,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void cancelPrint() { setState(STATE_PRINT_CANCELED); updateOptionsUi(); if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } doFinish(); } Loading Loading @@ -1874,9 +1889,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat public void onPrinterUnavailable(PrinterInfo printer) { if (mCurrentPrinter.getId().equals(printer.getId())) { setState(STATE_PRINTER_UNAVAILABLE); if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), PrintErrorFragment.ACTION_NONE); updateOptionsUi(); Loading Loading @@ -1933,12 +1946,18 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (writeToUri != null) { mPrintedDocument.writeContent(getContentResolver(), writeToUri); } setState(STATE_PRINT_COMPLETED); doFinish(); } }).transform(); } private void doFinish() { if (mPrintedDocument.isUpdating()) { // The printedDocument will call doFinish() when the current command finishes return; } if (mPrinterRegistry != null) { mPrinterRegistry.setTrackedPrinter(null); } Loading Loading
packages/PrintSpooler/src/com/android/printspooler/model/RemotePrintDocument.java +4 −4 Original line number Diff line number Diff line Loading @@ -282,12 +282,10 @@ public final class RemotePrintDocument { Log.i(LOG_TAG, "[CALLED] cancel()"); } if (mState == STATE_CANCELING) { return; } mNextCommand = null; if (mState != STATE_UPDATING) { throw new IllegalStateException("Cannot cancel in state:" + stateToString(mState)); return; } mState = STATE_CANCELING; Loading Loading @@ -568,6 +566,8 @@ public final class RemotePrintDocument { Log.w(LOG_TAG, "Error while canceling", re); } } } else if (isCanceling()) { // Nothing to do } else { canceled(); Loading
packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +37 −18 Original line number Diff line number Diff line Loading @@ -320,9 +320,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (isFinishing() || (isFinalState(mState) && !mPrintedDocument.isUpdating())) { return; } if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } setState(STATE_PRINT_CANCELED); doFinish(); } Loading Loading @@ -372,12 +370,14 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat spooler.updatePrintJobUserConfigurableOptionsNoPersistence(mPrintJob); switch (mState) { case STATE_PRINT_CONFIRMED: { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_QUEUED, null); } break; case STATE_PRINT_COMPLETED: { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_COMPLETED, null); if (mCurrentPrinter == mDestinationSpinnerAdapter.getPdfPrinter()) { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_COMPLETED, null); } else { spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_QUEUED, null); } } break; case STATE_CREATE_FILE_FAILED: { Loading Loading @@ -491,6 +491,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat requestCreatePdfFileOrFinish(); } break; case STATE_CREATE_FILE_FAILED: case STATE_PRINT_COMPLETED: case STATE_PRINT_CANCELED: { doFinish(); } break; Loading Loading @@ -528,8 +530,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat requestCreatePdfFileOrFinish(); } break; case STATE_CREATE_FILE_FAILED: case STATE_PRINT_COMPLETED: case STATE_PRINT_CANCELED: { updateOptionsUi(); doFinish(); } break; default: { Loading @@ -550,6 +556,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mProgressMessageController.cancel(); ensureErrorUiShown(error, PrintErrorFragment.ACTION_RETRY); if (mState == STATE_CREATE_FILE_FAILED || mState == STATE_PRINT_COMPLETED || mState == STATE_PRINT_CANCELED) { doFinish(); } setState(STATE_UPDATE_FAILED); updateOptionsUi(); Loading Loading @@ -644,7 +656,6 @@ 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(); final Uri uri = data.getData(); // Calling finish here does not invoke lifecycle callbacks but we Loading @@ -657,6 +668,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat }); } else if (resultCode == RESULT_CANCELED) { mState = STATE_CONFIGURING; // The previous update might have been canceled updateDocument(false); updateOptionsUi(); } else { setState(STATE_CREATE_FILE_FAILED); Loading Loading @@ -875,9 +890,9 @@ 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_COMPLETED; return state == STATE_PRINT_CANCELED || state == STATE_PRINT_COMPLETED || state == STATE_CREATE_FILE_FAILED; } private void updateSelectedPagesFromPreview() { Loading Loading @@ -998,6 +1013,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat } private void requestCreatePdfFileOrFinish() { mPrintedDocument.cancel(); if (mCurrentPrinter == mDestinationSpinnerAdapter.getPdfPrinter()) { startCreateDocumentActivity(); } else { Loading Loading @@ -1113,9 +1130,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private void cancelPrint() { setState(STATE_PRINT_CANCELED); updateOptionsUi(); if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } doFinish(); } Loading Loading @@ -1874,9 +1889,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat public void onPrinterUnavailable(PrinterInfo printer) { if (mCurrentPrinter.getId().equals(printer.getId())) { setState(STATE_PRINTER_UNAVAILABLE); if (mPrintedDocument.isUpdating()) { mPrintedDocument.cancel(); } ensureErrorUiShown(getString(R.string.print_error_printer_unavailable), PrintErrorFragment.ACTION_NONE); updateOptionsUi(); Loading Loading @@ -1933,12 +1946,18 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat if (writeToUri != null) { mPrintedDocument.writeContent(getContentResolver(), writeToUri); } setState(STATE_PRINT_COMPLETED); doFinish(); } }).transform(); } private void doFinish() { if (mPrintedDocument.isUpdating()) { // The printedDocument will call doFinish() when the current command finishes return; } if (mPrinterRegistry != null) { mPrinterRegistry.setTrackedPrinter(null); } Loading