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

Commit d270cb92 authored by Svetoslav's avatar Svetoslav
Browse files

Cancel current work in PrintDocumentAdatper if printing is cancelled.

Layout and write may take some time during which the user can
cancel printing. Currently we wait for the last operation,
being write or layout, to complete before closing the print
dialog. Now in such a scenario we request a cancellation of
the ongoing operation.

bug:11329523

Change-Id: Ia9d747163cc73509369a86c8b5afc83b7ee54859
parent b207ea96
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,4 +37,5 @@ oneway interface IPrintDocumentAdapter {
    void write(in PageRange[] pages, in ParcelFileDescriptor fd,
            IWriteResultCallback callback, int sequence);
    void finish();
    void cancel();
}
+12 −0
Original line number Diff line number Diff line
@@ -615,6 +615,18 @@ public final class PrintManager {
            }
        }

        @Override
        public void cancel() {
            // Start not called or finish called or destroyed - nothing to do.
            if (!mStartReqeusted || mFinishRequested || mDestroyed) {
                return;
            }
            // Request cancellation of pending work if needed.
            synchronized (mLock) {
                cancelPreviousCancellableOperationLocked();
            }
        }

        @Override
        public void onActivityPaused(Activity activity) {
            /* do nothing */
+3 −0
Original line number Diff line number Diff line
@@ -357,6 +357,9 @@ public class PrintJobConfigActivity extends Activity {
        }

        public void cancel() {
            if (isWorking()) {
                mRemotePrintAdapter.cancel();
            }
            mControllerState = CONTROLLER_STATE_CANCELLED;
        }

+11 −0
Original line number Diff line number Diff line
@@ -137,4 +137,15 @@ final class RemotePrintDocumentAdapter {
            Log.e(LOG_TAG, "Error calling finish()", re);
        }
    }

    public void cancel() {
        if (DEBUG) {
            Log.i(LOG_TAG, "cancel()");
        }
        try {
            mRemoteInterface.cancel();
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error calling cancel()", re);
        }
    }
}