package epson.print.service;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.os.RemoteException;

import com.epson.cameracopy.printlayout.ImageAndLayout;
import com.epson.iprint.apf.ApfEpImageAdapter;
import com.epson.iprint.storage.StorageSecureStore;
import com.epson.mobilephone.common.PrintingLib.define.Constants;
import com.epson.mobilephone.common.escpr.EscprError;
import com.epson.mobilephone.common.escpr.EscprLib;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;

import epson.common.ExternalFileUtils;
import epson.common.Info_paper;
import epson.common.Utils;
import epson.print.EPImageCreator;
import epson.print.EPImageList;
import epson.print.EPPrinterManager;
import epson.print.MyPrinter;
import epson.print.Util.EPLog;
import epson.print.ecclient.EcClientLib;
import epson.print.ecclient.EcClientLibUtil;
import epson.print.ecclient.EpsJobAttrib;
import epson.print.ecclient.EpsMediaSize;
import epson.print.ecclient.EpsMediaType;
import epson.print.ecclient.EpsSupportedMedia;
import epson.print.screen.PrintSetting;
import epson.provider.SharedPreferencesProvider;

public class EpsonService extends Service implements ApfEpImageAdapter.ProgressCallback, PrintService {
    static final int DISABLE_SIMPLE_AP_TIMEOUT = 1800;
    public static final int EPS_ERR_MEMORY_ALLOCATION = -1001;
    public static final int EPS_ERR_NONE = 0;
    private static final int EPS_MLID_BORDERLESS = 1;
    static final int EPS_MSID_A3 = 62;
    static final int EPS_MSID_B4 = 63;
    static final int EPS_MSID_LEGAL = 2;
    public static final int MEDIA_INFO_MEMORY_ERROR = -5201;
    static final int NOT_SET_TIMEOUT = -1;
    public static final String PREFS_NAME = "PrintSetting";
    public static final int PROGRESS_NOTIFY_TYPE_APF = 2;
    public static final int PROGRESS_NOTIFY_TYPE_PRINTING = 1;
    private static volatile boolean bCancelPrinting = false;
    public static boolean bNotifyPrinter = false;
    private static boolean isInitDriver = false;
    static final RemoteCallbackList<IEpsonServiceCallback> mCallbacks = new RemoteCallbackList<>();
    private static final Object mCancelLock = new Object();
    private static final Object mConnect = new Object();
    private static final Object mLock = new Object();
    private static final Object mLockPrintingStatus = new Object();
    private static final Object mLockSearchingStatus = new Object();
    private static final Object mPrinting = new Object();
    private final int EPS_ERR_PRINTER_NOT_SET = EscprError.EPS_ERR_PRINTER_NOT_SET;
    private final int EPS_PRNERR_COMM = 102;
    private final int EPS_PRNERR_NOERROR = 0;
    private final int EPS_PRNST_BUSY = 2;
    private final int EPS_PRNST_ERROR = 4;
    private final String TAG = "EpsonService";
    private String accessKey = "";
    private boolean bEnd;
    private volatile boolean bPrinting = false;
    private volatile boolean bSearching = false;
    boolean bSetPrinter = false;
    private String clientId = null;
    public String debugString;
    private EpsJobAttrib epsJobattrib = new EpsJobAttrib();
    /* access modifiers changed from: private */

    /* renamed from: id */
    public String f406id;
    /* access modifiers changed from: private */

    /* renamed from: ip */
    public String f407ip;
    private final IEpsonService.Stub mBinder = new IEpsonService.Stub() {
        EcClientLib mEcClientLib = new EcClientLib();
        boolean mEpsonConnectlogin;
        int mRemotePrintMaxFileSize = 0;

        {
            mEcClientLib.Initialize();
            mEpsonConnectlogin = false;
        }

        public void unregisterCallback(IEpsonServiceCallback iEpsonServiceCallback) throws RemoteException {
            if (iEpsonServiceCallback != null) {
                EpsonService.mCallbacks.unregister(iEpsonServiceCallback);
            }
        }

        public void registerCallback(IEpsonServiceCallback iEpsonServiceCallback) throws RemoteException {
            if (iEpsonServiceCallback != null) {
                EpsonService.mCallbacks.register(iEpsonServiceCallback);
            }
        }

        public synchronized int searchPrinters(String str, String str2, int i) throws RemoteException {
            synchronized (EpsonService.mLockSearchingStatus) {
                EpsonService.bNotifyPrinter = false;
            }
            String unused = EpsonService.this.f406id = str;
            String unused2 = EpsonService.this.f407ip = str2;
            int unused3 = EpsonService.this.probeMethod = i;
            if (EpsonService.this.searchingPrinter != null) {
                EPLog.d("EpsonService", "searchPrinters() search intterrupt()");
                EpsonService.this.searchingPrinter.interrupt();
                try {
                    EpsonService.this.searchingPrinter.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            EpsonService.access$504(EpsonService.this);
            if (EpsonService.this.mSearchCount > 1) {
                EPLog.e("EpsonService", "search count error! mSearchCount => " + EpsonService.this.mSearchCount);
            }
            if (!EpsonService.isInitDriver) {
                EpsonService.this.mEscprLib.release_driver();
                boolean unused4 = EpsonService.isInitDriver = true;
                EpsonService.this.mEscprLib.init_driver(EpsonService.this.getApplicationContext(), ExternalFileUtils.getInstance(EpsonService.this.getApplicationContext()).getSupportedMediaDir());
            }
            EpsonService.this.createSearchingThread();
            EpsonService.this.searchingPrinter.start();
            return 0;
        }

        public synchronized int cancelSearchPrinter() throws RemoteException {
            EPLog.e("Epson", "cancelSearchPrinter() call");
            if (EpsonService.this.searchingPrinter == null) {
                EPLog.e("Epson", "cancelSearchPrinter() finish1");
                return 0;
            }
            EpsonService.this.searchingPrinter.interrupt();
            try {
                EPLog.d("EpsonService", "searchingPrinter.join() enter");
                EpsonService.this.searchingPrinter.join(1000);
                int i = 0;
                while (true) {
                    if (!Thread.State.RUNNABLE.equals(EpsonService.this.searchingPrinter.getState())) {
                        break;
                    }
                    int i2 = i + 1;
                    if (i > 60) {
                        EPLog.w("EpsonService", "mSearchThread.join() timeout");
                        break;
                    }
                    EPLog.d("EpsonService", "retry doCancelFindPrinter() " + i2);
                    EpsonService.this.searchingPrinter.interrupt();
                    EpsonService.this.searchingPrinter.join(1000);
                    i = i2;
                }
                EPLog.d("EpsonService", "searchingPrinter.join() leave");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            EPLog.e("Epson", "cancelSearchPrinter() finish");
            return 0;
        }

        public void setTimeOut(int i) throws RemoteException {
            EPLog.d("EpsonService", "timeout = " + i);
            int unused = EpsonService.this.timeout_sec = i;
        }

        public int setCurPrinter(int i) throws RemoteException {
            int i2;
            EPLog.d("EpsonService", "setCurPrinter(): " + i);
            cancelSearchPrinter();
            EPLog.e("Epson", "Finish cancelSearchPrinter()");
            synchronized (EpsonService.mLock) {
                EPLog.d("EpsonService", "Start set_printer()");
                i2 = EpsonService.this.mEscprLib.set_printer(i);
                EPLog.d("EpsonService", "setCurPrinter: result = " + i2);
            }
            return i2;
        }

        public int print(EPImageList ePImageList, String str, boolean z) throws RemoteException {
            EPLog.i();
            boolean z2 = SharedPreferencesProvider.getInstace(EpsonService.this).getInt(Constants.PRINTER_LOCATION, 0) == 2;
            EPLog.i("☆☆　　　　 isRemotePrinter  " + z2);
            PrintSetting.Kind valueOf = PrintSetting.Kind.valueOf(str);
            if (z2) {
                int unused = EpsonService.this.createECPrintingThread(valueOf, ePImageList);
                if (EpsonService.this.printingThread != null) {
                    EpsonService.this.printingThread.start();
                }
                return 0;
            }
            EpsonService.this.startLocalNonPdfPrintThread(valueOf, ePImageList, z);
            return 0;
        }

        public int printLocalPdf(String str, String str2, String str3, boolean z, int i, int i2, boolean z2) {
            EpsonService.this.startPdfPrintThread(str, str2, str3, z, i, i2, z2);
            return 0;
        }

        public int printWithImagesAndLayouts(List<ImageAndLayout> list, boolean z) {
            EpsonService epsonService = EpsonService.this;
            Thread unused = epsonService.printingThread = new PrintAndLayoutThread(epsonService, list, z);
            EpsonService.this.printingThread.start();
            return 0;
        }

        public int cancelPrint() throws RemoteException {
            return EpsonService.this.mEscprLib.cancel_print();
        }

        public int getLang() throws RemoteException {
            int i;
            synchronized (EpsonService.mLock) {
                i = EpsonService.this.mEscprLib.get_lang();
            }
            return i;
        }

        public int getSupportedMedia(boolean z, int i, String str, String str2) throws RemoteException {
            int i2;
            synchronized (EpsonService.mPrinting) {
                synchronized (EpsonService.mLock) {
                    synchronized (EpsonService.mPrinting) {
                        if (z) {
                            i2 = EpsonConnectGetSupportedMedia(i, str, str2);
                        } else {
                            i2 = EpsonService.this.mEscprLib.get_supported_media2();
                        }
                    }
                }
            }
            return i2;
        }

        public int[] getPaperSize() throws RemoteException {
            int[] iArr;
            synchronized (EpsonService.mLock) {
                iArr = EpsonService.this.mEscprLib.get_paper_size();
            }
            return iArr;
        }

        public int[] getPaperType(int i) throws RemoteException {
            int[] iArr;
            synchronized (EpsonService.mLock) {
                iArr = EpsonService.this.mEscprLib.get_paper_type(i);
            }
            return iArr;
        }

        public int[] getLayout(int i, int i2) throws RemoteException {
            int[] iArr;
            synchronized (EpsonService.mLock) {
                iArr = EpsonService.this.mEscprLib.get_layout(i, i2);
            }
            return iArr;
        }

        public int[] getQuality(int i, int i2) throws RemoteException {
            int[] iArr;
            synchronized (EpsonService.mLock) {
                iArr = EpsonService.this.mEscprLib.get_quality(i, i2);
            }
            return iArr;
        }

        public int[] getPaperSource(int i, int i2, int i3) throws RemoteException {
            int[] iArr;
            synchronized (EpsonService.mLock) {
                iArr = EpsonService.this.mEscprLib.get_paper_source(i, i2);
            }
            return iArr;
        }

        public int[] getColor(boolean z, int i, int i2, int i3) throws RemoteException {
            int[] iArr;
            int i4;
            synchronized (EpsonService.mLock) {
                if (z) {
                    ArrayList arrayList = new ArrayList();
                    if (i == 1) {
                        i4 = mEcClientLib.mColorModeAtRemote;
                    } else {
                        i4 = mEcClientLib.mColorModeAtLocal;
                    }
                    if ((i4 & 1) != 0) {
                        arrayList.add(0);
                    }
                    if ((i4 & 2) != 0) {
                        arrayList.add(1);
                    }
                    int size = arrayList.size();
                    iArr = new int[arrayList.size()];
                    for (int i5 = 0; i5 < size; i5++) {
                        iArr[i5] = ((Integer) arrayList.get(i5)).intValue();
                    }
                } else {
                    iArr = EpsonService.this.mEscprLib.get_color(i2, i3);
                }
            }
            return iArr;
        }

        public int getDuplex(int i, int i2) throws RemoteException {
            int i3;
            synchronized (EpsonService.mLock) {
                i3 = EpsonService.this.mEscprLib.get_duplex(i, i2);
            }
            return i3;
        }

        public boolean isPrinting() {
            boolean access$1700;
            synchronized (EpsonService.mLockPrintingStatus) {
                access$1700 = EpsonService.this.bPrinting;
            }
            return access$1700;
        }

        public boolean isSearchingPrinter() {
            boolean access$1800;
            synchronized (EpsonService.mLockSearchingStatus) {
                access$1800 = EpsonService.this.bSearching;
            }
            return access$1800;
        }

        public int confirmCancel(boolean z) {
            EPLog.e("LAM DAI HIEP", "confirmCancel() call");
            EPLog.v("cancel ", "iscancel " + z);
            if (!z) {
                return 0;
            }
            synchronized (EpsonService.mLockPrintingStatus) {
                boolean unused = EpsonService.bCancelPrinting = true;
                synchronized (EpsonService.mCancelLock) {
                    if (EpsonService.this.mEPImageCreator != null) {
                        EpsonService.this.mEPImageCreator.requestStop();
                    }
                }
                if (EpsonService.this.bPrinting) {
                    if (EpsonService.this.mLocalPrintThread != null) {
                        EpsonService.this.mLocalPrintThread.interrupt();
                    }
                    EPLog.e("lam dai hiep", "confirm_cancel: " + z);
                    EpsonService.this.mEscprLib.confirm_cancel(z);
                } else if (isSearchingPrinter()) {
                    try {
                        cancelSearchPrinter();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                }
            }
            return 0;
        }

        public int confirmContinueable(boolean z) {
            EPLog.e("LAM DAI HIEP", "confirmContinueable() call: " + z);
            return EpsonService.this.mEscprLib.confirm_continue(z);
        }

        public int updatePrinterSettings(String str) {
            int i;
            int i2;
            int i3;
            int i4;
            int i5;
            int i6;
            int i7;
            EPLog.m83w("EpsonService", "call updatePrinterSettings() :: " + Binder.getCallingPid());
            PrintSetting printSetting = new PrintSetting(EpsonService.this, PrintSetting.Kind.valueOf(str));
            printSetting.loadSettings();
            int i8 = printSetting.paperSizeValue;
            int i9 = printSetting.paperTypeValue;
            int i10 = printSetting.layoutValue;
            int i11 = printSetting.qualityValue;
            int i12 = printSetting.paperSourceValue;
            int i13 = printSetting.duplexValue;
            int i14 = printSetting.colorValue;
            try {
                int[] paperSize = getPaperSize();
                if (paperSize != null) {
                    if (paperSize.length != 0) {
                        int i15 = 0;
                        while (true) {
                            if (i15 >= paperSize.length) {
                                i = 0;
                                break;
                            } else if (i8 == paperSize[i15]) {
                                i = i15;
                                break;
                            } else {
                                i15++;
                            }
                        }
                        if (i15 >= paperSize.length) {
                            int defaultPaperSize = printSetting.getDefaultPaperSize();
                            i2 = 0;
                            while (true) {
                                if (i2 >= paperSize.length) {
                                    break;
                                } else if (defaultPaperSize == paperSize[i2]) {
                                    i8 = paperSize[i2];
                                    EPLog.w("EpsonService", "updatePrinterSettings paperSize = " + i8);
                                    i = i2;
                                    break;
                                } else {
                                    i2++;
                                }
                            }
                        } else {
                            i2 = i15;
                        }
                        if (i2 >= paperSize.length) {
                            i8 = paperSize[0];
                            EPLog.w("EpsonService", "updatePrinterSettings paperSize = " + i8);
                            i = 0;
                        }
                        int[] paperType = getPaperType(i);
                        if (paperType != null) {
                            if (paperType.length != 0) {
                                int i16 = 0;
                                while (true) {
                                    if (i16 >= paperType.length) {
                                        i3 = 0;
                                        break;
                                    } else if (i9 == paperType[i16]) {
                                        i3 = i16;
                                        break;
                                    } else {
                                        i16++;
                                    }
                                }
                                if (i16 >= paperType.length) {
                                    int defaultPaperType = printSetting.getDefaultPaperType();
                                    i4 = 0;
                                    while (true) {
                                        if (i4 >= paperType.length) {
                                            break;
                                        } else if (defaultPaperType == paperType[i4]) {
                                            i9 = paperType[i4];
                                            EPLog.w("EpsonService", "updatePrinterSettings paperType = " + i9);
                                            i3 = i4;
                                            break;
                                        } else {
                                            i4++;
                                        }
                                    }
                                } else {
                                    i4 = i16;
                                }
                                if (i4 >= paperType.length) {
                                    if (PrintSetting.Kind.photo.compareTo(PrintSetting.Kind.valueOf(str)) == 0) {
                                        int code = Constants.MediaName.EPS_MTID_MATTE.getCode();
                                        int i17 = 0;
                                        while (true) {
                                            if (i4 >= paperType.length) {
                                                break;
                                            } else if (code == paperType[i4]) {
                                                i9 = paperType[i4];
                                                EPLog.w("EpsonService", "updatePrinterSettings paperType = " + i9);
                                                i3 = i4;
                                                break;
                                            } else {
                                                i17 = i4 + 1;
                                            }
                                        }
                                    } else {
                                        int code2 = Constants.MediaName.EPS_MTID_PLAIN1.getCode();
                                        int i18 = 0;
                                        while (true) {
                                            if (i4 >= paperType.length) {
                                                break;
                                            } else if (code2 == paperType[i4]) {
                                                i9 = paperType[i4];
                                                EPLog.w("EpsonService", "updatePrinterSettings paperType = " + i9);
                                                i3 = i4;
                                                break;
                                            } else {
                                                i18 = i4 + 1;
                                            }
                                        }
                                        if (i4 >= paperType.length) {
                                            int code3 = Constants.MediaName.EPS_MTID_AUTO_PLAIN.getCode();
                                            int i19 = 0;
                                            while (true) {
                                                if (i4 >= paperType.length) {
                                                    break;
                                                } else if (code3 == paperType[i4]) {
                                                    i9 = paperType[i4];
                                                    EPLog.w("EpsonService", "updatePrinterSettings paperType = " + i9);
                                                    i3 = i4;
                                                    break;
                                                } else {
                                                    i19 = i4 + 1;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (i4 >= paperType.length) {
                                    i9 = paperType[0];
                                    EPLog.w("EpsonService", "updatePrinterSettings paperType = " + i9);
                                    i3 = 0;
                                }
                                int[] layout = getLayout(i, i3);
                                if (layout != null) {
                                    int i20 = 0;
                                    while (true) {
                                        if (i20 >= layout.length) {
                                            break;
                                        } else if (i10 == layout[i20]) {
                                            i10 = layout[i20];
                                            break;
                                        } else {
                                            i20++;
                                        }
                                    }
                                    if (i20 >= layout.length) {
                                        EPLog.w("EpsonService", "updatePrinterSettings layout = EPS_MLID_BORDERS");
                                        i10 = 2;
                                    }
                                } else {
                                    EPLog.w("EpsonService", "updatePrinterSettings layout = EPS_MLID_BORDERS");
                                    i10 = 2;
                                }
                                int[] quality = getQuality(i, i3);
                                if (quality != null) {
                                    int i21 = 0;
                                    while (true) {
                                        if (i21 >= quality.length) {
                                            break;
                                        } else if (i11 == quality[i21]) {
                                            i11 = quality[i21];
                                            break;
                                        } else {
                                            i21++;
                                        }
                                    }
                                    if (i21 >= quality.length) {
                                        i5 = quality.length > 0 ? quality[0] : 2;
                                        EPLog.w("EpsonService", "updatePrinterSettings quality = " + i5);
                                    }
                                } else {
                                    EPLog.w("EpsonService", "updatePrinterSettings quality = " + 2);
                                    i5 = 2;
                                }
                                int[] paperSource = getPaperSource(i, i3, 0);
                                if (paperSource != null) {
                                    int i22 = 0;
                                    while (true) {
                                        if (i22 >= paperSource.length) {
                                            break;
                                        } else if (i12 == paperSource[i22]) {
                                            i12 = paperSource[i22];
                                            break;
                                        } else {
                                            i22++;
                                        }
                                    }
                                    if (i22 >= paperSource.length) {
                                        i6 = paperSource.length > 0 ? paperSource[0] : 0;
                                        EPLog.w("EpsonService", "updatePrinterSettings paperSource = " + i6);
                                    }
                                } else {
                                    EPLog.w("EpsonService", "updatePrinterSettings paperSource = EPS_MPID_NOT_SPEC");
                                    i6 = 0;
                                }
                                int duplex = getDuplex(i, i3);
                                if ((duplex == 0 || (i10 == 1 && (duplex & 2) != 0)) && i13 != 0) {
                                    EPLog.w("EpsonService", "updatePrinterSettings duplex = EPS_DUPLEX_NONE");
                                    i13 = 0;
                                }
                                int[] color = getColor(false, 0, i, i3);
                                if (color != null) {
                                    int i23 = 0;
                                    while (true) {
                                        if (i23 >= color.length) {
                                            break;
                                        } else if (i14 == color[i23]) {
                                            i14 = color[i23];
                                            break;
                                        } else {
                                            i23++;
                                        }
                                    }
                                    if (i23 >= color.length) {
                                        i7 = color.length > 0 ? color[0] : 0;
                                        EPLog.w("EpsonService", "updatePrinterSettings color = " + i7);
                                    }
                                } else {
                                    EPLog.w("EpsonService", "updatePrinterSettings color = " + 0);
                                    i7 = 0;
                                }
                                printSetting.paperSizeValue = i8;
                                printSetting.paperTypeValue = i9;
                                printSetting.layoutValue = i10;
                                printSetting.qualityValue = i5;
                                printSetting.paperSourceValue = i6;
                                printSetting.duplexValue = i13;
                                printSetting.colorValue = i7;
                                printSetting.saveSettings();
                                return 0;
                            }
                        }
                        EPLog.w("EpsonService", "updatePrinterSettings Failed getPaperType");
                        return -1;
                    }
                }
                EPLog.w("EpsonService", "updatePrinterSettings Failed getPaperSize");
                return -1;
            } catch (RemoteException e) {
                e.printStackTrace();
                return -1;
            }
        }

        public int EpsonConnectUpdatePrinterSettings(String str) {
            int i;
            EpsSupportedMedia epsSupportedMedia;
            boolean z;
            boolean z2;
            int i2;
            int i3;
            EPLog.d("EpsonService", "EpsonConnectUpdatePrinterSettings() called.");
            PrintSetting instance = PrintSetting.getInstance(EpsonService.this, str);
            instance.loadSettings();
            int i4 = instance.paperSizeValue;
            int i5 = instance.paperTypeValue;
            int i6 = instance.layoutValue;
            int i7 = instance.qualityValue;
            int i8 = instance.paperSourceValue;
            int i9 = instance.duplexValue;
            int i10 = instance.colorValue;
            try {
                int i11 = 0;
                WiFiDirectManager.setPriorityToSimpleAP(EpsonService.this, false);
                int updateSettingsRemoteSourceType = instance.getUpdateSettingsRemoteSourceType();
                int supportedMedia = getSupportedMedia(true, updateSettingsRemoteSourceType, (String) null, (String) null);
                switch (updateSettingsRemoteSourceType) {
                    case 1:
                        epsSupportedMedia = mEcClientLib.mMediaAtRemote;
                        i = mEcClientLib.mColorModeAtRemote;
                        break;
                    case 2:
                        epsSupportedMedia = mEcClientLib.mMediaAtPhoto;
                        i = mEcClientLib.mColorModeAtPhoto;
                        break;
                    case 3:
                        epsSupportedMedia = mEcClientLib.mMediaAtLocal;
                        i = mEcClientLib.mColorModeAtLocal;
                        break;
                    default:
                        EPLog.e("EpsonService", "remoteSourceType is invalid.");
                        return -1;
                }
                if (supportedMedia == 0) {
                    int i12 = 0;
                    while (true) {
                        if (i12 >= epsSupportedMedia.mSizeList.length) {
                            z = true;
                            i12 = 0;
                        } else if (i4 == epsSupportedMedia.mSizeList[i12].mMediaSizeID) {
                            z = false;
                        } else {
                            i12++;
                        }
                    }
                    if (z) {
                        int defaultPaperSize = instance.getDefaultPaperSize();
                        while (true) {
                            if (i11 >= epsSupportedMedia.mSizeList.length) {
                                i11 = i12;
                            } else if (defaultPaperSize == epsSupportedMedia.mSizeList[i11].mMediaSizeID) {
                                EPLog.w("EpsonService", "EpsonConnectUpdatePrinterSettings paperSize_index = " + i11);
                                z = false;
                            } else {
                                i11++;
                            }
                        }
                        if (z) {
                            i11 = 0;
                        }
                    } else {
                        i11 = i12;
                    }
                    int i13 = 0;
                    while (true) {
                        if (i13 >= epsSupportedMedia.mSizeList[i11].mTypeList.length) {
                            z2 = true;
                            i2 = 0;
                        } else if (i5 == epsSupportedMedia.mSizeList[i11].mTypeList[i13].mMediaTypeId) {
                            i2 = i13;
                            z2 = false;
                        } else {
                            i13++;
                        }
                    }
                    if (z2) {
                        int defaultPaperType = instance.getDefaultPaperType();
                        int i14 = 0;
                        while (true) {
                            if (i14 < epsSupportedMedia.mSizeList[i11].mTypeList.length) {
                                if (defaultPaperType == epsSupportedMedia.mSizeList[i11].mTypeList[i14].mMediaTypeId) {
                                    EPLog.w("EpsonService", "EpsonConnectUpdatePrinterSettings paperType_index = " + i14);
                                    i2 = i14;
                                    z2 = false;
                                } else {
                                    i14++;
                                }
                            }
                        }
                        if (z2) {
                            i2 = 0;
                        }
                    }
                    int i15 = epsSupportedMedia.mSizeList[i11].mMediaSizeID;
                    int i16 = epsSupportedMedia.mSizeList[i11].mTypeList[i2].mMediaTypeId;
                    EpsMediaType epsMediaType = epsSupportedMedia.mSizeList[i11].mTypeList[i2];
                    int i17 = 8;
                    if ((epsMediaType.mPaperSource & i8) == i8) {
                        i3 = i8;
                    } else if ((epsMediaType.mPaperSource & 1) == 1) {
                        i3 = 1;
                    } else if ((epsMediaType.mPaperSource & 2) == 2) {
                        i3 = 2;
                    } else if ((epsMediaType.mPaperSource & 4) == 4) {
                        i3 = 4;
                    } else if ((epsMediaType.mPaperSource & 8) == 8) {
                        i3 = 8;
                    } else if ((epsMediaType.mPaperSource & 16) == 16) {
                        i3 = 16;
                    } else {
                        i3 = 128;
                        if ((epsMediaType.mPaperSource & 128) != 128) {
                            i3 = 32768;
                            if ((epsMediaType.mPaperSource & 32768) != 32768) {
                                if ((epsMediaType.mPaperSource & 32) == 32) {
                                    i3 = 32;
                                } else {
                                    i3 = 64;
                                    if ((epsMediaType.mPaperSource & 64) != 64) {
                                        i3 = 2;
                                    }
                                }
                            }
                        }
                    }
                    if ((epsMediaType.mLayout & i6) == i6) {
                        i17 = i6 == 0 ? 2 : i6;
                    } else if ((epsMediaType.mLayout & 1) == 1) {
                        i17 = 1;
                    } else if ((epsMediaType.mLayout & 2) == 2) {
                        i17 = 2;
                    } else if ((epsMediaType.mLayout & 4) == 4) {
                        i17 = 4;
                    } else if ((epsMediaType.mLayout & 8) != 8) {
                        i17 = 2;
                    }
                    if ((epsMediaType.mQuality & i7) == i7) {
                        if (i7 == 0) {
                            i7 = 2;
                        }
                    } else if ((epsMediaType.mQuality & 1) == 1) {
                        i7 = 1;
                    } else if ((epsMediaType.mQuality & 2) == 2) {
                        i7 = 2;
                    } else {
                        i7 = (epsMediaType.mQuality & 4) == 4 ? 4 : 2;
                    }
                    if (epsMediaType.mDuplex == 0 && i9 != 0) {
                        i9 = 0;
                    }
                    if (((1 << i10) & i) == 0) {
                        i10 = (i & 1) != 0 ? 0 : (2 & i) != 0 ? 1 : 0;
                    }
                    instance.paperSizeValue = i15;
                    instance.paperTypeValue = i16;
                    instance.layoutValue = i17;
                    instance.layoutMultiPageValue = 0;
                    instance.qualityValue = i7;
                    instance.paperSourceValue = i3;
                    instance.duplexValue = i9;
                    instance.colorValue = i10;
                    instance.printdate = 0;
                    instance.saveSettings();
                    return 0;
                }
                ExternalFileUtils instance2 = ExternalFileUtils.getInstance(EpsonService.this.getApplicationContext());
                instance2.getSupportedMedia().delete();
                instance2.getSavedSupportedMedia().delete();
                instance.paperSizeValue = instance.getDefaultPaperSize();
                instance.paperTypeValue = instance.getDefaultPaperType();
                instance.layoutValue = 2;
                instance.layoutMultiPageValue = 0;
                instance.qualityValue = 2;
                instance.paperSourceValue = 2;
                instance.duplexValue = 0;
                instance.printdate = 0;
                instance.saveSettings();
                return -1;
            } catch (RemoteException e) {
                e.printStackTrace();
                return -1;
            }
        }

        public int EpsonConnectCreateJob(int i, String str, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12, int i13, int i14) {
            int i15;
            int i16;
            int i17 = i;
            EPLog.d("EpsonService", "EpsonConnectCreateJob() called.");
            mEcClientLib.resetCancel();
            EpsonService.this.epsJobattrib.mMediaSizeIdx = i2;
            EpsonService.this.epsJobattrib.mMediaTypeIdx = i3;
            EpsonService.this.epsJobattrib.mPrintLayout = i4;
            EpsonService.this.epsJobattrib.mPrintQuality = i5;
            EpsonService.this.epsJobattrib.mPaperSource = i6;
            if (i7 == 1) {
                EpsonService.this.epsJobattrib.mColorMode = 2;
            } else {
                EpsonService.this.epsJobattrib.mColorMode = 1;
            }
            EpsonService.this.epsJobattrib.mBrightness = i8;
            EpsonService.this.epsJobattrib.mContrast = i9;
            EpsonService.this.epsJobattrib.mSaturation = i10;
            EpsonService.this.epsJobattrib.mPrintDirection = i11;
            EpsonService.this.epsJobattrib.mDuplex = i12;
            int i18 = 0;
            int ensureLogin = ensureLogin(false);
            if (ensureLogin != 0) {
                return ensureLogin;
            }
            if (i17 == 1) {
                String str2 = str;
                i18 = (int) new File(str).length();
                i16 = i13;
                i15 = i14;
            } else {
                String str3 = str;
                i16 = 0;
                i15 = 0;
            }
            try {
                String createJobFileName = EcClientLibUtil.getCreateJobFileName(i, str);
                try {
                    ensureLogin = mEcClientLib.CreateJob(i, createJobFileName == null ? i17 != 2 ? "iPrint" : "iPrint Photo" : createJobFileName, i18, EpsonService.this.epsJobattrib, i16, i15);
                    mRemotePrintMaxFileSize = mEcClientLib.mEccJobInfo.mMaxFileSize;
                    return ensureLogin;
                } catch (NullPointerException e) {
                    e.printStackTrace();
                    return ensureLogin;
                }
            } catch (Exception e2) {
                e2.printStackTrace();
                return -1;
            }
        }

        public int EpsonConnectChangePrintSetting() {
            EPLog.d("EpsonService", "EpsonConnectChangePrintSetting() called.");
            return mEcClientLib.ChangePrintSetting(EpsonService.this.epsJobattrib, EcClientLibUtil.quoteForJsonString(EpsonService.this.mailAddress), EcClientLibUtil.quoteForJsonString(EpsonService.this.accessKey), false);
        }

        public int EpsonConnectUploadFile(String str, int i) {
            EPLog.d("EpsonService", "EpsonConnectUploadFile() called. - " + str);
            int ensureLogin = ensureLogin(false);
            if (ensureLogin != 0) {
                return ensureLogin;
            }
            return mEcClientLib.UploadFile(str, (int) new File(str).length(), i);
        }

        public int EpsonConnectStartPrint(int i, int i2) {
            EPLog.d("EpsonService", "EpsonConnectStartPrint() called.");
            return mEcClientLib.StartPrint(i, i2);
        }

        public int EpsonConnectEndJob() {
            EPLog.d("EpsonService", "EpsonConnectEndJob() called.");
            int EndJob = mEcClientLib.EndJob();
            mEcClientLib.resetCancel();
            return EndJob;
        }

        public int EpsonConnectCheckSupportedFileType(String str) {
            EPLog.d("EpsonService", "EpsonConnectCheckSupportedFileType() called.");
            return 0;
        }

        public int EpsonConnectGetRenderingStatus(int[] iArr) {
            int GetRenderingStatus;
            synchronized (EpsonService.mConnect) {
                iArr[0] = 1;
                iArr[1] = 0;
                GetRenderingStatus = mEcClientLib.GetRenderingStatus();
                if (GetRenderingStatus == 0) {
                    iArr[0] = mEcClientLib.mRenderStatus;
                    iArr[1] = mEcClientLib.mCompletePage;
                }
            }
            return GetRenderingStatus;
        }

        public int EpsonConnectGetPreview(int i, String str) {
            int DownloadPreview;
            synchronized (EpsonService.mConnect) {
                EPLog.d("EpsonService", "EpsonConnectGetPreview() called.");
                DownloadPreview = mEcClientLib.DownloadPreview(i, str);
            }
            return DownloadPreview;
        }

        public int EpsonConnectGetSupportedMedia(int i, String str, String str2) {
            EpsSupportedMedia epsSupportedMedia;
            int i2 = i;
            String path = ExternalFileUtils.getInstance(EpsonService.this.getApplicationContext()).getSupportedMedia().getPath();
            WiFiDirectManager.setPriorityToSimpleAP(EpsonService.this, false);
            if (str == null || str.length() <= 0) {
                int ensureLogin = ensureLogin(false);
                if (ensureLogin != 0) {
                    return ensureLogin;
                }
            } else {
                mEpsonConnectlogin = false;
                int Login = mEcClientLib.Login(EcClientLibUtil.quoteForJsonString(str), EcClientLibUtil.quoteForJsonString(str2), EpsonService.this.clientId);
                if (Login != 0) {
                    return Login;
                }
            }
            int GetCapability = mEcClientLib.GetCapability();
            if (GetCapability != 0) {
                return GetCapability;
            }
            switch (i2) {
                case 1:
                    epsSupportedMedia = mEcClientLib.mMediaAtRemote;
                    break;
                case 2:
                    epsSupportedMedia = mEcClientLib.mMediaAtPhoto;
                    break;
                case 3:
                    epsSupportedMedia = mEcClientLib.mMediaAtLocal;
                    break;
                default:
                    EPLog.e("EpsonService", "sourceType is invalid.");
                    return -1;
            }
            try {
                File file = new File(path);
                DataOutputStream dataOutputStream = new DataOutputStream(new FileOutputStream(file));
                byte[] bArr = new byte[32];
                ByteBuffer wrap = ByteBuffer.wrap(bArr);
                wrap.order(ByteOrder.LITTLE_ENDIAN);
                wrap.clear();
                wrap.putInt(epsSupportedMedia.mJpegSizeLimit);
                wrap.putInt(r10);
                dataOutputStream.write(bArr, 0, wrap.position());
                wrap.clear();
                for (EpsMediaSize epsMediaSize : epsSupportedMedia.mSizeList) {
                    wrap.putInt(epsMediaSize.mMediaSizeID);
                    wrap.putInt(r13);
                    dataOutputStream.write(bArr, 0, wrap.position());
                    wrap.clear();
                    for (EpsMediaType epsMediaType : epsMediaSize.mTypeList) {
                        wrap.putInt(epsMediaType.mMediaTypeId);
                        wrap.putInt(epsMediaType.mLayout);
                        wrap.putInt(epsMediaType.mQuality);
                        wrap.putInt(epsMediaType.mPaperSource);
                        wrap.putInt(epsMediaType.mDuplex);
                        dataOutputStream.write(bArr, 0, wrap.position());
                        wrap.clear();
                    }
                }
                wrap.putInt(epsSupportedMedia.mResolution);
                wrap.putInt(1);
                dataOutputStream.write(bArr, 0, wrap.position());
                wrap.clear();
                dataOutputStream.close();
                EPLog.i("EpsonService", "finishu output SUPPORTED_MEDIA for EC. filename = " + path + " sourceType = " + i2 + " filesize = " + file.length());
                Utils.copyFile(file, new File(ExternalFileUtils.getInstance(EpsonService.this.getApplicationContext()).getSavedSupportedMedia().getPath()));
                return 0;
            } catch (IOException e) {
                EPLog.e("EpsonService", "get_epsonconnect_supported_media(): IOExceptin.");
                e.printStackTrace();
                return -1;
            }
        }

        public int ensureLogin(boolean z) {
            EpsonService.this.updateLoginInfo();
            if (z) {
                mEpsonConnectlogin = false;
            }
            if (!this.mEpsonConnectlogin) {
                int Login = mEcClientLib.Login(EcClientLibUtil.quoteForJsonString(EpsonService.this.mailAddress), EcClientLibUtil.quoteForJsonString(EpsonService.this.accessKey), EpsonService.this.clientId);
                if (Login != 0) {
                    return Login;
                }
                mEpsonConnectlogin = true;
            }
            return 0;
        }

        public int EpsonConnectGetRemotePrintMaxFileSize() {
            return mRemotePrintMaxFileSize;
        }

        public void EpsonConnectCancel() {
            mEcClientLib.cancel();
        }

        public void refreshRemotePrinterLogin() {
            EpsonService.this.updateLoginInfo();
        }
    };
    private int mCreatetSheetIndex = 0;
    volatile EPImageCreator mEPImageCreator;
    private final EscprLib mEscprLib = EscprLib.getInstance();
    Handler mHandler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            int i = message.what;
            if (i != 30) {
                switch (i) {
                    case 0:
                        EpsonService.this.epsNotifyDataChange((String) message.obj);
                        return true;
                    case 1:
                        EpsonService.this.epsNotifyContinueable(message.arg1);
                        return true;
                    case 2:
                        EpsonService.this.epsNotifyError(message.arg1, message.arg2, ((Boolean) message.obj).booleanValue());
                        return true;
                    default:
                        return true;
                }
            } else {
                EpsonService.this.epsNotifyPage(message.arg1);
                return true;
            }
        }
    });
    private LocalPrintThread mLocalPrintThread;
    private volatile int mSearchCount = 0;
    private String mailAddress = "";
    private Thread printingThread = null;
    private int probeMethod;
    private SearchingThread searchingPrinter = null;
    private int timeout_sec = -1;

    static /* synthetic */ int access$504(EpsonService epsonService) {
        int i = epsonService.mSearchCount + 1;
        epsonService.mSearchCount = i;
        return i;
    }

    static /* synthetic */ int access$506(EpsonService epsonService) {
        int i = epsonService.mSearchCount - 1;
        epsonService.mSearchCount = i;
        return i;
    }

    public void javaDebugCB() {
        System.out.println(this.debugString);
        debugString = "";
    }

    public void epsNotifyPage(int i) {
        EPLog.m304d(" Д percent = " + i);
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i2 = 0; i2 < beginBroadcast; i2++) {
                try {
                    mCallbacks.getBroadcastItem(i2).onNotifyProgress(1, i);
                } catch (RemoteException e) {
                    EPLog.e("Epson", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public void epsNotifyDataChange(String str) {
        String str2;
        EPLog.d(" *****************  epsNotifyDataChange() call: " + str);
        String str3 = "";
        String str4 = "";
        String[] split = str.split("\\|\\|");
        synchronized (mLockSearchingStatus) {
            if (!bNotifyPrinter) {
                bNotifyPrinter = true;
            }
        }
        synchronized (mLock) {
            String str5 = "";
            if (split.length >= 5) {
                str = split[0];
                str3 = split[1];
                str4 = split[2];
                if (split[3] != null) {
                    str5 = split[3];
                }
                str2 = split[4] != null ? split[4] : "";
            } else if (split.length == 4) {
                str = split[0];
                str3 = split[1];
                str4 = split[2];
                if (split[3] != null) {
                    str5 = split[3];
                    str2 = "";
                } else {
                    str2 = "";
                }
            } else if (split.length == 3) {
                str = split[0];
                str3 = split[1];
                str4 = split[2];
                str2 = "";
            } else {
                str2 = "";
            }
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i = 0; i < beginBroadcast; i++) {
                try {
                    mCallbacks.getBroadcastItem(i).onFindPrinterResult(str, str3, str4, str5, str2);
                } catch (RemoteException e) {
                    EPLog.e("Epson", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    private void updateLoginInfo() {
        clearRemotePrinterInfo();
        clientId = SharedPreferencesProvider.getInstace(this).getString(epson.common.Constants.PRINTER_CLIENT_ID, (String) null);
        EPLog.d("▲clientId = " + clientId);
        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
        mailAddress = curPrinter.getEmailAddress();
        accessKey = curPrinter.getRemotePrinterAccessKey(this);
    }

    private void clearRemotePrinterInfo() {
        StorageSecureStore.invalidateCache();
        new EPPrinterManager(getApplicationContext()).rollbackRemotePrinterInfo();
    }

    private synchronized void createSearchingThread() {
        EPLog.e("Epson", "createSearchingThread() call");
        searchingPrinter = new SearchingThread();
    }

    class SearchingThread extends Thread {
        private volatile boolean mExecuting_search_printer = false;

        SearchingThread() {
        }

        /* JADX WARNING: Code restructure failed: missing block: B:51:?, code lost:
            sleep(1000);
            epson.print.Util.EPLog.e("EpsonService", "sleep some second to waiting printing thread");
         */
        /* JADX WARNING: Code restructure failed: missing block: B:52:0x00fd, code lost:
            r2 = move-exception;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:53:0x00fe, code lost:
            r2.printStackTrace();
            r2 = true;
         */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public void run() {
            /*
                r7 = this;
                epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this
                r1 = 0
                boolean unused = r0.bEnd = r1
                r0 = 1
                r2 = 0
            L_0x0008:
                boolean r3 = interrupted()
                if (r3 == 0) goto L_0x0017
                java.lang.String r2 = "EpsonService"
                java.lang.String r3 = "user cancel searching printer"
                epson.print.Util.EPLog.e((java.lang.String) r2, (java.lang.String) r3)
                r2 = 1
                goto L_0x0025
            L_0x0017:
                java.lang.Object r3 = epson.print.service.EpsonService.mLockPrintingStatus
                monitor-enter(r3)
                epson.print.service.EpsonService r4 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x0104 }
                boolean r4 = r4.bPrinting     // Catch:{ all -> 0x0104 }
                if (r4 != 0) goto L_0x00ee
                monitor-exit(r3)     // Catch:{ all -> 0x0104 }
            L_0x0025:
                if (r2 == 0) goto L_0x0034
                java.lang.String r0 = "EpsonService"
                java.lang.String r1 = "bCancel = true"
                epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1)
                epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this
                epson.print.service.EpsonService.access$506(r0)
                return
            L_0x0034:
                java.lang.Object r2 = epson.print.service.EpsonService.mLockSearchingStatus
                monitor-enter(r2)
                epson.print.service.EpsonService r3 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x00eb }
                boolean unused = r3.bSearching = r0     // Catch:{ all -> 0x00eb }
                r7.mExecuting_search_printer = r0     // Catch:{ all -> 0x00eb }
                monitor-exit(r2)     // Catch:{ all -> 0x00eb }
                java.lang.String r2 = "EpsonService"
                java.lang.String r3 = "begin search printer"
                epson.print.Util.EPLog.e((java.lang.String) r2, (java.lang.String) r3)
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                int r2 = r2.timeout_sec
                r3 = -1
                r4 = 60
                if (r2 <= r3) goto L_0x005a
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                int r4 = r2.timeout_sec
                goto L_0x0070
            L_0x005a:
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                int r2 = r2.probeMethod
                r3 = 2
                if (r2 == r3) goto L_0x006a
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                java.lang.String r2 = r2.f406id
                goto L_0x0070
            L_0x006a:
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                java.lang.String r2 = r2.f407ip
            L_0x0070:
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.setPriorityToSimpleAP(r2, r0)
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                com.epson.mobilephone.common.escpr.EscprLib r2 = r2.mEscprLib
                epson.print.service.EpsonService r3 = epson.print.service.EpsonService.this
                android.os.Handler r3 = r3.mHandler
                r2.setHanlder(r3)
                java.lang.StringBuilder r2 = new java.lang.StringBuilder
                r2.<init>()
                java.lang.String r3 = "SearchingThread : search_printer2 ☆☆　timeout = "
                r2.append(r3)
                r2.append(r4)
                java.lang.String r2 = r2.toString()
                com.epson.mobilephone.common.EPLog.d(r2)
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                com.epson.mobilephone.common.escpr.EscprLib r2 = r2.mEscprLib
                epson.print.service.EpsonService r3 = epson.print.service.EpsonService.this
                java.lang.String r3 = r3.f406id
                epson.print.service.EpsonService r5 = epson.print.service.EpsonService.this
                java.lang.String r5 = r5.f407ip
                epson.print.service.EpsonService r6 = epson.print.service.EpsonService.this
                int r6 = r6.probeMethod
                int r2 = r2.search_printer2(r3, r5, r6, r4)
                if (r2 != 0) goto L_0x00cc
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                java.lang.String r2 = r2.f406id
                if (r2 == 0) goto L_0x00cc
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                java.lang.String r2 = r2.f406id
                int r2 = r2.length()
                if (r2 <= 0) goto L_0x00cc
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this
                r2.bSetPrinter = r0
            L_0x00cc:
                java.lang.Object r0 = epson.print.service.EpsonService.mLockSearchingStatus
                monitor-enter(r0)
                epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x00e8 }
                boolean unused = r2.bSearching = r1     // Catch:{ all -> 0x00e8 }
                epson.print.service.EpsonService.bNotifyPrinter = r1     // Catch:{ all -> 0x00e8 }
                r7.mExecuting_search_printer = r1     // Catch:{ all -> 0x00e8 }
                monitor-exit(r0)     // Catch:{ all -> 0x00e8 }
                epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this
                epson.print.service.EpsonService.access$506(r0)
                java.lang.String r0 = "Epson"
                java.lang.String r1 = "search printer finish"
                epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1)
                return
            L_0x00e8:
                r1 = move-exception
                monitor-exit(r0)     // Catch:{ all -> 0x00e8 }
                throw r1
            L_0x00eb:
                r0 = move-exception
                monitor-exit(r2)     // Catch:{ all -> 0x00eb }
                throw r0
            L_0x00ee:
                monitor-exit(r3)     // Catch:{ all -> 0x0104 }
                r3 = 1000(0x3e8, double:4.94E-321)
                sleep(r3)     // Catch:{ InterruptedException -> 0x00fd }
                java.lang.String r3 = "EpsonService"
                java.lang.String r4 = "sleep some second to waiting printing thread"
                epson.print.Util.EPLog.e((java.lang.String) r3, (java.lang.String) r4)     // Catch:{ InterruptedException -> 0x00fd }
                goto L_0x0008
            L_0x00fd:
                r2 = move-exception
                r2.printStackTrace()
                r2 = 1
                goto L_0x0008
            L_0x0104:
                r0 = move-exception
                monitor-exit(r3)     // Catch:{ all -> 0x0104 }
                throw r0
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.service.EpsonService.SearchingThread.run():void");
        }

        public void interrupt() {
            if (this.mExecuting_search_printer && EpsonService.this.mEscprLib.cancel_search_printer() == -1305) {
                mExecuting_search_printer = false;
                boolean unused = EpsonService.this.bEnd = true;
            }
            super.interrupt();
            synchronized (EpsonService.mLockSearchingStatus) {
                boolean unused2 = EpsonService.this.bSearching = false;
            }
        }
    }

    public boolean updateApfProgress(int i) {
        if (bCancelPrinting) {
            return false;
        }
        notifyProgress(2, i);
        return true;
    }

    private void stopSearchingThread() throws RemoteException {
        if (this.searchingPrinter != null) {
            mBinder.cancelSearchPrinter();
        }
    }

    private void startLocalNonPdfPrintThread(PrintSetting.Kind kind, EPImageList ePImageList, boolean z) {
        mLocalPrintThread = new LocalPrintThread(this, new LegacyRenderingController(this, ePImageList, kind), z);
        mLocalPrintThread.start();
    }

    private void startPdfPrintThread(String str, String str2, String str3, boolean z, int i, int i2, boolean z2) {
        mLocalPrintThread = new LocalPrintThread(this, new PdfRenderingController(this, str, str2, str3, z, new int[]{i, i2}), z2);
        mLocalPrintThread.start();
    }

    private synchronized int createECPrintingThread(final PrintSetting.Kind kind, final EPImageList ePImageList) {
        printingThread = new Thread() {
            /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
                java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
                	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
                	at java.util.ArrayList.get(ArrayList.java:433)
                	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
                	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
                	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
                	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
                	at jadx.core.dex.visitors.regions.RegionMaker.processExcHandler(RegionMaker.java:1043)
                	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:975)
                	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
                */
            public void run() {
                /*
                    r29 = this;
                    r7 = r29
                    java.lang.Object r8 = epson.print.service.EpsonService.mPrinting
                    monitor-enter(r8)
                    java.lang.String r0 = "EpsonService"
                    java.lang.String r1 = "createECPrintingThread() called."
                    com.epson.mobilephone.common.EPLog.d(r0, r1)     // Catch:{ all -> 0x040b }
                    epson.print.screen.PrintSetting r0 = new epson.print.screen.PrintSetting     // Catch:{ all -> 0x040b }
                    epson.print.service.EpsonService r1 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    epson.print.screen.PrintSetting$Kind r2 = r2     // Catch:{ all -> 0x040b }
                    r0.<init>(r1, r2)     // Catch:{ all -> 0x040b }
                    r0.loadSettings()     // Catch:{ all -> 0x040b }
                    int r6 = r0.paperSizeValue     // Catch:{ all -> 0x040b }
                    int r13 = r0.paperTypeValue     // Catch:{ all -> 0x040b }
                    int r5 = r0.layoutValue     // Catch:{ all -> 0x040b }
                    int r4 = r0.qualityValue     // Catch:{ all -> 0x040b }
                    int r1 = r0.paperSourceValue     // Catch:{ all -> 0x040b }
                    int r3 = r0.colorValue     // Catch:{ all -> 0x040b }
                    int r2 = r0.copiesValue     // Catch:{ all -> 0x040b }
                    int r15 = r0.brightnessValue     // Catch:{ all -> 0x040b }
                    int r14 = r0.contrastValue     // Catch:{ all -> 0x040b }
                    int r12 = r0.saturationValue     // Catch:{ all -> 0x040b }
                    int r11 = r0.duplexValue     // Catch:{ all -> 0x040b }
                    int r10 = r0.feedDirectionValue     // Catch:{ all -> 0x040b }
                    r25 = 0
                    epson.print.service.EpsonService r9 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    r26 = r3
                    r3 = 1
                    boolean unused = r9.bPrinting = r3     // Catch:{ all -> 0x040b }
                    r9 = 0
                    boolean unused = epson.print.service.EpsonService.bCancelPrinting = r9     // Catch:{ all -> 0x040b }
                    epson.print.service.EpsonService r3 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    epson.provider.SharedPreferencesProvider$SharedPreferencesMulti r3 = epson.provider.SharedPreferencesProvider.getInstace(r3)     // Catch:{ all -> 0x040b }
                    java.lang.String r9 = "SOURCE_TYPE"
                    r17 = r10
                    r10 = 2
                    int r3 = r3.getInt(r9, r10)     // Catch:{ all -> 0x040b }
                    epson.print.service.EpsonService r9 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    r10 = 0
                    com.epson.mobilephone.common.wifidirect.WiFiDirectManager.setPriorityToSimpleAP(r9, r10)     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    epson.print.EPImageList r9 = r3     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    epson.print.EPImage r9 = r9.get(r10)     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    r10 = 3
                    r20 = r1
                    r1 = 2
                    if (r3 == r1) goto L_0x010b
                    if (r3 != r10) goto L_0x0065
                    goto L_0x010b
                L_0x0065:
                    r1 = 1
                    if (r3 != r1) goto L_0x0103
                    epson.print.EPImageList r4 = r3     // Catch:{ Exception -> 0x0100, all -> 0x00fd }
                    r5 = 0
                    r4.get(r5)     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    epson.print.service.EpsonService r4 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    r4.epsNotifyPage(r5)     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    boolean r4 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    if (r4 == r1) goto L_0x00f7
                    epson.print.service.EpsonService r1 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    epson.print.ecclient.EpsJobAttrib r1 = r1.epsJobattrib     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    r1.mCopies = r2     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    epson.print.service.EpsonService r1 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    epson.print.service.IEpsonService$Stub r1 = r1.mBinder     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    int r9 = r1.EpsonConnectChangePrintSetting()     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    if (r9 != 0) goto L_0x00f1
                    epson.print.service.EpsonService r1 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r2 = 50
                    r1.epsNotifyPage(r2)     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    boolean r1 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r2 = 1
                    if (r1 == r2) goto L_0x00e2
                    int r1 = r0.startValue     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    int r2 = r0.endValue     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    epson.print.service.EpsonService r4 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    java.lang.String r6 = "PREFS_EPSON_CONNECT"
                    epson.provider.SharedPreferencesProvider$SharedPreferencesMulti r4 = epson.provider.SharedPreferencesProvider.getInstace(r4, r6)     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    java.lang.String r6 = "ENABLE_SHOW_PREVIEW"
                    r10 = 1
                    boolean r4 = r4.getBoolean(r6, r10)     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    boolean r0 = r0.printAll     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    if (r4 == 0) goto L_0x00b4
                    if (r0 != r10) goto L_0x00b6
                L_0x00b4:
                    r1 = 0
                    r2 = 0
                L_0x00b6:
                    boolean r0 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    if (r0 == r10) goto L_0x00dc
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    int r9 = r0.EpsonConnectStartPrint(r1, r2)     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    if (r9 != 0) goto L_0x00d6
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r1 = 100
                    r0.epsNotifyPage(r1)     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r28 = r3
                    r1 = r9
                    r9 = 1
                    r15 = 1
                    goto L_0x02be
                L_0x00d6:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r0.<init>()     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    throw r0     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                L_0x00dc:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    r0.<init>()     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    throw r0     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                L_0x00e2:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    r0.<init>()     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    throw r0     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                L_0x00e8:
                    r0 = move-exception
                    r1 = r0
                    r2 = r3
                    r3 = 1
                    goto L_0x011b
                L_0x00ed:
                    r0 = move-exception
                    r2 = r3
                    r3 = 1
                    goto L_0x0122
                L_0x00f1:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    r0.<init>()     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                    throw r0     // Catch:{ Exception -> 0x00ed, all -> 0x00e8 }
                L_0x00f7:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    r0.<init>()     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    throw r0     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                L_0x00fd:
                    r0 = move-exception
                    r5 = 0
                    goto L_0x0117
                L_0x0100:
                    r0 = move-exception
                    r5 = 0
                    goto L_0x011f
                L_0x0103:
                    r5 = 0
                    r28 = r3
                    r1 = 0
                    r9 = 1
                    r15 = 1
                    goto L_0x02be
                L_0x010b:
                    r1 = 100
                    r16 = 0
                    java.lang.String r0 = r9.loadImageFileName     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    if (r3 != r10) goto L_0x0125
                    java.lang.String r0 = r9.webUrl     // Catch:{ Exception -> 0x011e, all -> 0x0116 }
                    goto L_0x0125
                L_0x0116:
                    r0 = move-exception
                L_0x0117:
                    r1 = r0
                    r2 = r3
                    r3 = 1
                    r9 = 0
                L_0x011b:
                    r15 = 1
                    goto L_0x03da
                L_0x011e:
                    r0 = move-exception
                L_0x011f:
                    r2 = r3
                    r3 = 1
                    r9 = 0
                L_0x0122:
                    r15 = 1
                    goto L_0x0373
                L_0x0125:
                    epson.print.service.EpsonService r9 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    epson.print.service.IEpsonService$Stub r9 = r9.mBinder     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    r23 = 0
                    r24 = 0
                    r10 = 0
                    r27 = r2
                    r21 = r17
                    r2 = 0
                    r10 = r3
                    r22 = r11
                    r11 = r0
                    r0 = r12
                    r12 = r6
                    r19 = r14
                    r14 = r5
                    r18 = r15
                    r15 = r4
                    r16 = r20
                    r17 = r26
                    r20 = r0
                    int r19 = r9.EpsonConnectCreateJob(r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24)     // Catch:{ Exception -> 0x036e, all -> 0x0366 }
                    if (r19 != 0) goto L_0x035a
                    boolean r0 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0353, all -> 0x034a }
                    r9 = 1
                    if (r0 == r9) goto L_0x033e
                    epson.print.service.EpsonService r9 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0353, all -> 0x034a }
                    epson.print.EPImageList r10 = r3     // Catch:{ Exception -> 0x0353, all -> 0x034a }
                    r11 = 0
                    r14 = 0
                    r16 = 0
                    r18 = 0
                    r12 = r6
                    r13 = r26
                    r15 = r5
                    r17 = r4
                    r9.createPrintImage(r10, r11, r12, r13, r14, r15, r16, r17, r18)     // Catch:{ Exception -> 0x0353, all -> 0x034a }
                    r9 = 0
                L_0x0168:
                    epson.print.EPImageList r0 = r3     // Catch:{ Exception -> 0x0337, all -> 0x032e }
                    int r0 = r0.size()     // Catch:{ Exception -> 0x0337, all -> 0x032e }
                    if (r9 >= r0) goto L_0x0292
                    epson.print.EPImageList r0 = r3     // Catch:{ Exception -> 0x028d, all -> 0x0287 }
                    epson.print.EPImage r0 = r0.get(r9)     // Catch:{ Exception -> 0x028d, all -> 0x0287 }
                    epson.print.service.EpsonService r10 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    r10.epsNotifyPage(r2)     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    boolean r10 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    r11 = 1
                    if (r10 == r11) goto L_0x0264
                    epson.print.service.EpsonService r10 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    int r12 = r9 + 1
                    int unused = r10.mCreatetSheetIndex = r12     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    epson.print.service.EpsonService$3$1 r10 = new epson.print.service.EpsonService$3$1     // Catch:{ Exception -> 0x0281, all -> 0x027a }
                    r13 = 100
                    r1 = r10
                    r14 = r27
                    r15 = 0
                    r2 = r29
                    r28 = r3
                    r11 = r26
                    r15 = 1
                    r3 = r6
                    r17 = r4
                    r4 = r11
                    r18 = r5
                    r19 = r6
                    r6 = r17
                    r1.<init>(r3, r4, r5, r6)     // Catch:{ Exception -> 0x0274, all -> 0x026d }
                    epson.print.EPImageList r1 = r3     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    int r1 = r1.size()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    if (r12 >= r1) goto L_0x01b0
                    r10.start()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                L_0x01b0:
                    epson.print.service.EpsonService r1 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    r2 = 25
                    r1.epsNotifyPage(r2)     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    epson.print.EPImageCreator r1 = new epson.print.EPImageCreator     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    android.content.Context r2 = r2.getApplicationContext()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    r1.<init>(r2)     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    int r1 = r1.createJpegImage(r0, r13)     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    if (r1 != 0) goto L_0x023c
                    epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    r3 = 50
                    r2.epsNotifyPage(r3)     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    boolean r2 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    if (r2 == r15) goto L_0x0226
                    epson.print.service.EpsonService r2 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    epson.print.service.IEpsonService$Stub r2 = r2.mBinder     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    java.lang.String r0 = r0.decodeImageFileName     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    int r1 = r2.EpsonConnectUploadFile(r0, r12)     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    if (r1 != 0) goto L_0x0220
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    r2 = 75
                    r0.epsNotifyPage(r2)     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    boolean r0 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    if (r0 == r15) goto L_0x021a
                    r10.join()     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    r0.epsNotifyPage(r13)     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    boolean r0 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    if (r0 == r15) goto L_0x0214
                    r25 = r10
                    r26 = r11
                    r9 = r12
                    r27 = r14
                    r4 = r17
                    r5 = r18
                    r6 = r19
                    r3 = r28
                    r2 = 0
                    r19 = r1
                    r1 = 100
                    goto L_0x0168
                L_0x0214:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    r0.<init>()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    throw r0     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                L_0x021a:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    r0.<init>()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    throw r0     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                L_0x0220:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    r0.<init>()     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                    throw r0     // Catch:{ Exception -> 0x0234, all -> 0x022c }
                L_0x0226:
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    r0.<init>()     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                    throw r0     // Catch:{ Exception -> 0x025f, all -> 0x0259 }
                L_0x022c:
                    r0 = move-exception
                    r3 = r9
                    r25 = r10
                    r2 = r28
                    goto L_0x0310
                L_0x0234:
                    r0 = move-exception
                    r3 = r9
                    r25 = r10
                    r2 = r28
                    goto L_0x0317
                L_0x023c:
                    r1 = -1200(0xfffffffffffffb50, float:NaN)
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x024f, all -> 0x0244 }
                    r0.<init>()     // Catch:{ Exception -> 0x024f, all -> 0x0244 }
                    throw r0     // Catch:{ Exception -> 0x024f, all -> 0x0244 }
                L_0x0244:
                    r0 = move-exception
                    r1 = r0
                    r3 = r9
                    r25 = r10
                    r2 = r28
                    r9 = -1200(0xfffffffffffffb50, float:NaN)
                    goto L_0x03da
                L_0x024f:
                    r0 = move-exception
                    r3 = r9
                    r25 = r10
                    r2 = r28
                    r9 = -1200(0xfffffffffffffb50, float:NaN)
                    goto L_0x0373
                L_0x0259:
                    r0 = move-exception
                    r1 = r0
                    r3 = r9
                    r25 = r10
                    goto L_0x0270
                L_0x025f:
                    r0 = move-exception
                    r3 = r9
                    r25 = r10
                    goto L_0x0276
                L_0x0264:
                    r28 = r3
                    r15 = 1
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0274, all -> 0x026d }
                    r0.<init>()     // Catch:{ Exception -> 0x0274, all -> 0x026d }
                    throw r0     // Catch:{ Exception -> 0x0274, all -> 0x026d }
                L_0x026d:
                    r0 = move-exception
                    r1 = r0
                    r3 = r9
                L_0x0270:
                    r2 = r28
                    goto L_0x036b
                L_0x0274:
                    r0 = move-exception
                    r3 = r9
                L_0x0276:
                    r2 = r28
                    goto L_0x0372
                L_0x027a:
                    r0 = move-exception
                    r15 = 1
                    r1 = r0
                    r2 = r3
                L_0x027e:
                    r3 = r9
                    goto L_0x036b
                L_0x0281:
                    r0 = move-exception
                    r15 = 1
                    r2 = r3
                L_0x0284:
                    r3 = r9
                    goto L_0x0372
                L_0x0287:
                    r0 = move-exception
                    r15 = 1
                    r1 = r0
                    r2 = r3
                    goto L_0x0332
                L_0x028d:
                    r0 = move-exception
                    r15 = 1
                    r2 = r3
                    goto L_0x033a
                L_0x0292:
                    r28 = r3
                    r14 = r27
                    r15 = 1
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    epson.print.ecclient.EpsJobAttrib r0 = r0.epsJobattrib     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    r0.mCopies = r14     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    int r1 = r0.EpsonConnectChangePrintSetting()     // Catch:{ Exception -> 0x032a, all -> 0x0326 }
                    if (r1 != 0) goto L_0x031a
                    boolean r0 = epson.print.service.EpsonService.bCancelPrinting     // Catch:{ Exception -> 0x0313, all -> 0x030c }
                    if (r0 == r15) goto L_0x02fd
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x0313, all -> 0x030c }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x0313, all -> 0x030c }
                    r2 = 0
                    int r1 = r0.EpsonConnectStartPrint(r2, r2)     // Catch:{ Exception -> 0x0313, all -> 0x030c }
                    if (r1 != 0) goto L_0x02f5
                L_0x02be:
                    if (r25 == 0) goto L_0x02c6
                    r25.join()     // Catch:{ Exception -> 0x02d4 }
                    r2 = r28
                    goto L_0x02c8
                L_0x02c6:
                    r2 = r28
                L_0x02c8:
                    if (r2 == r15) goto L_0x02d6
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x02d4 }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x02d4 }
                    r0.EpsonConnectEndJob()     // Catch:{ Exception -> 0x02d4 }
                    goto L_0x02d6
                L_0x02d4:
                    r0 = move-exception
                    goto L_0x02e7
                L_0x02d6:
                    if (r2 != r15) goto L_0x02de
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x02d4 }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r15)     // Catch:{ Exception -> 0x02d4 }
                    goto L_0x02e3
                L_0x02de:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x02d4 }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r9)     // Catch:{ Exception -> 0x02d4 }
                L_0x02e3:
                    epson.print.service.EpsonService.onNotifyEndJob(r1)     // Catch:{ Exception -> 0x02d4 }
                    goto L_0x02ea
                L_0x02e7:
                    r0.printStackTrace()     // Catch:{ all -> 0x040b }
                L_0x02ea:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    r1 = 0
                    boolean unused = r0.bPrinting = r1     // Catch:{ all -> 0x040b }
                L_0x02f0:
                    boolean unused = epson.print.service.EpsonService.bCancelPrinting = r1     // Catch:{ all -> 0x040b }
                    goto L_0x03d3
                L_0x02f5:
                    r2 = r28
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                    r0.<init>()     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                    throw r0     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                L_0x02fd:
                    r2 = r28
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0309, all -> 0x0305 }
                    r0.<init>()     // Catch:{ Exception -> 0x0309, all -> 0x0305 }
                    throw r0     // Catch:{ Exception -> 0x0309, all -> 0x0305 }
                L_0x0305:
                    r0 = move-exception
                    r1 = r0
                    goto L_0x027e
                L_0x0309:
                    r0 = move-exception
                    goto L_0x0284
                L_0x030c:
                    r0 = move-exception
                    r2 = r28
                L_0x030f:
                    r3 = r9
                L_0x0310:
                    r9 = r1
                    goto L_0x03d9
                L_0x0313:
                    r0 = move-exception
                    r2 = r28
                L_0x0316:
                    r3 = r9
                L_0x0317:
                    r9 = r1
                    goto L_0x0373
                L_0x031a:
                    r2 = r28
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                    r0.<init>()     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                    throw r0     // Catch:{ Exception -> 0x0324, all -> 0x0322 }
                L_0x0322:
                    r0 = move-exception
                    goto L_0x030f
                L_0x0324:
                    r0 = move-exception
                    goto L_0x0316
                L_0x0326:
                    r0 = move-exception
                    r2 = r28
                    goto L_0x0331
                L_0x032a:
                    r0 = move-exception
                    r2 = r28
                    goto L_0x033a
                L_0x032e:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x0331:
                    r1 = r0
                L_0x0332:
                    r3 = r9
                    r9 = r19
                    goto L_0x03da
                L_0x0337:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x033a:
                    r3 = r9
                    r9 = r19
                    goto L_0x0373
                L_0x033e:
                    r2 = r3
                    r15 = 1
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0348, all -> 0x0346 }
                    r0.<init>()     // Catch:{ Exception -> 0x0348, all -> 0x0346 }
                    throw r0     // Catch:{ Exception -> 0x0348, all -> 0x0346 }
                L_0x0346:
                    r0 = move-exception
                    goto L_0x0369
                L_0x0348:
                    r0 = move-exception
                    goto L_0x0371
                L_0x034a:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x034d:
                    r1 = r0
                    r9 = r19
                    r3 = 1
                    goto L_0x03da
                L_0x0353:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x0356:
                    r9 = r19
                    r3 = 1
                    goto L_0x0373
                L_0x035a:
                    r2 = r3
                    r15 = 1
                    java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0364, all -> 0x0362 }
                    r0.<init>()     // Catch:{ Exception -> 0x0364, all -> 0x0362 }
                    throw r0     // Catch:{ Exception -> 0x0364, all -> 0x0362 }
                L_0x0362:
                    r0 = move-exception
                    goto L_0x034d
                L_0x0364:
                    r0 = move-exception
                    goto L_0x0356
                L_0x0366:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x0369:
                    r1 = r0
                    r3 = 1
                L_0x036b:
                    r9 = 0
                    goto L_0x03da
                L_0x036e:
                    r0 = move-exception
                    r2 = r3
                    r15 = 1
                L_0x0371:
                    r3 = 1
                L_0x0372:
                    r9 = 0
                L_0x0373:
                    r0.printStackTrace()     // Catch:{ all -> 0x03d8 }
                    java.lang.Object r1 = epson.print.service.EpsonService.mLock     // Catch:{ all -> 0x03d8 }
                    monitor-enter(r1)     // Catch:{ all -> 0x03d8 }
                    android.os.RemoteCallbackList<epson.print.service.IEpsonServiceCallback> r0 = epson.print.service.EpsonService.mCallbacks     // Catch:{ all -> 0x03d5 }
                    int r4 = r0.beginBroadcast()     // Catch:{ all -> 0x03d5 }
                    r5 = 0
                L_0x0382:
                    if (r5 >= r4) goto L_0x039e
                    android.os.RemoteCallbackList<epson.print.service.IEpsonServiceCallback> r0 = epson.print.service.EpsonService.mCallbacks     // Catch:{ RemoteException -> 0x0391 }
                    android.os.IInterface r0 = r0.getBroadcastItem(r5)     // Catch:{ RemoteException -> 0x0391 }
                    epson.print.service.IEpsonServiceCallback r0 = (epson.print.service.IEpsonServiceCallback) r0     // Catch:{ RemoteException -> 0x0391 }
                    r6 = 0
                    r0.onNotifyError(r6, r9, r6)     // Catch:{ RemoteException -> 0x0391 }
                    goto L_0x039b
                L_0x0391:
                    r0 = move-exception
                    java.lang.String r6 = "EpsonService"
                    java.lang.String r0 = r0.toString()     // Catch:{ all -> 0x03d5 }
                    epson.print.Util.EPLog.e((java.lang.String) r6, (java.lang.String) r0)     // Catch:{ all -> 0x03d5 }
                L_0x039b:
                    int r5 = r5 + 1
                    goto L_0x0382
                L_0x039e:
                    android.os.RemoteCallbackList<epson.print.service.IEpsonServiceCallback> r0 = epson.print.service.EpsonService.mCallbacks     // Catch:{ all -> 0x03d5 }
                    r0.finishBroadcast()     // Catch:{ all -> 0x03d5 }
                    monitor-exit(r1)     // Catch:{ all -> 0x03d5 }
                    if (r25 == 0) goto L_0x03a9
                    r25.join()     // Catch:{ Exception -> 0x03b5 }
                L_0x03a9:
                    if (r2 == r15) goto L_0x03b7
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03b5 }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x03b5 }
                    r0.EpsonConnectEndJob()     // Catch:{ Exception -> 0x03b5 }
                    goto L_0x03b7
                L_0x03b5:
                    r0 = move-exception
                    goto L_0x03c8
                L_0x03b7:
                    if (r2 != r15) goto L_0x03bf
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03b5 }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r15)     // Catch:{ Exception -> 0x03b5 }
                    goto L_0x03c4
                L_0x03bf:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03b5 }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r3)     // Catch:{ Exception -> 0x03b5 }
                L_0x03c4:
                    epson.print.service.EpsonService.onNotifyEndJob(r9)     // Catch:{ Exception -> 0x03b5 }
                    goto L_0x03cb
                L_0x03c8:
                    r0.printStackTrace()     // Catch:{ all -> 0x040b }
                L_0x03cb:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    r1 = 0
                    boolean unused = r0.bPrinting = r1     // Catch:{ all -> 0x040b }
                    goto L_0x02f0
                L_0x03d3:
                    monitor-exit(r8)     // Catch:{ all -> 0x040b }
                    return
                L_0x03d5:
                    r0 = move-exception
                    monitor-exit(r1)     // Catch:{ all -> 0x03d5 }
                    throw r0     // Catch:{ all -> 0x03d8 }
                L_0x03d8:
                    r0 = move-exception
                L_0x03d9:
                    r1 = r0
                L_0x03da:
                    if (r25 == 0) goto L_0x03df
                    r25.join()     // Catch:{ Exception -> 0x03eb }
                L_0x03df:
                    if (r2 == r15) goto L_0x03ed
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03eb }
                    epson.print.service.IEpsonService$Stub r0 = r0.mBinder     // Catch:{ Exception -> 0x03eb }
                    r0.EpsonConnectEndJob()     // Catch:{ Exception -> 0x03eb }
                    goto L_0x03ed
                L_0x03eb:
                    r0 = move-exception
                    goto L_0x03fe
                L_0x03ed:
                    if (r2 != r15) goto L_0x03f5
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03eb }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r15)     // Catch:{ Exception -> 0x03eb }
                    goto L_0x03fa
                L_0x03f5:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ Exception -> 0x03eb }
                    com.epson.iprint.prtlogger.Analytics.savePrintInfo(r0, r3)     // Catch:{ Exception -> 0x03eb }
                L_0x03fa:
                    epson.print.service.EpsonService.onNotifyEndJob(r9)     // Catch:{ Exception -> 0x03eb }
                    goto L_0x0401
                L_0x03fe:
                    r0.printStackTrace()     // Catch:{ all -> 0x040b }
                L_0x0401:
                    epson.print.service.EpsonService r0 = epson.print.service.EpsonService.this     // Catch:{ all -> 0x040b }
                    r2 = 0
                    boolean unused = r0.bPrinting = r2     // Catch:{ all -> 0x040b }
                    boolean unused = epson.print.service.EpsonService.bCancelPrinting = r2     // Catch:{ all -> 0x040b }
                    throw r1     // Catch:{ all -> 0x040b }
                L_0x040b:
                    r0 = move-exception
                    monitor-exit(r8)     // Catch:{ all -> 0x040b }
                    throw r0
                */
                throw new UnsupportedOperationException("Method not decompiled: epson.print.service.EpsonService.C23713.run():void");
            }
        };
        return 0;
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r14v1, resolved type: epson.print.EPImageCreator} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r14v2, resolved type: java.lang.String} */
    /* JADX WARNING: type inference failed for: r14v0 */
    /* JADX WARNING: type inference failed for: r14v4 */
    /* JADX WARNING: type inference failed for: r14v5 */
    /* JADX WARNING: type inference failed for: r14v7 */
    /* JADX WARNING: type inference failed for: r14v8 */
    /*  JADX ERROR: IndexOutOfBoundsException in pass: RegionMakerVisitor
        java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
        	at java.util.ArrayList.get(ArrayList.java:433)
        	at jadx.core.dex.nodes.InsnNode.getArg(InsnNode.java:101)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:611)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverseMonitorExits(RegionMaker.java:619)
        	at jadx.core.dex.visitors.regions.RegionMaker.processMonitorEnter(RegionMaker.java:561)
        	at jadx.core.dex.visitors.regions.RegionMaker.traverse(RegionMaker.java:133)
        	at jadx.core.dex.visitors.regions.RegionMaker.makeRegion(RegionMaker.java:86)
        	at jadx.core.dex.visitors.regions.RegionMaker.processExcHandler(RegionMaker.java:1043)
        	at jadx.core.dex.visitors.regions.RegionMaker.processTryCatchBlocks(RegionMaker.java:975)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:52)
        */
    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* JADX WARNING: Multi-variable type inference failed */
    public java.lang.String createPrintImage(epson.print.EPImageList r18, int r19, int r20, int r21, int r22, int r23, int r24, int r25, int r26) {
        /*
            r17 = this;
            r1 = r17
            r0 = r20
            r2 = r22
            r9 = r23
            com.epson.mobilephone.common.EPLog.m68d()
            epson.print.EPImage r15 = r18.get(r19)
            epson.print.EPImageCreator r3 = new epson.print.EPImageCreator
            android.content.Context r4 = r17.getApplicationContext()
            r3.<init>(r4)
            java.lang.Object r4 = mCancelLock
            monitor-enter(r4)
            r1.mEPImageCreator = r3     // Catch:{ all -> 0x023d }
            monitor-exit(r4)     // Catch:{ all -> 0x023d }
            java.lang.System.gc()
            r14 = 0
            boolean r4 = bCancelPrinting     // Catch:{ Exception -> 0x022f }
            r5 = 1
            if (r4 == r5) goto L_0x0229
            com.epson.mobilephone.common.escpr.EscprLib r4 = r1.mEscprLib     // Catch:{ Exception -> 0x022f }
            int[] r4 = r4.get_printable_area()     // Catch:{ Exception -> 0x022f }
            epson.print.MyPrinter.getCurPrinter(r17)     // Catch:{ Exception -> 0x022f }
            boolean r13 = epson.print.MyPrinter.isRemotePrinter(r17)     // Catch:{ Exception -> 0x022f }
            java.lang.StringBuilder r6 = new java.lang.StringBuilder     // Catch:{ Exception -> 0x022f }
            r6.<init>()     // Catch:{ Exception -> 0x022f }
            java.lang.String r7 = " ☆☆ isRemotePrinter  "
            r6.append(r7)     // Catch:{ Exception -> 0x022f }
            r6.append(r13)     // Catch:{ Exception -> 0x022f }
            java.lang.String r6 = r6.toString()     // Catch:{ Exception -> 0x022f }
            com.epson.mobilephone.common.EPLog.i(r6)     // Catch:{ Exception -> 0x022f }
            r6 = 2
            r7 = 0
            if (r13 != r5) goto L_0x00e2
            android.content.Context r4 = r17.getApplicationContext()     // Catch:{ Exception -> 0x022f }
            epson.common.Info_paper r4 = epson.common.Info_paper.getInfoPaper(r4, r0)     // Catch:{ Exception -> 0x022f }
            int[] r8 = new int[r6]     // Catch:{ Exception -> 0x022f }
            if (r9 != r6) goto L_0x0065
            int r10 = r4.getPaper_width_boder()     // Catch:{ Exception -> 0x022f }
            r8[r7] = r10     // Catch:{ Exception -> 0x022f }
            int r4 = r4.getPaper_height_boder()     // Catch:{ Exception -> 0x022f }
            r8[r5] = r4     // Catch:{ Exception -> 0x022f }
            goto L_0x0073
        L_0x0065:
            if (r9 != r5) goto L_0x0073
            int r10 = r4.getPaper_width_boderless()     // Catch:{ Exception -> 0x022f }
            r8[r7] = r10     // Catch:{ Exception -> 0x022f }
            int r4 = r4.getPaper_height_boderless()     // Catch:{ Exception -> 0x022f }
            r8[r5] = r4     // Catch:{ Exception -> 0x022f }
        L_0x0073:
            int r4 = r15.srcWidth     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            if (r4 <= r10) goto L_0x0080
            int r4 = r15.srcHeight     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            if (r4 <= r10) goto L_0x0080
            goto L_0x00e3
        L_0x0080:
            int r4 = r15.srcWidth     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            if (r4 <= r10) goto L_0x009a
            r4 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r4 = (float) r4     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r4 = r4 / r10
            int r10 = r15.srcHeight     // Catch:{ Exception -> 0x022f }
            r8[r5] = r10     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r10 = r10 * r4
            int r4 = (int) r10     // Catch:{ Exception -> 0x022f }
            r8[r7] = r4     // Catch:{ Exception -> 0x022f }
            goto L_0x00e3
        L_0x009a:
            int r4 = r15.srcHeight     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            if (r4 <= r10) goto L_0x00b4
            r4 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r4 = (float) r4     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r4 = r4 / r10
            int r10 = r15.srcWidth     // Catch:{ Exception -> 0x022f }
            r8[r7] = r10     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r10 = r10 * r4
            int r4 = (int) r10     // Catch:{ Exception -> 0x022f }
            r8[r5] = r4     // Catch:{ Exception -> 0x022f }
            goto L_0x00e3
        L_0x00b4:
            int r4 = r15.srcWidth     // Catch:{ Exception -> 0x022f }
            int r10 = r15.srcHeight     // Catch:{ Exception -> 0x022f }
            if (r4 >= r10) goto L_0x00ce
            r4 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r4 = (float) r4     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r4 = r4 / r10
            int r10 = r15.srcWidth     // Catch:{ Exception -> 0x022f }
            r8[r7] = r10     // Catch:{ Exception -> 0x022f }
            r10 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r10 = r10 * r4
            int r4 = (int) r10     // Catch:{ Exception -> 0x022f }
            r8[r5] = r4     // Catch:{ Exception -> 0x022f }
            goto L_0x00e3
        L_0x00ce:
            r4 = r8[r7]     // Catch:{ Exception -> 0x022f }
            float r4 = (float) r4     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r4 = r4 / r10
            int r10 = r15.srcHeight     // Catch:{ Exception -> 0x022f }
            r8[r5] = r10     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            float r10 = (float) r10     // Catch:{ Exception -> 0x022f }
            float r10 = r10 * r4
            int r4 = (int) r10     // Catch:{ Exception -> 0x022f }
            r8[r7] = r4     // Catch:{ Exception -> 0x022f }
            goto L_0x00e3
        L_0x00e2:
            r8 = r4
        L_0x00e3:
            r15.rotate = r7     // Catch:{ Exception -> 0x022f }
            epson.print.service.IEpsonService$Stub r4 = r1.mBinder     // Catch:{ Exception -> 0x022f }
            int r4 = r4.getLang()     // Catch:{ Exception -> 0x022f }
            switch(r4) {
                case 1: goto L_0x0142;
                case 2: goto L_0x0135;
                case 3: goto L_0x0135;
                case 4: goto L_0x00f0;
                case 5: goto L_0x0135;
                case 6: goto L_0x0135;
                case 7: goto L_0x00f0;
                default: goto L_0x00ee;
            }     // Catch:{ Exception -> 0x022f }
        L_0x00ee:
            goto L_0x017f
        L_0x00f0:
            com.epson.mobilephone.common.escpr.EscprLib r4 = r1.mEscprLib     // Catch:{ Exception -> 0x022f }
            boolean r4 = r4.pageS_needRotate2(r0)     // Catch:{ Exception -> 0x022f }
            if (r4 == 0) goto L_0x011c
            r4 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            r8[r7] = r10     // Catch:{ Exception -> 0x022f }
            r8[r5] = r4     // Catch:{ Exception -> 0x022f }
            if (r24 != 0) goto L_0x010c
            boolean r4 = r15.isPaperLandScape     // Catch:{ Exception -> 0x022f }
            if (r4 != 0) goto L_0x010c
            int r4 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r4 = r4 + 90
            r15.rotate = r4     // Catch:{ Exception -> 0x022f }
        L_0x010c:
            if (r2 != r6) goto L_0x0118
            int r2 = r19 % 2
            if (r2 != r5) goto L_0x0118
            int r2 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r2 = r2 + 180
            r15.rotate = r2     // Catch:{ Exception -> 0x022f }
        L_0x0118:
            r16 = 1
            goto L_0x0181
        L_0x011c:
            if (r24 != 0) goto L_0x0128
            boolean r4 = r15.isPaperLandScape     // Catch:{ Exception -> 0x022f }
            if (r4 != r5) goto L_0x0128
            int r4 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r4 = r4 + 90
            r15.rotate = r4     // Catch:{ Exception -> 0x022f }
        L_0x0128:
            if (r2 != r5) goto L_0x017f
            int r2 = r19 % 2
            if (r2 != r5) goto L_0x017f
            int r2 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r2 = r2 + 180
            r15.rotate = r2     // Catch:{ Exception -> 0x022f }
            goto L_0x017f
        L_0x0135:
            if (r24 != 0) goto L_0x017f
            boolean r2 = r15.isPaperLandScape     // Catch:{ Exception -> 0x022f }
            if (r2 != r5) goto L_0x017f
            int r2 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r2 = r2 + 90
            r15.rotate = r2     // Catch:{ Exception -> 0x022f }
            goto L_0x017f
        L_0x0142:
            r4 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            if (r4 > r10) goto L_0x014a
            r4 = 1
            goto L_0x014b
        L_0x014a:
            r4 = 0
        L_0x014b:
            if (r24 != 0) goto L_0x0166
            if (r4 != r5) goto L_0x015a
            boolean r10 = r15.isPaperLandScape     // Catch:{ Exception -> 0x022f }
            if (r10 != r5) goto L_0x015a
            int r10 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r10 = r10 + 90
            r15.rotate = r10     // Catch:{ Exception -> 0x022f }
            goto L_0x0166
        L_0x015a:
            if (r4 != 0) goto L_0x0166
            boolean r10 = r15.isPaperLandScape     // Catch:{ Exception -> 0x022f }
            if (r10 != 0) goto L_0x0166
            int r10 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r10 = r10 + 90
            r15.rotate = r10     // Catch:{ Exception -> 0x022f }
        L_0x0166:
            int r10 = r19 % 2
            if (r10 != r5) goto L_0x017f
            if (r4 != r5) goto L_0x0175
            if (r2 != r5) goto L_0x0175
            int r2 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r2 = r2 + 180
            r15.rotate = r2     // Catch:{ Exception -> 0x022f }
            goto L_0x017f
        L_0x0175:
            if (r4 != 0) goto L_0x017f
            if (r2 != r6) goto L_0x017f
            int r2 = r15.rotate     // Catch:{ Exception -> 0x022f }
            int r2 = r2 + 180
            r15.rotate = r2     // Catch:{ Exception -> 0x022f }
        L_0x017f:
            r16 = 0
        L_0x0181:
            int r2 = r17.getLang()     // Catch:{ Exception -> 0x022f }
            r4 = r25
            int r6 = r1.getStartPageResolution(r13, r4, r2)     // Catch:{ Exception -> 0x022f }
            int r2 = r18.getRenderingMode()     // Catch:{ Exception -> 0x022f }
            if (r2 != r5) goto L_0x01e1
            if (r24 != 0) goto L_0x01bb
            android.content.Context r4 = r17.getApplicationContext()     // Catch:{ Exception -> 0x022f }
            r7 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r8 = r8[r5]     // Catch:{ Exception -> 0x022f }
            r2 = r3
            r3 = r4
            r4 = r15
            r5 = r6
            r6 = r7
            r7 = r8
            r8 = r20
            r9 = r23
            r10 = r24
            r11 = r21
            r12 = r26
            r0 = r14
            r14 = r16
            r2.createPrintImage(r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14)     // Catch:{ Exception -> 0x01b8 }
            java.lang.String r2 = r15.decodeImageFileName     // Catch:{ Exception -> 0x01b8 }
            r15.printImageFileName = r2     // Catch:{ Exception -> 0x01b8 }
            r14 = r0
            goto L_0x0231
        L_0x01b8:
            r14 = r0
            goto L_0x022f
        L_0x01bb:
            android.content.Context r4 = r17.getApplicationContext()     // Catch:{ Exception -> 0x022f }
            r9 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            int r13 = r15.rotate     // Catch:{ Exception -> 0x022f }
            r2 = r3
            r3 = r4
            r4 = r24
            r5 = r6
            r6 = r18
            r7 = r19
            r8 = r9
            r9 = r10
            r10 = r20
            r11 = r21
            r12 = r26
            r0 = r14
            r14 = r16
            java.lang.String r2 = r2.createMultiPrintImage(r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14)     // Catch:{ Exception -> 0x01b8 }
            r15.printImageFileName = r2     // Catch:{ Exception -> 0x01b8 }
            r14 = r0
            goto L_0x0231
        L_0x01e1:
            if (r24 == 0) goto L_0x020a
            java.lang.String r2 = "割り付け画像を生成"
            com.epson.mobilephone.common.EPLog.d(r2)     // Catch:{ Exception -> 0x022f }
            android.content.Context r4 = r17.getApplicationContext()     // Catch:{ Exception -> 0x022f }
            r9 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r10 = r8[r5]     // Catch:{ Exception -> 0x022f }
            int r13 = r15.rotate     // Catch:{ Exception -> 0x022f }
            r2 = r3
            r3 = r4
            r4 = r24
            r5 = r6
            r6 = r18
            r7 = r19
            r8 = r9
            r9 = r10
            r10 = r20
            r11 = r21
            r12 = r26
            java.lang.String r0 = r2.createMultiPrintImage_org(r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13)     // Catch:{ Exception -> 0x022f }
            r15.printImageFileName = r0     // Catch:{ Exception -> 0x022f }
            goto L_0x0231
        L_0x020a:
            android.content.Context r4 = r17.getApplicationContext()     // Catch:{ Exception -> 0x022f }
            r7 = r8[r7]     // Catch:{ Exception -> 0x022f }
            r8 = r8[r5]     // Catch:{ Exception -> 0x022f }
            r2 = r3
            r3 = r4
            r4 = r15
            r5 = r6
            r6 = r7
            r7 = r8
            r8 = r20
            r9 = r23
            r10 = r21
            r11 = r26
            r12 = r13
            r2.createPrintImage_origi(r3, r4, r5, r6, r7, r8, r9, r10, r11, r12)     // Catch:{ Exception -> 0x022f }
            java.lang.String r0 = r15.decodeImageFileName     // Catch:{ Exception -> 0x022f }
            r15.printImageFileName = r0     // Catch:{ Exception -> 0x022f }
            goto L_0x0231
        L_0x0229:
            java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x022f }
            r0.<init>()     // Catch:{ Exception -> 0x022f }
            throw r0     // Catch:{ Exception -> 0x022f }
        L_0x022f:
            r15.printImageFileName = r14
        L_0x0231:
            java.lang.Object r2 = mCancelLock
            monitor-enter(r2)
            r1.mEPImageCreator = r14     // Catch:{ all -> 0x023a }
            monitor-exit(r2)     // Catch:{ all -> 0x023a }
            java.lang.String r0 = r15.printImageFileName
            return r0
        L_0x023a:
            r0 = move-exception
            monitor-exit(r2)     // Catch:{ all -> 0x023a }
            throw r0
        L_0x023d:
            r0 = move-exception
            monitor-exit(r4)     // Catch:{ all -> 0x023d }
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: epson.print.service.EpsonService.createPrintImage(epson.print.EPImageList, int, int, int, int, int, int, int, int):java.lang.String");
    }

    private int getStartPageResolution(boolean z, int i, int i2) {
        if (z) {
            return EPImageCreator.getPrintAreaResolution(i2, i);
        }
        return mEscprLib.get_start_job_resolution2();
    }

    private int epsonConnectCreateJob(int i, String str, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12, int i13, int i14) throws RemoteException {
        return mBinder.EpsonConnectCreateJob(i, str, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14);
    }

    private int epsonConnectEndJob() throws RemoteException {
        return mBinder.EpsonConnectEndJob();
    }

    private int epsonConnectUploadFile(String str, int i) throws RemoteException {
        return mBinder.EpsonConnectUploadFile(str, i);
    }

    private int epsonConnectChangePrintSetting() throws RemoteException {
        return mBinder.EpsonConnectChangePrintSetting();
    }

    private int epsonConnectStartPrint(int i, int i2) throws RemoteException {
        return mBinder.EpsonConnectStartPrint(i, i2);
    }

    private void setEpsonConnectCopies(int i) {
        epsJobattrib.mCopies = i;
    }

    public void waitIfSimpleAp() {
        int[] printerStatus;
        if (WiFiDirectManager.isSimpleAP(getApplicationContext())) {
            try {
                int[] iArr = new int[3];
                Thread.sleep(5000);
                int i = 0;
                do {
                    printerStatus = getPrinterStatus();
                    Thread.sleep(1000);
                    i++;
                    if (i >= 1800) {
                        return;
                    }
                } while (printerStatus[0] != 0);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public int startJob(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, boolean z) {
        StringBuilder sb = new StringBuilder();
        sb.append("service:: paperSize = ");
        sb.append(i);
        sb.append(" paperType = ");
        int i12 = i2;
        sb.append(i12);
        sb.append(" layout = ");
        int i13 = i3;
        sb.append(i13);
        EPLog.m304d(sb.toString());
        return mEscprLib.start_job2(i, i12, i13, i4, i5, i6, i7, i8, i9, i10, i11, z);
    }

    public int getStartJobResolution() {
        return mEscprLib.get_start_job_resolution2();
    }

    public int startPage() {
        return mEscprLib.start_page();
    }

    public int endJob() {
        return mEscprLib.end_job();
    }

    public int printPage() {
        return mEscprLib.print_page();
    }

    public int getLang() {
        return mEscprLib.get_lang();
    }

    public int endPage(boolean z) {
        return mEscprLib.end_page(z);
    }

    public int initImage(String str) {
        return mEscprLib.init_image(str);
    }

    public int releaseImage() {
        return mEscprLib.release_image();
    }

    public int[] getPrintableArea() {
        return mEscprLib.get_printable_area();
    }

    @NonNull
    public int[] getLocalPrinterLayout1AreaSize(int i) {
        int[] iArr = mEscprLib.get_printable_area();
        if (i == 0) {
            return iArr;
        }
        return Info_paper.getMultiLayoutArea(i, iArr[0], iArr[1], mEscprLib.get_start_job_resolution2());
    }

    public boolean pageSneedRotate(int i) {
        return mEscprLib.pageS_needRotate2(i);
    }

    public int[] getPrinterStatus() {
        return mEscprLib.get_printer_status();
    }

    public Object getPrintLockObject() {
        return mPrinting;
    }

    public void setCancelPrinting(boolean z) {
        bCancelPrinting = z;
    }

    public boolean getCancelPrinting() {
        return bCancelPrinting;
    }

    public void setPrinting(boolean z) {
        bPrinting = z;
    }

    public void notifyEndJob(int i) {
        onNotifyEndJob(i);
    }

    public Context getLocalApplicationContext() {
        return getApplicationContext();
    }

    public void onCreate() {
        EPLog.i();
        super.onCreate();
    }

    public IBinder onBind(Intent intent) {
        EPLog.i();
        try {
            if (!isInitDriver) {
                mEscprLib.init_driver(getApplicationContext(), ExternalFileUtils.getInstance(getApplicationContext()).getSupportedMediaDir());
                isInitDriver = true;
            }
            updateLoginInfo();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mBinder;
    }

    public void onRebind(Intent intent) {
        EPLog.i();
        mEscprLib.release_driver();
        isInitDriver = false;
        mEscprLib.init_driver(getApplicationContext(), ExternalFileUtils.getInstance(getApplicationContext()).getSupportedMediaDir());
        isInitDriver = true;
        clientId = SharedPreferencesProvider.getInstace(this).getString(epson.common.Constants.PRINTER_CLIENT_ID, (String) null);
        EPLog.d("▲clientId = " + clientId);
        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
        mailAddress = curPrinter.getEmailAddress();
        accessKey = curPrinter.getRemotePrinterAccessKey(this);
        super.onRebind(intent);
    }

    public boolean onUnbind(Intent intent) {
        EPLog.i();
        mEscprLib.setHanlder((Handler) null);
        mEscprLib.release_driver();
        isInitDriver = false;
        return super.onUnbind(intent);
    }

    public void onDestroy() {
        EPLog.i();
        super.onDestroy();
    }

    public static void onNotifyProgress(int i) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i2 = 0; i2 < beginBroadcast; i2++) {
                try {
                    mCallbacks.getBroadcastItem(i2).onNotifyProgress(1, i);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public static void notifyProgress(int i, int i2) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i3 = 0; i3 < beginBroadcast; i3++) {
                try {
                    mCallbacks.getBroadcastItem(i3).onNotifyProgress(i, i2);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public static void onNotifyContinueable(int i) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i2 = 0; i2 < beginBroadcast; i2++) {
                try {
                    mCallbacks.getBroadcastItem(i2).onNotifyContinueable(i);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public void epsNotifyContinueable(int i) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i2 = 0; i2 < beginBroadcast; i2++) {
                try {
                    mCallbacks.getBroadcastItem(i2).onNotifyContinueable(i);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public static void onNotifyEndJob(int i) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i2 = 0; i2 < beginBroadcast; i2++) {
                try {
                    mCallbacks.getBroadcastItem(i2).onNotifyEndJob(i);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public static void onNotifyError(int i, int i2, boolean z) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i3 = 0; i3 < beginBroadcast; i3++) {
                try {
                    mCallbacks.getBroadcastItem(i3).onNotifyError(i, i2, z);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }

    public void epsNotifyError(int i, int i2, boolean z) {
        synchronized (mLock) {
            int beginBroadcast = mCallbacks.beginBroadcast();
            for (int i3 = 0; i3 < beginBroadcast; i3++) {
                try {
                    mCallbacks.getBroadcastItem(i3).onNotifyError(i, i2, z);
                } catch (RemoteException e) {
                    EPLog.e("NotificationService", e.toString());
                }
            }
            mCallbacks.finishBroadcast();
        }
    }
}
