package com.epson.cameracopy.ui;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.epson.cameracopy.printlayout.ImageAndLayout;
import com.epson.iprint.prtlogger.Analytics;
import com.epson.mobilephone.common.escpr.MediaInfo;
import com.epson.mobilephone.common.wifidirect.NfcTagUtils;

import epson.common.Utils;

import epson.print.CommonDefine;
import epson.print.MyPrinter;
import epson.print.Util.EPLog;
import epson.print.screen.PrintProgress;
import epson.print.screen.PrintSetting;
import epson.print.service.IEpsonService;
import epson.print.service.IEpsonServiceCallback;
import epson.print.widgets.CustomTitleAlertDialogBuilder;

import java.util.ArrayList;

/* renamed from: com.epson.cameracopy.ui.CameraPrintProgress */
public class CameraPrintProgress extends Activity implements CommonDefine {
    private static final int DIALOG_CONFIRM = 1;
    private static final int DIALOG_INFORM = 0;
    public static final int END_PRINT = 4;
    public static final String KEY_IMAGE_AND_LAYOUT = "image_and_layout";
    public static final String PARAM_PRINT_PROGRESS = "progress-params";
    public static final String PREFS_NAME = "PrintSetting";
    public static final int RESULT_ERROR = 1000;
    private static boolean bRestartactivity = false;
    static int copies = 0;
    static int curError = 0;
    static int fileIndex = 0;
    static boolean isBkRetry = false;
    static boolean isContinue = false;
    static boolean isDocument = false;
    private static final Object lockBCancel = new Object();
    private static IEpsonServiceCallback mCallback;
    private static ServiceConnection mEpsonConnection;
    private static IEpsonService mEpsonService = null;
    private static final Object mLock = new Object();
    private static final Object mLockInit = new Object();
    static ProgressBar mProgressCopies;
    static ProgressBar mProgressPage;
    static ProgressBar mProgressPercent;
    private final int CHECK_PRINTER = 6;
    private final int CHECK_PRINTER_CONTINUE = 10;
    private final int CONFIRM = 7;
    private final int CONNECTED_SIMPLEAP = 1;
    private final int CONTINUE_PRINT = 3;
    private final int ECC_LIB_ERROR = 9;
    private final int EPS_DUPLEX_NONE = 0;
    private final int EPS_JOB_CANCELED = 40;
    private final int ERROR = 4;
    private final int FINISH = 5;
    private final String PERCENT = "PERCENT";
    private final int PRINT_NEXT_PAGE = 1;
    private final int SHOW_COMPLETE_DIALOG = 8;
    private final int START_PRINT = 2;
    private final int UPDATE_PERCENT = 0;
    boolean bCancel = false;
    private boolean bSearching = false;
    private boolean bSearchingPrinter = false;
    private Context context = null;
    private int curCopy = 1;
    private int curSheet = 1;
    int duplex = 0;
    private boolean isDialogOpen = false;
    private boolean isRemotePrinter = false;
    Button mCancelButton;
    boolean mCanceled = false;
    TextView mCopies;
    private volatile boolean mError = false;
    Handler mHandler = new Handler(new Handler.Callback() {
        /* JADX WARNING: Can't fix incorrect switch cases order */
        /* JADX WARNING: Code restructure failed: missing block: B:32:0x020e, code lost:
            if (com.epson.mobilephone.common.wifidirect.WiFiDirectManager.reconnect(r8.this$0, com.epson.mobilephone.common.wifidirect.WiFiDirectManager.DEVICE_TYPE_PRINTER, 1) == false) goto L_0x0212;
         */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public boolean handleMessage(android.os.Message r9) {
            /*
                r8 = this;
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r0 = r0.mCanceled
                r1 = 5
                r2 = 1
                if (r0 == 0) goto L_0x002a
                int r0 = r9.what
                if (r0 == r1) goto L_0x0019
                r9 = 8
                if (r0 == r9) goto L_0x0011
                return r2
            L_0x0011:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.os.Handler r9 = r9.mHandler
                r9.sendEmptyMessage(r1)
                return r2
            L_0x0019:
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.content.Context r0 = r0.context
                java.lang.String r3 = "printer"
                com.epson.cameracopy.ui.CameraPrintProgress r4 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r4 = r4.printerIp
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.disconnect(r0, r3, r4)
            L_0x002a:
                int r0 = r9.what
                r3 = 4
                r4 = 2
                r5 = 100
                r7 = 0
                switch(r0) {
                    case 0: goto L_0x0459;
                    case 1: goto L_0x0034;
                    case 2: goto L_0x03ff;
                    case 3: goto L_0x0034;
                    case 4: goto L_0x03ae;
                    case 5: goto L_0x027f;
                    case 6: goto L_0x01ed;
                    case 7: goto L_0x0034;
                    case 8: goto L_0x018c;
                    case 9: goto L_0x0036;
                    case 10: goto L_0x0212;
                    default: goto L_0x0034;
                }
            L_0x0034:
                goto L_0x0573
            L_0x0036:
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean unused = r0.mError = r2
                int r0 = r9.arg1
                r1 = -1100(0xfffffffffffffbb4, float:NaN)
                if (r0 == r1) goto L_0x0173
                r1 = -1056(0xfffffffffffffbe0, float:NaN)
                r3 = 2131624019(0x7f0e0053, float:1.8875206E38)
                r4 = 2131624018(0x7f0e0052, float:1.8875204E38)
                r5 = 2131624020(0x7f0e0054, float:1.8875208E38)
                r6 = 2131624021(0x7f0e0055, float:1.887521E38)
                if (r0 == r1) goto L_0x0136
                switch(r0) {
                    case -1209: goto L_0x00f9;
                    case -1208: goto L_0x00f9;
                    default: goto L_0x0054;
                }
            L_0x0054:
                switch(r0) {
                    case -1206: goto L_0x00e5;
                    case -1205: goto L_0x00d1;
                    case -1204: goto L_0x0136;
                    case -1203: goto L_0x00bd;
                    case -1202: goto L_0x00a9;
                    case -1201: goto L_0x0095;
                    case -1200: goto L_0x0136;
                    default: goto L_0x0057;
                }
            L_0x0057:
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r0 = r0.getString(r6)
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r6 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r5 = r6.getString(r5)
                r1.append(r5)
                com.epson.cameracopy.ui.CameraPrintProgress r5 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r4 = r5.getString(r4)
                r1.append(r4)
                java.lang.String r4 = "0X"
                r1.append(r4)
                int r9 = r9.arg1
                java.lang.String r9 = java.lang.Integer.toHexString(r9)
                java.lang.String r9 = r9.toUpperCase()
                r1.append(r9)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r9 = r9.getString(r3)
                r1.append(r9)
                java.lang.String r9 = r1.toString()
                goto L_0x0185
            L_0x0095:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624025(0x7f0e0059, float:1.8875218E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624024(0x7f0e0058, float:1.8875216E38)
                java.lang.String r9 = r9.getString(r1)
                goto L_0x0185
            L_0x00a9:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624028(0x7f0e005c, float:1.8875224E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624027(0x7f0e005b, float:1.8875222E38)
                java.lang.String r9 = r9.getString(r1)
                goto L_0x0185
            L_0x00bd:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624023(0x7f0e0057, float:1.8875214E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624022(0x7f0e0056, float:1.8875212E38)
                java.lang.String r9 = r9.getString(r1)
                goto L_0x0185
            L_0x00d1:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624016(0x7f0e0050, float:1.88752E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624012(0x7f0e004c, float:1.8875192E38)
                java.lang.String r9 = r9.getString(r1)
                goto L_0x0185
            L_0x00e5:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624787(0x7f0e0353, float:1.8876764E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624786(0x7f0e0352, float:1.8876762E38)
                java.lang.String r9 = r9.getString(r1)
                goto L_0x0185
            L_0x00f9:
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624009(0x7f0e0049, float:1.8875186E38)
                java.lang.String r0 = r0.getString(r1)
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r4 = 2131624007(0x7f0e0047, float:1.8875182E38)
                java.lang.String r3 = r3.getString(r4)
                r1.append(r3)
                java.lang.String r3 = "0X"
                r1.append(r3)
                int r9 = r9.arg1
                java.lang.String r9 = java.lang.Integer.toHexString(r9)
                java.lang.String r9 = r9.toUpperCase()
                r1.append(r9)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r3 = 2131624008(0x7f0e0048, float:1.8875184E38)
                java.lang.String r9 = r9.getString(r3)
                r1.append(r9)
                java.lang.String r9 = r1.toString()
                goto L_0x0185
            L_0x0136:
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r0 = r0.getString(r6)
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r6 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r5 = r6.getString(r5)
                r1.append(r5)
                com.epson.cameracopy.ui.CameraPrintProgress r5 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r4 = r5.getString(r4)
                r1.append(r4)
                java.lang.String r4 = "0X"
                r1.append(r4)
                int r9 = r9.arg1
                java.lang.String r9 = java.lang.Integer.toHexString(r9)
                java.lang.String r9 = r9.toUpperCase()
                r1.append(r9)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r9 = r9.getString(r3)
                r1.append(r9)
                java.lang.String r9 = r1.toString()
                goto L_0x0185
            L_0x0173:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r0 = 2131624032(0x7f0e0060, float:1.8875232E38)
                java.lang.String r0 = r9.getString(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131624031(0x7f0e005f, float:1.887523E38)
                java.lang.String r9 = r9.getString(r1)
            L_0x0185:
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1.showErrorDialog(r0, r9)
                goto L_0x0573
            L_0x018c:
                android.app.AlertDialog$Builder r9 = new android.app.AlertDialog$Builder
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.content.Context r0 = r0.context
                r9.<init>(r0)
                android.app.AlertDialog$Builder r9 = r9.setCancelable(r7)
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r3 = 2131624796(0x7f0e035c, float:1.8876782E38)
                java.lang.String r1 = r1.getString(r3)
                r0.append(r1)
                java.lang.String r1 = "\n"
                r0.append(r1)
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r3 = 2131624797(0x7f0e035d, float:1.8876784E38)
                java.lang.String r1 = r1.getString(r3)
                r0.append(r1)
                java.lang.String r1 = "\n\n"
                r0.append(r1)
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r3 = 2131624798(0x7f0e035e, float:1.8876786E38)
                java.lang.String r1 = r1.getString(r3)
                r0.append(r1)
                java.lang.String r0 = r0.toString()
                android.app.AlertDialog$Builder r9 = r9.setMessage(r0)
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r1 = 2131625202(0x7f0e04f2, float:1.8877605E38)
                java.lang.String r0 = r0.getString(r1)
                com.epson.cameracopy.ui.CameraPrintProgress$4$1 r1 = new com.epson.cameracopy.ui.CameraPrintProgress$4$1
                r1.<init>()
                android.app.AlertDialog$Builder r9 = r9.setPositiveButton(r0, r1)
                r9.show()
                goto L_0x0573
            L_0x01ed:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int unused = r9.curSheet = r2
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int unused = r9.curCopy = r2
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.content.Context r9 = r9.context
                java.lang.String r0 = "printer"
                boolean r9 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.isNeedConnect(r9, r0)
                if (r9 != 0) goto L_0x0206
                goto L_0x0212
            L_0x0206:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r0 = "printer"
                boolean r9 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.reconnect(r9, r0, r2)
                if (r9 == 0) goto L_0x0212
                goto L_0x0573
            L_0x0212:
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService
                if (r9 == 0) goto L_0x0274
                java.lang.String r9 = "Epson"
                java.lang.String r0 = "begin probe printer before printing"
                epson.print.Util.EPLog.e((java.lang.String) r9, (java.lang.String) r0)     // Catch:{ RemoteException -> 0x026e }
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x026e }
                epson.print.MyPrinter r9 = epson.print.MyPrinter.getCurPrinter(r9)     // Catch:{ RemoteException -> 0x026e }
                java.lang.String r0 = r9.getPrinterId()     // Catch:{ RemoteException -> 0x026e }
                java.lang.String r1 = r9.getIp()     // Catch:{ RemoteException -> 0x026e }
                if (r0 == 0) goto L_0x0243
                int r5 = r9.getLocation()     // Catch:{ RemoteException -> 0x026e }
                if (r5 != r2) goto L_0x0243
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x026e }
                boolean unused = r9.bSearching = r2     // Catch:{ RemoteException -> 0x026e }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x026e }
                r9.searchPrinters(r0, r1, r2)     // Catch:{ RemoteException -> 0x026e }
                goto L_0x0573
            L_0x0243:
                if (r1 == 0) goto L_0x025a
                int r9 = r9.getLocation()     // Catch:{ RemoteException -> 0x026e }
                r5 = 3
                if (r9 != r5) goto L_0x025a
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x026e }
                boolean unused = r9.bSearching = r2     // Catch:{ RemoteException -> 0x026e }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x026e }
                r9.searchPrinters(r0, r1, r4)     // Catch:{ RemoteException -> 0x026e }
                goto L_0x0573
            L_0x025a:
                com.epson.cameracopy.ui.CameraPrintProgress.isContinue = r7     // Catch:{ RemoteException -> 0x026e }
                r9 = -1351(0xfffffffffffffab9, float:NaN)
                com.epson.cameracopy.ui.CameraPrintProgress.curError = r9     // Catch:{ RemoteException -> 0x026e }
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x026e }
                boolean unused = r9.mError = r2     // Catch:{ RemoteException -> 0x026e }
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x026e }
                android.os.Handler r9 = r9.mHandler     // Catch:{ RemoteException -> 0x026e }
                r9.sendEmptyMessage(r3)     // Catch:{ RemoteException -> 0x026e }
                goto L_0x0573
            L_0x026e:
                r9 = move-exception
                r9.printStackTrace()
                goto L_0x0573
            L_0x0274:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.os.Handler r9 = r9.mHandler
                r0 = 10
                r9.sendEmptyMessageDelayed(r0, r5)
                goto L_0x0573
            L_0x027f:
                java.lang.String r9 = "PrintProgress"
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                java.lang.String r4 = "message FINISH : mError => "
                r0.append(r4)
                com.epson.cameracopy.ui.CameraPrintProgress r4 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r4 = r4.mError
                r0.append(r4)
                java.lang.String r4 = " mCanceled =>"
                r0.append(r4)
                com.epson.cameracopy.ui.CameraPrintProgress r4 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r4 = r4.mCanceled
                r0.append(r4)
                java.lang.String r0 = r0.toString()
                epson.print.Util.EPLog.d(r9, r0)
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService
                if (r9 == 0) goto L_0x034d
                java.lang.Object r9 = com.epson.cameracopy.ui.CameraPrintProgress.mLock     // Catch:{ RemoteException -> 0x031f }
                monitor-enter(r9)     // Catch:{ RemoteException -> 0x031f }
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ all -> 0x031c }
                boolean r0 = r0.bSearchingPrinter     // Catch:{ all -> 0x031c }
                if (r0 == 0) goto L_0x02da
                boolean r0 = com.epson.cameracopy.ui.CameraPrintProgress.bRestartactivity     // Catch:{ all -> 0x031c }
                if (r0 != 0) goto L_0x02da
                epson.print.service.IEpsonService r0 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ all -> 0x031c }
                boolean r0 = r0.isSearchingPrinter()     // Catch:{ all -> 0x031c }
                if (r0 == 0) goto L_0x02da
                java.lang.String r0 = "PrintProgress"
                java.lang.String r4 = "message FINISH: mEpsonService.cancelSearchPrinter()"
                epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r4)     // Catch:{ all -> 0x031c }
                epson.print.service.IEpsonService r0 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ all -> 0x031c }
                r0.cancelSearchPrinter()     // Catch:{ all -> 0x031c }
                r0 = 1
                goto L_0x02db
            L_0x02da:
                r0 = 0
            L_0x02db:
                monitor-exit(r9)     // Catch:{ all -> 0x031c }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x031f }
                if (r9 == 0) goto L_0x0301
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x031f }
                boolean r9 = r9.isPrinting()     // Catch:{ RemoteException -> 0x031f }
                if (r9 == 0) goto L_0x0301
                boolean r9 = com.epson.cameracopy.ui.CameraPrintProgress.bRestartactivity     // Catch:{ RemoteException -> 0x031f }
                if (r9 != 0) goto L_0x0301
                java.lang.String r9 = "PrintProgress"
                java.lang.String r0 = "message FINISH: mEpsonService.confirmCancel(true) call"
                epson.print.Util.EPLog.d(r9, r0)     // Catch:{ RemoteException -> 0x031f }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x031f }
                r9.confirmCancel(r2)     // Catch:{ RemoteException -> 0x031f }
                r0 = 1
            L_0x0301:
                if (r0 == 0) goto L_0x0323
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x031f }
                boolean r9 = r9.mWaitEpsonServiceForFinish     // Catch:{ RemoteException -> 0x031f }
                if (r9 == 0) goto L_0x0323
                java.lang.String r9 = "PrintProgress"
                java.lang.String r0 = "on message FINISH: sendEmptyMessageDelayed(FINISH...)"
                epson.print.Util.EPLog.d(r9, r0)     // Catch:{ RemoteException -> 0x031f }
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x031f }
                android.os.Handler r9 = r9.mHandler     // Catch:{ RemoteException -> 0x031f }
                r4 = 500(0x1f4, double:2.47E-321)
                r9.sendEmptyMessageDelayed(r1, r4)     // Catch:{ RemoteException -> 0x031f }
                return r2
            L_0x031c:
                r0 = move-exception
                monitor-exit(r9)     // Catch:{ all -> 0x031c }
                throw r0     // Catch:{ RemoteException -> 0x031f }
            L_0x031f:
                r9 = move-exception
                r9.printStackTrace()
            L_0x0323:
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x0349 }
                if (r9 == 0) goto L_0x034d
                java.lang.String r9 = "PrintProgress"
                java.lang.String r0 = "message FINISH: mEpsonService.unregisterCallback() call"
                epson.print.Util.EPLog.e((java.lang.String) r9, (java.lang.String) r0)     // Catch:{ RemoteException -> 0x0349 }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ RemoteException -> 0x0349 }
                epson.print.service.IEpsonServiceCallback r0 = com.epson.cameracopy.ui.CameraPrintProgress.mCallback     // Catch:{ RemoteException -> 0x0349 }
                r9.unregisterCallback(r0)     // Catch:{ RemoteException -> 0x0349 }
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ RemoteException -> 0x0349 }
                android.content.ServiceConnection r0 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonConnection     // Catch:{ RemoteException -> 0x0349 }
                r9.unbindService(r0)     // Catch:{ RemoteException -> 0x0349 }
                r9 = 0
                epson.print.service.IEpsonService unused = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService = r9     // Catch:{ RemoteException -> 0x0349 }
                goto L_0x034d
            L_0x0349:
                r9 = move-exception
                r9.printStackTrace()
            L_0x034d:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r9 = r9.mCanceled
                if (r9 == 0) goto L_0x0355
                r3 = 0
                goto L_0x035f
            L_0x0355:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r9 = r9.mError
                if (r9 == 0) goto L_0x035f
                r3 = 1000(0x3e8, float:1.401E-42)
            L_0x035f:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.app.Activity r9 = r9.getParent()
                if (r9 != 0) goto L_0x036d
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r9.setResult(r3)
                goto L_0x0376
            L_0x036d:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.app.Activity r9 = r9.getParent()
                r9.setResult(r3)
            L_0x0376:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean unused = r9.bSearching = r7
                java.lang.String r9 = "PrintProgress"
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                java.lang.String r1 = "finish with return code => "
                r0.append(r1)
                r0.append(r3)
                java.lang.String r0 = r0.toString()
                epson.print.Util.EPLog.d(r9, r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.content.Context r9 = r9.context
                java.lang.String r0 = "printer"
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r1 = r1.printerIp
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.disconnect(r9, r0, r1)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r9.sendPrintLog()
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r9.finish()
                goto L_0x0573
            L_0x03ae:
                java.lang.String r9 = "Epson"
                java.lang.String r0 = "NOTIFY ERROR"
                epson.print.Util.EPLog.e((java.lang.String) r9, (java.lang.String) r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean r9 = r9.isDialogOpen
                if (r9 != 0) goto L_0x03d6
                java.lang.String r9 = "Epson"
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                java.lang.String r1 = "Show Error code:"
                r0.append(r1)
                int r1 = com.epson.cameracopy.ui.CameraPrintProgress.curError
                r0.append(r1)
                java.lang.String r0 = r0.toString()
                epson.print.Util.EPLog.e((java.lang.String) r9, (java.lang.String) r0)
                goto L_0x03f3
            L_0x03d6:
                java.lang.String r9 = "Epson"
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                java.lang.String r1 = "Remove and show Error code:"
                r0.append(r1)
                int r1 = com.epson.cameracopy.ui.CameraPrintProgress.curError
                r0.append(r1)
                java.lang.String r0 = r0.toString()
                epson.print.Util.EPLog.e((java.lang.String) r9, (java.lang.String) r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r9.removeDialog(r7)
            L_0x03f3:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean unused = r9.isDialogOpen = r2
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r9.showDialog(r7)
                goto L_0x0573
            L_0x03ff:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                boolean unused = r9.mError = r7
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService
                if (r9 == 0) goto L_0x0426
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ Exception -> 0x0420 }
                boolean unused = r9.bSearching = r7     // Catch:{ Exception -> 0x0420 }
                epson.print.service.IEpsonService r9 = com.epson.cameracopy.ui.CameraPrintProgress.mEpsonService     // Catch:{ Exception -> 0x0420 }
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this     // Catch:{ Exception -> 0x0420 }
                java.util.ArrayList r0 = r0.mImageAndLayoutList     // Catch:{ Exception -> 0x0420 }
                boolean r1 = com.epson.cameracopy.ui.CameraPrintProgress.isBkRetry     // Catch:{ Exception -> 0x0420 }
                r9.printWithImagesAndLayouts(r0, r1)     // Catch:{ Exception -> 0x0420 }
                goto L_0x0573
            L_0x0420:
                r9 = move-exception
                r9.printStackTrace()
                goto L_0x0573
            L_0x0426:
                java.lang.String r9 = "Epson"
                java.lang.String r0 = "Service or resource file not ready, please wait..."
                epson.print.Util.EPLog.i(r9, r0)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.widget.TextView r9 = r9.mPercent
                java.lang.StringBuilder r0 = new java.lang.StringBuilder
                r0.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r1 = r1.percentString
                r0.append(r1)
                java.lang.String r1 = "         0%"
                r0.append(r1)
                java.lang.String r0 = r0.toString()
                r9.setText(r0)
                android.widget.ProgressBar r9 = com.epson.cameracopy.ui.CameraPrintProgress.mProgressPercent
                r9.setProgress(r7)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.os.Handler r9 = r9.mHandler
                r9.sendEmptyMessageDelayed(r4, r5)
                goto L_0x0573
            L_0x0459:
                android.os.Bundle r9 = r9.getData()
                java.lang.String r0 = "PERCENT"
                int r9 = r9.getInt(r0)
                r0 = 100
                if (r9 < r0) goto L_0x0469
                r9 = 100
            L_0x0469:
                if (r9 > 0) goto L_0x0548
                android.widget.ProgressBar r9 = com.epson.cameracopy.ui.CameraPrintProgress.mProgressPercent
                r9.setProgress(r7)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.widget.TextView r9 = r9.mPercent
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r3 = r3.percentString
                r1.append(r3)
                java.lang.String r3 = "         0%"
                r1.append(r3)
                java.lang.String r1 = r1.toString()
                r9.setText(r1)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r9 = r9.sheets
                if (r9 <= r2) goto L_0x04e2
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.widget.TextView r9 = r9.mPage
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r4 = 2131624963(0x7f0e0403, float:1.887712E38)
                java.lang.String r3 = r3.getString(r4)
                r1.append(r3)
                java.lang.String r3 = ": "
                r1.append(r3)
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r3 = r3.curSheet
                r1.append(r3)
                java.lang.String r3 = "/"
                r1.append(r3)
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r3 = r3.sheets
                r1.append(r3)
                java.lang.String r1 = r1.toString()
                r9.setText(r1)
                android.widget.ProgressBar r9 = com.epson.cameracopy.ui.CameraPrintProgress.mProgressPage
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r1 = r1.curSheet
                int r1 = r1 * 100
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r3 = r3.sheets
                int r1 = r1 / r3
                r9.setProgress(r1)
            L_0x04e2:
                int r9 = com.epson.cameracopy.ui.CameraPrintProgress.copies
                if (r9 <= r2) goto L_0x052a
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.widget.TextView r9 = r9.mCopies
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                r4 = 2131624716(0x7f0e030c, float:1.887662E38)
                java.lang.String r3 = r3.getString(r4)
                r1.append(r3)
                java.lang.String r3 = ": "
                r1.append(r3)
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r3 = r3.curCopy
                r1.append(r3)
                java.lang.String r3 = "/"
                r1.append(r3)
                int r3 = com.epson.cameracopy.ui.CameraPrintProgress.copies
                r1.append(r3)
                java.lang.String r1 = r1.toString()
                r9.setText(r1)
                android.widget.ProgressBar r9 = com.epson.cameracopy.ui.CameraPrintProgress.mProgressCopies
                com.epson.cameracopy.ui.CameraPrintProgress r1 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r1 = r1.curCopy
                int r1 = r1 * 100
                int r0 = com.epson.cameracopy.ui.CameraPrintProgress.copies
                int r1 = r1 / r0
                r9.setProgress(r1)
            L_0x052a:
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                com.epson.cameracopy.ui.CameraPrintProgress.access$1208(r9)
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r9 = r9.curSheet
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int r0 = r0.sheets
                if (r9 <= r0) goto L_0x0573
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                int unused = r9.curSheet = r2
                com.epson.cameracopy.ui.CameraPrintProgress r9 = com.epson.cameracopy.ui.CameraPrintProgress.this
                com.epson.cameracopy.ui.CameraPrintProgress.access$1308(r9)
                goto L_0x0573
            L_0x0548:
                android.widget.ProgressBar r0 = com.epson.cameracopy.ui.CameraPrintProgress.mProgressPercent
                r0.setProgress(r9)
                com.epson.cameracopy.ui.CameraPrintProgress r0 = com.epson.cameracopy.ui.CameraPrintProgress.this
                android.widget.TextView r0 = r0.mPercent
                java.lang.StringBuilder r1 = new java.lang.StringBuilder
                r1.<init>()
                com.epson.cameracopy.ui.CameraPrintProgress r3 = com.epson.cameracopy.ui.CameraPrintProgress.this
                java.lang.String r3 = r3.percentString
                r1.append(r3)
                java.lang.String r3 = "         "
                r1.append(r3)
                r1.append(r9)
                java.lang.String r9 = "%"
                r1.append(r9)
                java.lang.String r9 = r1.toString()
                r0.setText(r9)
            L_0x0573:
                return r2
            */
            throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.ui.CameraPrintProgress.C08464.handleMessage(android.os.Message):boolean");
        }
    });
    private ArrayList<ImageAndLayout> mImageAndLayoutList;
    TextView mPage;
    TextView mPercent;
    private volatile boolean mWaitEpsonServiceForFinish = false;
    private String percentString = "";
    private String printerIp;
    private int sheets;

    public static boolean isPrintSuccess(int i) {
        return i == 4;
    }

    static /* synthetic */ int access$1208(CameraPrintProgress cameraPrintProgress) {
        int i = cameraPrintProgress.curSheet;
        cameraPrintProgress.curSheet = i + 1;
        return i;
    }

    static /* synthetic */ int access$1308(CameraPrintProgress cameraPrintProgress) {
        int i = cameraPrintProgress.curCopy;
        cameraPrintProgress.curCopy = i + 1;
        return i;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x000e, code lost:
        epson.print.Util.EPLog.e("Epson", "mEpsonService = null");
        mCallback = new com.epson.cameracopy.ui.CameraPrintProgress.C08391(r3);
        mEpsonConnection = new com.epson.cameracopy.ui.CameraPrintProgress.C08442(r3);
        epson.print.Util.EPLog.e("Epson", "bindService() call");
        bindService(new android.content.Intent(r3, epson.print.service.EpsonService.class), mEpsonConnection, 1);
        epson.print.Util.EPLog.e("Epson", "bindService() finish");
     */
    /* JADX WARNING: Code restructure failed: missing block: B:18:?, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:?, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x000c, code lost:
        if (mEpsonService != null) goto L_?;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void init() {
        /*
            r3 = this;
            java.lang.Object r0 = mLockInit
            monitor-enter(r0)
            epson.print.service.IEpsonService r1 = mEpsonService     // Catch:{ all -> 0x003f }
            if (r1 == 0) goto L_0x0009
            monitor-exit(r0)     // Catch:{ all -> 0x003f }
            return
        L_0x0009:
            monitor-exit(r0)     // Catch:{ all -> 0x003f }
            epson.print.service.IEpsonService r0 = mEpsonService
            if (r0 != 0) goto L_0x003e
            java.lang.String r0 = "Epson"
            java.lang.String r1 = "mEpsonService = null"
            epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1)
            com.epson.cameracopy.ui.CameraPrintProgress$1 r0 = new com.epson.cameracopy.ui.CameraPrintProgress$1
            r0.<init>()
            mCallback = r0
            com.epson.cameracopy.ui.CameraPrintProgress$2 r0 = new com.epson.cameracopy.ui.CameraPrintProgress$2
            r0.<init>()
            mEpsonConnection = r0
            java.lang.String r0 = "Epson"
            java.lang.String r1 = "bindService() call"
            epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1)
            android.content.Intent r0 = new android.content.Intent
            java.lang.Class<epson.print.service.EpsonService> r1 = epson.print.service.EpsonService.class
            r0.<init>(r3, r1)
            android.content.ServiceConnection r1 = mEpsonConnection
            r2 = 1
            r3.bindService(r0, r1, r2)
            java.lang.String r0 = "Epson"
            java.lang.String r1 = "bindService() finish"
            epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1)
        L_0x003e:
            return
        L_0x003f:
            r1 = move-exception
            monitor-exit(r0)     // Catch:{ all -> 0x003f }
            throw r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.ui.CameraPrintProgress.init():void");
    }

    protected void onCreate(Bundle bundle) {
        EPLog.e("Epson", "PrintProgress.java: onCreate() call");
        EPLog.e("Epson", "addFlags : FLAG_KEEP_SCREEN_ON ");
        getWindow().addFlags(128);
        super.onCreate(bundle);
        Utils.setFInishOnTOuchOutside(this, false);
        mError = false;
        curError = 0;
        mWaitEpsonServiceForFinish = false;
        synchronized (mLockInit) {
            EPLog.e("Epson", "PrintProgress.java: onCreate() call init() funciton");
            init();
        }
        isDocument = getIntent().getExtras().getBoolean(PrintProgress.PARAM_DOCUMENT_MODE, false);
        isDocument = true;
        PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.cameracopy);
        printSetting.loadSettings();
        copies = printSetting.copiesValue;
        mImageAndLayoutList = getIntent().getExtras().getParcelableArrayList(KEY_IMAGE_AND_LAYOUT);
        ArrayList<ImageAndLayout> arrayList = mImageAndLayoutList;
        if (arrayList == null) {
            finish();
            return;
        }
        sheets = arrayList.size();
        isRemotePrinter = MyPrinter.isRemotePrinter(this);
        setContentView(R.layout.progress_layout);
        context = this;
        mProgressPercent = (ProgressBar) findViewById(R.id.progress_percent);
        mPercent = (TextView) findViewById(R.id.percent);
        mProgressCopies = (ProgressBar) findViewById(R.id.progress_copies);
        mCopies = (TextView) findViewById(R.id.copies);
        mPage = (TextView) findViewById(R.id.page);
        mProgressPage = (ProgressBar) findViewById(R.id.progress_page);
        if (this.sheets > 1) {
            TextView textView = mPage;
            textView.setText(getString(R.string.page) + ": " + curSheet + CommonDefine.SLASH + sheets);
            mProgressPage.setProgress((this.curSheet * 100) / sheets);
        } else {
            mProgressPage.setVisibility(4);
            mPage.setVisibility(4);
        }
        if (copies <= 1 || isRemotePrinter) {
            mProgressCopies.setVisibility(4);
            mCopies.setVisibility(4);
            copies = 1;
        } else {
            TextView textView2 = mCopies;
            textView2.setText(getString(R.string.copies) + ": " + curCopy + CommonDefine.SLASH + copies);
            mProgressCopies.setProgress((this.curCopy * 100) / copies);
        }
        mCancelButton = (Button) findViewById(R.id.cancel_button);
        mCancelButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                CameraPrintProgress.this.CancelPrint();
            }
        });
        bSearching = false;
        if (this.isRemotePrinter) {
            percentString = getString(R.string.epsonconnect_str_remote_print_file_uploading);
        } else {
            percentString = getString(R.string.printing);
        }
        TextView textView3 = mPercent;
        textView3.setText(this.percentString + "         0%");
        mProgressPercent.setProgress(0);
        findViewById(R.id.epsonColorImageView).setVisibility(View.GONE);
        if (this.isRemotePrinter) {
            mHandler.sendEmptyMessage(2);
        } else {
            mHandler.sendEmptyMessage(6);
        }
        EPLog.i("Epson", "printProgress.java: onCreate() finish");
    }

    private void triggerPrint() {
        mHandler.sendEmptyMessage(2);
    }

    protected void onDestroy() {
        super.onDestroy();
        EPLog.e("Epson", "PrintProgress.java: onDestroy()call");
        EPLog.e("Epson", "clearFlags : FLAG_KEEP_SCREEN_ON ");
        getWindow().clearFlags(128);
        mHandler.removeMessages(1);
        mHandler.removeMessages(3);
        mHandler.removeMessages(2);
        mHandler.removeMessages(4);
        EPLog.e("Epson", "PrintProgress.java: onDestroy() finish");
    }

    protected void onStop() {
        super.onStop();
        if (mEpsonService == null) {
            EPLog.e("Epson", "set bRestartactivity = true (2)");
        }
    }

    protected void onResume() {
        super.onResume();
        EPLog.e("Epson", "PrintProgress.java call onResume()");
        NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
    }

    protected void onPause() {
        super.onPause();
        NfcTagUtils.disableForegroundDispatch(this);
    }

    protected Dialog onCreateDialog(int i) {
        switch (i) {
            case 0:
                EPLog.e("Epson", "show dialog: " + curError + " cancontinue: " + isContinue);
                removeDialog(1);
                Integer[] stringId = MediaInfo.ErrorTable.getStringId(curError);
                if (stringId == null) {
                    stringId = new Integer[]{Integer.valueOf(R.string.NOT_IMPLEMENT), Integer.valueOf(R.string.NOT_IMPLEMENT_TITLE), 1};
                }
                String[] replaceMessage = Utils.replaceMessage(stringId, curError, getApplicationContext());
                if (!isContinue) {
                    EPLog.e("Epson", "show str_cancel button");
                    AlertDialog.Builder negativeButton = new CustomTitleAlertDialogBuilder(this).setCancelable(false).setTitle(replaceMessage[1]).setMessage(replaceMessage[0]).setNegativeButton(getString(R.string.str_cancel), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialogInterface, int i) {
                            try {
                                CameraPrintProgress.mEpsonService.confirmContinueable(false);
                            } catch (RemoteException e) {
                                e.printStackTrace();
                            }
                            EPLog.e("Epson", "user click str_cancel button");
                            CameraPrintProgress.curError = 0;
                            boolean unused = CameraPrintProgress.this.isDialogOpen = false;
                            CameraPrintProgress.this.removeDialog(0);
                            CameraPrintProgress.mHandler.sendEmptyMessage(5);
                        }
                    });
                    negativeButton.setOnKeyListener(new DialogInterface.OnKeyListener() {
                        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                            return keyEvent.getKeyCode() == 84;
                        }
                    });
                    return negativeButton.create();
                }
                AlertDialog.Builder negativeButton2 = new CustomTitleAlertDialogBuilder(this).setTitle((CharSequence) replaceMessage[1]).setMessage(replaceMessage[0]).setCancelable(false).setPositiveButton(getString(R.string.str_continue), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        try {
                            if (CameraPrintProgress.curError == 109) {
                                CameraPrintProgress.isBkRetry = true;
                                CameraPrintProgress.this.triggerPrint();
                            }
                            CameraPrintProgress.mEpsonService.confirmContinueable(true);
                            CameraPrintProgress.curError = 0;
                            boolean unused = CameraPrintProgress.mError = false;
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                        boolean unused2 = CameraPrintProgress.this.isDialogOpen = false;
                        CameraPrintProgress.this.removeDialog(0);
                    }
                }).setNegativeButton(getString(R.string.str_cancel), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        boolean unused = CameraPrintProgress.this.isDialogOpen = false;
                        CameraPrintProgress.this.removeDialog(0);
                        try {
                            CameraPrintProgress.mEpsonService.confirmContinueable(false);
                            CameraPrintProgress.curError = 0;
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                        boolean unused2 = CameraPrintProgress.mWaitEpsonServiceForFinish = true;
                        boolean unused3 = CameraPrintProgress.mError = true;
                        EPLog.d("PrintProgress", "cont/cancel dialog. cancel clicked");
                        CameraPrintProgress.mHandler.sendEmptyMessage(5);
                    }
                });
                negativeButton2.setOnKeyListener(new DialogInterface.OnKeyListener() {
                    public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                        return keyEvent.getKeyCode() == 84;
                    }
                });
                return negativeButton2.create();
            case 1:
                if (this.isDialogOpen) {
                    return null;
                }
                AlertDialog.Builder negativeButton3 = new AlertDialog.Builder(this).setTitle((CharSequence) null).setCancelable(false).setMessage(getString(R.string.str_msg_scan_cancel)).setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        CameraPrintProgress.mHandler.removeMessages(1);
                        try {
                            EPLog.e("Epson", "user choice cancel print from GUI");
                            if ((CameraPrintProgress.mEpsonService != null ? CameraPrintProgress.mEpsonService.confirmCancel(true) : 0) == 0) {
                                synchronized (CameraPrintProgress.lockBCancel) {
                                    EPLog.e("Epson", "===> set bCancel = true");
                                }
                            }
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                        CameraPrintProgress.this.removeDialog(1);
                        CameraPrintProgress cameraPrintProgress = CameraPrintProgress.this;
                        cameraPrintProgress.mCanceled = true;
                        cameraPrintProgress.mCancelButton.setVisibility(4);
                        CameraPrintProgress.mCancelButton.setEnabled(false);
                        if (CameraPrintProgress.this.bSearching) {
                            CameraPrintProgress.mHandler.sendEmptyMessage(5);
                            boolean unused = CameraPrintProgress.this.bSearching = false;
                        }
                    }
                }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        CameraPrintProgress.this.removeDialog(1);
                    }
                });
                negativeButton3.setOnKeyListener(new DialogInterface.OnKeyListener() {
                    public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                        return keyEvent.getKeyCode() == 84;
                    }
                });
                return negativeButton3.create();
            default:
                return null;
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 1) {
            switch (i2) {
                case -1:
                    mHandler.sendEmptyMessage(10);
                    return;
                case 0:
                    mHandler.sendEmptyMessage(5);
                    return;
                default:
                    return;
            }
        }
    }

    private void CancelPrint() {
        try {
            if (mEpsonService != null) {
                mEpsonService.cancelPrint();
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        showDialog(1);
    }

    public void onBackPressed() {
        EPLog.e("Epson", "onBackPressed()call");
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        EPLog.e("Epson", "onKeyDown() call");
        if (keyEvent.getAction() != 0 || i != 84) {
            return false;
        }
        EPLog.e("Epson", "onKeyDown() KEYCODE_SEARCH key press");
        return true;
    }

    public void showErrorDialog(String str, String str2) {
        new CustomTitleAlertDialogBuilder(this).setCancelable(false).setTitle(str).setMessage(str2).setNegativeButton(getString(R.string.ok_button), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
                CameraPrintProgress.mHandler.sendEmptyMessage(5);
            }
        }).create().show();
    }

    private void sendPrintLog() {
        Analytics.sendPrintLog(this, new CameraCopyProgressParams());
    }
}
