package epson.maintain.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Point;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import android.support.p000v4.app.DialogFragment;
import android.support.p000v4.app.FragmentActivity;
import android.support.p000v4.content.ContextCompat;
import android.support.p000v4.view.ViewCompat;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
import com.epson.iprint.prtlogger.Analytics;
import com.epson.mobilephone.common.EpLog;
import com.epson.mobilephone.common.escpr.MediaInfo;
import com.epson.mobilephone.common.maintain2.BatteryInfoEx;
import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
import com.epson.mobilephone.common.maintain2.MaintainPrinterInfo2;
import com.epson.mobilephone.common.wifidirect.MacAddrUtils;
import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
import epson.common.Constants;
import epson.common.DialogProgress;
import epson.common.EventWrapper;
import epson.common.IPAddressUtils;
import epson.common.Utils;
import epson.epsonconnectregistration.ActivityECConfiguration;
import epson.maintain.BatteryInfoAdapter;
import epson.print.ActivityIACommon;
import epson.print.C2135R;
import epson.print.CommonDefine;
import epson.print.MyPrinter;
import epson.print.Util.AsyncTaskExecutor;
import epson.print.Util.EPLog;
import epson.print.inkrpln.InkRplnInfoClient;
import epson.print.inkrpln.InkRplnProgressDialog;
import epson.print.inkrpln.InkRplnRepository;
import epson.print.inkrpln.JumpUrlProgressActivity;
import epson.print.screen.WorkingDialog;
import epson.print.service.EpsonService;
import epson.print.service.IEpsonService;
import epson.print.service.IEpsonServiceCallback;
import java.util.Arrays;

public class MaintainActivity extends ActivityIACommon implements View.OnClickListener, MediaInfo {
    private static final int CANCEL_LOADCONFIG = 14;
    private static final int CLEANING_ERROR = 10;
    private static final int DELAY_TIME_MAINTAIN = 10;
    private static final String DIALOG_PROGRESS = "dialog_progress";
    private static final String DIALOG_TAG_NOZZLE_GUIDANCE = "dialog_nozzle_guidance";
    private static final int EC_BUTTON_HIDE = 2;
    private static final int EC_BUTTON_INVALID = 1;
    private static final int EC_BUTTON_VALID = 0;
    private static final int EPS_COMM_BID = 2;
    private static final int EPS_ERR_COMM_ERROR = -1100;
    private static final int EPS_LANG_ESCPR = 1;
    private static final int EPS_MNT_CLEANING = 2;
    private static final int EPS_MNT_NOZZLE = 3;
    private static final int EPS_PRNERR_CEMPTY = 103;
    private static final int EPS_PRNERR_CFAIL = 104;
    private static final int EPS_PRNERR_COMM = 102;
    private static final int EPS_PRNERR_DISABEL_CLEANING = 108;
    private static final int EPS_PRNERR_INKOUT = 6;
    private static final String[] GAGA_DEVICE_ID_ARRAY = {"LX-10000F", "LX-7000F", "WF-C20590 Series", "WF-C17590 Series", "LX-10000FK", "LX-10010MF", "WF-M20590 Series", "LX-10050KF", "LX-10050MF", "LX-6050MF", "LX-7550MF", "WF-C20600 Series", "WF-C20750 Series", "WF-C21000 Series"};
    private static final int GET_PRINTER_NAME = 8;
    private static final int HANDLE_ERROR = 4;
    public static final int ITEM_HEIGHT = 40;
    private static final int LOGIN_STATUS_COMM_ERROR = -1;
    private static final int LOGIN_STATUS_LOGIN_FAILED = -2;
    private static final int LOGIN_STATUS_LOGIN_SUCCEEDED = 0;
    private static final int MAINTAIN_OK = 1;
    private static final int MAINTAIN_START = 0;
    private static final int MAX_WAIT_CONNECTING_3G = 10;
    private static final int MESSAGE_MAINTENANCE_BOX_INFO = 16;
    private static final int NO_PRINTER_NAME = 9;
    private static final String PREFS_NAME = "PrintSetting";
    private static final int PROBE_ERROR = 7;
    private static final String PROBE_RESULT = "PROBE_ERROR";
    private static final int REQUEST_CODE_INK_DS_DIALOG = 100;
    private static final int REQUEST_CODE_SELECT_PRINTER = 101;
    private static final int START_LOADCONFIG = 6;
    private static final String TAG = "MAINTAIN";
    private static final int UPDATE_BATTERY = 15;
    private static final int UPDATE_INK = 3;
    private static final int UPDATE_MAINTENANCE_LABEL = 11;
    private static final int UPDATE_SELECTED_PRINTER = 5;
    private static final int UPDATE_STT = 2;
    private static boolean isMessageScreenShowing = false;
    private Switch btnToggleAlert;
    /* access modifiers changed from: private */
    public Switch btnTogglePreview;
    private Dialog customPro;
    /* access modifiers changed from: private */
    public int escprSetPrinterSuccessed = -1;
    /* access modifiers changed from: private */
    public boolean isGotError = false;
    /* access modifiers changed from: private */
    public boolean isKeepSimpleAPConnection = false;
    /* access modifiers changed from: private */
    public boolean isRemotePrinter = false;
    boolean isResearchScanner = false;
    /* access modifiers changed from: private */
    public boolean isTryConnectSimpleAp = false;
    private View mAlertMesseageSeparater;
    private LinearLayout mAlertMesseageView;
    private Thread mBackGround;
    private LinearLayout mBuyInkGroup;
    private int mBuyInkGroupVisibility;
    private View mBuyInkSeparator;
    private LinearLayout mBuyInkView;
    /* access modifiers changed from: private */
    public IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
        public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
        }

        public void onGetInkState() throws RemoteException {
        }

        public void onGetStatusState() throws RemoteException {
        }

        public void onNotifyContinueable(int i) throws RemoteException {
        }

        public void onNotifyEndJob(int i) throws RemoteException {
        }

        public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
        }

        public void onNotifyProgress(int i, int i2) throws RemoteException {
        }
    };
    private LinearLayout mCleanCheckView;
    private Context mContext = null;
    private Display mDisplay;
    private Thread mDoMaintainThread;
    private LinearLayout mEpsonConnectView;
    private ServiceConnection mEpsonConnection = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName componentName) {
            try {
                MaintainActivity.this.mEpsonService.unregisterCallback(MaintainActivity.this.mCallback);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            IEpsonService unused = MaintainActivity.this.mEpsonService = null;
        }

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IEpsonService unused = MaintainActivity.this.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
            if (MaintainActivity.this.mEpsonService != null) {
                try {
                    MaintainActivity.this.mEpsonService.registerCallback(MaintainActivity.this.mCallback);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    /* access modifiers changed from: private */
    public IEpsonService mEpsonService = null;
    private TextView mFWUpdateText;
    private LinearLayout mFWUpdateView;
    boolean mHavePrinter = false;
    private TextView mHeadCleanText;
    private LinearLayout mHeadCleanView;
    private LinearLayout mInkDsView;
    private LinearLayout mInkView;
    /* access modifiers changed from: private */
    public volatile boolean mIsCancelProbe = false;
    private Boolean mIsNozzleCheckEnable = true;
    /* access modifiers changed from: private */
    public volatile boolean mIsStillUpdate = true;
    boolean mIsStop = false;
    private LinearLayout mLLSerialNo;
    private View mLoadConPro;
    private Thread mLoadConfigThread;
    private TextView mMaintenanceBoxText;
    private LinearLayout mMaintenanceBoxView;
    private TextView mNozzleCheckText;
    private LinearLayout mNozzleCheckView;
    private View mOnlineRegistrationSeparator;
    private LinearLayout mOnlineRegistrationView;
    private View mPrintHistorySeparator;
    private LinearLayout mPrintHistoryView;
    private LinearLayout mPrintPreviewView;
    /* access modifiers changed from: private */
    public MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
    private View mPrinterSettingSeparator;
    private LinearLayout mPrinterSettingView;
    /* access modifiers changed from: private */
    public int[] mPrinterStatus;
    boolean mStartSearch = false;
    private TextView mTextMaintenance;
    /* access modifiers changed from: private */
    public TextView mTvPrinterName;
    private TextView mTvPrinterStatus;
    private TextView mTvPrinterStatusDetail;
    private TextView mTvSerialNo;
    /* access modifiers changed from: private */
    public Handler mUiHandler = new Handler(new Handler.Callback() {
        public boolean handleMessage(Message message) {
            switch (message.what) {
                case 0:
                    MaintainActivity.this.showProDia();
                    break;
                case 1:
                    EPLog.m313i("Maintain", "********Maintain finish********");
                    MaintainActivity.this.interrupMaintainThread();
                    MaintainActivity.this.cancelProDia();
                    break;
                case 2:
                    MaintainActivity.this.updateStatus(message.getData().getInt("GET_STT_RESULT"));
                    break;
                case 3:
                    MaintainActivity.this.updateInkInfo(message.getData().getInt("GET_INK_RESULT"));
                    break;
                case 4:
                    MaintainActivity.this.interrupMaintainThread();
                    break;
                case 5:
                    MaintainActivity.this.updateSelectedPrinter();
                    break;
                case 6:
                    MaintainActivity.this.showLoadProgressBar();
                    MaintainActivity.this.setButtonClickable(false);
                    MaintainActivity.this.setEpsonConnectButton(1);
                    break;
                case 7:
                    MaintainActivity.this.handlerError(message.getData().getInt(MaintainActivity.PROBE_RESULT), true);
                    break;
                case 8:
                    MaintainActivity.this.mTvPrinterName.setText(MaintainActivity.this.printerName);
                    switch (MaintainActivity.this.printerLocation) {
                        case 2:
                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_remote);
                            break;
                        case 3:
                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
                            ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_ip);
                            break;
                        default:
                            if (!MaintainActivity.this.printerName.equals("")) {
                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(0);
                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setImageResource(C2135R.C2136drawable.print_local);
                                break;
                            } else {
                                ((ImageView) MaintainActivity.this.findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(8);
                                break;
                            }
                    }
                case 9:
                    MaintainActivity.this.mUiHandler.sendEmptyMessage(11);
                    MaintainActivity.this.hideLoadProgressBar();
                    MaintainActivity.this.stopLoadConfigThread();
                    break;
                case 10:
                    MaintainActivity.this.setupErrorMessage(10);
                    MaintainActivity.this.interrupMaintainThread();
                    break;
                case 11:
                    MaintainActivity.this.updateButton();
                    break;
                case 14:
                    MaintainActivity.this.hideLoadProgressBar();
                    break;
                case 15:
                    MaintainActivity.this.updateBatteryInfoEx(message.getData().getInt("GET_BATTERY_RESULT"), (BatteryInfoEx) message.getData().getParcelable("GET_BATTERY_INFO"));
                    break;
                case 16:
                    MaintainActivity.this.updateMaintenanceBoxInfo((int[]) message.obj);
                    break;
            }
            return false;
        }
    });
    private View mVSerialSeparator;
    private boolean mWaiteInkDsDialog;
    private MaintainBuyInkOnlineRegTask modelBuyInkOnlineRegTask;
    /* access modifiers changed from: private */
    public String printerId = "";
    /* access modifiers changed from: private */
    public String printerIp = "";
    /* access modifiers changed from: private */
    public int printerLocation = 1;
    /* access modifiers changed from: private */
    public String printerName = "";
    /* access modifiers changed from: private */
    public int serverLoginStatus = -2;

    private static int calcInkWidth(int i, float f) {
        if (i <= 0) {
            i = 1;
        } else if (i > 100) {
            i = 100;
        }
        int i2 = (int) ((f / 100.0f) * ((float) i));
        if (i2 > 0) {
            return i2;
        }
        return 1;
    }

    private boolean isMaintenanceBoxStatusDisplayX(int i) {
        switch (i) {
            case -2:
            case -1:
                return true;
            default:
                return false;
        }
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        EpLog.m78i(TAG, "onCreate IN");
        super.onCreate(bundle);
        setContentView((int) C2135R.layout.maintain);
        this.mContext = this;
        this.mBuyInkGroupVisibility = 0;
        setActionBar((int) C2135R.string.str_maintenance, true);
        if (this.mEpsonService == null) {
            bindService(new Intent(this, EpsonService.class), this.mEpsonConnection, 1);
        }
        this.mDisplay = getWindowManager().getDefaultDisplay();
        findViewById(C2135R.C2137id.printer).setOnClickListener(this);
        this.mTvPrinterName = (TextView) findViewById(C2135R.C2137id.printer_name);
        this.mVSerialSeparator = findViewById(C2135R.C2137id.serial_separator);
        this.mLLSerialNo = (LinearLayout) findViewById(C2135R.C2137id.serial);
        this.mTvSerialNo = (TextView) findViewById(C2135R.C2137id.serial_no);
        this.mTvPrinterStatus = (TextView) findViewById(C2135R.C2137id.printer_status);
        this.mTvPrinterStatusDetail = (TextView) findViewById(C2135R.C2137id.printer_status_detail);
        this.mTextMaintenance = (TextView) findViewById(C2135R.C2137id.text_maintenance);
        this.mInkView = (LinearLayout) findViewById(C2135R.C2137id.ink_view_ln);
        this.mMaintenanceBoxText = (TextView) findViewById(C2135R.C2137id.maintenance_box_text);
        this.mMaintenanceBoxView = (LinearLayout) findViewById(C2135R.C2137id.maintenance_box_info_layout);
        this.mCleanCheckView = (LinearLayout) findViewById(C2135R.C2137id.clean_check);
        this.mHeadCleanView = (LinearLayout) findViewById(C2135R.C2137id.head_clean_view);
        this.mHeadCleanView.setOnClickListener(this);
        this.mHeadCleanText = (TextView) findViewById(C2135R.C2137id.head_clean_text);
        this.mNozzleCheckView = (LinearLayout) findViewById(C2135R.C2137id.nozzle_check_view);
        this.mNozzleCheckView.setOnClickListener(this);
        this.mNozzleCheckText = (TextView) findViewById(C2135R.C2137id.nozzle_check_text);
        this.mFWUpdateView = (LinearLayout) findViewById(C2135R.C2137id.fwupdate_view);
        this.mFWUpdateView.setOnClickListener(this);
        this.mFWUpdateText = (TextView) findViewById(C2135R.C2137id.fwupdate_text);
        this.btnTogglePreview = (Switch) findViewById(C2135R.C2137id.togglePreview);
        this.btnTogglePreview.setOnClickListener(this);
        this.btnToggleAlert = (Switch) findViewById(C2135R.C2137id.toggleAlert);
        this.btnToggleAlert.setOnClickListener(this);
        this.mPrinterSettingView = (LinearLayout) findViewById(C2135R.C2137id.printer_setting);
        this.mPrinterSettingView.setOnClickListener(this);
        this.mEpsonConnectView = (LinearLayout) findViewById(C2135R.C2137id.epsonconnect_option);
        this.mEpsonConnectView.setOnClickListener(this);
        this.mPrintHistoryView = (LinearLayout) findViewById(C2135R.C2137id.print_history);
        this.mPrintHistoryView.setOnClickListener(this);
        this.mOnlineRegistrationView = (LinearLayout) findViewById(C2135R.C2137id.online_registration);
        this.mOnlineRegistrationView.setOnClickListener(this);
        this.mBuyInkGroup = (LinearLayout) findViewById(C2135R.C2137id.mentenance_buy_ink_frame);
        this.mBuyInkView = (LinearLayout) findViewById(C2135R.C2137id.mentenance_buy_ink);
        this.mBuyInkView.setOnClickListener(this);
        this.mBuyInkSeparator = findViewById(C2135R.C2137id.buy_ink_separator);
        this.mInkDsView = (LinearLayout) findViewById(C2135R.C2137id.maintenance_inkds);
        this.mInkDsView.setOnClickListener(this);
        this.mPrintPreviewView = (LinearLayout) findViewById(C2135R.C2137id.print_preview);
        this.mAlertMesseageView = (LinearLayout) findViewById(C2135R.C2137id.alert_messeage);
        this.mPrinterSettingSeparator = findViewById(C2135R.C2137id.printer_setting_separator);
        this.mPrintHistorySeparator = findViewById(C2135R.C2137id.print_history_separator);
        this.mOnlineRegistrationSeparator = findViewById(C2135R.C2137id.online_registration_separator);
        this.mAlertMesseageSeparater = findViewById(C2135R.C2137id.comm_messeage_separator);
        this.mPrinterSettingView.setEnabled(false);
        ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
        ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
        this.mVSerialSeparator.setVisibility(8);
        this.mLLSerialNo.setVisibility(8);
        EpLog.m78i(TAG, "onCreate :: doInitDriver");
        this.mPrinter.doInitDriver(this, 2);
        this.isResearchScanner = Utils.getPrefBoolean(getApplicationContext(), Constants.SCAN_REFS_USED_SCANNER_PATH, Constants.SCAN_REFS_SETTINGS_RESEACH);
        if (MyPrinter.getCurPrinter(this).getName() == null) {
            startSelectPrinterActivity();
        }
        this.mWaiteInkDsDialog = false;
        this.modelBuyInkOnlineRegTask = (MaintainBuyInkOnlineRegTask) ViewModelProviders.m2of((FragmentActivity) this).get(MaintainBuyInkOnlineRegTask.class);
        this.modelBuyInkOnlineRegTask.getUriEvent().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                MaintainActivity.lambda$onCreate$0(MaintainActivity.this, (EventWrapper) obj);
            }
        });
    }

    public static /* synthetic */ void lambda$onCreate$0(MaintainActivity maintainActivity, EventWrapper eventWrapper) {
        if (!eventWrapper.hasBeenHandled()) {
            maintainActivity.dismissDialog(DIALOG_PROGRESS);
            maintainActivity.startActivity(new Intent("android.intent.action.VIEW", (Uri) eventWrapper.getEventContent()));
        }
    }

    private void startLoadConThread() {
        this.mIsCancelProbe = false;
        this.mLoadConfigThread = new Thread(new Runnable() {
            /* JADX WARNING: Code restructure failed: missing block: B:83:0x01e6, code lost:
                return;
             */
            /* Code decompiled incorrectly, please refer to instructions dump. */
            public synchronized void run() {
                /*
                    r8 = this;
                    monitor-enter(r8)
                    java.lang.String r0 = "MAINTAIN"
                    java.lang.String r1 = "new load Config thread"
                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r1 = 6
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    r0 = 500(0x1f4, double:2.47E-321)
                    java.lang.Thread.sleep(r0)     // Catch:{ InterruptedException -> 0x01e7 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    r0.loadConfig()     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r1 = 8
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r0 = r0.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
                    if (r0 == 0) goto L_0x0034
                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
                    monitor-exit(r8)
                    return
                L_0x0034:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r2 = epson.print.MyPrinter.isRemotePrinter(r2)     // Catch:{ all -> 0x01f0 }
                    boolean unused = r0.isRemotePrinter = r2     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r0 = r0.isRemotePrinter     // Catch:{ all -> 0x01f0 }
                    r2 = -1
                    r3 = 0
                    r4 = 1
                    if (r0 != r4) goto L_0x00ae
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    r1 = -2
                    int unused = r0.serverLoginStatus = r1     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    r0 = 0
                L_0x0051:
                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    epson.print.service.IEpsonService r5 = r5.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    if (r5 != 0) goto L_0x006b
                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    boolean r5 = r5.mIsCancelProbe     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    if (r5 != 0) goto L_0x006b
                    r5 = 100
                    java.lang.Thread.sleep(r5)     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    int r0 = r0 + r4
                    r5 = 10
                    if (r0 < r5) goto L_0x0051
                L_0x006b:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    epson.print.service.IEpsonService r0 = r0.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    if (r0 == 0) goto L_0x009e
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    epson.print.service.IEpsonService r0 = r0.mEpsonService     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    int r0 = r0.ensureLogin(r4)     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    if (r0 != 0) goto L_0x0085
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    int unused = r0.serverLoginStatus = r3     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    goto L_0x009e
                L_0x0085:
                    r3 = -1100(0xfffffffffffffbb4, float:NaN)
                    if (r0 != r3) goto L_0x008f
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    int unused = r0.serverLoginStatus = r2     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    goto L_0x009e
                L_0x008f:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    int unused = r0.serverLoginStatus = r1     // Catch:{ InterruptedException -> 0x009a, RemoteException -> 0x0095 }
                    goto L_0x009e
                L_0x0095:
                    r0 = move-exception
                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
                    goto L_0x009e
                L_0x009a:
                    r0 = move-exception
                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
                L_0x009e:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r1 = 11
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
                    monitor-exit(r8)
                    return
                L_0x00ae:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r0 = r0.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
                    if (r0 == 0) goto L_0x00bb
                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
                    monitor-exit(r8)
                    return
                L_0x00bb:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r0 = r0.printerId     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = ""
                    boolean r0 = r0.equals(r5)     // Catch:{ all -> 0x01f0 }
                    if (r0 != 0) goto L_0x01cf
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r0 = r0.printerName     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = ""
                    boolean r0 = r0.equals(r5)     // Catch:{ all -> 0x01f0 }
                    if (r0 != 0) goto L_0x01cf
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    int r0 = r0.printerLocation     // Catch:{ all -> 0x01f0 }
                    if (r0 != r4) goto L_0x0108
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = "printer"
                    boolean r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.isNeedConnect(r0, r5)     // Catch:{ all -> 0x01f0 }
                    if (r0 != 0) goto L_0x00ef
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean unused = r0.isTryConnectSimpleAp = r3     // Catch:{ all -> 0x01f0 }
                    goto L_0x0108
                L_0x00ef:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r0 = r0.isTryConnectSimpleAp     // Catch:{ all -> 0x01f0 }
                    if (r0 != 0) goto L_0x0108
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean unused = r0.isTryConnectSimpleAp = r4     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = "printer"
                    boolean r0 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.reconnect(r0, r5, r2)     // Catch:{ all -> 0x01f0 }
                    if (r0 == 0) goto L_0x0108
                    monitor-exit(r8)
                    return
                L_0x0108:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    java.lang.String r0 = "startLoadConThread"
                    java.lang.String r1 = "mPrinter.doProbePrinter"
                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r1 = r1.printerId     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = r5.printerIp     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    int r6 = r6.printerLocation     // Catch:{ all -> 0x01f0 }
                    r7 = 60
                    int r0 = r0.doProbePrinter(r7, r1, r5, r6)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    int unused = r1.escprSetPrinterSuccessed = r2     // Catch:{ all -> 0x01f0 }
                L_0x013b:
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    boolean r1 = r1.mIsCancelProbe     // Catch:{ InterruptedException -> 0x018e }
                    if (r1 != 0) goto L_0x0192
                    if (r0 != 0) goto L_0x0146
                    goto L_0x0192
                L_0x0146:
                    android.os.Message r1 = new android.os.Message     // Catch:{ InterruptedException -> 0x018e }
                    r1.<init>()     // Catch:{ InterruptedException -> 0x018e }
                    r2 = 7
                    r1.what = r2     // Catch:{ InterruptedException -> 0x018e }
                    android.os.Bundle r2 = new android.os.Bundle     // Catch:{ InterruptedException -> 0x018e }
                    r2.<init>()     // Catch:{ InterruptedException -> 0x018e }
                    java.lang.String r5 = "PROBE_ERROR"
                    r2.putInt(r5, r0)     // Catch:{ InterruptedException -> 0x018e }
                    r1.setData(r2)     // Catch:{ InterruptedException -> 0x018e }
                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    android.os.Handler r2 = r2.mUiHandler     // Catch:{ InterruptedException -> 0x018e }
                    r2.sendMessage(r1)     // Catch:{ InterruptedException -> 0x018e }
                    r1 = 4000(0xfa0, double:1.9763E-320)
                    java.lang.Thread.sleep(r1)     // Catch:{ InterruptedException -> 0x018e }
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    boolean r1 = r1.mIsCancelProbe     // Catch:{ InterruptedException -> 0x018e }
                    if (r1 != 0) goto L_0x013b
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r1.mPrinter     // Catch:{ InterruptedException -> 0x018e }
                    epson.maintain.activity.MaintainActivity r2 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    java.lang.String r2 = r2.printerId     // Catch:{ InterruptedException -> 0x018e }
                    epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    java.lang.String r5 = r5.printerIp     // Catch:{ InterruptedException -> 0x018e }
                    epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x018e }
                    int r6 = r6.printerLocation     // Catch:{ InterruptedException -> 0x018e }
                    int r0 = r1.doProbePrinter(r7, r2, r5, r6)     // Catch:{ InterruptedException -> 0x018e }
                    goto L_0x013b
                L_0x018e:
                    r1 = move-exception
                    r1.printStackTrace()     // Catch:{ all -> 0x01f0 }
                L_0x0192:
                    java.lang.String r1 = "MAINTAIN"
                    java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch:{ all -> 0x01f0 }
                    r2.<init>()     // Catch:{ all -> 0x01f0 }
                    java.lang.String r5 = "Probe Printer result: "
                    r2.append(r5)     // Catch:{ all -> 0x01f0 }
                    r2.append(r0)     // Catch:{ all -> 0x01f0 }
                    java.lang.String r2 = r2.toString()     // Catch:{ all -> 0x01f0 }
                    epson.print.Util.EPLog.m313i(r1, r2)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r1 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    boolean r1 = r1.mIsCancelProbe     // Catch:{ all -> 0x01f0 }
                    if (r1 != 0) goto L_0x01e5
                    if (r0 != 0) goto L_0x01e5
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter     // Catch:{ all -> 0x01f0 }
                    r0.setMSearchPos(r3)     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    int unused = r0.escprSetPrinterSuccessed = r3     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    r0.mHavePrinter = r4     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r1 = 5
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    goto L_0x01e5
                L_0x01cf:
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    r0.mHavePrinter = r3     // Catch:{ all -> 0x01f0 }
                    epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this     // Catch:{ all -> 0x01f0 }
                    android.os.Handler r0 = r0.mUiHandler     // Catch:{ all -> 0x01f0 }
                    r1 = 9
                    r0.sendEmptyMessage(r1)     // Catch:{ all -> 0x01f0 }
                    java.lang.String r0 = "MAINTAIN"
                    java.lang.String r1 = "not select printer"
                    epson.print.Util.EPLog.m313i(r0, r1)     // Catch:{ all -> 0x01f0 }
                L_0x01e5:
                    monitor-exit(r8)
                    return
                L_0x01e7:
                    r0 = move-exception
                    r0.printStackTrace()     // Catch:{ all -> 0x01f0 }
                    r8.hideLoadProgress()     // Catch:{ all -> 0x01f0 }
                    monitor-exit(r8)
                    return
                L_0x01f0:
                    r0 = move-exception
                    monitor-exit(r8)
                    throw r0
                */
                throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainActivity.C20151.run():void");
            }

            private void hideLoadProgress() {
                MaintainActivity.this.mUiHandler.sendEmptyMessage(14);
            }
        }, "load-config");
        this.mLoadConfigThread.start();
    }

    /* access modifiers changed from: private */
    public void updateButton() {
        switch (this.printerLocation) {
            case 0:
                this.mTvPrinterName.setText(getString(C2135R.string.str_lbl_title_scan));
                ((ImageView) findViewById(C2135R.C2137id.imageViewPrinterLocation)).setVisibility(8);
                this.mTvPrinterStatus.setText(C2135R.string.EPS_PRNERR_NOT_SELECTED_TITTLE);
                this.mTvPrinterStatusDetail.setText(C2135R.string.EPS_PRNERR_NOT_SELECTED);
                LinearLayout linearLayout = this.mInkView;
                if (linearLayout != null) {
                    linearLayout.removeAllViews();
                }
                this.mTextMaintenance.setVisibility(0);
                this.mCleanCheckView.setVisibility(0);
                this.mPrinterSettingView.setVisibility(0);
                this.mHeadCleanView.setEnabled(false);
                this.mNozzleCheckView.setEnabled(false);
                this.mFWUpdateView.setEnabled(false);
                this.mPrinterSettingView.setEnabled(false);
                ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
                localSetBuyInkGroupVisibility(8);
                this.mOnlineRegistrationSeparator.setVisibility(8);
                this.mOnlineRegistrationView.setVisibility(8);
                this.mPrinterSettingSeparator.setVisibility(8);
                this.mPrintPreviewView.setVisibility(8);
                this.mAlertMesseageSeparater.setVisibility(8);
                this.mAlertMesseageView.setVisibility(8);
                this.mPrintHistorySeparator.setVisibility(8);
                this.mPrintHistoryView.setVisibility(8);
                this.mMaintenanceBoxText.setVisibility(8);
                this.mMaintenanceBoxView.setVisibility(8);
                return;
            case 1:
                if (this.mPrinter.doGetLang() != 1) {
                    this.mTextMaintenance.setVisibility(8);
                    this.mCleanCheckView.setVisibility(8);
                    this.mOnlineRegistrationSeparator.setVisibility(8);
                    this.mOnlineRegistrationView.setVisibility(8);
                } else {
                    this.mTextMaintenance.setVisibility(0);
                    this.mCleanCheckView.setVisibility(0);
                    this.mOnlineRegistrationSeparator.setVisibility(0);
                    this.mOnlineRegistrationView.setVisibility(0);
                    this.mOnlineRegistrationView.setEnabled(true);
                }
                updateBuyInkGroupForLocalOrIPPrinter();
                this.mPrinterSettingView.setVisibility(0);
                this.mPrinterSettingSeparator.setVisibility(8);
                this.mPrintPreviewView.setVisibility(8);
                this.mAlertMesseageSeparater.setVisibility(8);
                this.mAlertMesseageView.setVisibility(8);
                this.mPrintHistorySeparator.setVisibility(8);
                this.mPrintHistoryView.setVisibility(8);
                if (this.escprSetPrinterSuccessed == 0) {
                    this.mHeadCleanView.setEnabled(true);
                    this.mNozzleCheckView.setEnabled(true);
                    this.mFWUpdateView.setEnabled(true);
                    this.mPrinterSettingView.setEnabled(true);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
                    setEpsonConnectButton(0);
                } else {
                    this.mHeadCleanView.setEnabled(false);
                    this.mNozzleCheckView.setEnabled(false);
                    this.mFWUpdateView.setEnabled(false);
                    this.mPrinterSettingView.setEnabled(false);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
                    setEpsonConnectButton(1);
                }
                if (MyPrinter.PRINTER_USB.equals(this.printerIp)) {
                    this.mFWUpdateView.setVisibility(8);
                    this.mPrinterSettingSeparator.setVisibility(8);
                    this.mPrinterSettingView.setVisibility(8);
                    return;
                }
                return;
            case 2:
                localSetBuyInkGroupVisibility(0);
                this.mBuyInkView.setVisibility(0);
                this.mPrinterSettingSeparator.setVisibility(0);
                this.mPrinterSettingView.setVisibility(0);
                this.mPrintPreviewView.setVisibility(0);
                this.mAlertMesseageSeparater.setVisibility(0);
                this.mAlertMesseageView.setVisibility(0);
                this.mPrintHistorySeparator.setVisibility(0);
                this.mPrintHistoryView.setVisibility(0);
                setEpsonConnectButton(2);
                LinearLayout linearLayout2 = this.mInkView;
                if (linearLayout2 != null) {
                    linearLayout2.removeAllViews();
                }
                TextView textView = new TextView(this.mContext);
                textView.setTextColor(getResources().getColor(C2135R.color.black));
                textView.setTextSize(16.0f);
                textView.setText(getString(C2135R.string.epsonconnect_str_status_inkinfo_error));
                this.mInkView.addView(textView);
                SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0);
                boolean z = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
                boolean z2 = sharedPreferences.getBoolean(Constants.ENABLE_SHOW_WARNING, true);
                if (z) {
                    this.btnTogglePreview.setChecked(true);
                } else {
                    this.btnTogglePreview.setChecked(false);
                }
                if (z2) {
                    this.btnToggleAlert.setChecked(true);
                } else {
                    this.btnToggleAlert.setChecked(false);
                }
                BatteryInfoAdapter.BatteryInfoManager.clearBatteryList(this);
                this.mTextMaintenance.setVisibility(8);
                this.mCleanCheckView.setVisibility(8);
                this.mOnlineRegistrationSeparator.setVisibility(8);
                this.mOnlineRegistrationView.setVisibility(8);
                this.mMaintenanceBoxText.setVisibility(8);
                this.mMaintenanceBoxView.setVisibility(8);
                int i = this.serverLoginStatus;
                if (i == 0) {
                    this.mTvPrinterStatus.setText(getString(C2135R.string.EPS_PRNST_IDLE_TITLE));
                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.EPS_PRNST_IDLE_MSG));
                    this.mPrintHistoryView.setEnabled(true);
                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(0);
                    this.mPrinterSettingView.setEnabled(true);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
                    return;
                } else if (i == -1) {
                    this.mTvPrinterStatus.setText(getString(C2135R.string.EC_ERR_COMM_ERROR_TITLE));
                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.EC_ERR_COMM_ERROR));
                    this.mPrintHistoryView.setEnabled(false);
                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(8);
                    this.mPrinterSettingView.setEnabled(false);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
                    return;
                } else {
                    this.mTvPrinterStatus.setText(C2135R.string.epsonconnect_str_status_login_error_title);
                    this.mTvPrinterStatusDetail.setText(getString(C2135R.string.epsonconnect_str_status_login_error));
                    this.mPrintHistoryView.setEnabled(false);
                    ((TextView) findViewById(C2135R.C2137id.text_print_history)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                    ((ImageView) findViewById(C2135R.C2137id.print_history_arrow)).setVisibility(8);
                    this.mPrinterSettingView.setEnabled(false);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
                    return;
                }
            case 3:
                if (this.mPrinter.doGetLang() != 1) {
                    this.mTextMaintenance.setVisibility(8);
                    this.mCleanCheckView.setVisibility(8);
                } else {
                    this.mTextMaintenance.setVisibility(0);
                    this.mCleanCheckView.setVisibility(0);
                }
                updateBuyInkGroupForLocalOrIPPrinter();
                this.mPrinterSettingView.setVisibility(0);
                this.mPrinterSettingSeparator.setVisibility(8);
                this.mPrintPreviewView.setVisibility(8);
                this.mAlertMesseageSeparater.setVisibility(8);
                this.mAlertMesseageView.setVisibility(8);
                this.mPrintHistorySeparator.setVisibility(8);
                this.mPrintHistoryView.setVisibility(8);
                this.mOnlineRegistrationSeparator.setVisibility(8);
                this.mOnlineRegistrationView.setVisibility(8);
                if (this.escprSetPrinterSuccessed == 0) {
                    this.mHeadCleanView.setEnabled(true);
                    this.mNozzleCheckView.setEnabled(true);
                    this.mPrinterSettingView.setEnabled(true);
                    ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
                    ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(0);
                    setEpsonConnectButton(0);
                    return;
                }
                this.mHeadCleanView.setEnabled(false);
                this.mNozzleCheckView.setEnabled(false);
                this.mPrinterSettingView.setEnabled(false);
                ((TextView) findViewById(C2135R.C2137id.text_printer_setting)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                ((ImageView) findViewById(C2135R.C2137id.printer_setting_arrow)).setVisibility(8);
                setEpsonConnectButton(1);
                return;
            default:
                return;
        }
    }

    private void localSetBuyInkGroupVisibility(int i) {
        this.mBuyInkGroup.setVisibility(i);
        this.mBuyInkGroupVisibility = i;
    }

    private void updateBuyInkGroupForLocalOrIPPrinter() {
        int i;
        int i2;
        int i3;
        int i4 = 0;
        InkRplnInfoClient.InkRsInfo info = new InkRplnRepository(false).getInfo(this);
        if (info != null) {
            i = info.getButtonType();
        } else {
            i = 0;
        }
        int i5 = 8;
        switch (i) {
            case 1:
                i3 = 0;
                i2 = 8;
                break;
            case 2:
                i3 = 0;
                i5 = 0;
                i2 = 0;
                break;
            case 3:
                i3 = 8;
                i4 = 8;
                i2 = 8;
                break;
            default:
                i3 = 8;
                i5 = 0;
                i2 = 8;
                break;
        }
        localSetBuyInkGroupVisibility(i4);
        this.mBuyInkView.setVisibility(i5);
        this.mInkDsView.setVisibility(i3);
        this.mBuyInkSeparator.setVisibility(i2);
    }

    /* access modifiers changed from: private */
    public void setupErrorMessage(int i) {
        Utils.makeMessageBox(this, getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_TITLE), getString(C2135R.string.EPS_PRNERR_DISABEL_CLEANING_MSG), getString(C2135R.string.str_cancel)).show();
    }

    public void onClick(View view) {
        int id = view.getId();
        int i = C2135R.string.str_nozzle_check;
        switch (id) {
            case C2135R.C2137id.epsonconnect_option /*2131231020*/:
                Intent intent = new Intent(this, ActivityECConfiguration.class);
                intent.putExtra(ActivityECConfiguration.INTENT_EC_BLE_CONTENT, false);
                startActivity(intent);
                return;
            case C2135R.C2137id.fwupdate_view /*2131231071*/:
                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_FIRMWARE_UPDATE);
                Intent intent2 = new Intent(this, FirmwareUpdateActivity.class);
                intent2.putExtra(Constants.PRINTER_IP, this.printerIp);
                intent2.putExtra("PRINTER_MODEL_NAME", this.printerName);
                this.isKeepSimpleAPConnection = true;
                startActivity(intent2);
                return;
            case C2135R.C2137id.head_clean_view /*2131231097*/:
                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_HEAD_CLEANING);
                AlertDialog.Builder icon = new AlertDialog.Builder(this).setIcon(C2135R.C2136drawable.ic_action_warning);
                if (view.getId() != C2135R.C2137id.nozzle_check_view) {
                    i = C2135R.string.str_head_clean;
                }
                icon.setTitle(i).setPositiveButton(C2135R.string.str_yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        MaintainActivity.this.performMaintain(2);
                    }
                }).setNegativeButton(C2135R.string.str_no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).show();
                return;
            case C2135R.C2137id.maintenance_inkds /*2131231241*/:
                Analytics.sendAction(this, Analytics.ACTION_ID_MAINTENANCE_READY_INK);
                startBrowsReadyInkUrl();
                return;
            case C2135R.C2137id.mentenance_buy_ink /*2131231247*/:
                Analytics.sendAction(this, Analytics.ACTION_ID_MAINTENANCE_BUY_INK);
                showDialog(DIALOG_PROGRESS);
                BuyInkTask(1, this.printerIp);
                return;
            case C2135R.C2137id.nozzle_check_view /*2131231280*/:
                Analytics.sendAction(getApplicationContext(), Analytics.ACTION_ID_MAINTENANCE_NOZZLE_CHECK);
                AlertDialog.Builder icon2 = new AlertDialog.Builder(this).setIcon(C2135R.C2136drawable.ic_action_warning);
                if (view.getId() != C2135R.C2137id.nozzle_check_view) {
                    i = C2135R.string.str_head_clean;
                }
                icon2.setTitle(i).setPositiveButton(C2135R.string.str_yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                        new NozzleCheckTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
                    }
                }).setNegativeButton(C2135R.string.str_no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).show();
                return;
            case C2135R.C2137id.online_registration /*2131231289*/:
                showDialog(DIALOG_PROGRESS);
                OnlineRegTask(this.printerIp);
                return;
            case C2135R.C2137id.print_history /*2131231348*/:
                startActivity(new Intent(this, EccPrintLog.class));
                return;
            case C2135R.C2137id.printer /*2131231358*/:
                EPLog.m305d(TAG, "onClick() R.id.printer");
                new AsyncTask<Void, Void, Void>() {
                    WorkingDialog dialog = new WorkingDialog(MaintainActivity.this);

                    /* access modifiers changed from: protected */
                    public void onPreExecute() {
                        super.onPreExecute();
                        MaintainActivity.this.hideLoadProgressBar();
                        this.dialog.show();
                    }

                    /* access modifiers changed from: protected */
                    public Void doInBackground(Void... voidArr) {
                        MaintainActivity.this.stopLoadConfigThread();
                        MaintainActivity.this.endBackGroundThread();
                        MaintainActivity maintainActivity = MaintainActivity.this;
                        WiFiDirectManager.disconnect(maintainActivity, WiFiDirectManager.DEVICE_TYPE_PRINTER, maintainActivity.printerIp);
                        return null;
                    }

                    /* access modifiers changed from: protected */
                    public void onPostExecute(Void voidR) {
                        MaintainActivity.this.startSelectPrinterActivity();
                        this.dialog.dismiss();
                    }
                }.execute(new Void[0]);
                return;
            case C2135R.C2137id.printer_setting /*2131231369*/:
                switch (this.printerLocation) {
                    case 1:
                    case 3:
                        if (!WiFiDirectManager.isSimpleAP(this) || this.isKeepSimpleAPConnection) {
                            this.printerIp = this.mPrinter.doGetIp();
                            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(IPAddressUtils.buildURL(Analytics.EXTENSION_STRING_WEB, this.printerIp, CommonDefine.SLASH))));
                            return;
                        }
                        new AlertDialog.Builder(this.mContext).setCancelable(false).setMessage(C2135R.string.str_webconfig_warn_message).setPositiveButton(C2135R.string.str_ok, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
                                boolean unused = MaintainActivity.this.isKeepSimpleAPConnection = true;
                                MaintainActivity maintainActivity = MaintainActivity.this;
                                String unused2 = maintainActivity.printerIp = maintainActivity.mPrinter.doGetIp();
                                MaintainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(CommonDefine.HTTP_PREFIX + MaintainActivity.this.printerIp + CommonDefine.SLASH)));
                            }
                        }).create().show();
                        return;
                    case 2:
                        startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.epsonconnect.com/user/")));
                        return;
                    default:
                        return;
                }
            case C2135R.C2137id.toggleAlert /*2131231560*/:
                if (this.btnToggleAlert.isChecked()) {
                    SharedPreferences.Editor edit = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
                    edit.putBoolean(Constants.ENABLE_SHOW_WARNING, true);
                    edit.commit();
                    return;
                }
                SharedPreferences.Editor edit2 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
                edit2.putBoolean(Constants.ENABLE_SHOW_WARNING, false);
                edit2.commit();
                return;
            case C2135R.C2137id.togglePreview /*2131231563*/:
                if (!this.btnTogglePreview.isChecked()) {
                    SharedPreferences.Editor edit3 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
                    edit3.putBoolean(Constants.ENABLE_SHOW_PREVIEW, false);
                    edit3.commit();
                    return;
                } else if (!isMessageScreenShowing) {
                    showMessageDialog();
                    return;
                } else {
                    SharedPreferences.Editor edit4 = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
                    edit4.putBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
                    edit4.commit();
                    return;
                }
            default:
                return;
        }
    }

    /* access modifiers changed from: private */
    public void startSelectPrinterActivity() {
        this.mWaiteInkDsDialog = true;
        Intent intent = new Intent(this, MaintainPrinterSearchActivity.class);
        intent.putExtra(Constants.PRINTER_ID, this.printerId);
        intent.setAction("android.intent.action.VIEW");
        startActivityForResult(intent, 101);
    }

    private void startBrowsReadyInkUrl() {
        startActivity(new Intent(this, JumpUrlProgressActivity.class));
    }

    /* access modifiers changed from: private */
    public void showNozzleCheckGuidanceDialog() {
        if (!checkGaga()) {
            new NozzleGuidanceDialog().show(getSupportFragmentManager(), DIALOG_TAG_NOZZLE_GUIDANCE);
        }
    }

    private boolean checkGaga() {
        String printerDeviceId = MyPrinter.getPrinterDeviceId(this, false);
        if (printerDeviceId == null) {
            return false;
        }
        return Arrays.asList(GAGA_DEVICE_ID_ARRAY).contains(printerDeviceId);
    }

    private void showMessageDialog() {
        isMessageScreenShowing = true;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(C2135R.string.epsonconnect_str_preview_warning) + "\n\n" + getString(C2135R.string.epsonconnect_str_preview_warning2));
        C20299 r1 = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                SharedPreferences.Editor edit = MaintainActivity.this.getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).edit();
                edit.putBoolean(Constants.ENABLE_SHOW_PREVIEW, true);
                edit.commit();
            }
        };
        C201610 r2 = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                MaintainActivity.this.btnTogglePreview.setChecked(false);
            }
        };
        builder.setPositiveButton(C2135R.string.str_yes, r1);
        builder.setNegativeButton(C2135R.string.str_no, r2);
        builder.setCancelable(false);
        builder.show();
        isMessageScreenShowing = false;
    }

    /* access modifiers changed from: private */
    public void showProDia() {
        if (this.customPro == null) {
            this.customPro = new CustomProDialog(this, C2135R.style.AppTheme_Translucent, C2135R.layout.maintain_executing_dialog);
        }
        this.customPro.show();
    }

    /* access modifiers changed from: private */
    public void cancelProDia() {
        Dialog dialog = this.customPro;
        if (dialog != null && dialog.isShowing()) {
            this.customPro.cancel();
            this.customPro = null;
        }
    }

    /* access modifiers changed from: private */
    public void showLoadProgressBar() {
        if (this.mLoadConPro == null) {
            this.mLoadConPro = findViewById(C2135R.C2137id.progress_status);
        }
        this.mLoadConPro.setVisibility(0);
    }

    /* access modifiers changed from: private */
    public void hideLoadProgressBar() {
        View view = this.mLoadConPro;
        if (view != null) {
            view.setVisibility(8);
        }
    }

    /* access modifiers changed from: private */
    public void stopLoadConfigThread() {
        this.mIsCancelProbe = true;
        Thread thread = this.mLoadConfigThread;
        if (thread != null && thread.isAlive()) {
            this.mPrinter.doCancelFindPrinter();
            if (this.mEpsonService != null) {
                new AsyncTaskExecutor<Void, Void, Void>() {
                    /* access modifiers changed from: protected */
                    public Void doInBackground(Void... voidArr) {
                        try {
                            MaintainActivity.this.mEpsonService.EpsonConnectCancel();
                            return null;
                        } catch (RemoteException e) {
                            e.printStackTrace();
                            return null;
                        }
                    }
                }.executeOnExecutor(new Void[0]);
            }
            this.mLoadConfigThread.interrupt();
            this.mLoadConfigThread = null;
        }
    }

    private void startBackgroundThread() {
        this.mIsStillUpdate = true;
        this.mBackGround = new Thread(new Runnable() {
            public void run() {
                int doGetStatus = MaintainActivity.this.mPrinter.doGetStatus();
                Message message = new Message();
                message.what = 2;
                Bundle bundle = new Bundle();
                bundle.putInt("GET_STT_RESULT", doGetStatus);
                message.setData(bundle);
                MaintainActivity.this.mUiHandler.sendMessage(message);
                int doGetInkInfo = MaintainActivity.this.mPrinter.doGetInkInfo();
                Message message2 = new Message();
                message2.what = 3;
                Bundle bundle2 = new Bundle();
                bundle2.putInt("GET_INK_RESULT", doGetInkInfo);
                message2.setData(bundle2);
                MaintainActivity.this.mUiHandler.sendMessage(message2);
                BatteryInfoEx batteryInfoEx = new BatteryInfoEx();
                int batteryInfo = MaintainActivity.this.mPrinter.getBatteryInfo(batteryInfoEx);
                boolean z = batteryInfo == 0 && batteryInfoEx.powerSourceType != -1;
                Message message3 = new Message();
                message3.what = 15;
                Bundle bundle3 = new Bundle();
                bundle3.putInt("GET_BATTERY_RESULT", batteryInfo);
                bundle3.putParcelable("GET_BATTERY_INFO", batteryInfoEx);
                message3.setData(bundle3);
                MaintainActivity.this.mUiHandler.sendMessage(message3);
                int[] maintenanceBoxInformation = MaintainActivity.this.mPrinter.getMaintenanceBoxInformation();
                MaintainActivity maintainActivity = MaintainActivity.this;
                maintainActivity.sendMaintenanceBoxInfoMessage(maintainActivity.mUiHandler, maintenanceBoxInformation);
                while (MaintainActivity.this.mIsStillUpdate) {
                    try {
                        EPLog.m313i(MaintainActivity.TAG, "thread update stt running");
                        int doGetStatus2 = MaintainActivity.this.mPrinter.doGetStatus();
                        Message message4 = new Message();
                        message4.what = 2;
                        bundle3.putInt("GET_STT_RESULT", doGetStatus2);
                        Bundle bundle4 = new Bundle();
                        message4.setData(bundle4);
                        MaintainActivity.this.mUiHandler.sendMessage(message4);
                        if (z) {
                            int batteryInfo2 = MaintainActivity.this.mPrinter.getBatteryInfo(batteryInfoEx);
                            Message message5 = new Message();
                            message5.what = 15;
                            bundle3 = new Bundle();
                            bundle3.putInt("GET_BATTERY_RESULT", batteryInfo2);
                            bundle3.putParcelable("GET_BATTERY_INFO", batteryInfoEx);
                            message5.setData(bundle3);
                            MaintainActivity.this.mUiHandler.sendMessage(message5);
                        } else {
                            bundle3 = bundle4;
                        }
                        MaintainActivity.this.sendMaintenanceBoxInfoMessage(MaintainActivity.this.mUiHandler, MaintainActivity.this.mPrinter.getMaintenanceBoxInformation());
                        Thread.sleep(4000);
                    } catch (InterruptedException e) {
                        EPLog.m318w("startBackgroundThread", "InterruptedException");
                        e.printStackTrace();
                        return;
                    }
                }
            }
        }, "status-update");
        this.mBackGround.setPriority(5);
        this.mBackGround.start();
    }

    /* access modifiers changed from: private */
    public void sendMaintenanceBoxInfoMessage(Handler handler, int[] iArr) {
        this.mUiHandler.removeMessages(16);
        handler.sendMessage(handler.obtainMessage(16, 0, 0, iArr));
    }

    /* access modifiers changed from: private */
    public void endBackGroundThread() {
        this.mIsStillUpdate = false;
        Thread thread = this.mBackGround;
        if (thread != null && thread.isAlive()) {
            this.mBackGround.interrupt();
            try {
                this.mBackGround.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            this.mBackGround = null;
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
    }

    /* access modifiers changed from: protected */
    public void onActivityResult(int i, int i2, Intent intent) {
        IEpsonService iEpsonService;
        super.onActivityResult(i, i2, intent);
        switch (i) {
            case 100:
                onInkReplenishDialogEnd();
                return;
            case 101:
                MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
                if (curPrinter.getName() == null) {
                    finish();
                    return;
                } else if (i2 == 1) {
                    if (MyPrinter.isRemotePrinter(getApplicationContext()) && (iEpsonService = this.mEpsonService) != null) {
                        try {
                            iEpsonService.refreshRemotePrinterLogin();
                        } catch (RemoteException unused) {
                        }
                    }
                    if (!isSimpleApOrP2p(curPrinter)) {
                        startInkDsDialog();
                        return;
                    } else {
                        onInkReplenishDialogEnd();
                        return;
                    }
                } else {
                    onInkReplenishDialogEnd();
                    return;
                }
            default:
                return;
        }
    }

    private boolean isSimpleApOrP2p(MyPrinter myPrinter) {
        return WiFiDirectManager.getCurConnectInfo(this, MacAddrUtils.getMacAddressFromPrinterId(myPrinter.getPrinterId())) != null;
    }

    private void onInkReplenishDialogEnd() {
        this.mWaiteInkDsDialog = false;
    }

    private void startInkDsDialog() {
        startActivityForResult(InkRplnProgressDialog.getStartIntent(this), 100);
    }

    /* access modifiers changed from: private */
    public void updateSelectedPrinter() {
        hideLoadProgressBar();
        stopLoadConfigThread();
        this.mIsNozzleCheckEnable = true;
        this.escprSetPrinterSuccessed = this.mPrinter.doSetPrinter();
        int i = this.escprSetPrinterSuccessed;
        int i2 = 0;
        if (i == 0) {
            startBackgroundThread();
            this.mIsStillUpdate = true;
            setButtonClickable(true);
        } else {
            this.mIsStillUpdate = false;
            handlerError(i, false);
        }
        if (this.mPrinter.doGetLang() != 1) {
            this.mHeadCleanView.setVisibility(8);
            this.mNozzleCheckView.setVisibility(8);
            this.mFWUpdateView.setVisibility(8);
        } else {
            this.mHeadCleanView.setVisibility(0);
            this.mNozzleCheckView.setVisibility(0);
            LinearLayout linearLayout = this.mFWUpdateView;
            if (this.printerLocation != 1) {
                i2 = 8;
            }
            linearLayout.setVisibility(i2);
        }
        this.printerIp = this.mPrinter.doGetIp();
    }

    /* access modifiers changed from: private */
    public synchronized void updateStatus(int i) {
        this.mUiHandler.sendEmptyMessage(11);
        if (i == 0) {
            if (isPrinterReady() != 1) {
                setButtonClickable(false);
            } else {
                setButtonClickable(true);
                int doGetInkInfo = this.mPrinter.doGetInkInfo();
                Message message = new Message();
                message.what = 3;
                Bundle bundle = new Bundle();
                bundle.putInt("GET_INK_RESULT", doGetInkInfo);
                message.setData(bundle);
                this.mUiHandler.sendMessage(message);
            }
            if (this.mPrinterStatus[0] == 4) {
                if (this.mPrinterStatus[1] == 102) {
                    this.escprSetPrinterSuccessed = -1;
                } else {
                    this.escprSetPrinterSuccessed = 0;
                }
                if (this.isRemotePrinter && this.mPrinterStatus[1] == 102) {
                    this.mUiHandler.sendEmptyMessage(11);
                } else {
                    setErrorStatus(this.mPrinterStatus[0], this.mPrinterStatus[1]);
                    if (this.mPrinterStatus[1] == 102) {
                        this.mInkView.removeAllViews();
                    }
                    if (this.mPrinterStatus[1] == 6 || this.mPrinterStatus[1] == 103 || this.mPrinterStatus[1] == 104) {
                        int doGetInkInfo2 = this.mPrinter.doGetInkInfo();
                        Message message2 = new Message();
                        message2.what = 3;
                        Bundle bundle2 = new Bundle();
                        bundle2.putInt("GET_INK_RESULT", doGetInkInfo2);
                        message2.setData(bundle2);
                        this.mUiHandler.sendMessage(message2);
                    }
                }
            } else {
                this.escprSetPrinterSuccessed = 0;
                Integer[] stringId = MediaInfo.StatusTable.getStringId(this.mPrinterStatus[0]);
                if (stringId != null) {
                    this.mTvPrinterStatus.setText(getString(stringId[0].intValue()));
                    this.mTvPrinterStatusDetail.setText(getString(stringId[1].intValue()));
                } else {
                    TextView textView = this.mTvPrinterStatus;
                    textView.setText("Stt Code: " + this.mPrinterStatus[0]);
                    TextView textView2 = this.mTvPrinterStatusDetail;
                    textView2.setText("Err Code: " + this.mPrinterStatus[1]);
                }
            }
        } else {
            handlerError(i, false);
        }
    }

    public void updateInkInfo(int i) {
        createInkView(this.mPrinter.getMPrinterInfor(), i);
    }

    /* access modifiers changed from: private */
    public void updateBatteryInfoEx(int i, BatteryInfoEx batteryInfoEx) {
        int i2 = batteryInfoEx.number;
        int i3 = batteryInfoEx.powerSourceType;
        if (i != 0 || i2 <= 0 || i3 == -1) {
            BatteryInfoAdapter.BatteryInfoManager.clearBatteryList(this);
            return;
        }
        int[] iArr = batteryInfoEx.batteryState;
        int[] iArr2 = batteryInfoEx.batteryRemain;
        BatteryInfoAdapter.BatteryInfoManager.showPowerText(this);
        BatteryInfoAdapter.BatteryInfoManager.showBatteryList(this, i2, i3, iArr, iArr2);
    }

    /* access modifiers changed from: private */
    public void updateMaintenanceBoxInfo(int[] iArr) {
        int i = this.mBuyInkGroupVisibility;
        if (iArr == null || iArr.length <= 0) {
            this.mMaintenanceBoxText.setVisibility(8);
            this.mMaintenanceBoxView.setVisibility(8);
            if (8 != this.mInkView.getVisibility()) {
                int i2 = this.mBuyInkGroupVisibility;
                return;
            }
            return;
        }
        this.mMaintenanceBoxText.setVisibility(0);
        this.mMaintenanceBoxView.setVisibility(0);
        this.mBuyInkGroup.setVisibility(i);
        LayoutInflater from = LayoutInflater.from(this);
        Point point = new Point();
        this.mDisplay.getSize(point);
        int i3 = (point.x - 30) / 2;
        this.mMaintenanceBoxView.removeAllViews();
        int length = iArr.length / 2;
        for (int i4 = 0; i4 < length; i4++) {
            int i5 = i4 * 2;
            int i6 = iArr[i5];
            int i7 = iArr[i5 + 1];
            View inflate = from.inflate(C2135R.layout.ink_item, this.mMaintenanceBoxView, false);
            ((TextView) inflate.findViewById(C2135R.C2137id.ink_name)).setVisibility(8);
            ((RelativeLayout) inflate.findViewById(C2135R.C2137id.ink_holder)).getLayoutParams().width = i3;
            ViewGroup viewGroup = (ViewGroup) inflate.findViewById(C2135R.C2137id.ink_level);
            if (i7 <= 0 || isMaintenanceBoxStatusDisplayX(i6)) {
                viewGroup.getLayoutParams().width = 0;
                inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
                viewGroup.setVisibility(4);
            } else {
                viewGroup.getLayoutParams().width = (int) ((((float) (i3 - 4)) / 100.0f) * ((float) i7));
                viewGroup.setBackgroundResource(C2135R.color.maintenance_box_info);
                viewGroup.setVisibility(0);
            }
            this.mMaintenanceBoxView.addView(inflate);
        }
    }

    /* access modifiers changed from: private */
    public void handlerError(int i, boolean z) {
        hideLoadProgressBar();
        if (i == -1351 || i == -1100) {
            i = -1300;
        }
        if (this.isRemotePrinter && i == -1300) {
            setButtonClickable(false);
            this.mUiHandler.sendEmptyMessage(11);
            return;
        }
        setErrorStatus(4, i);
        setButtonClickable(false);
        this.mUiHandler.sendEmptyMessage(11);
        if (!z) {
            return;
        }
        if (i == -1300 || i == -500001) {
            this.mInkView.removeAllViews();
        }
    }

    private void setErrorStatus(int i, int i2) {
        Integer[] stringId = MediaInfo.ErrorTable.getStringId(i2);
        if (stringId != null) {
            String[] replaceMessage = Utils.replaceMessage(stringId, i2, getApplicationContext());
            this.mTvPrinterStatus.setText(replaceMessage[1]);
            EPLog.m313i(TAG, "Stt title: " + replaceMessage[1]);
            String str = replaceMessage[0];
            this.mTvPrinterStatusDetail.setText(str);
            EPLog.m313i(TAG, "Stt detail: " + str);
            return;
        }
        TextView textView = this.mTvPrinterStatus;
        textView.setText("Stt Code: " + i);
        TextView textView2 = this.mTvPrinterStatusDetail;
        textView2.setText("Err Code: " + i2);
    }

    private int isPrinterReady() {
        this.mPrinterStatus = this.mPrinter.getMPrinterInfor().getMStatus();
        int[] iArr = this.mPrinterStatus;
        if (iArr[0] == 2 || iArr[0] == 1 || iArr[0] == 3) {
            return 0;
        }
        if (iArr[0] == 4) {
            return -1;
        }
        return 1;
    }

    /* access modifiers changed from: private */
    public void interrupMaintainThread() {
        Thread thread = this.mDoMaintainThread;
        if (thread != null && thread.isAlive()) {
            this.mDoMaintainThread.interrupt();
            this.mDoMaintainThread = null;
        }
    }

    /* access modifiers changed from: protected */
    public void onDestroy() {
        super.onDestroy();
        EPLog.m313i(TAG, "onDestroy");
        IEpsonService iEpsonService = this.mEpsonService;
        if (iEpsonService != null) {
            try {
                iEpsonService.unregisterCallback(this.mCallback);
                unbindService(this.mEpsonConnection);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        EPLog.m307e("MaintainActivity", "onResume()");
        super.onResume();
        this.isKeepSimpleAPConnection = false;
        if (!this.mWaiteInkDsDialog) {
            startLoadConThread();
        }
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        EPLog.m305d("MaintainActivity", "onPause");
        this.mIsCancelProbe = true;
        hideLoadProgressBar();
        this.mPrinter.doCancelFindPrinter();
        stopLoadConfigThread();
        interrupMaintainThread();
        endBackGroundThread();
        this.mUiHandler.removeMessages(16);
        if (!this.isKeepSimpleAPConnection) {
            WiFiDirectManager.disconnect(this, WiFiDirectManager.DEVICE_TYPE_PRINTER, this.printerIp);
        }
        super.onPause();
    }

    /* access modifiers changed from: protected */
    public void onStop() {
        super.onStop();
    }

    /* access modifiers changed from: private */
    public void performMaintain(final int i) {
        if (isPrinterReady() == 1) {
            this.mUiHandler.sendEmptyMessage(0);
            this.mDoMaintainThread = new Thread(new Runnable() {
                /* JADX WARNING: Removed duplicated region for block: B:35:0x0092 A[EDGE_INSN: B:35:0x0092->B:29:0x0092 ?: BREAK  , SYNTHETIC] */
                /* JADX WARNING: Removed duplicated region for block: B:37:0x002a A[SYNTHETIC] */
                /* Code decompiled incorrectly, please refer to instructions dump. */
                public void run() {
                    /*
                        r9 = this;
                        epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this
                        com.epson.mobilephone.common.maintain2.MaintainPrinter2 r0 = r0.mPrinter
                        int r1 = r3
                        int r0 = r0.doDoMainteCmd(r1)
                        r1 = 108(0x6c, float:1.51E-43)
                        r2 = 10
                        r3 = 1
                        r4 = 0
                        if (r0 != r1) goto L_0x0028
                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this
                        boolean unused = r5.isGotError = r3
                        r5 = 11
                        epson.maintain.activity.MaintainActivity r6 = epson.maintain.activity.MaintainActivity.this
                        android.os.Handler r6 = r6.mUiHandler
                        r6.sendEmptyMessage(r2)
                        r5 = 0
                        r6 = 11
                        goto L_0x002a
                    L_0x0028:
                        r5 = 1
                        r6 = 0
                    L_0x002a:
                        if (r5 != 0) goto L_0x002e
                        if (r6 > r2) goto L_0x0092
                    L_0x002e:
                        r7 = 1000(0x3e8, double:4.94E-321)
                        java.lang.Thread.sleep(r7)     // Catch:{ InterruptedException -> 0x009c }
                        int r6 = r6 + 1
                        if (r0 != r1) goto L_0x004a
                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x0046 }
                        boolean unused = r5.isGotError = r3     // Catch:{ InterruptedException -> 0x0046 }
                        epson.maintain.activity.MaintainActivity r5 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x0046 }
                        android.os.Handler r5 = r5.mUiHandler     // Catch:{ InterruptedException -> 0x0046 }
                        r5.sendEmptyMessage(r2)     // Catch:{ InterruptedException -> 0x0046 }
                        goto L_0x0092
                    L_0x0046:
                        r5 = move-exception
                        r7 = r5
                        r5 = 0
                        goto L_0x009d
                    L_0x004a:
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        com.epson.mobilephone.common.maintain2.MaintainPrinter2 r7 = r7.mPrinter     // Catch:{ InterruptedException -> 0x009c }
                        r7.doGetStatus()     // Catch:{ InterruptedException -> 0x009c }
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
                        r7 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
                        r8 = 4
                        if (r7 != r8) goto L_0x006d
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        boolean unused = r7.isGotError = r3     // Catch:{ InterruptedException -> 0x009c }
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        android.os.Handler r7 = r7.mUiHandler     // Catch:{ InterruptedException -> 0x009c }
                        r7.sendEmptyMessage(r8)     // Catch:{ InterruptedException -> 0x009c }
                        goto L_0x0072
                    L_0x006d:
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        boolean unused = r7.isGotError = r4     // Catch:{ InterruptedException -> 0x009c }
                    L_0x0072:
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
                        r7 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
                        if (r7 == 0) goto L_0x0089
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        int[] r7 = r7.mPrinterStatus     // Catch:{ InterruptedException -> 0x009c }
                        r5 = r7[r4]     // Catch:{ InterruptedException -> 0x009c }
                        if (r5 != r8) goto L_0x0087
                        goto L_0x0089
                    L_0x0087:
                        r5 = 1
                        goto L_0x008a
                    L_0x0089:
                        r5 = 0
                    L_0x008a:
                        epson.maintain.activity.MaintainActivity r7 = epson.maintain.activity.MaintainActivity.this     // Catch:{ InterruptedException -> 0x009c }
                        boolean r7 = r7.isGotError     // Catch:{ InterruptedException -> 0x009c }
                        if (r7 == 0) goto L_0x002a
                    L_0x0092:
                        epson.maintain.activity.MaintainActivity r0 = epson.maintain.activity.MaintainActivity.this
                        android.os.Handler r0 = r0.mUiHandler
                        r0.sendEmptyMessage(r3)
                        return
                    L_0x009c:
                        r7 = move-exception
                    L_0x009d:
                        r7.printStackTrace()
                        goto L_0x002a
                    */
                    throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.MaintainActivity.C201913.run():void");
                }
            });
            this.mDoMaintainThread.start();
        }
    }

    /* access modifiers changed from: private */
    public void loadConfig() {
        MyPrinter curPrinter = MyPrinter.getCurPrinter(this);
        this.printerName = curPrinter.getUserDefName(this);
        if (this.printerName == null) {
            this.printerName = "";
        }
        this.printerId = curPrinter.getPrinterId();
        if (this.printerId == null) {
            this.printerId = "";
        }
        this.printerIp = curPrinter.getIp();
        if (this.printerIp == null) {
            this.printerIp = "";
        }
        this.printerLocation = curPrinter.getLocation();
    }

    public void createInkView(MaintainPrinterInfo2 maintainPrinterInfo2, int i) {
        MaintainPrinterInfo2 maintainPrinterInfo22 = maintainPrinterInfo2;
        LayoutInflater from = LayoutInflater.from(this);
        Point point = new Point();
        this.mDisplay.getSize(point);
        int i2 = (point.x - 30) / 2;
        LinearLayout linearLayout = this.mInkView;
        if (linearLayout != null) {
            linearLayout.removeAllViews();
        }
        int inkNum = maintainPrinterInfo2.getInkNum();
        if (inkNum > 0) {
            findViewById(C2135R.C2137id.ink_text).setVisibility(0);
            this.mInkView.setVisibility(0);
            this.mBuyInkGroup.setVisibility(this.mBuyInkGroupVisibility);
            for (int i3 = 0; i3 < inkNum; i3++) {
                int inkRemainingAmount = maintainPrinterInfo22.getInkRemainingAmount(i3);
                int inkName = maintainPrinterInfo22.getInkName(i3);
                Integer[] colorName = MediaInfo.ColorTable.getColorName(inkName);
                if (colorName == null) {
                    EpLog.m77i("colorNo = " + inkName);
                    colorName = MediaInfo.ColorTable.getColorName(Constants.ColorName.EPS_COLOR_WHITE.ordinal());
                    if (colorName != null) {
                        colorName[1] = 0;
                    } else {
                        return;
                    }
                } else {
                    logColorInfo(inkName, colorName);
                }
                View inflate = from.inflate(C2135R.layout.ink_item, (ViewGroup) null);
                TextView textView = (TextView) inflate.findViewById(C2135R.C2137id.ink_name);
                if (colorName[1].intValue() != 0) {
                    textView.setText(colorName[1].intValue());
                } else {
                    textView.setText("");
                }
                ((RelativeLayout) inflate.findViewById(C2135R.C2137id.ink_holder)).getLayoutParams().width = i2;
                ViewGroup viewGroup = (ViewGroup) inflate.findViewById(C2135R.C2137id.ink_level);
                float f = (float) (i2 - 4);
                if (maintainPrinterInfo22.getInkStatus(i3) == -4 || i != 0) {
                    viewGroup.getLayoutParams().width = 0;
                    viewGroup.setVisibility(4);
                    if (maintainPrinterInfo22.getInkStatus(i3) != -4) {
                        inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
                    }
                } else {
                    viewGroup.getLayoutParams().width = calcInkWidth(inkRemainingAmount, f);
                    if (!(maintainPrinterInfo22.getInkStatus(i3) == 0 || maintainPrinterInfo22.getInkStatus(i3) == 1 || maintainPrinterInfo22.getInkStatus(i3) == 2)) {
                        viewGroup.getLayoutParams().width = 0;
                    }
                    if (checkIfWhite(colorName[0].intValue())) {
                        View findViewById = inflate.findViewById(C2135R.C2137id.white_ink_level);
                        findViewById.setBackgroundResource(colorName[0].intValue());
                        findViewById.setVisibility(0);
                    } else {
                        viewGroup.setBackgroundResource(colorName[0].intValue());
                    }
                    viewGroup.setVisibility(0);
                    if (inkRemainingAmount <= 0) {
                        inflate.findViewById(C2135R.C2137id.ink_error).setVisibility(0);
                    }
                }
                this.mInkView.addView(inflate);
            }
            return;
        }
        findViewById(C2135R.C2137id.ink_text).setVisibility(8);
        this.mInkView.setVisibility(8);
    }

    private boolean checkIfWhite(@ColorRes int i) {
        try {
            return (getResources().getColor(i) & ViewCompat.MEASURED_SIZE_MASK) == 16777215;
        } catch (Resources.NotFoundException unused) {
            return false;
        }
    }

    private void logColorInfo(int i, @NonNull Integer[] numArr) {
        String str;
        String str2;
        String str3;
        int intValue = numArr[1].intValue();
        int intValue2 = numArr[0].intValue();
        int intValue3 = numArr[2].intValue();
        StringBuilder sb = new StringBuilder();
        sb.append("colorNo = ");
        sb.append(i);
        sb.append(":");
        if (intValue == 0) {
            str = "--";
        } else {
            str = getString(numArr[1].intValue());
        }
        sb.append(str);
        sb.append(":");
        if (intValue2 == 0) {
            str2 = "--";
        } else {
            str2 = String.format("#%06X", new Object[]{Integer.valueOf(16777215 & ContextCompat.getColor(this, numArr[0].intValue()))});
        }
        sb.append(str2);
        sb.append(":");
        if (intValue3 == 0) {
            str3 = "--";
        } else {
            str3 = getString(numArr[2].intValue());
        }
        sb.append(str3);
        EpLog.m77i(sb.toString());
    }

    private class CustomProDialog extends Dialog {
        private int mLayoutId;

        CustomProDialog(Context context, int i, int i2) {
            super(context, i);
            this.mLayoutId = i2;
            setCancelable(false);
        }

        /* access modifiers changed from: protected */
        public void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            requestWindowFeature(1);
            View inflate = getLayoutInflater().inflate(this.mLayoutId, (ViewGroup) null);
            if (this.mLayoutId == C2135R.layout.maintain_executing_dialog) {
                ((Button) inflate.findViewById(C2135R.C2137id.close_btn)).setOnClickListener(new View.OnClickListener() {
                    public void onClick(View view) {
                        CustomProDialog.this.cancel();
                        MaintainActivity.this.interrupMaintainThread();
                    }
                });
            }
            setContentView(inflate);
        }
    }

    /* access modifiers changed from: private */
    public void setButtonClickable(boolean z) {
        this.mNozzleCheckView.setClickable(z);
        this.mHeadCleanView.setClickable(z);
        this.mFWUpdateView.setClickable(z);
        if (z) {
            if (!this.mIsNozzleCheckEnable.booleanValue()) {
                this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
            } else {
                this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
            }
            this.mHeadCleanText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
            this.mFWUpdateText.setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
            return;
        }
        this.mNozzleCheckText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
        this.mHeadCleanText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
        this.mFWUpdateText.setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
    }

    /* access modifiers changed from: private */
    public void setEpsonConnectButton(int i) {
        switch (i) {
            case 0:
                this.mEpsonConnectView.setClickable(true);
                this.mEpsonConnectView.setEnabled(true);
                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.black));
                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(0);
                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(0);
                this.mEpsonConnectView.setVisibility(0);
                return;
            case 1:
                this.mEpsonConnectView.setClickable(false);
                this.mEpsonConnectView.setEnabled(false);
                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(8);
                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(0);
                this.mEpsonConnectView.setVisibility(0);
                return;
            case 2:
                this.mEpsonConnectView.setClickable(false);
                this.mEpsonConnectView.setEnabled(false);
                ((TextView) findViewById(C2135R.C2137id.text_epson_connect)).setTextColor(this.mContext.getResources().getColor(C2135R.color.light_gray));
                ((ImageView) findViewById(C2135R.C2137id.epsonconnect_arrow)).setVisibility(8);
                findViewById(C2135R.C2137id.epsonconnect_separator).setVisibility(8);
                this.mEpsonConnectView.setVisibility(8);
                return;
            default:
                return;
        }
    }

    /* access modifiers changed from: package-private */
    public void startBrowseNozzleCheckGuidance() {
        showDialog(DIALOG_PROGRESS);
        BuyInkTask(2, this.printerIp);
    }

    private void BuyInkTask(int i, String str) {
        if (this.modelBuyInkOnlineRegTask.getReady()) {
            this.modelBuyInkOnlineRegTask.loadData(i, str);
        }
    }

    private void OnlineRegTask(String str) {
        if (this.modelBuyInkOnlineRegTask.getReady()) {
            this.modelBuyInkOnlineRegTask.loadData(str);
        }
    }

    public static boolean disableSimpleApAndWait(Context context, String str) {
        if (!WiFiDirectManager.disconnect(context, WiFiDirectManager.DEVICE_TYPE_PRINTER, str)) {
            return false;
        }
        int i = 0;
        while (i < 10) {
            try {
                if (Utils.isOnline(context)) {
                    return true;
                }
                EPLog.m305d(TAG, "Wait Connection 3G");
                i++;
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
                return false;
            }
        }
        return false;
    }

    private void showDialog(String str) {
        DialogProgress newInstance = DialogProgress.newInstance(str, 0, getString(C2135R.string.str_wait));
        newInstance.setCancelable(false);
        newInstance.show(getSupportFragmentManager(), str);
    }

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

    private class NozzleCheckTask extends AsyncTask<Void, Void, Integer> {
        private NozzleCheckTask() {
        }

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

        /* access modifiers changed from: protected */
        public Integer doInBackground(Void... voidArr) {
            return Integer.valueOf(MaintainActivity.this.mPrinter.doDoMainteCmd(3));
        }

        /* access modifiers changed from: protected */
        public void onPostExecute(Integer num) {
            MaintainActivity.this.cancelProDia();
            if (num.intValue() == 108) {
                MaintainActivity.this.setupErrorMessage(10);
            } else {
                MaintainActivity.this.showNozzleCheckGuidanceDialog();
            }
        }
    }
}
