package epson.print.rpcopy.Component.ecopycomponent;

import android.content.Context;
import android.os.AsyncTask;

import com.epson.iprint.prtlogger.Analytics;
import com.epson.iprint.prtlogger.CommonLog;
import com.epson.iprint.prtlogger.PrintLog;

import java.util.ArrayList;
import java.util.Iterator;

import epson.print.Util.EPLog;
import epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy;
import epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation;
import epson.print.rpcopy.Component.eremoteoperation.ERemotePrinter;

class RemoteCopyTask extends AsyncTask<Void, Progress, Result> implements ECopyComponent.ITask {
    ERemoteCopy.IRemoteCancelParameter cancelParameter;
    boolean cancelRequested;
    String clientID;
    CopyMode copyMode;
    String jobToken;
    private Context mContext;
    private RepeatCopyAnalyticsParams mCopyParams;
    ERemoteCopy operation;
    ECopyOptionContext optionContext;
    Progress progress;
    String recoverJobToken;
    ECopyComponent.ICopyStatusListener statusListener;
    ERemoteCopy.IRemoteCopyStatusParameter statusParameter;
    ECopyComponent.ICopySystemSettings systemSettings;

    public enum CopyMode {
        Copy,
        Recover
    }

    class Progress {
        int currentPages;
        ECopyComponent.ICopyInvalidateResumeRequest resumeRequest;
        ECopyComponent.ICopyResumeRequest.ResumeState resumeState;
        ECopyComponent.ICopyStatusListener.CopyTaskProgress taskProgress;
        int totalPages;

        Progress() {
        }
    }

    class Result {
        ECopyComponent.ICopyStatusListener.CopyTaskResult taskResult;

        private void setResult(ERemoteOperation.ERemoteParam eRemoteParam) {
            switch (eRemoteParam) {
                case none:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.Succeed;
                    return;
                case success:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.Succeed;
                    return;
                case canceled:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.Canceled;
                    return;
                case busy:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.Busy;
                    return;
                case illegal_combination:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
                case memory_full:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
                case remove_adf_paper:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.RemoveAdfPaper;
                    return;
                case set_adf_paper:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
                case document_error:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
                case x_failed_communication:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorCommunication;
                    return;
                case unknown_token:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
                default:
                    taskResult = ECopyComponent.ICopyStatusListener.CopyTaskResult.ErrorOther;
                    return;
            }
        }

        public Result(ERemoteOperation.ERemoteParam eRemoteParam) {
            setResult(eRemoteParam);
        }

        public Result(ERemoteOperation.ERemoteReasonResult eRemoteReasonResult) {
            if (eRemoteReasonResult.isNull(ERemoteOperation.ERemoteParam.success)) {
                setResult(ERemoteOperation.ERemoteParam.x_failed_communication);
            } else {
                setResult(eRemoteReasonResult.reason());
            }
        }
    }

    static ECopyComponent.ICopyResumeRequest.StopReason getPrinterStopReason(ArrayList<ERemoteOperation.ERemoteParam> arrayList) {
        ECopyComponent.ICopyResumeRequest.StopReason stopReason = ECopyComponent.ICopyResumeRequest.StopReason.None;
        stopReason.string = ERemoteOperation.ERemoteParam.none.string;
        Iterator<ERemoteOperation.ERemoteParam> it = arrayList.iterator();
        while (it.hasNext()) {
            ERemoteOperation.ERemoteParam next = it.next();
            boolean z = true;
            switch (next) {
                case marker_supply_empty_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterMarkerSupplyEmptyError;
                    break;
                case marker_waste_full_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterMarkerWasteFullError;
                    break;
                case media_jam_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterMediaJamError;
                    break;
                case media_empty_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterMediaEmptyError;
                    break;
                case input_tray_missing_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterOtherError;
                    break;
                case cover_open_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterCoverOpenError;
                    break;
                case output_area_full_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterOutputAreaFullError;
                    break;
                case other_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.PrinterOtherError;
                    break;
                default:
                    z = false;
                    break;
            }
            if (z) {
                stopReason.string = next.string;
            }
        }
        return stopReason;
    }

    static ECopyComponent.ICopyResumeRequest.StopReason getScannerStopReason(ArrayList<ERemoteOperation.ERemoteParam> arrayList) {
        ECopyComponent.ICopyResumeRequest.StopReason stopReason = ECopyComponent.ICopyResumeRequest.StopReason.None;
        stopReason.string = ERemoteOperation.ERemoteParam.none.string;
        Iterator<ERemoteOperation.ERemoteParam> it = arrayList.iterator();
        while (it.hasNext()) {
            ERemoteOperation.ERemoteParam next = it.next();
            switch (next) {
                case media_jam_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.ScannerOtherError;
                    break;
                case media_empty_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.ScannerOtherError;
                    break;
                case other_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.ScannerOtherError;
                    break;
                case media_size_missmatch_error:
                    stopReason = ECopyComponent.ICopyResumeRequest.StopReason.ScannerOtherError;
                    break;
            }
            stopReason.string = next.string;
        }
        return stopReason;
    }

    public RemoteCopyTask(CopyMode copyMode2, String str, ECopyComponent.ICopyStatusListener iCopyStatusListener, Context context) {
        operation = new ERemoteCopy();
        progress = new Progress();
        statusListener = iCopyStatusListener;
        copyMode = copyMode2;
        recoverJobToken = str;
        mContext = context;
    }

    public RemoteCopyTask(CopyMode copyMode2, ECopyComponent.ICopyStatusListener iCopyStatusListener, Context context) {
        this(copyMode2, "", iCopyStatusListener, context);
    }

    public ECopyComponent.ICopyCancelRequest start() {
        super.execute(new Void[0]);
        return new ECopyComponent.ICopyCancelRequest() {
            public void cancel() {
                synchronized (this) {
                    RemoteCopyTask.this.cancelRequested = true;
                }
            }
        };
    }

    public void setSystemSettings(ECopyComponent.ICopySystemSettings iCopySystemSettings) {
        systemSettings = iCopySystemSettings;
    }

    public void setRequestConnectionTimeout(int i) {
        operation.setRequestConnectionTimeout(i);
    }

    public void setClientID(String str) {
        clientID = str;
    }

    public void setOptionContext(ECopyOptionContext eCopyOptionContext) {
        optionContext = eCopyOptionContext;
    }

    protected void onPreExecute() {
        cancelParameter = new ERemoteCopy.IRemoteCancelParameter() {
            public String client_id() {
                return RemoteCopyTask.this.clientID;
            }

            public String job_token() {
                return RemoteCopyTask.this.jobToken;
            }
        };
        statusParameter = new ERemoteCopy.IRemoteCopyStatusParameter() {
            public String client_id() {
                return RemoteCopyTask.this.clientID;
            }

            public String job_token() {
                return RemoteCopyTask.this.jobToken;
            }

            public ArrayList<ERemoteOperation.ERemoteParam> keys() {
                ArrayList<ERemoteOperation.ERemoteParam> arrayList = new ArrayList<>();
                arrayList.add(ERemoteOperation.ERemoteParam.job_state);
                arrayList.add(ERemoteOperation.ERemoteParam.job_result);
                arrayList.add(ERemoteOperation.ERemoteParam.job_tokens);
                arrayList.add(ERemoteOperation.ERemoteParam.printer_state);
                arrayList.add(ERemoteOperation.ERemoteParam.printer_state_reasons);
                arrayList.add(ERemoteOperation.ERemoteParam.scanner_state);
                arrayList.add(ERemoteOperation.ERemoteParam.scanner_state_reasons);
                arrayList.add(ERemoteOperation.ERemoteParam.job_print_total_pages);
                arrayList.add(ERemoteOperation.ERemoteParam.job_print_current_pages);
                return arrayList;
            }
        };
        statusListener.onStarted(ECopyComponent.ICopyStatusListener.CopyTaskType.Copy);
    }

    protected void onProgressUpdate(Progress... progressArr) {
        Progress progress2 = progressArr[0];
        statusListener.onProcessed(ECopyComponent.ICopyStatusListener.CopyTaskType.Copy, progress2.totalPages, progress2.currentPages, progress2.taskProgress, progress2.resumeRequest);
    }

    private void resumeNotify(ECopyComponent.ICopyResumeRequest.ResumeState resumeState) {
        synchronized (this.progress) {
            progress.resumeState = resumeState;
            progress.notify();
        }
    }

    private void resumeExecute() {
        ERemoteCopy.ERemoteCopyStatusResult status;
        if (this.progress.resumeRequest != null) {
            synchronized (this.progress) {
                while (true) {
                    try {
                        if (this.progress.resumeState == null) {
                            progress.wait(1000);
                            switch (this.operation.getStatus(this.statusParameter).printer_state()) {
                                case idle:
                                    progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Processing;
                                    localPublishProgress(this.progress);
                                    resumeNotify(ECopyComponent.ICopyResumeRequest.ResumeState.Cancel);
                                    continue;
                                case processing:
                                    progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Processing;
                                    localPublishProgress(this.progress);
                                    resumeNotify(ECopyComponent.ICopyResumeRequest.ResumeState.ClearError);
                                    continue;
                                case stopped:
                                    if (this.progress.resumeRequest.getStopReason().equals(getPrinterStopReason(status.printer_state_reasons()))) {
                                        continue;
                                    } else {
                                        return;
                                    }
                                default:
                                    continue;
                            }
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        switch (this.progress.resumeState) {
                            case ClearError:
                                ERemotePrinter eRemotePrinter = new ERemotePrinter();
                                eRemotePrinter.setHostIP(this.operation.getHostIP());
                                eRemotePrinter.setRequestConnectionTimeout(this.operation.getRequestConnectionTimeout());
                                eRemotePrinter.clearError(new ERemoteOperation.IRemoteOperationParameter() {
                                    public String client_id() {
                                        return RemoteCopyTask.this.clientID;
                                    }
                                });
                                for (int i = 0; i < 6 && !this.operation.getStatus(this.statusParameter).printer_state().equals(ERemoteOperation.ERemoteParam.processing); i++) {
                                    try {
                                        Thread.sleep(5000);
                                    } catch (InterruptedException e2) {
                                        e2.printStackTrace();
                                    }
                                }
                                break;
                            case Cancel:
                                cancelRequested = true;
                                break;
                            case NextPageReady:
                            case NextPageNotExist:
                                boolean success = operation.documentChanged(new ERemoteCopy.IRemoteCopyDocumentChangedParameter() {
                                    public String client_id() {
                                        return RemoteCopyTask.this.clientID;
                                    }

                                    public String job_token() {
                                        return RemoteCopyTask.this.jobToken;
                                    }

                                    public boolean next_document() {
                                        return RemoteCopyTask.this.progress.resumeState == ECopyComponent.ICopyResumeRequest.ResumeState.NextPageReady;
                                    }
                                }).success();
                                break;
                        }
                        Progress progress2 = progress;
                        progress2.resumeState = null;
                        progress2.resumeRequest = null;
                        return;
                    }
                }
            }
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v1, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v5, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyResult} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v6, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v7, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v8, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v9, resolved type: epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult} */
    /* access modifiers changed from: package-private */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation.ERemoteReasonResult startCopy() {
        /*
            r13 = this;
            epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$CopyMode r0 = r13.copyMode
            epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$CopyMode r1 = epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask.CopyMode.Copy
            if (r0 != r1) goto L_0x0071
            epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$6 r0 = new epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$6
            r0.<init>()
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionContext r1 = r13.optionContext
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemKey r2 = epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem.ECopyOptionItemKey.RepeatLayout
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem r1 = r1.getCopyOptionItemOf(r2)
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemChoice r1 = r1.getSelectedChoice()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteParam r1 = r1.param
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionContext r2 = r13.optionContext
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemKey r3 = epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem.ECopyOptionItemKey.RemoveBackground
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem r2 = r2.getCopyOptionItemOf(r3)
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemChoice r2 = r2.getSelectedChoice()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteParam r9 = r2.param
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionContext r2 = r13.optionContext
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemKey r3 = epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem.ECopyOptionItemKey.XCutLine
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem r2 = r2.getCopyOptionItemOf(r3)
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemChoice r2 = r2.getSelectedChoice()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteParam r10 = r2.param
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionContext r2 = r13.optionContext
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemKey r3 = epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem.ECopyOptionItemKey.XCutLineStyle
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem r2 = r2.getCopyOptionItemOf(r3)
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemChoice r2 = r2.getSelectedChoice()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteParam r11 = r2.param
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionContext r2 = r13.optionContext
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemKey r3 = epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem.ECopyOptionItemKey.XCutLineWeight
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem r2 = r2.getCopyOptionItemOf(r3)
            epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem$ECopyOptionItemChoice r2 = r2.getSelectedChoice()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteParam r12 = r2.param
            r2 = r13
            r3 = r0
            r4 = r1
            r5 = r9
            r6 = r10
            r7 = r11
            r8 = r12
            epson.print.rpcopy.Component.ecopycomponent.RepeatCopyAnalyticsParams r2 = r2.getCopyParams(r3, r4, r5, r6, r7, r8)
            r13.mCopyParams = r2
            epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy r2 = r13.operation
            epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyResult r0 = r2.copy(r3, r4, r5, r6, r7, r8)
            boolean r1 = r0.success()
            if (r1 == 0) goto L_0x00a1
            java.lang.String r1 = r0.job_token()
            r13.jobToken = r1
            goto L_0x00a1
        L_0x0071:
            epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy r0 = r13.operation
            epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$7 r1 = new epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask$7
            r1.<init>()
            epson.print.rpcopy.Component.eremoteoperation.ERemoteCopy$ERemoteCopyStatusResult r0 = r0.getStatus(r1)
            boolean r1 = r0.success()
            if (r1 == 0) goto L_0x00a1
            java.util.ArrayList r1 = r0.job_tokens()
            java.util.Iterator r1 = r1.iterator()
        L_0x008a:
            boolean r2 = r1.hasNext()
            if (r2 == 0) goto L_0x00a1
            java.lang.Object r2 = r1.next()
            java.lang.String r2 = (java.lang.String) r2
            java.lang.String r3 = r13.recoverJobToken
            boolean r3 = r2.equals(r3)
            if (r3 == 0) goto L_0x008a
            r13.jobToken = r2
            goto L_0x008a
        L_0x00a1:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: epson.print.rpcopy.Component.ecopycomponent.RemoteCopyTask.startCopy():epson.print.rpcopy.Component.eremoteoperation.ERemoteOperation$ERemoteReasonResult");
    }

    private RepeatCopyAnalyticsParams getCopyParams(@NonNull ERemoteCopy.IRemoteCopyParameter iRemoteCopyParameter, @NonNull ERemoteOperation.ERemoteParam eRemoteParam, @NonNull ERemoteOperation.ERemoteParam eRemoteParam2, @NonNull ERemoteOperation.ERemoteParam eRemoteParam3, @NonNull ERemoteOperation.ERemoteParam eRemoteParam4, @NonNull ERemoteOperation.ERemoteParam eRemoteParam5) {
        try {
            RepeatCopyAnalyticsParams repeatCopyAnalyticsParams = new RepeatCopyAnalyticsParams();
            repeatCopyAnalyticsParams.colorMode = iRemoteCopyParameter.color_effects_type().toString();
            repeatCopyAnalyticsParams.density = Integer.toString(iRemoteCopyParameter.x_density());
            repeatCopyAnalyticsParams.repeatLayout = eRemoteParam.toString();
            repeatCopyAnalyticsParams.paperSize = iRemoteCopyParameter.print_media_size().toString();
            repeatCopyAnalyticsParams.paperType = iRemoteCopyParameter.print_media_type().toString();
            repeatCopyAnalyticsParams.printDevice = iRemoteCopyParameter.print_media_source().toString();
            repeatCopyAnalyticsParams.copyQuality = iRemoteCopyParameter.print_quality().toString();
            repeatCopyAnalyticsParams.removeBackground = eRemoteParam2.toString();
            if (!(eRemoteParam3 == null || eRemoteParam3 == ERemoteOperation.ERemoteParam.dash)) {
                repeatCopyAnalyticsParams.XCutLine = eRemoteParam3.toString();
                if (eRemoteParam3 == ERemoteOperation.ERemoteParam.on) {
                    repeatCopyAnalyticsParams.XCutLineStyle = eRemoteParam4.toString();
                    repeatCopyAnalyticsParams.XCutLineWeight = eRemoteParam5.toString();
                }
            }
            return repeatCopyAnalyticsParams;
        } catch (Throwable unused) {
            return null;
        }
    }

    protected Result doInBackground(Void... voidArr) {
        operation.setHostIP(this.systemSettings.getPrinterIPAddress());
        ERemoteOperation.ERemoteReasonResult startCopy = startCopy();
        if (!startCopy.success()) {
            return new Result(startCopy);
        }
        Result result = null;
        boolean z = false;
        boolean z2 = false;
        while (!z) {
            if (this.cancelRequested && !z2) {
                if (!this.operation.cancel(this.cancelParameter).success()) {
                    return new Result(ERemoteOperation.ERemoteParam.canceled);
                }
                z2 = true;
            }
            final ERemoteCopy.ERemoteCopyStatusResult status = operation.getStatus(this.statusParameter);
            if (!status.success()) {
                sendLog(this.progress.currentPages);
                return new Result((ERemoteOperation.ERemoteReasonResult) status);
            }
            Result result2 = new Result(status.job_result());
            progress.totalPages = status.job_print_total_pages();
            progress.currentPages = status.job_print_current_pages();
            if (this.progress.currentPages < 1) {
                progress.currentPages = 1;
            }
            ERemoteOperation.ERemoteParam job_state = status.job_state();
            switch (job_state) {
                case scanning:
                    progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Scanning;
                    break;
                case copying:
                    progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Copying;
                    break;
                case canceling:
                    progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Canceling;
                    break;
                case nextpaper:
                    Progress progress2 = progress;
                    progress2.resumeState = null;
                    progress2.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Waiting2ndPage;
                    progress.resumeRequest = new ECopyComponent.ICopyInvalidateResumeRequest() {
                        public void invalidate() {
                        }

                        public boolean isPossibleClearError() {
                            return false;
                        }

                        public ECopyComponent.ICopyResumeRequest.StopReason getStopReason() {
                            return ECopyComponent.ICopyResumeRequest.StopReason.ChangePage;
                        }

                        public void resume(ECopyComponent.ICopyResumeRequest.ResumeState resumeState) {
                            RemoteCopyTask.this.resumeNotify(resumeState);
                        }
                    };
                    break;
                case finished:
                    sendLog(this.progress.currentPages);
                    result = result2;
                    z = true;
                    continue;
            }
            switch (status.printer_state()) {
                case stopped:
                    if (job_state == ERemoteOperation.ERemoteParam.copying || job_state == ERemoteOperation.ERemoteParam.scanning) {
                        Progress progress3 = progress;
                        progress3.resumeState = null;
                        progress3.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Stopped;
                        progress.resumeRequest = new ECopyComponent.ICopyInvalidateResumeRequest() {
                            public void invalidate() {
                            }

                            public ECopyComponent.ICopyResumeRequest.StopReason getStopReason() {
                                ECopyComponent.ICopyResumeRequest.StopReason printerStopReason = RemoteCopyTask.getPrinterStopReason(status.printer_state_reasons());
                                return printerStopReason == ECopyComponent.ICopyResumeRequest.StopReason.None ? RemoteCopyTask.getScannerStopReason(status.scanner_state_reasons()) : printerStopReason;
                            }

                            public boolean isPossibleClearError() {
                                switch (RemoteCopyTask.getPrinterStopReason(status.printer_state_reasons())) {
                                    case PrinterMarkerSupplyEmptyError:
                                        return false;
                                    case PrinterMarkerWasteFullError:
                                        return false;
                                    case PrinterMediaJamError:
                                        return true;
                                    case PrinterMediaEmptyError:
                                        return true;
                                    case PrinterInputTrayMissingError:
                                        return true;
                                    case PrinterCoverOpenError:
                                        return false;
                                    case PrinterOutputAreaFullError:
                                        return true;
                                    case PrinterOtherError:
                                        return false;
                                    default:
                                        switch (RemoteCopyTask.getScannerStopReason(status.scanner_state_reasons())) {
                                            case ScannerMediaEmptyError:
                                                return true;
                                            case ScannerMediaJamError:
                                                return true;
                                            case ScannerMediaSizeMissmatchError:
                                                return true;
                                            case ScannerOtherError:
                                                return true;
                                            default:
                                                return false;
                                        }
                                }
                            }

                            public void resume(ECopyComponent.ICopyResumeRequest.ResumeState resumeState) {
                                RemoteCopyTask.this.progress.taskProgress = ECopyComponent.ICopyStatusListener.CopyTaskProgress.Processing;
                                RemoteCopyTask remoteCopyTask = RemoteCopyTask.this;
                                remoteCopyTask.localPublishProgress(remoteCopyTask.progress);
                                RemoteCopyTask.this.resumeNotify(resumeState);
                            }
                        };
                        break;
                    }
            }
            localPublishProgress(this.progress);
            resumeExecute();
            try {
                Thread.sleep((long) 1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            result = result2;
        }
        return result;
    }

    private void sendLog(int i) {
        RepeatCopyAnalyticsParams repeatCopyAnalyticsParams = mCopyParams;
        Context context = mContext;
        if (context != null && repeatCopyAnalyticsParams != null) {
            CommonLog commonLog = new CommonLog();
            commonLog.setConnectionType(context);
            commonLog.setPrinterName(context);
            commonLog.action = PrintLog.ACTION_REPEAT_COPY;
            commonLog.numberOfSheet = i;
            Analytics.sendRepeatCopyLog(context, repeatCopyAnalyticsParams, commonLog);
        }
    }

    private void localPublishProgress(Progress... progressArr) {
        if (progressArr[0].taskProgress == null) {
            EPLog.e("RemoteCOpyTask", "Error: Progress.taskProgress == null");
        } else {
            publishProgress(progressArr);
        }
    }

    protected void onPostExecute(Result result) {
        statusListener.onFinished(ECopyComponent.ICopyStatusListener.CopyTaskType.Copy, result.taskResult);
    }
}
