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

Commit ef5577a1 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Android (Google) Code Review
Browse files

Merge "Treat all remotedocumentadapter-command results as cancel in the case...

Merge "Treat all remotedocumentadapter-command results as cancel in the case we are canceling the command." into nyc-dev
parents 386f7853 27db6611
Loading
Loading
Loading
Loading
+45 −16
Original line number Diff line number Diff line
@@ -870,39 +870,56 @@ public final class RemotePrintDocument {
                // AsyncCommand.AsyncCommandHandler#handleMessage
                if (isFailed()) {
                    if (DEBUG) {
                        Log.i(LOG_TAG, "[CALLBACK] on canceled layout command");
                        Log.i(LOG_TAG, "[CALLBACK] on failed layout command");
                    }

                    return;
                } else {
                    if (message.what != MSG_ON_LAYOUT_STARTED) {
                        // No need to force cancel anymore if layout finished
                }

                int sequence;
                int what = message.what;
                switch (what) {
                    case MSG_ON_LAYOUT_FINISHED:
                        removeForceCancel();
                        sequence = message.arg2;
                        break;
                    case MSG_ON_LAYOUT_FAILED:
                    case MSG_ON_LAYOUT_CANCELED:
                        removeForceCancel();
                        // $FALL-THROUGH - message uses the same format as "started"
                    case MSG_ON_LAYOUT_STARTED:
                        // Don't remote force-cancel as command is still running and might need to
                        // be canceled later
                        sequence = message.arg1;
                        break;
                    default:
                        // not reached
                        sequence = -1;
                }

                // If we are canceling any result is treated as a cancel
                if (isCanceling() && what != MSG_ON_LAYOUT_STARTED) {
                    what = MSG_ON_LAYOUT_CANCELED;
                }

                switch (message.what) {
                switch (what) {
                    case MSG_ON_LAYOUT_STARTED: {
                        ICancellationSignal cancellation = (ICancellationSignal) message.obj;
                        final int sequence = message.arg1;
                        handleOnLayoutStarted(cancellation, sequence);
                    } break;

                    case MSG_ON_LAYOUT_FINISHED: {
                        PrintDocumentInfo info = (PrintDocumentInfo) message.obj;
                        final boolean changed = (message.arg1 == 1);
                        final int sequence = message.arg2;
                        handleOnLayoutFinished(info, changed, sequence);
                    } break;

                    case MSG_ON_LAYOUT_FAILED: {
                        CharSequence error = (CharSequence) message.obj;
                        final int sequence = message.arg1;
                        handleOnLayoutFailed(error, sequence);
                    } break;

                    case MSG_ON_LAYOUT_CANCELED: {
                        final int sequence = message.arg1;
                        handleOnLayoutCanceled(sequence);
                    } break;
                }
@@ -1142,18 +1159,30 @@ public final class RemotePrintDocument {
                // AsyncCommand.AsyncCommandHandler#handleMessage
                if (isFailed()) {
                    if (DEBUG) {
                        Log.i(LOG_TAG, "[CALLBACK] on canceled write command");
                        Log.i(LOG_TAG, "[CALLBACK] on failed write command");
                    }

                    return;
                } else {
                    if (message.what != MSG_ON_WRITE_STARTED) {
                        // No need to force cancel anymore if write finished
                }

                int what = message.what;
                switch (what) {
                    case MSG_ON_WRITE_FINISHED:
                    case MSG_ON_WRITE_FAILED:
                    case MSG_ON_WRITE_CANCELED:
                        removeForceCancel();
                    case MSG_ON_WRITE_STARTED:
                        // Don't remote force-cancel as command is still running and might need to
                        // be canceled later
                        break;
                }

                // If we are canceling any result is treated as a cancel
                if (isCanceling() && what != MSG_ON_WRITE_STARTED) {
                    what = MSG_ON_WRITE_CANCELED;
                }

                switch (message.what) {
                switch (what) {
                    case MSG_ON_WRITE_STARTED: {
                        ICancellationSignal cancellation = (ICancellationSignal) message.obj;
                        final int sequence = message.arg1;