package epson.print;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;

import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;

import epson.print.Util.EPLog;
import epson.print.screen.WorkingDialog;
import epson.scan.lib.escanLib;

public class ActivityNfcPrinter extends Activity {
    public static final String CHANGEMODE = "changeMode";
    public static final int CHANGE_HOME = 0;
    public static final int CHANGE_PRINTER_ONLY = 1;
    public static final int CHANGE_SCANNER_ONLY = 2;
    private static final int CHECK_WIFIACCESSS = 8;
    private static final int CONNECTED_SIMPLEAP = 2;
    public static final String CONNECTINFO = "connectInfo";
    private static final int CONNECT_PRINTER_VIA_INFRA = 9;
    private static final int CONNECT_SIMPLEAP = 10;
    private static final int CONNECT_SIMPLEAP_PRINTER = 11;
    private static final int ENABLED_WIFI = 1;
    private static final int EPS_COMM_BID = 2;
    private static final int FINISH = 20;
    private static final int FOUND_PRINTER = 0;
    private static final String IS_NEW_SAVE = "IS_NEW_SAVE";
    private static final String NO_CLEAR_RESULT = "NO_CLEAR_RESULT";
    private static final String PRINTER_ID = "id";
    private static final String PRINTER_IP = "ip";
    private static final String PRINTER_NAME = "name";
    private static final String PRINTER_SERIAL_NO = "serial_no";
    private static final int PROBE_PRINTER = 12;
    private static final int PROBE_SCANNER = 13;
    private static final int REQUEST_LOCATION_PERMISSION = 3;
    public static final int SEARCH_TIME_INFRA = 5;
    private static final String TAG = "ActivityChangeWifiPrinter";
    private static MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
    private static escanLib mScanner = new escanLib();
    private NfcTagUtils.EpsonNfcConnectInfo connectInfo;
    private MyPrinter foundPrinter = null;
    final Handler mHandler = new Handler(new Handler.Callback() {
        /* JADX WARNING: Code restructure failed: missing block: B:12:0x0040, code lost:
            r0 = new epson.print.EPPrinterManager(r6.this$0);
         */
        /* JADX WARNING: Code restructure failed: missing block: B:23:0x00b1, code lost:
            r0 = new epson.print.EPPrinterManager(r6.this$0);
         */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public boolean handleMessage(android.os.Message r7) {
            /*
                r6 = this;
                int r0 = r7.what
                r1 = 0
                if (r0 == 0) goto L_0x0304
                r2 = 1
                r3 = 20
                if (r0 == r3) goto L_0x02af
                r4 = 2
                r5 = 3
                switch(r0) {
                    case 8: goto L_0x0272;
                    case 9: goto L_0x0217;
                    case 10: goto L_0x0135;
                    case 11: goto L_0x0112;
                    case 12: goto L_0x0082;
                    case 13: goto L_0x0011;
                    default: goto L_0x000f;
                }
            L_0x000f:
                goto L_0x0331
            L_0x0011:
                java.lang.Object r7 = r7.obj
                epson.print.MyPrinter r7 = (epson.print.MyPrinter) r7
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                java.lang.String r2 = "epson.scanner.SelectedScanner"
                java.lang.String r4 = "SCAN_REFS_SCANNER_ID"
                java.lang.String r0 = epson.common.Utils.getPrefString(r0, r2, r4)
                java.lang.String r0 = com.epson.mobilephone.common.wifidirect.NfcMacAddrUtils.getMacAddressFromScannerId(r0)
                if (r0 == 0) goto L_0x0076
                java.lang.String r2 = r7.getPrinterId()
                java.lang.String r2 = com.epson.mobilephone.common.wifidirect.NfcMacAddrUtils.getMacAddressFromPrinterId(r2)
                boolean r0 = r0.equals(r2)
                if (r0 == 0) goto L_0x0076
                java.lang.String r0 = "ActivityChangeWifiPrinter"
                java.lang.String r2 = "Needless changing Scanner Info"
                epson.print.Util.EPLog.m318w((java.lang.String) r0, (java.lang.String) r2)
                int r0 = r7.getLocation()
                if (r0 != r5) goto L_0x0061
                epson.print.EPPrinterManager r0 = new epson.print.EPPrinterManager
                epson.print.ActivityNfcPrinter r2 = epson.print.ActivityNfcPrinter.this
                r0.<init>(r2)
                java.lang.String r2 = r7.getPrinterId()
                epson.print.EPPrinterInfo r2 = r0.loadIpPrinterInfo(r2)
                if (r2 == 0) goto L_0x0061
                java.lang.String r4 = r7.getIp()
                r2.printerIP = r4
                java.lang.String r4 = r7.getPrinterId()
                r0.saveIPPrinterInfo(r4, r2)
                r0.commitIPPrinterInfo()
            L_0x0061:
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r0 = r0.mHandler
                android.os.Message r0 = r0.obtainMessage()
                r0.what = r3
                r0.obj = r7
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r7.sendMessage(r0)
                goto L_0x0331
            L_0x0076:
                epson.print.ActivityNfcPrinter$1$4 r0 = new epson.print.ActivityNfcPrinter$1$4
                r0.<init>(r7)
                java.lang.Void[] r7 = new java.lang.Void[r1]
                r0.execute(r7)
                goto L_0x0331
            L_0x0082:
                java.lang.Object r7 = r7.obj
                epson.print.MyPrinter r7 = (epson.print.MyPrinter) r7
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                epson.print.MyPrinter r0 = epson.print.MyPrinter.getCurPrinter(r0)
                java.lang.String r0 = r0.getPrinterId()
                java.lang.String r0 = com.epson.mobilephone.common.wifidirect.NfcMacAddrUtils.getMacAddressFromPrinterId(r0)
                if (r0 == 0) goto L_0x0106
                java.lang.String r4 = r7.getPrinterId()
                java.lang.String r4 = com.epson.mobilephone.common.wifidirect.NfcMacAddrUtils.getMacAddressFromPrinterId(r4)
                boolean r0 = r0.equals(r4)
                if (r0 == 0) goto L_0x0106
                java.lang.String r0 = "ActivityChangeWifiPrinter"
                java.lang.String r4 = "Needless changing Printer Info"
                epson.print.Util.EPLog.m318w((java.lang.String) r0, (java.lang.String) r4)
                int r0 = r7.getLocation()
                if (r0 != r5) goto L_0x00d2
                epson.print.EPPrinterManager r0 = new epson.print.EPPrinterManager
                epson.print.ActivityNfcPrinter r4 = epson.print.ActivityNfcPrinter.this
                r0.<init>(r4)
                java.lang.String r4 = r7.getPrinterId()
                epson.print.EPPrinterInfo r4 = r0.loadIpPrinterInfo(r4)
                if (r4 == 0) goto L_0x00d2
                java.lang.String r5 = r7.getIp()
                r4.printerIP = r5
                java.lang.String r5 = r7.getPrinterId()
                r0.saveIPPrinterInfo(r5, r4)
                r0.commitIPPrinterInfo()
            L_0x00d2:
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                int r0 = r0.nChangeMode
                if (r0 == r2) goto L_0x00f1
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r0 = r0.mHandler
                android.os.Message r0 = r0.obtainMessage()
                r2 = 13
                r0.what = r2
                r0.obj = r7
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r7.sendMessage(r0)
                goto L_0x0331
            L_0x00f1:
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r0 = r0.mHandler
                android.os.Message r0 = r0.obtainMessage()
                r0.what = r3
                r0.obj = r7
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r7.sendMessage(r0)
                goto L_0x0331
            L_0x0106:
                epson.print.ActivityNfcPrinter$1$3 r0 = new epson.print.ActivityNfcPrinter$1$3
                r0.<init>(r7)
                java.lang.Void[] r7 = new java.lang.Void[r1]
                r0.execute(r7)
                goto L_0x0331
            L_0x0112:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.ActivityNfcPrinter$NfcStatus r0 = epson.print.ActivityNfcPrinter.NfcStatus.CONNECTING_PRINTER_VIA_SIMPLEAP
                r7.status = r0
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.screen.WorkingDialog r7 = r7.progress
                boolean r7 = r7.isShowing()
                if (r7 != 0) goto L_0x0129
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.screen.WorkingDialog r7 = r7.progress
                r7.show()
            L_0x0129:
                epson.print.ActivityNfcPrinter$1$2 r7 = new epson.print.ActivityNfcPrinter$1$2
                r7.<init>()
                java.lang.Void[] r0 = new java.lang.Void[r1]
                r7.execute(r0)
                goto L_0x0331
            L_0x0135:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.ActivityNfcPrinter$NfcStatus r0 = epson.print.ActivityNfcPrinter.NfcStatus.CONNECTING_SIMPLEAP
                r7.status = r0
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                com.epson.mobilephone.common.wifidirect.NfcTagUtils$EpsonNfcConnectInfo r7 = r7.connectInfo
                boolean r7 = r7.isTagWithInterface()
                if (r7 == 0) goto L_0x01e4
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r7 = r7 & r3
                r0 = 65536(0x10000, float:9.18355E-41)
                if (r7 == 0) goto L_0x01af
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r7 = r7 & 4
                if (r7 != 0) goto L_0x0199
                int r7 = android.os.Build.VERSION.SDK_INT
                r2 = 21
                if (r7 < r2) goto L_0x0199
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.content.Context r7 = r7.getApplicationContext()
                java.lang.String r2 = "wifi"
                java.lang.Object r7 = r7.getSystemService(r2)
                android.net.wifi.WifiManager r7 = (android.net.wifi.WifiManager) r7
                if (r7 == 0) goto L_0x0199
                boolean r7 = r7.is5GHzBandSupported()
                if (r7 == 0) goto L_0x0179
                goto L_0x0199
            L_0x0179:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r7 = r7 & r0
                r0 = 2131624933(0x7f0e03e5, float:1.887706E38)
                if (r7 == 0) goto L_0x018f
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r2 = 2131624937(0x7f0e03e9, float:1.8877068E38)
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x018f:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r2 = 2131624936(0x7f0e03e8, float:1.8877066E38)
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x0199:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r7 = r7.strIpAddressV4SimpleAP
                if (r7 == 0) goto L_0x01a2
                goto L_0x01e4
            L_0x01a2:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r0 = 2131624930(0x7f0e03e2, float:1.8877054E38)
                r2 = 2131624929(0x7f0e03e1, float:1.8877052E38)
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x01af:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r2 = 16777216(0x1000000, float:2.3509887E-38)
                r7 = r7 & r2
                r2 = 2131624932(0x7f0e03e4, float:1.8877058E38)
                if (r7 == 0) goto L_0x01c7
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r0 = 2131624941(0x7f0e03ed, float:1.8877076E38)
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x01c7:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r7 = r7 & r0
                r0 = 2131624940(0x7f0e03ec, float:1.8877074E38)
                if (r7 == 0) goto L_0x01da
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x01da:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r2 = 2131624942(0x7f0e03ee, float:1.8877078E38)
                r7.showErrorMessage(r0, r2)
                goto L_0x0331
            L_0x01e4:
                int[] r7 = epson.print.ActivityNfcPrinter.C20953.$SwitchMap$epson$print$ActivityNfcPrinter$NfcSimpleApRetryStatus
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                epson.print.ActivityNfcPrinter$NfcSimpleApRetryStatus r0 = r0.retrystatus
                int r0 = r0.ordinal()
                r7 = r7[r0]
                switch(r7) {
                    case 1: goto L_0x0206;
                    case 2: goto L_0x01f5;
                    default: goto L_0x01f3;
                }
            L_0x01f3:
                goto L_0x0331
            L_0x01f5:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r0 = r7.strSSID
                epson.print.ActivityNfcPrinter r2 = epson.print.ActivityNfcPrinter.this
                java.lang.String r2 = r2.strInitPass
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.connectSimpleAP(r7, r0, r2, r4)
                goto L_0x0331
            L_0x0206:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r0 = r7.strSSID
                epson.print.ActivityNfcPrinter r2 = epson.print.ActivityNfcPrinter.this
                java.lang.String r2 = r2.strPass
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.connectSimpleAP(r7, r0, r2, r4)
                goto L_0x0331
            L_0x0217:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.ActivityNfcPrinter$NfcStatus r0 = epson.print.ActivityNfcPrinter.NfcStatus.CONNECTING_PRINTER_VIA_INFRA
                r7.status = r0
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                com.epson.mobilephone.common.wifidirect.NfcTagUtils$EpsonNfcConnectInfo r7 = r7.connectInfo
                boolean r7 = r7.isTagWithInterface()
                if (r7 == 0) goto L_0x0267
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r7 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurSSID(r7)
                if (r7 == 0) goto L_0x0267
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                boolean r7 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.isSimpleAP(r7)
                if (r7 != 0) goto L_0x0267
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                int r7 = r7.printerStatus
                r7 = r7 & r4
                if (r7 == 0) goto L_0x0267
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r7 = r7.strIpAddressV4
                if (r7 == 0) goto L_0x0267
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.screen.WorkingDialog r7 = r7.progress
                boolean r7 = r7.isShowing()
                if (r7 != 0) goto L_0x025b
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.screen.WorkingDialog r7 = r7.progress
                r7.show()
            L_0x025b:
                epson.print.ActivityNfcPrinter$1$1 r7 = new epson.print.ActivityNfcPrinter$1$1
                r7.<init>()
                java.lang.Void[] r0 = new java.lang.Void[r1]
                r7.execute(r0)
                goto L_0x0331
            L_0x0267:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r0 = 10
                r7.sendEmptyMessage(r0)
                goto L_0x0331
            L_0x0272:
                int r7 = android.os.Build.VERSION.SDK_INT
                r0 = 28
                if (r7 <= r0) goto L_0x0287
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                boolean r7 = com.epson.mobilephone.common.wifidirect.ActivityRequestLocationPermission.canAccessWiFiInfo(r7, r2)
                if (r7 != 0) goto L_0x0287
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                com.epson.mobilephone.common.wifidirect.ActivityRequestLocationPermission.requestLocationPermissionForce(r7, r5)
                goto L_0x0331
            L_0x0287:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                java.lang.String r7 = r7.strSSID
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                java.lang.String r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getCurSSID(r0)
                boolean r7 = r7.equals(r0)
                if (r7 == 0) goto L_0x02a4
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r0 = 11
                r7.sendEmptyMessage(r0)
                goto L_0x0331
            L_0x02a4:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.os.Handler r7 = r7.mHandler
                r0 = 9
                r7.sendEmptyMessage(r0)
                goto L_0x0331
            L_0x02af:
                java.lang.Object r7 = r7.obj
                epson.print.MyPrinter r7 = (epson.print.MyPrinter) r7
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                int r0 = r0.nChangeMode
                r3 = -1
                switch(r0) {
                    case 0: goto L_0x02e7;
                    case 1: goto L_0x02db;
                    case 2: goto L_0x02be;
                    default: goto L_0x02bd;
                }
            L_0x02bd:
                goto L_0x02fe
            L_0x02be:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.content.Intent r7 = r7.getIntent()
                java.lang.String r0 = "ACT_RESULT"
                java.lang.String r4 = "ACT_RESULT_SAVE"
                r7.putExtra(r0, r4)
                java.lang.String r0 = "IS_NEW_SAVE"
                r7.putExtra(r0, r2)
                java.lang.String r0 = "NO_CLEAR_RESULT"
                r7.putExtra(r0, r1)
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                r0.setResult(r3, r7)
                goto L_0x02fe
            L_0x02db:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                android.content.Intent r7 = r7.getIntent()
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                r0.setResult(r3, r7)
                goto L_0x02fe
            L_0x02e7:
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                r3 = 2131624943(0x7f0e03ef, float:1.887708E38)
                android.widget.Toast r0 = android.widget.Toast.makeText(r0, r3, r2)
                r0.show()
                epson.print.ActivityNfcPrinter r0 = epson.print.ActivityNfcPrinter.this
                java.lang.String r2 = "printer"
                java.lang.String r7 = r7.getIp()
                com.epson.mobilephone.common.wifidirect.WiFiDirectManager.disconnect(r0, r2, r7)
            L_0x02fe:
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                r7.finish()
                goto L_0x0331
            L_0x0304:
                android.os.Bundle r7 = r7.getData()
                epson.print.MyPrinter r0 = new epson.print.MyPrinter
                java.lang.String r2 = "name"
                java.lang.String r2 = r7.getString(r2)
                java.lang.String r3 = "ip"
                java.lang.String r3 = r7.getString(r3)
                java.lang.String r4 = "id"
                java.lang.String r4 = r7.getString(r4)
                java.lang.String r5 = "serial_no"
                java.lang.String r7 = r7.getString(r5)
                r0.<init>(r2, r3, r4, r7)
                com.epson.mobilephone.common.maintain2.MaintainPrinter2 r7 = epson.print.ActivityNfcPrinter.mPrinter
                r7.doCancelFindPrinter()
                epson.print.ActivityNfcPrinter r7 = epson.print.ActivityNfcPrinter.this
                epson.print.MyPrinter unused = r7.foundPrinter = r0
            L_0x0331:
                return r1
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityNfcPrinter.C20891.handleMessage(android.os.Message):boolean");
        }
    });
    private int nChangeMode = 0;
    private int printerStatus;
    WorkingDialog progress;
    NfcSimpleApRetryStatus retrystatus = NfcSimpleApRetryStatus.FIRST_CONNECTION;
    NfcStatus status = NfcStatus.INIT;
    private String strInitPass;
    private String strIpAddressV4;
    private String strIpAddressV4SimpleAP;
    private String strMacAdress;
    private String strPass;
    private String strSSID;

    enum NfcSimpleApRetryStatus {
        FIRST_CONNECTION,
        RETRY_CONNECTION
    }

    enum NfcStatus {
        INIT,
        ENABLING_WIFI,
        CONNECTING_PRINTER_VIA_INFRA,
        CONNECTING_SIMPLEAP,
        CONNECTING_PRINTER_VIA_SIMPLEAP
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        mPrinter.doInitDriver(this, 2);
        progress = new WorkingDialog(this);
        connectInfo = (NfcTagUtils.EpsonNfcConnectInfo) getIntent().getParcelableExtra(CONNECTINFO);
        strMacAdress = connectInfo.macAdress;
        strSSID = connectInfo.ssid;
        strPass = connectInfo.password;
        strInitPass = connectInfo.initialpassword;
        strIpAddressV4 = connectInfo.ipAddressV4;
        strIpAddressV4SimpleAP = connectInfo.ipAddressV4SimpleAP;
        printerStatus = connectInfo.printerStatus;
        if (!this.connectInfo.hasOwnAAR(this)) {
            showErrorMessage(R.string.nfc_connect_error_aar_title, R.string.nfc_connect_error_aar);
        } else if (!this.connectInfo.isTagWithInterface() || (this.printerStatus & 1) != 0) {
            nChangeMode = getIntent().getIntExtra(CHANGEMODE, 0);
            if (!WiFiDirectManager.isWifiEnabled(this)) {
                status = NfcStatus.ENABLING_WIFI;
                WiFiDirectManager.enableWiFi(this, 1);
                return;
            }
            mHandler.sendEmptyMessage(8);
        } else {
            showErrorMessage(R.string.nfc_connect_error_power_off_title, R.string.nfc_connect_error_power_off);
        }
    }

    protected void onDestroy() {
        super.onDestroy();
        if (this.progress.isShowing()) {
            progress.dismiss();
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        switch (i) {
            case 1:
                switch (i2) {
                    case -1:
                        mHandler.sendEmptyMessage(8);
                        return;
                    case 0:
                        setResult(0);
                        finish();
                        return;
                    default:
                        return;
                }
            case 2:
                switch (i2) {
                    case -1:
                        WiFiDirectManager.setFlagSimpleAPCreated();
                        mHandler.sendEmptyMessage(11);
                        return;
                    case 0:
                        if (WiFiDirectManager.getLastDetailError() == 1) {
                            setResult(0);
                            finish();
                            return;
                        } else if (this.retrystatus == NfcSimpleApRetryStatus.FIRST_CONNECTION && strInitPass != null) {
                            retrystatus = NfcSimpleApRetryStatus.RETRY_CONNECTION;
                            mHandler.sendEmptyMessage(10);
                            return;
                        } else if (!this.connectInfo.isTagWithInterface() || (this.printerStatus & 256) == 0) {
                            showErrorMessage(R.string.nfc_connect_error_title, R.string.nfc_connect_erorr_wifi);
                            return;
                        } else {
                            showErrorMessage(R.string.nfc_connect_error_max_connected_title, R.string.nfc_connect_error_max_connected);
                            return;
                        }
                    default:
                        return;
                }
            case 3:
                switch (i2) {
                    case -1:
                        mHandler.sendEmptyMessage(8);
                        return;
                    case 0:
                        setResult(0);
                        finish();
                        return;
                    default:
                        return;
                }
            default:
                return;
        }
    }

    protected void onResume() {
        EPLog.m316v(TAG, "onResume status=" + status.toString());
        super.onResume();
        NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
    }

    protected void onPause() {
        EPLog.m316v(TAG, "onPause");
        super.onPause();
        NfcTagUtils.disableForegroundDispatch(this);
    }

    /* renamed from: epson.print.ActivityNfcPrinter$3 */
    static /* synthetic */ class C20953 {
        static final /* synthetic */ int[] $SwitchMap$epson$print$ActivityNfcPrinter$NfcSimpleApRetryStatus = new int[NfcSimpleApRetryStatus.values().length];

        /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|6) */
        /* JADX WARNING: Code restructure failed: missing block: B:7:?, code lost:
            return;
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
        static {
            /*
                epson.print.ActivityNfcPrinter$NfcSimpleApRetryStatus[] r0 = epson.print.ActivityNfcPrinter.NfcSimpleApRetryStatus.values()
                int r0 = r0.length
                int[] r0 = new int[r0]
                $SwitchMap$epson$print$ActivityNfcPrinter$NfcSimpleApRetryStatus = r0
                int[] r0 = $SwitchMap$epson$print$ActivityNfcPrinter$NfcSimpleApRetryStatus     // Catch:{ NoSuchFieldError -> 0x0014 }
                epson.print.ActivityNfcPrinter$NfcSimpleApRetryStatus r1 = epson.print.ActivityNfcPrinter.NfcSimpleApRetryStatus.FIRST_CONNECTION     // Catch:{ NoSuchFieldError -> 0x0014 }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x0014 }
                r2 = 1
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x0014 }
            L_0x0014:
                int[] r0 = $SwitchMap$epson$print$ActivityNfcPrinter$NfcSimpleApRetryStatus     // Catch:{ NoSuchFieldError -> 0x001f }
                epson.print.ActivityNfcPrinter$NfcSimpleApRetryStatus r1 = epson.print.ActivityNfcPrinter.NfcSimpleApRetryStatus.RETRY_CONNECTION     // Catch:{ NoSuchFieldError -> 0x001f }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x001f }
                r2 = 2
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x001f }
            L_0x001f:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityNfcPrinter.C20953.<clinit>():void");
        }
    }

    private void showErrorMessage(int i, int i2) {
        if (WiFiDirectManager.isSimpleAP(this)) {
            WiFiDirectManager.disconnectSimpleAP(this, WiFiDirectManager.getCurSSID(this), (String) null);
        }
        final AlertDialog create = new AlertDialog.Builder(this).create();
        create.setTitle(getString(i));
        create.setMessage(getString(i2));
        create.setCancelable(false);
        create.setButton(-1, getString(R.string.str_ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                create.dismiss();
                ActivityNfcPrinter.this.setResult(0);
                ActivityNfcPrinter.this.finish();
            }
        });
        create.show();
    }
}
