package epson.scan.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.UiThread;
import android.support.p000v4.app.DialogFragment;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.TextView;
import com.epson.mobilephone.common.wifidirect.ActivityWiFiDirectStart;
import com.epson.mobilephone.common.wifidirect.ActivityiPrintConnect;
import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
import com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask;
import com.epson.mobilephone.common.wifidirect.WiFiControl;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
import com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils;
import com.epson.mobilephone.common.wifidirect.escprLib;
import epson.common.Constants;
import epson.common.Utils;
import epson.maintain.activity.PrinterNotFoundDialogCreator;
import epson.print.ActivityIACommon;
import epson.print.C2135R;
import epson.print.CommonDefine;
import epson.print.CustomLayoutDialogFragment;
import epson.print.CustomTitleDialogFragment;
import epson.print.MyPrinter;
import epson.print.Util.EPLog;
import epson.print.screen.WorkingDialog;
import epson.print.widgets.ListControlHelper;
import epson.print.widgets.PrinterInfoBuilder;
import epson.scan.lib.CancelableFind;
import epson.scan.lib.CancelablePropertyTaker;
import epson.scan.lib.EscanLibException;
import epson.scan.lib.escanLib;
import java.util.Locale;
import java.util.concurrent.Semaphore;

public class ScanSearchActivity extends ActivityIACommon implements CustomTitleDialogFragment.Callback {
    private static final int DIALOG_ID_PRINTER_NOT_FOUND_WITH_WEB_GUIDANCE = 1;
    private static final String DIALOG_TAG_PRINTER_NOT_FOUND = "printer_not_found_dialog";
    private static final int Menu_Delete = 1;
    private static final int Menu_Edit = 2;
    private static final String PARAM_KEY_SCANNER_ID = "scanner-id";
    private static final String PARAM_KEY_SCANNER_LOCATION = "scanner-location";
    private static final String PARAM_KEY_SCANNER_SSID = "scanner-ssid";
    private static final String TAG = "ScanSearch";
    /* access modifiers changed from: private */
    public static final Semaphore sEscanLibSemaphore = new Semaphore(1);
    private final int ADD_SCANER = 8;
    private final String COMMONDEVICENAME = "commonDeviceName";
    private final int CONNECT_SIMPLEAP = 7;
    private final int DELAY = 100;
    private final int DELETE_PRINTER = 9;
    private final int EDIT_IPPRINTER = 10;
    private final int FINISH_FIND_SCANER = 5;
    private final int FOUND_SIMPLEAP = 6;
    private final String PRINTER_ID = "id";
    private final String PRINTER_IP = escprLib.PRINTER_IP;
    private final String PRINTER_NAME = "name";
    private final int PROBE_SCANNER = 11;
    private final String SCANER_ID = "id";
    private final String SCANER_INDEX = "index";
    private final String SCANER_IP = escprLib.PRINTER_IP;
    private final String SCANER_LOCATION = "location";
    private final String SCANER_NAME = "name";
    private final int SEARCH_PRINTER_P2P = 12;
    private final int SEARCH_SCANER = 1;
    private final int SELECT_SCANER = 4;
    private boolean bCheckWiFiStatus = false;
    private String connectionInfo = null;
    private AlertDialog errorDialog;
    ListControlHelper helper = null;
    /* access modifiers changed from: private */
    public volatile boolean isFinishSearchScanner = true;
    /* access modifiers changed from: private */
    public Boolean isFocused = true;
    private boolean isJapaneseLocale = false;
    /* access modifiers changed from: private */
    public volatile boolean isSearchSimpleAp = false;
    /* access modifiers changed from: private */
    public boolean isSelected = false;
    private AdapterView.AdapterContextMenuInfo listItemIndex;
    /* access modifiers changed from: private */
    public volatile boolean mActivityBackRequested;
    private boolean mActivityForegroundLifetime;
    Button mAddButton;
    ScannerListAdapter mBuilder;
    /* access modifiers changed from: private */
    public Context mContext = null;
    int mDeletePos;
    /* access modifiers changed from: private */
    public escanLib mEscanLib;
    private FindScannerTask mFindScannerTask;
    private GetScannerCapabilityAndFinishTask mGetScannerCapabilityAndFinishTask;
    /* access modifiers changed from: private */
    public Handler mHandler = new Handler(new Handler.Callback() {
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r7v24, resolved type: java.lang.Object} */
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v30, resolved type: epson.print.MyPrinter} */
        /* JADX WARNING: Multi-variable type inference failed */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public boolean handleMessage(android.os.Message r7) {
            /*
                r6 = this;
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                boolean r0 = r0.isFinishing()
                r1 = 1
                r2 = 0
                if (r0 != 0) goto L_0x0012
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                boolean r0 = r0.mActivityBackRequested
                if (r0 == 0) goto L_0x001d
            L_0x0012:
                int r0 = r7.what
                if (r0 == r1) goto L_0x0183
                r3 = 8
                if (r0 == r3) goto L_0x0183
                switch(r0) {
                    case 5: goto L_0x0183;
                    case 6: goto L_0x0183;
                    default: goto L_0x001d;
                }
            L_0x001d:
                int r0 = r7.what
                r3 = -1
                switch(r0) {
                    case 1: goto L_0x017d;
                    case 2: goto L_0x0023;
                    case 3: goto L_0x0023;
                    case 4: goto L_0x0023;
                    case 5: goto L_0x0172;
                    case 6: goto L_0x012f;
                    case 7: goto L_0x0023;
                    case 8: goto L_0x00de;
                    case 9: goto L_0x008a;
                    case 10: goto L_0x0044;
                    case 11: goto L_0x0023;
                    case 12: goto L_0x0025;
                    default: goto L_0x0023;
                }
            L_0x0023:
                goto L_0x0182
            L_0x0025:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                android.os.Handler r0 = r7.mHandler
                r1 = 6
                r3 = 60
                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.searchWiFiDirectPrinter(r7, r0, r1, r3)
                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask unused = r7.searchWiFiDirectPrinter = r0
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                com.epson.mobilephone.common.wifidirect.SearchWiFiDirectPrinterTask r7 = r7.searchWiFiDirectPrinter
                if (r7 != 0) goto L_0x0182
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                boolean unused = r7.isSearchSimpleAp = r2
                goto L_0x0182
            L_0x0044:
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                r0.interruptSearch()
                r0 = 0
                java.lang.Object r1 = r7.obj
                if (r1 == 0) goto L_0x0053
                java.lang.Object r7 = r7.obj
                r0 = r7
                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
            L_0x0053:
                android.content.Intent r7 = new android.content.Intent
                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
                java.lang.Class<epson.print.screen.ActivityIpPrinterSetting> r4 = epson.print.screen.ActivityIpPrinterSetting.class
                r7.<init>(r1, r4)
                android.os.Bundle r1 = new android.os.Bundle
                r1.<init>()
                if (r0 == 0) goto L_0x0073
                java.lang.String r4 = r0.getPrinterId()
                if (r4 == 0) goto L_0x0073
                java.lang.String r4 = "PRINTER_KEY"
                java.lang.String r0 = r0.getPrinterId()
                r1.putString(r4, r0)
                goto L_0x007a
            L_0x0073:
                java.lang.String r0 = "PRINTER_KEY"
                java.lang.String r4 = ""
                r1.putString(r0, r4)
            L_0x007a:
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                r0.mDeletePos = r3
                r7.putExtras(r1)
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                r1 = 10
                r0.startActivityForResult(r7, r1)
                goto L_0x0182
            L_0x008a:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                int r7 = r7.mDeletePos
                if (r7 < 0) goto L_0x0182
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                int r7 = r7.scanner_location
                r0 = 3
                if (r7 == r0) goto L_0x009a
                goto L_0x00d8
            L_0x009a:
                epson.print.EPPrinterManager r7 = new epson.print.EPPrinterManager
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                android.content.Context r0 = r0.mContext
                r7.<init>(r0)
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                epson.scan.activity.ScannerListAdapter r0 = r0.mBuilder
                java.util.Vector r0 = r0.getData()
                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
                int r1 = r1.mDeletePos
                java.lang.Object r0 = r0.elementAt(r1)
                epson.print.MyPrinter r0 = (epson.print.MyPrinter) r0
                java.lang.String r0 = r0.getPrinterId()
                r7.deleteIpPrinterInfo(r0)
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                epson.scan.activity.ScannerListAdapter r7 = r7.mBuilder
                android.widget.BaseAdapter r7 = r7.getAdapter()
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                epson.scan.activity.ScannerListAdapter r0 = r0.mBuilder
                java.util.Vector r0 = r0.getData()
                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
                int r1 = r1.mDeletePos
                r0.remove(r1)
                r7.notifyDataSetChanged()
            L_0x00d8:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                r7.mDeletePos = r3
                goto L_0x0182
            L_0x00de:
                epson.scan.activity.ScanSearchActivity r0 = epson.scan.activity.ScanSearchActivity.this
                int r0 = r0.scanner_location
                if (r0 == r1) goto L_0x00e8
                goto L_0x0182
            L_0x00e8:
                android.os.Bundle r7 = r7.getData()
                java.lang.String r0 = "name"
                java.lang.String r0 = r7.getString(r0)
                if (r0 == 0) goto L_0x0182
                epson.print.MyPrinter r0 = new epson.print.MyPrinter
                java.lang.String r1 = "name"
                java.lang.String r1 = r7.getString(r1)
                java.lang.String r3 = "ip"
                java.lang.String r3 = r7.getString(r3)
                java.lang.String r4 = ""
                java.lang.String r5 = ""
                r0.<init>(r1, r3, r4, r5)
                java.lang.String r1 = "id"
                java.lang.String r1 = r7.getString(r1)
                r0.setScannerId(r1)
                java.lang.String r1 = "commonDeviceName"
                java.lang.String r7 = r7.getString(r1)
                r0.setCommonDeviceName(r7)
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r7 = r7.wiFiDirectPrinterListUtils
                java.lang.String r1 = r0.getIp()
                java.lang.String r3 = r0.getScannerId()
                java.lang.String r3 = com.epson.mobilephone.common.wifidirect.MacAddrUtils.getMacAddressFromScannerId(r3)
                r7.addPrinter(r0, r2, r1, r3)
                goto L_0x0182
            L_0x012f:
                android.os.Bundle r7 = r7.getData()
                if (r7 == 0) goto L_0x015f
                boolean r0 = r7.isEmpty()
                if (r0 != 0) goto L_0x015f
                java.lang.String r0 = "ssid"
                java.lang.String r0 = r7.getString(r0)
                java.lang.String r1 = "name"
                java.lang.String r1 = r7.getString(r1)
                java.lang.String r3 = "addr_infra"
                java.lang.String r7 = r7.getString(r3)
                if (r1 != 0) goto L_0x0150
                r1 = r0
            L_0x0150:
                epson.print.MyPrinter r3 = new epson.print.MyPrinter
                java.lang.String r4 = ""
                r3.<init>(r1, r0, r7, r4)
                epson.scan.activity.ScanSearchActivity r1 = epson.scan.activity.ScanSearchActivity.this
                com.epson.mobilephone.common.wifidirect.WiFiDirectPrinterListUtils r1 = r1.wiFiDirectPrinterListUtils
                r1.addPrinter(r3, r2, r0, r7)
                goto L_0x0182
            L_0x015f:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                boolean unused = r7.isSearchSimpleAp = r2
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                boolean r7 = r7.isFinishSearchScanner
                if (r7 == 0) goto L_0x0182
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                r7.updateFindScannerResult()
                goto L_0x0182
            L_0x0172:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                r7.interruptSearch()
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                r7.updateFindScannerResult()
                goto L_0x0182
            L_0x017d:
                epson.scan.activity.ScanSearchActivity r7 = epson.scan.activity.ScanSearchActivity.this
                r7.search()
            L_0x0182:
                return r2
            L_0x0183:
                return r2
            */
            throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.ScanSearchActivity.C242011.handleMessage(android.os.Message):boolean");
        }
    });
    RadioButton mIpButton;
    ViewGroup mLayout;
    private TextView mListEmptyMessageTextView;
    /* access modifiers changed from: private */
    public ListView mListView;
    RadioButton mLocalButton;
    private String mMyPrinterForSimpleApDisconnect;
    private volatile boolean mProgress;
    ProgressBar mProgressBar;
    WorkingDialog mProgressDialog;
    /* access modifiers changed from: private */
    public volatile boolean mScannerFindCancelRequested;
    Button mSearchButton;
    /* access modifiers changed from: private */
    public String mSimpleApSsid;
    TextView mTextDetail;
    View mWiFiSettingButton;
    private String scannerId;
    private String scannerKey;
    /* access modifiers changed from: private */
    public int scanner_location;
    /* access modifiers changed from: private */
    public SearchWiFiDirectPrinterTask searchWiFiDirectPrinter = null;
    private TextView tvResult;
    WiFiDirectPrinterListUtils wiFiDirectPrinterListUtils = null;

    public void onLocalNegativeCallback(int i) {
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
            this.isJapaneseLocale = true;
        } else {
            this.isJapaneseLocale = false;
        }
        this.mLayout = (ViewGroup) getLayoutInflater().inflate(C2135R.layout.search_printer_layout, (ViewGroup) null);
        addWiFiSetupButton();
        this.mEscanLib = new escanLib();
        this.mEscanLib.escanWrapperInitDriver(this);
        Bundle extras = getIntent().getExtras();
        this.scanner_location = extras.getInt(PARAM_KEY_SCANNER_LOCATION);
        if (this.scanner_location == 0) {
            this.scanner_location = 1;
        }
        if (this.scanner_location != 3) {
            this.scannerId = extras.getString(PARAM_KEY_SCANNER_ID);
            this.connectionInfo = extras.getString(PARAM_KEY_SCANNER_SSID);
        } else {
            this.scannerKey = extras.getString(PARAM_KEY_SCANNER_ID);
        }
        setContentView((View) this.mLayout);
        this.tvResult = (TextView) this.mLayout.findViewById(C2135R.C2137id.empty);
        this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_processing));
        this.mListEmptyMessageTextView = (TextView) this.mLayout.findViewById(C2135R.C2137id.list_empty_message);
        this.mListView = (ListView) this.mLayout.findViewById(16908298);
        EPLog.m313i("epson.scan.activity.ScanSearchActivity", "builElements");
        buildElements();
        setNotFoundPrinterButton();
        setActionBar((int) C2135R.string.title_addprint, true);
        this.mContext = this;
    }

    private void setNotFoundPrinterButton() {
        this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
                scanSearchActivity.startActivity(PrinterNotFoundDialogCreator.getStartIntent(scanSearchActivity.getApplicationContext()));
            }
        });
    }

    /* access modifiers changed from: package-private */
    public void addWiFiSetupButton() {
        this.mWiFiSettingButton = this.mLayout.findViewById(C2135R.C2137id.rlWifiSettings);
        if (this.isJapaneseLocale) {
            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_goto_wifidirect_settings);
        } else {
            ((TextView) this.mWiFiSettingButton).setText(C2135R.string.str_wifidirect_settings);
        }
        this.mWiFiSettingButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                ScanSearchActivity.this.startWifiPrinterSelect();
            }
        });
    }

    /* access modifiers changed from: private */
    public void startWifiPrinterSelect() {
        startActivityForResult(new Intent(this, ActivityWiFiDirectStart.class), 7);
    }

    /* access modifiers changed from: private */
    public void buildElements() {
        this.mLocalButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_local);
        this.mIpButton = (RadioButton) this.mLayout.findViewById(C2135R.C2137id.btn_ip);
        this.mSearchButton = (Button) this.mLayout.findViewById(C2135R.C2137id.function_button);
        this.mProgressBar = (ProgressBar) this.mLayout.findViewById(C2135R.C2137id.progress_bar);
        this.mAddButton = (Button) this.mLayout.findViewById(C2135R.C2137id.edit_button);
        this.mTextDetail = (TextView) this.mLayout.findViewById(C2135R.C2137id.detail);
        this.mTextDetail.setVisibility(0);
        findViewById(C2135R.C2137id.btn_remote).setVisibility(8);
        this.mIpButton.setBackground(getResources().getDrawable(C2135R.C2136drawable.printer_selector_background_remote));
        this.mLayout.findViewById(C2135R.C2137id.ble_wifi_setting).setVisibility(8);
        Utils.setDrawble2TextView(this, this.mLocalButton, C2135R.C2136drawable.printer_selector_icon_local);
        Utils.setDrawble2TextView(this, this.mIpButton, C2135R.C2136drawable.printer_selector_icon_ip);
        TextView textView = null;
        if (this.scanner_location != 3) {
            this.mListView.setEmptyView((View) null);
            this.mListEmptyMessageTextView.setText((CharSequence) null);
            this.mListEmptyMessageTextView.setVisibility(8);
            this.mAddButton.setVisibility(8);
            this.mSearchButton.setVisibility(0);
            searchButtonSetEnabled(false);
            this.mProgressBar.setVisibility(0);
            this.tvResult.setVisibility(0);
            this.mWiFiSettingButton.setVisibility(0);
            this.mBuilder = new ScannerListAdapter(this, this.mLayout, 2);
            this.mBuilder.setResource(WiFiDirectPrinterListUtils.getCurPrinterString(this, this.scannerId, this.connectionInfo));
            this.helper = new ListControlHelper((PrinterInfoBuilder) this.mBuilder.getBuilder());
            this.wiFiDirectPrinterListUtils = new WiFiDirectPrinterListUtils(this, this.mBuilder.getData(), this.helper, this.connectionInfo);
            this.mLocalButton.setChecked(true);
            this.mTextDetail.setText(C2135R.string.str_detailtext_local_scan);
            this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(0);
        } else {
            this.mListEmptyMessageTextView.setText(C2135R.string.printer_list_empty_message);
            textView = this.mListEmptyMessageTextView;
            this.mAddButton.setVisibility(0);
            this.mSearchButton.setVisibility(8);
            this.mProgressBar.setVisibility(8);
            this.tvResult.setVisibility(8);
            this.mWiFiSettingButton.setVisibility(8);
            this.mBuilder = new ScannerListAdapter(this, this.mLayout, 1);
            this.mBuilder.setResource(this.scannerKey);
            this.mIpButton.setChecked(true);
            this.mTextDetail.setText(C2135R.string.str_detailtext_ip_scan);
            this.mLayout.findViewById(C2135R.C2137id.not_found_printer_epsonsn).setVisibility(8);
        }
        this.mBuilder.build();
        this.mBuilder.refresh();
        this.mListView.setEmptyView(textView);
        this.mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                if (!ScanSearchActivity.this.isSelected && ScanSearchActivity.this.isFocused.booleanValue()) {
                    Boolean unused = ScanSearchActivity.this.isFocused = false;
                    boolean unused2 = ScanSearchActivity.this.isSelected = true;
                    MyPrinter myPrinter = (MyPrinter) ScanSearchActivity.this.mBuilder.getData().elementAt(i);
                    String ip = myPrinter.getIp();
                    if (!WiFiControl.ConnectType.NONE.equals(WiFiDirectManager.getConnectType(ScanSearchActivity.this, ip))) {
                        ScanSearchActivity.this.interruptSearch();
                        WiFiDirectManager.connect(ScanSearchActivity.this, ip, 7);
                        return;
                    }
                    myPrinter.setLocation(ScanSearchActivity.this.scanner_location);
                    ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
                    String unused3 = scanSearchActivity.mSimpleApSsid = scanSearchActivity.getSimpleApSsid(myPrinter);
                    ScanSearchActivity.this.startGetCapabilityAndFinishTask(myPrinter);
                }
            }
        });
        this.mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
                if (ScanSearchActivity.this.scanner_location == 1) {
                    return true;
                }
                ScanSearchActivity scanSearchActivity = ScanSearchActivity.this;
                scanSearchActivity.mDeletePos = i;
                scanSearchActivity.registerForContextMenu(scanSearchActivity.mListView);
                return false;
            }
        });
        this.mAddButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (ScanSearchActivity.this.scanner_location == 3) {
                    if (ScanSearchActivity.this.mBuilder.getData().size() >= 32) {
                        new AlertDialog.Builder(ScanSearchActivity.this.mContext).setCancelable(false).setTitle(ScanSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size_title)).setMessage(ScanSearchActivity.this.getString(C2135R.string.epsonconnect_err_regist_remote_printer_max_size)).setPositiveButton(ScanSearchActivity.this.getString(C2135R.string.str_yes), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
                            }
                        }).show();
                        return;
                    }
                    Message message = new Message();
                    message.what = 10;
                    message.obj = null;
                    ScanSearchActivity.this.mHandler.sendMessage(message);
                }
            }
        });
        this.mSearchButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                ScanSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
            }
        });
        this.mLocalButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (ScanSearchActivity.this.scanner_location != 1) {
                    int unused = ScanSearchActivity.this.scanner_location = 1;
                    ScanSearchActivity.this.buildElements();
                    ScanSearchActivity.this.mHandler.sendEmptyMessageDelayed(1, 100);
                }
            }
        });
        this.mIpButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (ScanSearchActivity.this.scanner_location != 3) {
                    ScanSearchActivity.this.interruptSearch();
                    int unused = ScanSearchActivity.this.scanner_location = 3;
                    ScanSearchActivity.this.buildElements();
                }
            }
        });
    }

    public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
        super.onCreateContextMenu(contextMenu, view, contextMenuInfo);
        contextMenu.setHeaderTitle(C2135R.string.str_edit_bookmark);
        contextMenu.add(0, 1, 0, C2135R.string.str_delete);
        contextMenu.add(0, 2, 0, C2135R.string.str_edit_bookmark);
    }

    public boolean onContextItemSelected(MenuItem menuItem) {
        this.listItemIndex = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
        if (this.listItemIndex == null) {
            return true;
        }
        switch (menuItem.getItemId()) {
            case 1:
                new AlertDialog.Builder(this.mContext).setCancelable(false).setTitle(getString(C2135R.string.delete_file)).setIcon(getResources().getDrawable(C2135R.C2136drawable.delete_file)).setNegativeButton(getString(C2135R.string.str_ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Message obtainMessage = ScanSearchActivity.this.mHandler.obtainMessage();
                        obtainMessage.what = 9;
                        ScanSearchActivity.this.mHandler.sendMessageDelayed(obtainMessage, 100);
                    }
                }).setPositiveButton(getString(C2135R.string.str_cancel), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).show();
                break;
            case 2:
                Message message = new Message();
                if (this.scanner_location == 3) {
                    message.what = 10;
                }
                message.obj = this.mBuilder.getData().elementAt(this.mDeletePos);
                this.mHandler.sendMessage(message);
                break;
        }
        return true;
    }

    /* access modifiers changed from: protected */
    public void onDestroy() {
        EPLog.m313i("epson.scan.activity.ScanSearchActivity", "Destroy search screen");
        interruptSearch();
        this.mBuilder.destructor();
        super.onDestroy();
    }

    public void onBackPressed() {
        if (!this.mProgress) {
            this.mActivityBackRequested = true;
            if (sEscanLibSemaphore.availablePermits() <= 0) {
                interruptSearch();
                new CancelWaitTask().execute(new Void[0]);
                return;
            }
            releaseAndFinish();
        }
    }

    /* access modifiers changed from: private */
    public void releaseAndFinish() {
        this.mEscanLib.escanWrapperReleaseDriver();
        setResult(0);
        finish();
    }

    /* access modifiers changed from: protected */
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 7) {
            if (i == 10 && i2 == -1) {
                this.mBuilder.refresh();
                MyPrinter myPrinter = new MyPrinter(intent.getStringExtra(Constants.PRINTER_NAME), intent.getStringExtra(Constants.PRINTER_IP), intent.getStringExtra(Constants.SCAN_REFS_SCANNER_ID), (String) null);
                myPrinter.setLocation(3);
                startGetCapabilityAndFinishTask(myPrinter);
            }
        } else if (i2 == -1) {
            this.isSelected = true;
            intent.getBooleanExtra(ActivityiPrintConnect.FINISH_EAYSETUP, false);
            MyPrinter myPrinter2 = new MyPrinter(intent.getStringExtra("name"), intent.getStringExtra(escprLib.PRINTER_IP), intent.getStringExtra("id"), (String) null);
            myPrinter2.setLocation(this.scanner_location);
            this.mSimpleApSsid = getSimpleApSsid(myPrinter2);
            startGetCapabilityAndFinishTask(myPrinter2);
        } else {
            forceSetPrinterSearchEnd();
        }
    }

    /* access modifiers changed from: private */
    @UiThread
    public void search() {
        interruptSearch();
        this.mScannerFindCancelRequested = false;
        this.mEscanLib.resetEscanLib();
        this.mBuilder.refresh();
        this.mBuilder.destructor();
        this.wiFiDirectPrinterListUtils.clearPrinterInfoList();
        if (WiFiDirectManager.getCurSSID(this) != null) {
            this.mHandler.sendEmptyMessageDelayed(12, 5000);
            this.isSearchSimpleAp = true;
        } else if (WiFiDirectManager.isWifiEnabled(this)) {
            this.mHandler.sendEmptyMessage(12);
            this.isSearchSimpleAp = true;
        } else {
            boolean z = this.bCheckWiFiStatus;
            if (!z && !z) {
                this.bCheckWiFiStatus = true;
                WiFiDirectManager.enableWiFi(this, -1);
                return;
            }
        }
        WiFiDirectManager.setPriorityToSimpleAP(this, true);
        searchButtonSetEnabled(false);
        this.mProgressBar.setVisibility(0);
        this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_processing));
        this.isFinishSearchScanner = false;
        this.mEscanLib.setScanHandler(this.mHandler);
        this.mFindScannerTask = new FindScannerTask(this.mEscanLib);
        this.mFindScannerTask.execute(new Void[0]);
    }

    /* access modifiers changed from: private */
    @UiThread
    public void interruptSearch() {
        this.mScannerFindCancelRequested = true;
        this.mHandler.removeMessages(1);
        this.mHandler.removeMessages(12);
        EPLog.m313i("epson.scan.activity.ScanSettingsActivity", "Cancel search scanner");
        this.mHandler.removeMessages(8);
        this.mHandler.removeMessages(6);
        SearchWiFiDirectPrinterTask searchWiFiDirectPrinterTask = this.searchWiFiDirectPrinter;
        if (searchWiFiDirectPrinterTask != null) {
            searchWiFiDirectPrinterTask.interrupt();
            this.searchWiFiDirectPrinter = null;
        }
        this.isSearchSimpleAp = false;
        FindScannerTask findScannerTask = this.mFindScannerTask;
        if (findScannerTask != null) {
            findScannerTask.cancelFind();
        }
    }

    /* access modifiers changed from: private */
    public void updateFindScannerResult() {
        if (!isFinishing()) {
            this.mProgressBar.setVisibility(8);
            searchButtonSetEnabled(true);
            int size = this.mBuilder.getData().size();
            if (size <= 0) {
                this.tvResult.setText(C2135R.string.lbl_scanner_search_result_none);
                if (this.mActivityForegroundLifetime) {
                    showPrinterNotFoundDialog(getPrinterNotFoundDialog(this.isSearchSimpleAp));
                }
            } else if (Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPAN.getLanguage()) || Locale.getDefault().getLanguage().equalsIgnoreCase(Locale.JAPANESE.getLanguage())) {
                this.tvResult.setText(getString(C2135R.string.lbl_scanner_search_result));
            } else {
                this.tvResult.setText(String.format(getString(C2135R.string.lbl_scanner_search_result), new Object[]{Integer.valueOf(size)}));
            }
        }
    }

    private DialogFragment getPrinterNotFoundDialog(boolean z) {
        String str;
        String str2;
        if (z) {
            str = getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI);
            str2 = getString(C2135R.string.str_err_msg_scan_not_found_title);
        } else {
            str2 = getString(C2135R.string.str_err_msg_scan_not_found_title);
            if (Utils.getPrefBoolean(getApplicationContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, CommonDefine.RE_SEARCH)) {
                str = getString(C2135R.string.str_err_msg_scan_not_found_research);
                String ssid = Utils.getSSID(this);
                if (!Utils.isConnectedWifi(this) || ssid == null) {
                    return CustomLayoutDialogFragment.newInstance(1, str, str2, 0, (int) C2135R.string.str_btn_close);
                }
                str2 = str2 + "\nSSID: " + ssid;
            } else {
                str = getString(C2135R.string.str_err_msg_scan_not_found);
            }
        }
        return CustomLayoutDialogFragment.newInstance(1, str + "\n\n" + getString(C2135R.string.confirm_browse_wlan_setup_info), str2, (int) C2135R.string.browse_site, (int) C2135R.string.str_btn_close);
    }

    private void showPrinterNotFoundDialog(DialogFragment dialogFragment) {
        if (!isFinishing()) {
            dialogFragment.show(getSupportFragmentManager(), DIALOG_TAG_PRINTER_NOT_FOUND);
        }
    }

    /* access modifiers changed from: protected */
    public Dialog onCreateDialog(int i) {
        Dialog onCreateDialog = super.onCreateDialog(i);
        if (i == C2135R.string.EPS_PRNERR_COMM1_NOWIFI) {
            return Utils.makeMessageBox(this, getString(C2135R.string.str_err_msg_scan_not_found_title), getString(C2135R.string.EPS_PRNERR_COMM1_NOWIFI), getString(C2135R.string.str_ok));
        }
        switch (i) {
            case C2135R.string.str_err_msg_scan_not_found /*2131625133*/:
            case C2135R.string.str_err_msg_scan_not_found_research /*2131625134*/:
                String str = "";
                String ssid = Utils.getSSID(this);
                if (Utils.isConnectedWifi(this) && ssid != null) {
                    str = "\nSSID: " + ssid;
                }
                return Utils.makeMessageBox(this, getString(C2135R.string.str_err_msg_scan_not_found_title) + str, getString(i), getString(C2135R.string.str_ok));
            default:
                return onCreateDialog;
        }
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0012 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void removeAllDialog() {
        /*
            r1 = this;
            r0 = 2131625133(0x7f0e04ad, float:1.8877465E38)
            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0006 }
        L_0x0006:
            r0 = 2131625134(0x7f0e04ae, float:1.8877467E38)
            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x000c }
        L_0x000c:
            r0 = 2131624361(0x7f0e01a9, float:1.88759E38)
            r1.removeDialog(r0)     // Catch:{ IllegalArgumentException -> 0x0012 }
        L_0x0012:
            r1.dismissPrinterNotFoundDialog()     // Catch:{ Exception -> 0x0015 }
        L_0x0015:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: epson.scan.activity.ScanSearchActivity.removeAllDialog():void");
    }

    private void dismissPrinterNotFoundDialog() {
        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_PRINTER_NOT_FOUND);
        if (dialogFragment != null) {
            dialogFragment.dismiss();
        }
    }

    public void searchButtonSetEnabled(boolean z) {
        this.mSearchButton.setVisibility(0);
        if (z) {
            this.mSearchButton.setEnabled(true);
        } else {
            this.mSearchButton.setEnabled(false);
        }
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        EPLog.m307e("Epson", "ScanSearchActivity.java call onResume()");
        this.mActivityForegroundLifetime = true;
        dismissPrinterNotFoundDialog();
        if (this.scanner_location != 3) {
            if (!this.isSelected) {
                this.mHandler.removeMessages(1);
                this.mHandler.sendEmptyMessageDelayed(1, 100);
            }
            EPLog.m305d("ScanSearchActivity", "Send CHECK_PRINTER Message.");
        }
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        EPLog.m305d("SearchPrinterScr", "onPause");
        super.onPause();
        this.mActivityForegroundLifetime = false;
        interruptSearch();
        if (!this.isSelected) {
            removeAllDialog();
        }
        GetScannerCapabilityAndFinishTask getScannerCapabilityAndFinishTask = this.mGetScannerCapabilityAndFinishTask;
        if (getScannerCapabilityAndFinishTask != null) {
            getScannerCapabilityAndFinishTask.cancelTask();
        }
    }

    /* access modifiers changed from: package-private */
    @UiThread
    public void showErrorDialog(EscanLibException escanLibException) {
        int[] iArr;
        if (!isFinishing()) {
            if (escanLibException.getEscIVersion() == 1) {
                iArr = getEscanI1ErrorTitleAndMessageId(escanLibException.getEscanLibErrorCode());
            } else {
                iArr = getEscanI2ErrorTitleAndMessageId(escanLibException.getEscanLibErrorCode());
            }
            this.errorDialog = Utils.makeMessageBox(this, getString(iArr[0]), getString(iArr[1]), getString(C2135R.string.str_ok));
            this.errorDialog.show();
        }
    }

    @NonNull
    private static int[] getEscanI1ErrorTitleAndMessageId(int i) {
        if (i == -500001) {
            return new int[]{C2135R.string.EPS_PRNERR_COMM_TITLE2, C2135R.string.str_ipprinter_comerror};
        }
        if (i != -1501) {
            if (i == -1300) {
                return new int[]{C2135R.string.str_err_msg_scan_not_found_title, C2135R.string.str_err_msg_scan_not_found_research};
            }
            if (i != -1100) {
                switch (i) {
                    case 5:
                        break;
                    case 6:
                        break;
                    default:
                        return new int[]{C2135R.string.str_err_msg_scan_generic_internal_title, C2135R.string.str_err_msg_scan_generic_internal};
                }
            }
            return new int[]{C2135R.string.str_err_msg_scan_comm_title, C2135R.string.str_err_msg_scan_comm};
        }
        return new int[]{C2135R.string.str_err_msg_scan_busy_title, C2135R.string.str_err_msg_scan_busy};
    }

    @NonNull
    private static int[] getEscanI2ErrorTitleAndMessageId(int i) {
        int[] iArr = new int[2];
        switch (i) {
            case Constants.ESCAN_ERR_SCANNER_OCCUPIED:
            case -213:
                iArr[0] = C2135R.string.str_err_msg_scan_busy_title;
                iArr[1] = C2135R.string.str_err_msg_scan_busy;
                break;
            case -1300:
                iArr[0] = C2135R.string.str_err_msg_scan_not_found_title;
                iArr[1] = C2135R.string.str_err_msg_scan_not_found_research;
                break;
            case -1114:
            case -1100:
            case -214:
                iArr[0] = C2135R.string.str_err_msg_scan_comm_title;
                iArr[1] = C2135R.string.str_err_msg_scan_comm;
                break;
            case -202:
            case -201:
            case -102:
            case -101:
                iArr[0] = C2135R.string.str_blank;
                iArr[1] = C2135R.string.str_err_msg_out_of_memory_title;
                break;
            default:
                iArr[0] = C2135R.string.str_err_msg_scan_generic_internal_title;
                iArr[1] = C2135R.string.str_err_msg_scan_generic_internal;
                break;
        }
        return iArr;
    }

    /* access modifiers changed from: private */
    public void forceSetPrinterSearchEnd() {
        this.isFocused = true;
        this.isSelected = false;
    }

    /* access modifiers changed from: private */
    public void localFinish(ScannerPropertyWrapper scannerPropertyWrapper) {
        scannerPropertyWrapper.setSimpleApSsid(this.mSimpleApSsid);
        setResult(-1, SettingActivityParams.getScanSearchReturnIntent(scannerPropertyWrapper));
        finish();
    }

    /* access modifiers changed from: private */
    public String getSimpleApSsid(MyPrinter myPrinter) {
        String macAddressFromScannerId = MacAddrUtils.getMacAddressFromScannerId(myPrinter.getScannerId());
        if (macAddressFromScannerId == null) {
            macAddressFromScannerId = MacAddrUtils.getMacAddressFromPrinterId(myPrinter.getPrinterId());
        }
        String curConnectInfo = WiFiDirectManager.getCurConnectInfo(this, macAddressFromScannerId);
        return curConnectInfo != null ? curConnectInfo : "";
    }

    public void onLocalPositiveCallback(int i) {
        if (i == 1) {
            startActivity(PrinterNotFoundDialogCreator.getStartIntent(this));
        }
    }

    /* access modifiers changed from: private */
    public void showProgress() {
        this.mProgress = true;
        this.mProgressDialog = new WorkingDialog(this);
        this.mProgressDialog.show();
    }

    /* access modifiers changed from: private */
    public void dismissProgress() {
        if (this.mProgressBar != null && this.mProgressDialog.isShowing()) {
            this.mProgressDialog.dismiss();
        }
        this.mProgress = false;
    }

    /* access modifiers changed from: private */
    public void startGetCapabilityAndFinishTask(MyPrinter myPrinter) {
        this.mMyPrinterForSimpleApDisconnect = myPrinter.getIp();
        interruptSearch();
        this.mGetScannerCapabilityAndFinishTask = new GetScannerCapabilityAndFinishTask(this.mEscanLib, myPrinter);
        this.mGetScannerCapabilityAndFinishTask.execute(new Void[0]);
    }

    /* access modifiers changed from: private */
    public void disconnectSimpleAp() {
        WiFiDirectManager.disconnect(getApplicationContext(), WiFiDirectManager.DEVICE_TYPE_SCANNER, this.mMyPrinterForSimpleApDisconnect);
        WiFiDirectManager.disconnectSimpleAP(getApplicationContext(), WiFiDirectManager.getCurSSID(this), this.mMyPrinterForSimpleApDisconnect);
    }

    public static Intent getStartIntent(Context context, String str, int i, String str2) {
        Intent intent = new Intent(context, ScanSearchActivity.class);
        intent.putExtra(PARAM_KEY_SCANNER_LOCATION, i);
        intent.putExtra(PARAM_KEY_SCANNER_ID, str);
        intent.putExtra(PARAM_KEY_SCANNER_SSID, str2);
        return intent;
    }

    private class FindScannerTask extends AsyncTask<Void, Void, Boolean> {
        private CancelableFind mCancelableFind = new CancelableFind();

        /* access modifiers changed from: protected */
        public void onCancelled(Boolean bool) {
        }

        FindScannerTask(escanLib escanlib) {
            this.mCancelableFind.setEscanLib(escanlib);
        }

        /* access modifiers changed from: protected */
        public Boolean doInBackground(Void... voidArr) {
            if (ScanSearchActivity.this.mScannerFindCancelRequested) {
                return true;
            }
            try {
                ScanSearchActivity.sEscanLibSemaphore.acquire();
                this.mCancelableFind.setEscanLib(ScanSearchActivity.this.mEscanLib);
                this.mCancelableFind.findScanner(ScanSearchActivity.this.getApplicationContext(), ScanSearchActivity.this.mHandler);
            } catch (InterruptedException unused) {
            } catch (Throwable th) {
                ScanSearchActivity.sEscanLibSemaphore.release();
                throw th;
            }
            ScanSearchActivity.sEscanLibSemaphore.release();
            return true;
        }

        /* access modifiers changed from: protected */
        public void onPostExecute(Boolean bool) {
            boolean unused = ScanSearchActivity.this.isFinishSearchScanner = true;
            if (!this.mCancelableFind.isCanceled() && !ScanSearchActivity.this.isSearchSimpleAp) {
                ScanSearchActivity.this.updateFindScannerResult();
            }
        }

        public void cancelFind() {
            this.mCancelableFind.cancel();
        }
    }

    private class GetScannerCapabilityAndFinishTask extends AsyncTask<Void, Void, Boolean> {
        private boolean mCancelRequested;
        private CancelablePropertyTaker mCancelablePropertyTaker;
        private EscanLibException mEscanErrorCode = null;
        private escanLib mEscanLib;
        private MyPrinter mMyPrinter;
        private ScannerPropertyWrapper mScannerPropertyWrapper;

        public GetScannerCapabilityAndFinishTask(escanLib escanlib, MyPrinter myPrinter) {
            this.mEscanLib = escanlib;
            this.mMyPrinter = myPrinter;
        }

        /* access modifiers changed from: protected */
        public Boolean doInBackground(Void... voidArr) {
            if (ScanSearchActivity.this.mActivityBackRequested) {
                return false;
            }
            try {
                ScanSearchActivity.sEscanLibSemaphore.acquire();
                if (!ScanSearchActivity.this.mActivityBackRequested) {
                    if (!this.mCancelRequested) {
                        synchronized (this) {
                            this.mCancelablePropertyTaker = new CancelablePropertyTaker(this.mEscanLib);
                        }
                        this.mScannerPropertyWrapper = this.mCancelablePropertyTaker.getScannerProperty(this.mMyPrinter);
                        if (!ScanSearchActivity.this.mActivityBackRequested) {
                            if (!this.mCancelRequested) {
                                if (this.mScannerPropertyWrapper == null) {
                                    this.mEscanErrorCode = new EscanLibException(1, -1300);
                                    ScanSearchActivity.this.disconnectSimpleAp();
                                    ScanSearchActivity.sEscanLibSemaphore.release();
                                    return false;
                                }
                                this.mEscanLib.escanWrapperReleaseDriver();
                                ScanSearchActivity.this.disconnectSimpleAp();
                                ScanSearchActivity.sEscanLibSemaphore.release();
                                return true;
                            }
                        }
                        ScanSearchActivity.this.disconnectSimpleAp();
                        ScanSearchActivity.sEscanLibSemaphore.release();
                        return false;
                    }
                }
                ScanSearchActivity.this.disconnectSimpleAp();
                ScanSearchActivity.sEscanLibSemaphore.release();
                return false;
            } catch (EscanLibException e) {
                try {
                    this.mEscanErrorCode = e;
                    return false;
                } finally {
                    ScanSearchActivity.this.disconnectSimpleAp();
                    ScanSearchActivity.sEscanLibSemaphore.release();
                }
            } catch (InterruptedException unused) {
            }
        }

        /* access modifiers changed from: protected */
        public void onPostExecute(Boolean bool) {
            EscanLibException escanLibException;
            if (!ScanSearchActivity.this.isFinishing()) {
                ScanSearchActivity.this.dismissProgress();
                if (!bool.booleanValue()) {
                    ScanSearchActivity.this.forceSetPrinterSearchEnd();
                    if (!this.mCancelRequested && (escanLibException = this.mEscanErrorCode) != null) {
                        ScanSearchActivity.this.showErrorDialog(escanLibException);
                        return;
                    }
                    return;
                }
                ScanSearchActivity.this.localFinish(this.mScannerPropertyWrapper);
            }
        }

        /* access modifiers changed from: protected */
        public void onPreExecute() {
            ScanSearchActivity.this.showProgress();
        }

        /* access modifiers changed from: package-private */
        public void cancelTask() {
            this.mCancelRequested = true;
            synchronized (this) {
                if (this.mCancelablePropertyTaker != null) {
                    this.mCancelablePropertyTaker.cancel();
                }
            }
        }
    }

    class CancelWaitTask extends AsyncTask<Void, Void, Void> {
        CancelWaitTask() {
        }

        /* access modifiers changed from: protected */
        public Void doInBackground(Void... voidArr) {
            try {
                ScanSearchActivity.sEscanLibSemaphore.acquire();
                ScanSearchActivity.this.disconnectSimpleAp();
                ScanSearchActivity.sEscanLibSemaphore.release();
                return null;
            } catch (InterruptedException unused) {
                return null;
            }
        }

        /* access modifiers changed from: protected */
        public void onPostExecute(Void voidR) {
            ScanSearchActivity.this.releaseAndFinish();
        }
    }
}
