package com.epson.mobilephone.common.wifidirect;

import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.NetworkInfo;
import android.net.wifi.SupplicantState;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import android.support.p000v4.app.DialogFragment;
import android.support.p000v4.app.FragmentActivity;
import android.widget.Toast;
import com.epson.mobilephone.common.wifidirect.ActivityConnectBase;
import com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect;
import java.util.Deque;

public class ActivityConnectSimpleAP extends ActivityConnectBase implements DialogProgressWiFiDirect.DialogButtonClick {
    private static final int DELAY_CONNECTED_WIFI = 1000;
    private static final String IDD_WIFI_ERROR = "idd_wifi_error";
    private static final String IDD_WIFI_PROFILE_FAILED = "idd_wifi_profile_failed";
    private static final String IDD_WIFI_SIMPLEAP = "idd_wifi_simpleap";
    private static final String IDD_WIFI_WAITING = "idd_wifi_waiting";
    private static final int ID_CHECK_WIIFISTATE = 11;
    private static final int ID_CONNECTED_WIFI = 10;
    private static final int ID_FOUND = 1;
    private static final int ID_NOT_FOUND = 2;
    private static final int ID_RESULT = 0;
    private static final int MAX_RETRY_CONNECTING = 5;
    private static final String TAG = "ActivityConnectSimpleAP";
    private int connectingNetworkId = -1;
    boolean createSimpleAP = false;
    Handler mHandler = new Handler() {
        public void handleMessage(Message message) {
            super.handleMessage(message);
            switch (C10874.f150x55760faf[ActivityConnectSimpleAP.this.status.ordinal()]) {
                case 1:
                    if (message.what == 11) {
                        if (Build.VERSION.SDK_INT > 25 && !ActivityConnectSimpleAP.this.createSimpleAP) {
                            ActivityConnectSimpleAP.mModelDialog.doShow(ActivityConnectSimpleAP.IDD_WIFI_SIMPLEAP);
                            return;
                        } else if (!ActivityConnectSimpleAP.mWifiManager.isWifiEnabled()) {
                            ActivityConnectSimpleAP.this.startActivityForResult(new Intent(ActivityConnectSimpleAP.this, ActivityControlWiFi.class), 1);
                            return;
                        } else {
                            ActivityConnectSimpleAP.this.onEnabledWifi();
                            return;
                        }
                    } else {
                        return;
                    }
                case 2:
                    if (message.what == 0) {
                        Bundle data = message.getData();
                        if (data != null && !data.isEmpty()) {
                            String removeSSIDPrefix = WiFiControl.removeSSIDPrefix(data.getString("ssid"));
                            if (ActivityConnectSimpleAP.this.targetSsid.equals(removeSSIDPrefix)) {
                                if (ActivityConnectSimpleAP.this.searchWiFiDirectPrinter != null) {
                                    ActivityConnectSimpleAP.this.searchWiFiDirectPrinter.interrupt();
                                    ActivityConnectSimpleAP.this.searchWiFiDirectPrinter = null;
                                }
                                int unused = ActivityConnectSimpleAP.this.connectingNetworkId = data.getInt("id");
                                if (WiFiUtils.getInstance(ActivityConnectSimpleAP.this).enableSimpleAP(ActivityConnectSimpleAP.this.connectingNetworkId, removeSSIDPrefix)) {
                                    ActivityConnectSimpleAP.this.status = ActivityConnectBase.Status.WIFI_CONNECTING;
                                    ActivityConnectSimpleAP.this.setupObserver();
                                    break;
                                } else {
                                    ActivityConnectSimpleAP.this.onError();
                                    break;
                                }
                            }
                        } else {
                            EPLog.m87e(ActivityConnectSimpleAP.TAG, "Not Found Network");
                            ActivityConnectSimpleAP.this.status = ActivityConnectBase.Status.IDLE;
                            ActivityConnectSimpleAP.this.onError();
                            break;
                        }
                    }
                    break;
                case 3:
                    break;
                case 4:
                    switch (message.what) {
                        case 1:
                            Bundle data2 = message.getData();
                            if (data2 != null) {
                                String string = data2.getString("name");
                                String string2 = data2.getString(escprLib.PRINTER_IP);
                                String string3 = data2.getString("id");
                                if (string != null && string2 != null && string3 != null) {
                                    EPLog.m88i(ActivityConnectSimpleAP.TAG, "epsWrapperFindPrinter Success");
                                    if (!ActivityConnectSimpleAP.this.expectedPrtMacAddr.equals(MacAddrUtils.getMacAddressFromPrinterId(string3))) {
                                        EPLog.m88i(ActivityConnectSimpleAP.TAG, "This Printer is not expected " + string);
                                        return;
                                    }
                                    ActivityConnectSimpleAP.this.interruptFindingPrinter();
                                    Intent intent = new Intent();
                                    intent.putExtras(data2);
                                    ActivityConnectSimpleAP.this.onConnectedPrinter(intent);
                                    return;
                                }
                                return;
                            }
                            return;
                        case 2:
                            ActivityConnectSimpleAP.this.onError();
                            return;
                        default:
                            return;
                    }
                default:
                    return;
            }
            if (message.what == 10) {
                ActivityConnectSimpleAP.this.status = ActivityConnectBase.Status.WIFI_CONNECTED;
                ActivityConnectSimpleAP.this.onConnectedWiFi();
            }
        }
    };
    private DialogProgressWiFiDirectViewModel mModelDialog;
    NetworkStateChangeReciever networkStateChangeReciever = null;
    private int retryConnecting = 0;
    String targetPass = "";

    public void onCancelDialog(String str) {
    }

    public void onNeutralClick(String str) {
    }

    static /* synthetic */ int access$408(ActivityConnectSimpleAP activityConnectSimpleAP) {
        int i = activityConnectSimpleAP.retryConnecting;
        activityConnectSimpleAP.retryConnecting = i + 1;
        return i;
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        mModelDialog = (DialogProgressWiFiDirectViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressWiFiDirectViewModel.class);
        mModelDialog.getDialogJob().observe(this, new Observer<Deque<String[]>>() {
            public void onChanged(@Nullable Deque<String[]> deque) {
                String[] checkQueue = ActivityConnectSimpleAP.mModelDialog.checkQueue();
                if (checkQueue != null) {
                    String str = checkQueue[0];
                    String str2 = checkQueue[1];
                    if (str2.equals("do_show")) {
                        ActivityConnectSimpleAP.this.showDialog(str);
                    }
                    if (str2.equals("do_dismiss")) {
                        ActivityConnectSimpleAP.this.dismissDialog(str);
                    }
                }
            }
        });
        mModelDialog.doShow(IDD_WIFI_WAITING);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            targetSsid = extras.getString(ActivityConnectBase.APNAME);
            targetPass = extras.getString(ActivityConnectBase.APPASS);
            showErrorDlg = extras.getBoolean(ActivityConnectBase.SHOWERROR, false);
            showConnectedTip = extras.getBoolean(ActivityConnectBase.SHOWTIP, true);
            createSimpleAP = extras.getBoolean(ActivityConnectBase.CREATE, false);
            needInfo = extras.getBoolean(ActivityConnectBase.NEEDINFO, false);
            timeout = extras.getInt(ActivityConnectBase.TIMEOUT, 30);
        }
        EPLog.m88i(TAG, "Starting connect :" + targetSsid + " timeout = " + timeout);
        mHandler.sendEmptyMessage(11);
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 2) {
            switch (i) {
                case 4:
                    if (this.targetSsid.equals(WiFiUtils.getInstance(this).getCurSSID())) {
                        onConnectedWiFi();
                        return;
                    }
                    setResult(0);
                    setLastDetailResult(2);
                    finish();
                    return;
                case 5:
                    onEnabledWifi();
                    return;
                default:
                    return;
            }
        } else if (i2 != -1) {
            closeWaitingDialog();
            setResult(0);
            setLastDetailResult(1);
            finish();
        } else if (!this.searchWiFiDirectPrinter.start(1, mHandler, 0, timeout)) {
            onError();
        } else {
            status = ActivityConnectBase.Status.WIFI_SCANNING;
        }
    }

    protected void onEnabledWifi() {
        if (this.targetSsid.equals(WiFiUtils.getInstance(this).getCurSSID())) {
            EPLog.m86d(TAG, "Already Connected!!");
            status = ActivityConnectBase.Status.WIFI_CONNECTING;
            mHandler.sendEmptyMessage(10);
            return;
        }
        if (WifiP2pUtils.getInstance(this).isConnectedWiFiP2P()) {
            WifiP2pUtils.getInstance(this).disconnect();
        }
        if (this.createSimpleAP) {
            connectingNetworkId = WiFiUtils.getInstance(this).createSimpleAP(this.targetSsid, targetPass);
            if (this.connectingNetworkId == -1) {
                mModelDialog.doShow(IDD_WIFI_PROFILE_FAILED);
                return;
            }
            status = ActivityConnectBase.Status.WIFI_CONNECTING;
            setupObserver();
            return;
        }
        ActivityRequestLocationPermission.requestLocationPermissionForce(this, 2);
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x0046  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0049  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x007f  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x00b5  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x00cc  */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x00d8  */
    /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void showDialog(java.lang.String r11) {
        /*
            r10 = this;
            int r0 = r11.hashCode()
            r1 = -872067019(0xffffffffcc055035, float:-3.4947284E7)
            r2 = 0
            if (r0 == r1) goto L_0x0038
            r1 = -692203673(0xffffffffd6bdcf67, float:-1.04349242E14)
            if (r0 == r1) goto L_0x002e
            r1 = -174410503(0xfffffffff59ab4f9, float:-3.9222865E32)
            if (r0 == r1) goto L_0x0024
            r1 = 765832116(0x2da5abb4, float:1.883458E-11)
            if (r0 == r1) goto L_0x001a
            goto L_0x0042
        L_0x001a:
            java.lang.String r0 = "idd_wifi_error"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0042
            r0 = 1
            goto L_0x0043
        L_0x0024:
            java.lang.String r0 = "idd_wifi_waiting"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0042
            r0 = 0
            goto L_0x0043
        L_0x002e:
            java.lang.String r0 = "idd_wifi_profile_failed"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0042
            r0 = 3
            goto L_0x0043
        L_0x0038:
            java.lang.String r0 = "idd_wifi_simpleap"
            boolean r0 = r11.equals(r0)
            if (r0 == 0) goto L_0x0042
            r0 = 2
            goto L_0x0043
        L_0x0042:
            r0 = -1
        L_0x0043:
            switch(r0) {
                case 0: goto L_0x00cc;
                case 1: goto L_0x00b5;
                case 2: goto L_0x007f;
                case 3: goto L_0x0049;
                default: goto L_0x0046;
            }
        L_0x0046:
            r0 = 0
            goto L_0x00d6
        L_0x0049:
            r4 = 2
            java.lang.StringBuilder r0 = new java.lang.StringBuilder
            r0.<init>()
            int r1 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_notice_duplicated_simpleAP
            java.lang.String r1 = r10.getString(r1)
            r0.append(r1)
            java.lang.String r1 = "\n\nSSID: "
            r0.append(r1)
            java.lang.String r1 = r10.targetSsid
            r0.append(r1)
            java.lang.String r5 = r0.toString()
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_error_wifi_connecting_failed
            java.lang.String r6 = r10.getString(r0)
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_goto_wifi_setting
            java.lang.String r7 = r10.getString(r0)
            r8 = 0
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_cancel
            java.lang.String r9 = r10.getString(r0)
            r3 = r11
            com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect r0 = com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect.newInstance(r3, r4, r5, r6, r7, r8, r9)
            goto L_0x00d6
        L_0x007f:
            r4 = 2
            java.lang.StringBuilder r0 = new java.lang.StringBuilder
            r0.<init>()
            int r1 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_notice_connecting_simpleAP
            java.lang.String r1 = r10.getString(r1)
            r0.append(r1)
            java.lang.String r1 = "\n\nSSID: "
            r0.append(r1)
            java.lang.String r1 = r10.targetSsid
            r0.append(r1)
            java.lang.String r5 = r0.toString()
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_error_wifi_connecting_simpleAP
            java.lang.String r6 = r10.getString(r0)
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_goto_wifi_setting
            java.lang.String r7 = r10.getString(r0)
            r8 = 0
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_cancel
            java.lang.String r9 = r10.getString(r0)
            r3 = r11
            com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect r0 = com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect.newInstance(r3, r4, r5, r6, r7, r8, r9)
            goto L_0x00d6
        L_0x00b5:
            r4 = 2
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_error_connecting_printer
            java.lang.String r5 = r10.getString(r0)
            r6 = 0
            r0 = 17039370(0x104000a, float:2.42446E-38)
            java.lang.String r7 = r10.getString(r0)
            r8 = 0
            r9 = 0
            r3 = r11
            com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect r0 = com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect.newInstance(r3, r4, r5, r6, r7, r8, r9)
            goto L_0x00d6
        L_0x00cc:
            int r0 = com.epson.mobilephone.common.wifidirect.C1113R.string.str_connecting_printer
            java.lang.String r0 = r10.getString(r0)
            com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect r0 = com.epson.mobilephone.common.wifidirect.DialogProgressWiFiDirect.newInstance(r11, r2, r0)
        L_0x00d6:
            if (r0 == 0) goto L_0x00e2
            r0.setCancelable(r2)
            android.support.v4.app.FragmentManager r1 = r10.getSupportFragmentManager()
            r0.show(r1, r11)
        L_0x00e2:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.ActivityConnectSimpleAP.showDialog(java.lang.String):void");
    }

    private void dismissDialog(String str) {
        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
        if (dialogFragment != null) {
            dialogFragment.dismiss();
        }
    }

    protected void interruptConnecting() {
        super.interruptConnecting();
        NetworkStateChangeReciever networkStateChangeReciever2 = networkStateChangeReciever;
        if (networkStateChangeReciever2 != null) {
            try {
                unregisterReceiver(networkStateChangeReciever2);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            networkStateChangeReciever = null;
        }
    }

    private void onConnectedWiFi() {
        EPLog.m86d(TAG, "onConnect()");
        interruptConnecting();
        new AsyncTask<Void, Void, Void>() {
            protected Void doInBackground(Void... voidArr) {
                WiFiUtils.getInstance(ActivityConnectSimpleAP.this).waitConnected();
                return null;
            }

            protected void onPostExecute(Void voidR) {
                ManageDefaultNetwork.getInstance(ActivityConnectSimpleAP.this).setDefaultNetworkSimpleAp();
                if (ActivityConnectSimpleAP.this.showConnectedTip) {
                    ActivityConnectSimpleAP activityConnectSimpleAP = ActivityConnectSimpleAP.this;
                    Toast.makeText(activityConnectSimpleAP, activityConnectSimpleAP.getString(C1113R.string.str_notice_wifi_connected), 0).show();
                }
                if (!ActivityConnectSimpleAP.this.needInfo) {
                    ActivityConnectSimpleAP.this.closeWaitingDialog();
                    ActivityConnectSimpleAP.this.status = ActivityConnectBase.Status.IDLE;
                    ActivityConnectSimpleAP.this.setResult(-1);
                    ActivityConnectBase.setLastDetailResult(-1);
                    ActivityConnectSimpleAP.this.finish();
                    return;
                }
                if (ActivityConnectSimpleAP.this.taskFindPrinter != null) {
                    EPLog.m90w(ActivityConnectSimpleAP.TAG, "Already called onConnect()");
                }
                String curP2PMacAdder = WiFiUtils.getInstance(ActivityConnectSimpleAP.this).getCurP2PMacAdder();
                ActivityConnectSimpleAP.this.expectedPrtMacAddr = WiFiControl.p2pAddr2PtrAddrP2P(curP2PMacAdder, (String) null);
                ActivityConnectSimpleAP.this.status = ActivityConnectBase.Status.PRINTER_FINDING;
                ActivityConnectSimpleAP activityConnectSimpleAP2 = ActivityConnectSimpleAP.this;
                activityConnectSimpleAP2.taskFindPrinter = new FindPrinterTask(activityConnectSimpleAP2.mHandler, ActivityConnectSimpleAP.this.timeout, 1, 2);
                ActivityConnectSimpleAP.this.taskFindPrinter.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
    }

    private void onError() {
        closeWaitingDialog();
        Toast.makeText(this, getString(C1113R.string.str_error_connecting_printer_short), 1).show();
        if (this.searchWiFiDirectPrinter != null) {
            searchWiFiDirectPrinter.interrupt();
            searchWiFiDirectPrinter = null;
        }
        if (this.status == ActivityConnectBase.Status.WIFI_CONNECTING && connectingNetworkId != -1) {
            interruptConnecting();
            WiFiUtils.getInstance(this).removeNetwork(this.connectingNetworkId);
            connectingNetworkId = -1;
            WiFiUtils.getInstance(this).reConnectNetwork();
            if (this.showErrorDlg) {
                mModelDialog.doShow(IDD_WIFI_ERROR);
                return;
            }
        }
        EPLog.m86d(TAG, "finish():RESULT_CANCELED");
        setResult(0);
        setLastDetailResult(2);
        finish();
    }

    private void closeWaitingDialog() {
        EPLog.m86d(TAG, "Called closeWaitingDialog()");
        try {
            mModelDialog.doDismiss(IDD_WIFI_WAITING);
        } catch (IllegalArgumentException unused) {
            EPLog.m86d(TAG, "IDD_WIFI_WATING already closed");
        }
    }

    /* renamed from: com.epson.mobilephone.common.wifidirect.ActivityConnectSimpleAP$4 */
    static /* synthetic */ class C10874 {

        /* renamed from: $SwitchMap$com$epson$mobilephone$common$wifidirect$ActivityConnectBase$Status */
        static final /* synthetic */ int[] f150x55760faf = new int[ActivityConnectBase.Status.values().length];

        /* JADX WARNING: Can't wrap try/catch for region: R(10:0|1|2|3|4|5|6|7|8|10) */
        /* JADX WARNING: Can't wrap try/catch for region: R(8:0|1|2|3|4|5|6|(3:7|8|10)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001f */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x002a */
        static {
            /*
                com.epson.mobilephone.common.wifidirect.ActivityConnectBase$Status[] r0 = com.epson.mobilephone.common.wifidirect.ActivityConnectBase.Status.values()
                int r0 = r0.length
                int[] r0 = new int[r0]
                f150x55760faf = r0
                int[] r0 = f150x55760faf     // Catch:{ NoSuchFieldError -> 0x0014 }
                com.epson.mobilephone.common.wifidirect.ActivityConnectBase$Status r1 = com.epson.mobilephone.common.wifidirect.ActivityConnectBase.Status.IDLE     // Catch:{ NoSuchFieldError -> 0x0014 }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x0014 }
                r2 = 1
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x0014 }
            L_0x0014:
                int[] r0 = f150x55760faf     // Catch:{ NoSuchFieldError -> 0x001f }
                com.epson.mobilephone.common.wifidirect.ActivityConnectBase$Status r1 = com.epson.mobilephone.common.wifidirect.ActivityConnectBase.Status.WIFI_SCANNING     // Catch:{ NoSuchFieldError -> 0x001f }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x001f }
                r2 = 2
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x001f }
            L_0x001f:
                int[] r0 = f150x55760faf     // Catch:{ NoSuchFieldError -> 0x002a }
                com.epson.mobilephone.common.wifidirect.ActivityConnectBase$Status r1 = com.epson.mobilephone.common.wifidirect.ActivityConnectBase.Status.WIFI_CONNECTING     // Catch:{ NoSuchFieldError -> 0x002a }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x002a }
                r2 = 3
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x002a }
            L_0x002a:
                int[] r0 = f150x55760faf     // Catch:{ NoSuchFieldError -> 0x0035 }
                com.epson.mobilephone.common.wifidirect.ActivityConnectBase$Status r1 = com.epson.mobilephone.common.wifidirect.ActivityConnectBase.Status.PRINTER_FINDING     // Catch:{ NoSuchFieldError -> 0x0035 }
                int r1 = r1.ordinal()     // Catch:{ NoSuchFieldError -> 0x0035 }
                r2 = 4
                r0[r1] = r2     // Catch:{ NoSuchFieldError -> 0x0035 }
            L_0x0035:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.ActivityConnectSimpleAP.C10874.<clinit>():void");
        }
    }

    private void setupObserver() {
        super.setupObserver();
        networkStateChangeReciever = new NetworkStateChangeReciever();
        registerReceiver(this.networkStateChangeReciever, new IntentFilter("android.net.wifi.STATE_CHANGE"));
        registerReceiver(this.networkStateChangeReciever, new IntentFilter("android.net.wifi.WIFI_STATE_CHANGED"));
        registerReceiver(this.networkStateChangeReciever, new IntentFilter("android.net.wifi.supplicant.STATE_CHANGE"));
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0039  */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x0045  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0051  */
    /* JADX WARNING: Removed duplicated region for block: B:23:? A[RETURN, SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onPositiveClick(java.lang.String r5) {
        /*
            r4 = this;
            int r0 = r5.hashCode()
            r1 = -872067019(0xffffffffcc055035, float:-3.4947284E7)
            r2 = 2
            r3 = 0
            if (r0 == r1) goto L_0x002a
            r1 = -692203673(0xffffffffd6bdcf67, float:-1.04349242E14)
            if (r0 == r1) goto L_0x0020
            r1 = 765832116(0x2da5abb4, float:1.883458E-11)
            if (r0 == r1) goto L_0x0016
            goto L_0x0034
        L_0x0016:
            java.lang.String r0 = "idd_wifi_error"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0034
            r5 = 0
            goto L_0x0035
        L_0x0020:
            java.lang.String r0 = "idd_wifi_profile_failed"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0034
            r5 = 2
            goto L_0x0035
        L_0x002a:
            java.lang.String r0 = "idd_wifi_simpleap"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0034
            r5 = 1
            goto L_0x0035
        L_0x0034:
            r5 = -1
        L_0x0035:
            switch(r5) {
                case 0: goto L_0x0051;
                case 1: goto L_0x0045;
                case 2: goto L_0x0039;
                default: goto L_0x0038;
            }
        L_0x0038:
            goto L_0x0061
        L_0x0039:
            java.lang.String r5 = "ActivityConnectSimpleAP"
            java.lang.String r0 = "finish():GOTO_WIFI_SETTINGS"
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r5, r0)
            r5 = 5
            com.epson.mobilephone.common.wifidirect.WiFiUtils.showOsWifiSettings(r4, r5)
            goto L_0x0061
        L_0x0045:
            java.lang.String r5 = "ActivityConnectSimpleAP"
            java.lang.String r0 = "finish():GOTO_WIFI_SETTINGS"
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r5, r0)
            r5 = 4
            com.epson.mobilephone.common.wifidirect.WiFiUtils.showOsWifiSettings(r4, r5)
            goto L_0x0061
        L_0x0051:
            java.lang.String r5 = "ActivityConnectSimpleAP"
            java.lang.String r0 = "finish():RESULT_CANCELED"
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r5, r0)
            r4.setResult(r3)
            setLastDetailResult(r2)
            r4.finish()
        L_0x0061:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.ActivityConnectSimpleAP.onPositiveClick(java.lang.String):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x002a  */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x0038  */
    /* JADX WARNING: Removed duplicated region for block: B:16:? A[RETURN, SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onNegativeClick(java.lang.String r5) {
        /*
            r4 = this;
            int r0 = r5.hashCode()
            r1 = -872067019(0xffffffffcc055035, float:-3.4947284E7)
            r2 = 0
            r3 = 1
            if (r0 == r1) goto L_0x001b
            r1 = -692203673(0xffffffffd6bdcf67, float:-1.04349242E14)
            if (r0 == r1) goto L_0x0011
            goto L_0x0025
        L_0x0011:
            java.lang.String r0 = "idd_wifi_profile_failed"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0025
            r5 = 1
            goto L_0x0026
        L_0x001b:
            java.lang.String r0 = "idd_wifi_simpleap"
            boolean r5 = r5.equals(r0)
            if (r5 == 0) goto L_0x0025
            r5 = 0
            goto L_0x0026
        L_0x0025:
            r5 = -1
        L_0x0026:
            switch(r5) {
                case 0: goto L_0x0038;
                case 1: goto L_0x002a;
                default: goto L_0x0029;
            }
        L_0x0029:
            goto L_0x0048
        L_0x002a:
            java.lang.String r5 = "ActivityConnectSimpleAP"
            java.lang.String r0 = "finish():RESULT_CANCELED"
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r5, r0)
            r4.onError()
            setLastDetailResult(r3)
            goto L_0x0048
        L_0x0038:
            java.lang.String r5 = "ActivityConnectSimpleAP"
            java.lang.String r0 = "finish():RESULT_CANCELED"
            com.epson.mobilephone.common.wifidirect.EPLog.m86d(r5, r0)
            r4.setResult(r2)
            setLastDetailResult(r3)
            r4.finish()
        L_0x0048:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.mobilephone.common.wifidirect.ActivityConnectSimpleAP.onNegativeClick(java.lang.String):void");
    }

    class NetworkStateChangeReciever extends BroadcastReceiver {
        NetworkStateChangeReciever() {
        }

        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals("android.net.wifi.WIFI_STATE_CHANGED")) {
                EPLog.m86d(ActivityConnectSimpleAP.TAG, String.format("WiFi State Change : wifiState = %d", new Object[]{Integer.valueOf(intent.getIntExtra("wifi_state", 4))}));
            } else if (action.equals("android.net.wifi.STATE_CHANGE")) {
                NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra("networkInfo");
                EPLog.m86d(ActivityConnectSimpleAP.TAG, "Network State Changed:" + networkInfo.toString());
                if (networkInfo.isConnected() && ActivityConnectSimpleAP.this.targetSsid.equals(WiFiUtils.getInstance(ActivityConnectSimpleAP.this).getCurSSID())) {
                    EPLog.m88i(ActivityConnectSimpleAP.TAG, "Wi-Fi connected.");
                    ActivityConnectSimpleAP.mHandler.sendEmptyMessageDelayed(10, 1000);
                }
            } else if (action.equals("android.net.wifi.supplicant.STATE_CHANGE")) {
                SupplicantState supplicantState = (SupplicantState) intent.getParcelableExtra("newState");
                EPLog.m86d(ActivityConnectSimpleAP.TAG, "Supplicant State Changed: State = " + supplicantState.toString());
                if (intent.hasExtra("supplicantError")) {
                    Integer valueOf = Integer.valueOf(intent.getIntExtra("supplicantError", 0));
                    EPLog.m86d(ActivityConnectSimpleAP.TAG, "Supplicant State Changed: ErrorCode = " + valueOf.toString());
                    if (ActivityConnectSimpleAP.this.status == ActivityConnectBase.Status.WIFI_CONNECTING) {
                        EPLog.m86d(ActivityConnectSimpleAP.TAG, "EXTRA_SUPPLICANT_ERROR");
                        ActivityConnectSimpleAP.this.onError();
                        return;
                    }
                }
                if (supplicantState == SupplicantState.ASSOCIATING && ActivityConnectSimpleAP.this.status == ActivityConnectBase.Status.WIFI_CONNECTING) {
                    ActivityConnectSimpleAP.access$408(ActivityConnectSimpleAP.this);
                    if (ActivityConnectSimpleAP.this.retryConnecting > 5) {
                        EPLog.m86d(ActivityConnectSimpleAP.TAG, "Connecting Retry timeout");
                        ActivityConnectSimpleAP.this.onError();
                    }
                }
            }
        }
    }
}
