Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35

以下内容为反编译后的 UpgradeFirmwareByBLEActivity.java 源代码,内容仅作参考


package com.lumiunited.aqara.device.devicepage.gateway.firmware;

import android.animation.ValueAnimator;
import android.app.AlertDialog;
import android.app.Application;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanRecord;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.TooltipCompatHandler;
import androidx.constraintlayout.widget.Group;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.lumiunited.aqara.R;
import com.lumiunited.aqara.application.base.BaseActivity;
import com.lumiunited.aqara.application.base.BaseDeviceEntity;
import com.lumiunited.aqara.common.ui.RoundProgressBar;
import com.lumiunited.aqara.device.adddevicepage.gateway.view.viewbinder.GatewayAddStatusBean;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.bean.FirmwareBean;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.bean.UpgradeFirmwareBean;
import com.lumiunited.aqara.web.event.CheckFirmwareResultEvent;
import com.umeng.commonsdk.framework.UMModuleRegister;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import k.u.c.d.d.l0;
import k.u.c.f.a.q.w0;
import k.u.c.f.a.q.y0;
import k.u.c.i.i3.e.a;
import k.u.c.i.m1;
import me.drakeet.multitype.MultiTypeAdapter;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import p.a.b0;
import s.b3.w.k0;
import s.h0;
import s.i3.c0;
import s.p1;
import v.a.a.a.g2;
import v.a.a.a.h2;
@h0(bv = {1, 0, 3}, d1 = {"\u0000ä\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0011\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0016\u0018\u0000 »\u00012\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u00012\u00020\u00042\u00020\u0005:\u0002»\u0001B\u0005¢\u0006\u0002\u0010\u0006J\u0010\u0010{\u001a\u00020|2\u0006\u0010}\u001a\u00020~H\u0007J\b\u0010\u007f\u001a\u00020|H\u0002J\u0012\u0010\u0080\u0001\u001a\u00020|2\u0007\u0010\u0081\u0001\u001a\u00020jH\u0002J\t\u0010\u0082\u0001\u001a\u00020|H\u0002J\u0013\u0010\u0083\u0001\u001a\u00020|2\b\u0010\u0084\u0001\u001a\u00030\u0085\u0001H\u0002J\t\u0010\u0086\u0001\u001a\u00020|H\u0002J\u0012\u0010\u0087\u0001\u001a\u00020|2\u0007\u0010\u0088\u0001\u001a\u00020\u0018H\u0002J\t\u0010\u0089\u0001\u001a\u00020|H\u0002J\u0012\u0010\u008a\u0001\u001a\u00020\u001c2\u0007\u0010\u008b\u0001\u001a\u00020\u0018H\u0002J\t\u0010\u008c\u0001\u001a\u00020|H\u0002J\t\u0010\u008d\u0001\u001a\u00020|H\u0002J\u0007\u0010\u008e\u0001\u001a\u00020\u001cJ\u0007\u0010\u008f\u0001\u001a\u00020\u001cJ\u0012\u0010\u0090\u0001\u001a\u00020|2\u0007\u0010\u0091\u0001\u001a\u00020\bH\u0002J\u0011\u0010\u0092\u0001\u001a\u00020|2\u0006\u0010\u001e\u001a\u00020\u001cH\u0002J\u0012\u0010\u0093\u0001\u001a\u00020|2\u0007\u0010\u0094\u0001\u001a\u00020:H\u0016J\u0015\u0010\u0095\u0001\u001a\u00020|2\n\u0010\u0096\u0001\u001a\u0005\u0018\u00010\u0097\u0001H\u0014J\t\u0010\u0098\u0001\u001a\u00020|H\u0014J\u001b\u0010\u0099\u0001\u001a\u00020|2\u0007\u0010\u009a\u0001\u001a\u00020\b2\u0007\u0010\u009b\u0001\u001a\u00020\bH\u0016J\u0014\u0010\u009c\u0001\u001a\u00020|2\t\u0010\u009d\u0001\u001a\u0004\u0018\u00010\u0018H\u0016J\u0012\u0010\u009e\u0001\u001a\u00020|2\u0007\u0010\u009f\u0001\u001a\u00020\bH\u0016J\t\u0010 \u0001\u001a\u00020|H\u0016J4\u0010¡\u0001\u001a\u00020|2\u0007\u0010¢\u0001\u001a\u00020\b2\u0010\u0010£\u0001\u001a\u000b\u0012\u0006\b\u0001\u0012\u00020\u00180¤\u00012\b\u0010¥\u0001\u001a\u00030¦\u0001H\u0016¢\u0006\u0003\u0010§\u0001J\u0012\u0010¨\u0001\u001a\u00020|2\u0007\u0010©\u0001\u001a\u00020\bH\u0016J\u0012\u0010ª\u0001\u001a\u00020|2\u0007\u0010©\u0001\u001a\u00020\bH\u0016J\t\u0010«\u0001\u001a\u00020|H\u0002J\t\u0010¬\u0001\u001a\u00020|H\u0002J\u0012\u0010\u00ad\u0001\u001a\u00020|2\u0007\u0010®\u0001\u001a\u00020\u001cH\u0002J\t\u0010¯\u0001\u001a\u00020|H\u0002J\t\u0010°\u0001\u001a\u00020|H\u0002J\t\u0010±\u0001\u001a\u00020|H\u0002J\t\u0010²\u0001\u001a\u00020|H\u0002J\t\u0010³\u0001\u001a\u00020|H\u0002J\t\u0010´\u0001\u001a\u00020|H\u0002J\t\u0010µ\u0001\u001a\u00020|H\u0002J\u0012\u0010¶\u0001\u001a\u00020|2\u0007\u0010·\u0001\u001a\u00020\bH\u0002J\t\u0010¸\u0001\u001a\u00020|H\u0002J\u0012\u0010¹\u0001\u001a\u00020|2\u0007\u0010º\u0001\u001a\u00020\bH\u0002R\u000e\u0010\u0007\u001a\u00020\bX\u0082D¢\u0006\u0002\n\u0000R\u001a\u0010\t\u001a\u00020\nX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000eR\u000e\u0010\u000f\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u0010\u001a\u00020\u0011X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0012\u0010\u0013\"\u0004\b\u0014\u0010\u0015R\u001a\u0010\u0016\u001a\u000e\u0012\u0004\u0012\u00020\u0018\u0012\u0004\u0012\u00020\u00180\u0017X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u001aX\u0082.¢\u0006\u0002\n\u0000R\u0014\u0010\u001b\u001a\u00020\u001c8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u001b\u0010\u001dR\u000e\u0010\u001e\u001a\u00020\u001cX\u0082D¢\u0006\u0002\n\u0000R\u0010\u0010\u001f\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010 \u001a\b\u0012\u0004\u0012\u00020\u00180!X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\"\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010$\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b%\u0010&\"\u0004\b'\u0010(R\u001c\u0010)\u001a\u0004\u0018\u00010*X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u001a\u0010/\u001a\u00020\u0018X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b0\u00101\"\u0004\b2\u00103R\u000e\u00104\u001a\u00020\u001cX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00105\u001a\u000206X\u0082.¢\u0006\u0002\n\u0000R\u000e\u00107\u001a\u000206X\u0082.¢\u0006\u0002\n\u0000R\u000e\u00108\u001a\u000206X\u0082.¢\u0006\u0002\n\u0000R\u000e\u00109\u001a\u00020:X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010;\u001a\u00020:X\u0082.¢\u0006\u0002\n\u0000R\u001a\u0010<\u001a\u00020=X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b>\u0010?\"\u0004\b@\u0010AR\u000e\u0010B\u001a\u00020CX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010D\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bE\u0010&\"\u0004\bF\u0010(R\u001a\u0010G\u001a\u00020HX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bI\u0010J\"\u0004\bK\u0010LR\u001a\u0010M\u001a\u00020NX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bO\u0010P\"\u0004\bQ\u0010RR\u001a\u0010S\u001a\u00020NX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bT\u0010P\"\u0004\bU\u0010RR\u001a\u0010V\u001a\u00020NX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bW\u0010P\"\u0004\bX\u0010RR\u001a\u0010Y\u001a\u00020NX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bZ\u0010P\"\u0004\b[\u0010RR\u001a\u0010\\\u001a\u00020\u0018X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b]\u00101\"\u0004\b^\u00103R\u0010\u0010_\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010`\u001a\u0004\u0018\u00010aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010b\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010c\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bd\u0010&\"\u0004\be\u0010(R\u000e\u0010f\u001a\u00020gX\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010h\u001a\u00020*X\u0082.¢\u0006\u0002\n\u0000R\u001a\u0010i\u001a\u00020jX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bk\u0010l\"\u0004\bm\u0010nR\u001a\u0010o\u001a\u00020\u0018X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bp\u00101\"\u0004\bq\u00103R\u0010\u0010r\u001a\u0004\u0018\u00010sX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010t\u001a\u00020\u001cX\u0086D¢\u0006\b\n\u0000\u001a\u0004\bu\u0010\u001dR\u000e\u0010v\u001a\u00020wX\u0082.¢\u0006\u0002\n\u0000R\u001c\u0010x\u001a\u0004\u0018\u00010\u0018X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\by\u00101\"\u0004\bz\u00103¨\u0006¼\u0001"}, d2 = {"Lcom/lumiunited/aqara/device/devicepage/gateway/firmware/UpgradeFirmwareByBLEActivity;", "Lcom/lumiunited/aqara/application/base/BaseActivity;", "Lcom/lumiunited/aqara/application/base/IBasePresenter;", "Lcom/lumiunited/aqara/application/base/IBaseView;", "Landroid/view/View$OnClickListener;", "Lcom/lumiunited/aqara/device/lock/ble/BleOTAProcessListener;", "()V", "CODE_GETFINELOCATION", "", "adapter", "Landroid/bluetooth/BluetoothAdapter;", "getAdapter", "()Landroid/bluetooth/BluetoothAdapter;", "setAdapter", "(Landroid/bluetooth/BluetoothAdapter;)V", "backgroundUpdateCount", "bleManager", "Lcom/lumiunited/aqara/device/lock/ble/AqaraBleManager;", "getBleManager", "()Lcom/lumiunited/aqara/device/lock/ble/AqaraBleManager;", "setBleManager", "(Lcom/lumiunited/aqara/device/lock/ble/AqaraBleManager;)V", "changePropMap", "Ljava/util/HashMap;", "", "inputUrlDialog", "Lcom/lumiunited/aqara/common/ui/dialog/ClearableEditDialog;", "isCanUpdate", "", "()Z", "isFirstLoadProgress", "mCurrentFirmwareVersion", "mDidList", "Ljava/util/ArrayList;", "mDisposable", "Lio/reactivex/disposables/Disposable;", "mErrorCode", "getMErrorCode", "()I", "setMErrorCode", "(I)V", "mErrorDialog", "Lcom/lumiunited/aqara/common/ui/dialog/CustomAlertDialog;", "getMErrorDialog$app_homekitRelease", "()Lcom/lumiunited/aqara/common/ui/dialog/CustomAlertDialog;", "setMErrorDialog$app_homekitRelease", "(Lcom/lumiunited/aqara/common/ui/dialog/CustomAlertDialog;)V", "mErrorMsg", "getMErrorMsg", "()Ljava/lang/String;", "setMErrorMsg", "(Ljava/lang/String;)V", "mIsDownloadFirmware", "mIvCheckingUpdate", "Landroid/widget/ImageView;", "mIvSubdeviceLoading", "mIvUpdateState", "mLayoutProgress", "Landroid/view/View;", "mLayoutVersionInfo", "mRpbUpgradeProgress", "Lcom/lumiunited/aqara/common/ui/RoundProgressBar;", "getMRpbUpgradeProgress", "()Lcom/lumiunited/aqara/common/ui/RoundProgressBar;", "setMRpbUpgradeProgress", "(Lcom/lumiunited/aqara/common/ui/RoundProgressBar;)V", "mShowItems", "Lme/drakeet/multitype/Items;", "mSubdeviceProgress", "getMSubdeviceProgress", "setMSubdeviceProgress", "mSubdeviceProgressAnimator", "Landroid/animation/ValueAnimator;", "getMSubdeviceProgressAnimator", "()Landroid/animation/ValueAnimator;", "setMSubdeviceProgressAnimator", "(Landroid/animation/ValueAnimator;)V", "mTvCurrentVersion", "Landroid/widget/TextView;", "getMTvCurrentVersion", "()Landroid/widget/TextView;", "setMTvCurrentVersion", "(Landroid/widget/TextView;)V", "mTvOk", "getMTvOk", "setMTvOk", "mTvTipAndLog", "getMTvTipAndLog", "setMTvTipAndLog", "mTvUpgradeState", "getMTvUpgradeState", "setMTvUpgradeState", "mUpdateLog", "getMUpdateLog", "setMUpdateLog", "mUpdateState", "mUpgradeFirmwareBean", "Lcom/lumiunited/aqara/device/devicepage/gateway/firmware/bean/UpgradeFirmwareBean;", "mUpgradeFirmwareVersion", "mUpgradeStateCode", "getMUpgradeStateCode", "setMUpgradeStateCode", "mViewCheckingUpdate", "Landroidx/constraintlayout/widget/Group;", "openBluetoothDialog", "otaFile", "Ljava/io/File;", "getOtaFile", "()Ljava/io/File;", "setOtaFile", "(Ljava/io/File;)V", "randomForOTA", "getRandomForOTA", "setRandomForOTA", "scanCallback", "Landroid/bluetooth/le/ScanCallback;", "showOriginalVersion", "getShowOriginalVersion", "stateAdapter", "Lme/drakeet/multitype/MultiTypeAdapter;", "tempRandomNum", "getTempRandomNum", "setTempRandomNum", "checkFirmwareResultEvent", "", "event", "Lcom/lumiunited/aqara/web/event/CheckFirmwareResultEvent;", "checkSupportMiApp", "checkUpdateBLERandom", "file", "clickTvOk", "connectBle", "bledevice", "Landroid/bluetooth/BluetoothDevice;", "dismissErrorDialog", "downloadOTAwithBg", "otaUrl", "formatVersion", "hasTargetDevice", com.umeng.commonsdk.statistics.idtracking.i.a, "initIntent", "initView", "isOtaFileInit", "isRandomInit", "loadDataInterval", "delayInMillSeconds", "loadUpgradeProgress", "onClick", "v", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onFailed", "error", "feedbackCmd", "onFeedbackDetails", k.u.c.i.d3.b.g.f23330e, "onProcess", UMModuleRegister.PROCESS, "onProcessStart", "onRequestPermissionsResult", z.a.a.e.f33395k, z.a.a.e.f33396l, "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onUpdateSuccess", "status", "onWaiting", "openSetting", "queryUpdateAvailable", "showCheckingUpdate", "show", "showErrorDialog", "showInputOTAUrlDialog", "startScan", "startSubdeviceProgressAnimator", "stopLoadUpgradeProgress", "stopScan", "stopSubdeviceProgressAnimator", "updateVerInfoUI", "upgradeState", "upgradeFirmware", "upgradeProgress", "progress", "Companion", "app_homekitRelease"}, k = 1, mv = {1, 1, 15})
public final class UpgradeFirmwareByBLEActivity extends BaseActivity<k.u.c.d.a.u<k.u.c.d.a.v>> implements View.OnClickListener, k.u.c.i.i3.e.f {
    @NotNull
    public static final String E7 = "lock_random_code";
    public static final int F7 = 0;
    public static final int G7 = 1;
    public static final int H7 = 2;
    public static final int I7 = 3;
    public static final int K7 = 10;
    public static final int L7 = 908;
    public static final int M7 = 912;
    public static final int N7 = 602;
    public static final int R7 = 5;
    public static final int S7 = 6;
    public p.a.u0.c A7;
    @Nullable
    public y0 B7;
    public HashMap D7;
    public ScanCallback H;
    public Group I;
    public ImageView J;
    public View K;
    public ImageView L;
    public View M;
    public ImageView N;
    @NotNull
    public RoundProgressBar R;
    @NotNull
    public TextView S;
    @NotNull
    public TextView T;
    @NotNull
    public TextView U;
    @NotNull
    public TextView a7;
    public boolean b7;
    public UpgradeFirmwareBean e7;
    @NotNull
    public String g7;
    public String h7;
    public int i7;
    @Nullable
    public String m7;
    @NotNull
    public String n7;
    @NotNull
    public String o7;
    @NotNull
    public k.u.c.i.i3.e.a p7;
    @NotNull
    public File q7;
    @NotNull
    public BluetoothAdapter r7;
    public y0 t7;
    public MultiTypeAdapter v7;
    public w0 x7;
    @NotNull
    public ValueAnimator z7;
    public static final a T7 = new a(null);
    public static final int J7 = 4;
    @NotNull
    public static final ParcelUuid O7 = new ParcelUuid(UUID.fromString("0000ffa0-2333-5b1e-9d7c-c687fd2f04f2"));
    @NotNull
    public static final ParcelUuid P7 = new ParcelUuid(UUID.fromString("0000ffb1-2333-5b1e-9d7c-c687fd2f04f2"));
    @NotNull
    public static final ParcelUuid Q7 = new ParcelUuid(UUID.fromString("0000ffb2-2333-5b1e-9d7c-c687fd2f04f2"));
    public final ArrayList<String> c7 = new ArrayList<>();
    public String d7 = "";
    public String f7 = "";
    public final boolean j7 = true;
    public int k7 = -1;
    public int l7 = 3;
    public final int s7 = 101;
    public u.a.a.g u7 = new u.a.a.g();
    public int w7 = 10;
    public final boolean y7 = true;
    public final HashMap<String, String> C7 = new HashMap<>();

    public static final class a {
        public a() {
        }

        public final int a() {
            return UpgradeFirmwareByBLEActivity.J7;
        }

        @NotNull
        public final ParcelUuid b() {
            return UpgradeFirmwareByBLEActivity.P7;
        }

        @NotNull
        public final ParcelUuid c() {
            return UpgradeFirmwareByBLEActivity.O7;
        }

        @NotNull
        public final ParcelUuid d() {
            return UpgradeFirmwareByBLEActivity.Q7;
        }

        public a(s.b3.w.w wVar) {
            this();
        }
    }

    public static final class b extends k.u.c.d.j.o<Boolean> {
        public b() {
        }

        @Override
        public void a(int i2, @NotNull String str) {
            k0.f(str, "errorMessage");
        }

        @Override
        public void a(@Nullable Boolean bool) {
            if (UpgradeFirmwareByBLEActivity.this.isDestroyed() || bool != null) {
                return;
            }
            k0.f();
        }
    }

    public static final class c<T, R> implements p.a.x0.o<T, R> {
        public static final c a = new c();

        @Override
        public final String apply(@NotNull List<String> list) {
            k0.f(list, "strings");
            if (!list.isEmpty()) {
                String str = list.get(0);
                k0.a((Object) str, "strings[0]");
                return str.length() == 0 ? "" : list.get(0);
            }
            return "";
        }
    }

    public static final class d<T, R> implements p.a.x0.o<T, x.g.c<? extends R>> {
        public d() {
        }

        @Override
        public final p.a.l<String> apply(@NotNull String str) {
            k0.f(str, "s");
            k.u.c.i.e3.h.c.h0.a("get random num --- try to get code", null, 1, null);
            ArrayList arrayList = new ArrayList();
            arrayList.add("lock_random_code");
            return m1.d().a(UpgradeFirmwareByBLEActivity.this.f8954q, arrayList).n();
        }
    }

    public static final class e<T, R> implements p.a.x0.o<T, R> {
        public e() {
        }

        @Override
        public final String apply(@NotNull String str) {
            k0.f(str, "s");
            k.u.c.i.e3.h.c.h0.a("get random num ---- return result is " + str, null, 1, null);
            String string = JSON.parseObject(str).getString("lock_random_code");
            if (!TextUtils.isEmpty(UpgradeFirmwareByBLEActivity.this.w1()) && TextUtils.equals(UpgradeFirmwareByBLEActivity.this.w1(), string)) {
                UpgradeFirmwareByBLEActivity.this.l0(string);
                throw new k.u.c.d.d.r0.c(4, "error attr");
            } else if (!TextUtils.isEmpty(UpgradeFirmwareByBLEActivity.this.w1())) {
                if (TextUtils.isEmpty(UpgradeFirmwareByBLEActivity.this.w1()) || TextUtils.equals(UpgradeFirmwareByBLEActivity.this.w1(), string)) {
                    return "";
                }
                UpgradeFirmwareByBLEActivity.this.O1();
                return string;
            } else {
                UpgradeFirmwareByBLEActivity.this.l0(string);
                throw new k.u.c.d.d.r0.c(4, "error attr");
            }
        }
    }

    public static final class f<T> implements p.a.x0.g<String> {
        public final File b;

        public f(File file) {
            this.b = file;
        }

        @Override
        public final void accept(String str) {
            k.u.c.i.e3.h.c.h0.a("get random num success --- " + str, null, 1, null);
            UpgradeFirmwareByBLEActivity.this.d("正在建立蓝牙链接", 0);
            k.u.c.i.e3.h.c.h0.a("get random num success,the value is:" + str, null, 1, null);
            if (TextUtils.isEmpty(str.toString())) {
                UpgradeFirmwareByBLEActivity.this.g0("随机数获取失败");
                return;
            }
            UpgradeFirmwareByBLEActivity.this.k0(str.toString());
            UpgradeFirmwareByBLEActivity.this.a(this.b);
        }
    }

    public static final class g<T> implements p.a.x0.g<Throwable> {
        public g() {
        }

        @Override
        public final void accept(Throwable th) {
            k.u.c.i.e3.h.c.h0.a("OTA安全校验 错误 error", null, 1, null);
            if (th instanceof k.u.c.d.d.r0.c) {
                UpgradeFirmwareByBLEActivity.this.g0(th.getMessage());
                k.u.c.i.e3.h.c.h0.a("获取随机数失败  ---  " + th.getMessage(), null, 1, null);
                UpgradeFirmwareByBLEActivity.this.l(((k.u.c.d.d.r0.c) th).a(), th.getMessage());
                return;
            }
            k.u.c.i.e3.h.c.h0.a("获取随机数失败  ---  " + th.getMessage(), null, 1, null);
        }
    }

    public static final class h implements DialogInterface.OnClickListener {
        public static final h a = new h();

        @Override
        public final void onClick(DialogInterface dialogInterface, int i2) {
        }
    }

    public static final class i implements DialogInterface.OnClickListener {
        public i() {
        }

        @Override
        public final void onClick(DialogInterface dialogInterface, int i2) {
            StringBuilder sb = new StringBuilder();
            sb.append("package:");
            Application application = UpgradeFirmwareByBLEActivity.this.getApplication();
            k0.a((Object) application, "application");
            sb.append(application.getPackageName());
            UpgradeFirmwareByBLEActivity.this.startActivity(new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.parse(sb.toString())));
        }
    }

    public static final class j implements h2 {
        public j() {
        }

        @Override
        @Deprecated
        public void a(@NonNull BluetoothDevice bluetoothDevice, @IntRange(from = 0, to = 100) int i2) {
            g2.a(this, bluetoothDevice, i2);
        }

        @Override
        public void a(@NotNull BluetoothDevice bluetoothDevice, boolean z2) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("发现服务", address);
        }

        @Override
        public void b(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("绑定失败", address);
        }

        @Override
        public void c(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("设备连接", address);
            UpgradeFirmwareByBLEActivity.this.b0();
        }

        @Override
        public void d(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("需要绑定", address);
        }

        @Override
        public void e(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("正在连接", address);
        }

        @Override
        public void f(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("正在断开连接", address);
        }

        @Override
        public void g(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("绑定", address);
        }

        @Override
        public void h(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("设备不支持", address);
        }

        @Override
        public void i(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("断开连接时", address);
            UpgradeFirmwareByBLEActivity.this.g1().i();
        }

        @Override
        public void j(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("断开连接", address);
        }

        @Override
        @Deprecated
        public boolean k(@NonNull BluetoothDevice bluetoothDevice) {
            return g2.a(this, bluetoothDevice);
        }

        @Override
        public void a(@NotNull BluetoothDevice bluetoothDevice) {
            k0.f(bluetoothDevice, "device");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("设备准备", address);
        }

        @Override
        public void a(@NotNull BluetoothDevice bluetoothDevice, @NotNull String str, int i2) {
            k0.f(bluetoothDevice, "device");
            k0.f(str, "message");
            String address = bluetoothDevice.getAddress();
            k0.a((Object) address, "device.address");
            k.u.c.i.e3.h.c.h0.a("异常:" + str + ":状态码:" + i2, address);
        }
    }

    @h0(bv = {1, 0, 3}, d1 = {"\u0000'\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u001a\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000e2\b\u0010\u000f\u001a\u0004\u0018\u00010\u0010H\u0016J\u0012\u0010\u0011\u001a\u00020\f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u0010H\u0016J\u0010\u0010\u0013\u001a\u00020\f2\u0006\u0010\u0014\u001a\u00020\u000eH\u0016R\u001a\u0010\u0002\u001a\u00020\u0003X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0004\u0010\u0005\"\u0004\b\u0006\u0010\u0007R\u001a\u0010\b\u001a\u00020\u0003X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\t\u0010\u0005\"\u0004\b\n\u0010\u0007¨\u0006\u0015"}, d2 = {"com/lumiunited/aqara/device/devicepage/gateway/firmware/UpgradeFirmwareByBLEActivity$downloadOTAwithBg$1", "Lcom/lumiunited/aqara/application/helper/HttpHelper$OnDownloadListener;", "bean", "Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;", "getBean", "()Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;", "setBean", "(Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;)V", "preBean", "getPreBean", "setPreBean", "onDownloadFailed", "", "code", "", "error", "", "onDownloadSuccess", "path", "onDownloading", "progress", "app_homekitRelease"}, k = 1, mv = {1, 1, 15})
    public static final class k implements l0.l {
        @NotNull
        public GatewayAddStatusBean a;
        @NotNull
        public GatewayAddStatusBean b;

        public static final class a implements Runnable {
            public a() {
            }

            @Override
            public final void run() {
                if (UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    k.this.a(new GatewayAddStatusBean("下载失败", 1));
                    UpgradeFirmwareByBLEActivity.this.u7.add(k.this.a());
                    UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemInserted(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                }
                ((RecyclerView) UpgradeFirmwareByBLEActivity.this._$_findCachedViewById(R.id.rv_content)).scrollToPosition(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
            }
        }

        public static final class b implements Runnable {
            public final String b;

            public b(String str) {
                this.b = str;
            }

            @Override
            public final void run() {
                if (!UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    k kVar = k.this;
                    Object obj = UpgradeFirmwareByBLEActivity.this.u7.get(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                    if (obj != null) {
                        kVar.b((GatewayAddStatusBean) obj);
                        if (k.this.b().getStatus() != 0) {
                            k.this.b().setTitle("下载成功");
                            k.this.b().setStatus(0);
                            UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemChanged(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                        }
                    } else {
                        throw new p1("null cannot be cast to non-null type com.lumiunited.aqara.device.adddevicepage.gateway.view.viewbinder.GatewayAddStatusBean");
                    }
                }
                UpgradeFirmwareByBLEActivity.this.b(new File(this.b));
            }
        }

        public static final class c implements Runnable {
            public c() {
            }

            @Override
            public final void run() {
                if (UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    k.this.a(new GatewayAddStatusBean("固件下载中", 2));
                    UpgradeFirmwareByBLEActivity.this.u7.add(k.this.a());
                    UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemInserted(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                }
                ((RecyclerView) UpgradeFirmwareByBLEActivity.this._$_findCachedViewById(R.id.rv_content)).scrollToPosition(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
            }
        }

        public k() {
        }

        @NotNull
        public final GatewayAddStatusBean a() {
            GatewayAddStatusBean gatewayAddStatusBean = this.b;
            if (gatewayAddStatusBean == null) {
                k0.m("bean");
            }
            return gatewayAddStatusBean;
        }

        @NotNull
        public final GatewayAddStatusBean b() {
            GatewayAddStatusBean gatewayAddStatusBean = this.a;
            if (gatewayAddStatusBean == null) {
                k0.m("preBean");
            }
            return gatewayAddStatusBean;
        }

        public final void a(@NotNull GatewayAddStatusBean gatewayAddStatusBean) {
            k0.f(gatewayAddStatusBean, "<set-?>");
            this.b = gatewayAddStatusBean;
        }

        public final void b(@NotNull GatewayAddStatusBean gatewayAddStatusBean) {
            k0.f(gatewayAddStatusBean, "<set-?>");
            this.a = gatewayAddStatusBean;
        }

        @Override
        public void a(@Nullable String str) {
            k.u.c.i.e3.h.c.h0.a("下载成功  ---  路径:" + str, null, 1, null);
            UpgradeFirmwareByBLEActivity.this.b7 = false;
            UpgradeFirmwareByBLEActivity.this.k1().setTextIsDisplayable(true ^ UpgradeFirmwareByBLEActivity.this.b7);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new b(str));
        }

        @Override
        public void a(int i2) {
            k.u.c.i.e3.h.c.h0.a("下载中  ---  进度:" + i2 + " %", null, 1, null);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new c());
        }

        @Override
        public void a(int i2, @Nullable String str) {
            k.u.c.i.e3.h.c.h0.a("下载失败  ---  " + str, null, 1, null);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new a());
        }
    }

    public static final class l implements View.OnClickListener {
        public l() {
        }

        @Override
        public final void onClick(View view) {
            UpgradeFirmwareByBLEActivity.this.L1();
        }
    }

    public static final class m implements View.OnClickListener {
        public m() {
        }

        @Override
        public final void onClick(View view) {
            UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
            upgradeFirmwareByBLEActivity.w7--;
            if (UpgradeFirmwareByBLEActivity.this.w7 == 0) {
                UpgradeFirmwareByBLEActivity.this.N1();
            }
        }
    }

    public static final class n<T> implements p.a.x0.g<Long> {
        public n() {
        }

        @Override
        public final void accept(Long l2) {
            UpgradeFirmwareByBLEActivity.this.C(false);
        }
    }

    public static final class o extends k.u.c.d.j.o<String> {
        public o() {
        }

        @Override
        public void a(int i2, @NotNull String str) {
            k0.f(str, "errorMessage");
            UpgradeFirmwareByBLEActivity.this.l(i2, str);
        }

        @Override
        public void a(@NotNull String str) {
            k0.f(str, "s");
            UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
            upgradeFirmwareByBLEActivity.d(upgradeFirmwareByBLEActivity.getString(com.lumiunited.aqarahome.R.string.firmware_checking), 0);
        }
    }

    public static final class p extends k.u.c.d.j.o<FirmwareBean> {
        public p() {
        }

        @Override
        public void a(int i2, @NotNull String str) {
            k0.f(str, "errorMessage");
            if (UpgradeFirmwareByBLEActivity.this.isFinishing()) {
                return;
            }
            UpgradeFirmwareByBLEActivity.this.H(5);
        }

        @Override
        public void a(@Nullable FirmwareBean firmwareBean) {
            if (UpgradeFirmwareByBLEActivity.this.isFinishing()) {
                return;
            }
            if (firmwareBean == null) {
                UpgradeFirmwareByBLEActivity.this.H(3);
                return;
            }
            k.u.c.i.e3.h.c.h0.a("获取到最新版本号:" + firmwareBean.getFirmwareVersion(), null, 1, null);
            k.u.c.i.i3.e.a g1 = UpgradeFirmwareByBLEActivity.this.g1();
            String firmwareVersion = firmwareBean.getFirmwareVersion();
            k0.a((Object) firmwareVersion, "bean.firmwareVersion");
            g1.b(firmwareVersion);
            UpgradeFirmwareByBLEActivity.this.d7 = firmwareBean.getFirmwareVersion();
            UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
            UpgradeFirmwareBean upgradeFirmware = firmwareBean.getUpgradeFirmware();
            k0.a((Object) upgradeFirmware, "bean.upgradeFirmware");
            upgradeFirmwareByBLEActivity.f7 = upgradeFirmware.getFirmwareVersion();
            UpgradeFirmwareByBLEActivity.this.e7 = firmwareBean.getUpgradeFirmware();
            UpgradeFirmwareByBLEActivity.this.H(3);
        }
    }

    public static final class q implements View.OnClickListener {
        public q() {
        }

        @Override
        public final void onClick(View view) {
            y0 i1 = UpgradeFirmwareByBLEActivity.this.i1();
            if (i1 == null) {
                k0.f();
            }
            i1.dismiss();
        }
    }

    public static final class r implements w0.e {
        public r() {
        }

        @Override
        public final void a(String str) {
            UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
            k0.a((Object) str, "editTextContent");
            upgradeFirmwareByBLEActivity.m0(str);
            UpgradeFirmwareByBLEActivity.b(UpgradeFirmwareByBLEActivity.this).dismiss();
        }
    }

    public static final class s extends ScanCallback {
        public s() {
        }

        @Override
        public void onBatchScanResults(@Nullable List<ScanResult> list) {
        }

        @Override
        public void onScanFailed(int i2) {
        }

        @Override
        public void onScanResult(int i2, @Nullable ScanResult scanResult) {
            if (Build.VERSION.SDK_INT >= 21) {
                BluetoothDevice device = scanResult != null ? scanResult.getDevice() : null;
                if (device != null) {
                    ScanRecord scanRecord = scanResult.getScanRecord();
                    byte[] d = k.u.c.i.i3.r.s.d(k.u.c.i.i3.r.c.a(scanRecord != null ? scanRecord.getBytes() : null));
                    String a = k.u.c.i.i3.r.c.a(k.u.c.i.i3.r.v.a(d, d.length, false));
                    UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
                    k0.a((Object) a, com.umeng.commonsdk.statistics.idtracking.i.a);
                    if (upgradeFirmwareByBLEActivity.n0(a)) {
                        UpgradeFirmwareByBLEActivity.this.R1();
                        if (UpgradeFirmwareByBLEActivity.this.x1() && UpgradeFirmwareByBLEActivity.this.y1()) {
                            UpgradeFirmwareByBLEActivity.this.g1().b(UpgradeFirmwareByBLEActivity.this.t1());
                            UpgradeFirmwareByBLEActivity.this.g1().c(UpgradeFirmwareByBLEActivity.this.u1());
                            UpgradeFirmwareByBLEActivity.this.a(device);
                        }
                    }
                }
            }
        }
    }

    public static final class t implements ValueAnimator.AnimatorUpdateListener {
        public final int b;
        public final int c;

        public t(int i2, int i3) {
            this.b = i2;
            this.c = i3;
        }

        @Override
        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
            k0.a((Object) valueAnimator, k.e.a.q.p.c0.a.f16195g);
            Object animatedValue = valueAnimator.getAnimatedValue();
            if (animatedValue != null) {
                int intValue = ((Integer) animatedValue).intValue();
                if (intValue <= 100) {
                    UpgradeFirmwareByBLEActivity.this.k1().setCricleColor(this.b);
                    UpgradeFirmwareByBLEActivity.this.k1().setCricleProgressColor(this.c);
                    UpgradeFirmwareByBLEActivity.this.E(intValue);
                } else {
                    UpgradeFirmwareByBLEActivity.this.k1().setCricleColor(this.c);
                    UpgradeFirmwareByBLEActivity.this.k1().setCricleProgressColor(this.b);
                    UpgradeFirmwareByBLEActivity.this.E(intValue - 100);
                }
                UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity = UpgradeFirmwareByBLEActivity.this;
                upgradeFirmwareByBLEActivity.I(upgradeFirmwareByBLEActivity.l1());
                return;
            }
            throw new p1("null cannot be cast to non-null type kotlin.Int");
        }
    }

    public static final class u implements View.OnClickListener {
        public u() {
        }

        @Override
        public void onClick(@Nullable View view) {
            UpgradeFirmwareByBLEActivity.i(UpgradeFirmwareByBLEActivity.this).dismiss();
        }
    }

    public static final class v implements View.OnClickListener {
        public v() {
        }

        @Override
        public void onClick(@Nullable View view) {
            UpgradeFirmwareByBLEActivity.this.K1();
        }
    }

    @h0(bv = {1, 0, 3}, d1 = {"\u0000'\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u001a\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000e2\b\u0010\u000f\u001a\u0004\u0018\u00010\u0010H\u0016J\u0012\u0010\u0011\u001a\u00020\f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u0010H\u0016J\u0010\u0010\u0013\u001a\u00020\f2\u0006\u0010\u0014\u001a\u00020\u000eH\u0016R\u001a\u0010\u0002\u001a\u00020\u0003X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0004\u0010\u0005\"\u0004\b\u0006\u0010\u0007R\u001a\u0010\b\u001a\u00020\u0003X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\t\u0010\u0005\"\u0004\b\n\u0010\u0007¨\u0006\u0015"}, d2 = {"com/lumiunited/aqara/device/devicepage/gateway/firmware/UpgradeFirmwareByBLEActivity$upgradeFirmware$3", "Lcom/lumiunited/aqara/application/helper/HttpHelper$OnDownloadListener;", "bean", "Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;", "getBean", "()Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;", "setBean", "(Lcom/lumiunited/aqara/device/adddevicepage/gateway/view/viewbinder/GatewayAddStatusBean;)V", "preBean", "getPreBean", "setPreBean", "onDownloadFailed", "", "code", "", "error", "", "onDownloadSuccess", "path", "onDownloading", "progress", "app_homekitRelease"}, k = 1, mv = {1, 1, 15})
    public static final class w implements l0.l {
        @NotNull
        public GatewayAddStatusBean a;
        @NotNull
        public GatewayAddStatusBean b;

        public static final class a implements Runnable {
            public a() {
            }

            @Override
            public final void run() {
                if (UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    w.this.a(new GatewayAddStatusBean("下载失败", 1));
                    UpgradeFirmwareByBLEActivity.this.u7.add(w.this.a());
                    UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemInserted(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                }
                ((RecyclerView) UpgradeFirmwareByBLEActivity.this._$_findCachedViewById(R.id.rv_content)).scrollToPosition(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
            }
        }

        public static final class b implements Runnable {
            public final String b;

            public b(String str) {
                this.b = str;
            }

            @Override
            public final void run() {
                if (!UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    w wVar = w.this;
                    Object obj = UpgradeFirmwareByBLEActivity.this.u7.get(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                    if (obj != null) {
                        wVar.b((GatewayAddStatusBean) obj);
                        if (w.this.b().getStatus() != 0) {
                            w.this.b().setTitle("下载成功");
                            w.this.b().setStatus(0);
                            UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemChanged(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                        }
                    } else {
                        throw new p1("null cannot be cast to non-null type com.lumiunited.aqara.device.adddevicepage.gateway.view.viewbinder.GatewayAddStatusBean");
                    }
                }
                UpgradeFirmwareByBLEActivity.this.b(new File(this.b));
            }
        }

        public static final class c implements Runnable {
            public c() {
            }

            @Override
            public final void run() {
                if (UpgradeFirmwareByBLEActivity.this.u7.isEmpty()) {
                    w.this.a(new GatewayAddStatusBean("固件下载中", 2));
                    UpgradeFirmwareByBLEActivity.this.u7.add(w.this.a());
                    UpgradeFirmwareByBLEActivity.j(UpgradeFirmwareByBLEActivity.this).notifyItemInserted(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
                }
                ((RecyclerView) UpgradeFirmwareByBLEActivity.this._$_findCachedViewById(R.id.rv_content)).scrollToPosition(UpgradeFirmwareByBLEActivity.this.u7.size() - 1);
            }
        }

        public w() {
        }

        @NotNull
        public final GatewayAddStatusBean a() {
            GatewayAddStatusBean gatewayAddStatusBean = this.b;
            if (gatewayAddStatusBean == null) {
                k0.m("bean");
            }
            return gatewayAddStatusBean;
        }

        @NotNull
        public final GatewayAddStatusBean b() {
            GatewayAddStatusBean gatewayAddStatusBean = this.a;
            if (gatewayAddStatusBean == null) {
                k0.m("preBean");
            }
            return gatewayAddStatusBean;
        }

        public final void a(@NotNull GatewayAddStatusBean gatewayAddStatusBean) {
            k0.f(gatewayAddStatusBean, "<set-?>");
            this.b = gatewayAddStatusBean;
        }

        public final void b(@NotNull GatewayAddStatusBean gatewayAddStatusBean) {
            k0.f(gatewayAddStatusBean, "<set-?>");
            this.a = gatewayAddStatusBean;
        }

        @Override
        public void a(@Nullable String str) {
            k.u.c.i.e3.h.c.h0.a("下载成功  ---  路径:" + str, null, 1, null);
            UpgradeFirmwareByBLEActivity.this.b7 = false;
            UpgradeFirmwareByBLEActivity.this.k1().setTextIsDisplayable(true ^ UpgradeFirmwareByBLEActivity.this.b7);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new b(str));
        }

        @Override
        public void a(int i2) {
            k.u.c.i.e3.h.c.h0.a("下载中  ---  进度:" + i2 + " %", null, 1, null);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new c());
        }

        @Override
        public void a(int i2, @Nullable String str) {
            k.u.c.i.e3.h.c.h0.a("下载失败  ---  " + str, null, 1, null);
            UpgradeFirmwareByBLEActivity.this.runOnUiThread(new a());
        }
    }

    public final void C(boolean z2) {
        if (isFinishing()) {
            return;
        }
        k.u.c.i.i3.e.a aVar = this.p7;
        if (aVar == null) {
            k0.m("bleManager");
        }
        aVar.a(this);
    }

    private final void D1() {
        boolean z2;
        String str = this.d7;
        if (str == null) {
            k0.f();
        }
        if (str.compareTo("1.3.0") < 0) {
            String str2 = this.f7;
            if (str2 == null) {
                k0.f();
            }
            if (str2.compareTo("1.3.0") >= 0) {
                z2 = true;
                if (z2) {
                    return;
                }
                m1.d().l(this.f8954q, new b());
                return;
            }
        }
        z2 = false;
        if (z2) {
        }
    }

    private final void E1() {
        if (this.d7 != null && !TextUtils.isEmpty(this.f7) && !k0.a((Object) this.d7, (Object) this.f7)) {
            if (Build.VERSION.SDK_INT >= 23) {
                if (ContextCompat.checkSelfPermission(this, "android.permission.ACCESS_FINE_LOCATION") != 0) {
                    if (!ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.ACCESS_FINE_LOCATION")) {
                        new AlertDialog.Builder(this).setMessage("扫描需要您开启定位权限,请立即开启定位权限!").setPositiveButton(getString(com.lumiunited.aqarahome.R.string.txt_cancel), h.a).setNegativeButton(getString(com.lumiunited.aqarahome.R.string.txt_open), new i()).show();
                        return;
                    } else {
                        requestPermissions(new String[]{"android.permission.ACCESS_FINE_LOCATION"}, this.s7);
                        return;
                    }
                }
                T1();
                return;
            }
            T1();
            return;
        }
        finish();
    }

    private final void F1() {
        y0 y0Var = this.B7;
        if (y0Var != null) {
            if (y0Var == null) {
                k0.f();
            }
            if (y0Var.isShowing()) {
                y0 y0Var2 = this.B7;
                if (y0Var2 == null) {
                    k0.f();
                }
                y0Var2.dismiss();
            }
        }
    }

    private final void G(int i2) {
        p.a.u0.c cVar = this.A7;
        if (cVar != null) {
            p.a.u0.b bVar = this.f8942e;
            if (cVar == null) {
                k0.f();
            }
            bVar.a(cVar);
        }
        p.a.u0.c subscribe = b0.interval(i2, 10000, TimeUnit.MILLISECONDS).onTerminateDetach().observeOn(p.a.s0.d.a.a()).subscribe(new n());
        this.A7 = subscribe;
        p.a.u0.b bVar2 = this.f8942e;
        if (subscribe == null) {
            k0.f();
        }
        bVar2.b(subscribe);
    }

    private final void G1() {
        this.d7 = this.j7 ? this.d7 : k.u.c.i.o3.m.a(this.d7);
        UpgradeFirmwareBean upgradeFirmwareBean = this.e7;
        if (upgradeFirmwareBean != null) {
            if (upgradeFirmwareBean == null) {
                k0.f();
            }
            this.f7 = upgradeFirmwareBean.getFirmwareVersion();
            UpgradeFirmwareBean upgradeFirmwareBean2 = this.e7;
            if (upgradeFirmwareBean2 == null) {
                k0.f();
            }
            String updateLog = upgradeFirmwareBean2.getUpdateLog();
            k0.a((Object) updateLog, "mUpgradeFirmwareBean!!.updateLog");
            this.g7 = updateLog;
        }
    }

    public final void H(int i2) {
        Group group = this.I;
        if (group == null) {
            k0.m("mViewCheckingUpdate");
        }
        group.setVisibility(8);
        View view = this.K;
        if (view == null) {
            k0.m("mLayoutVersionInfo");
        }
        view.setVisibility(0);
        this.l7 = i2;
        TextView textView = (TextView) _$_findCachedViewById(R.id.retry_btn);
        k0.a((Object) textView, "retry_btn");
        textView.setVisibility(i2 == 5 ? 0 : 8);
        TextView textView2 = this.a7;
        if (textView2 == null) {
            k0.m("mTvOk");
        }
        textView2.setVisibility(i2 == 5 ? 8 : 0);
        if (i2 == 3) {
            G1();
            ImageView imageView = this.L;
            if (imageView == null) {
                k0.m("mIvUpdateState");
            }
            imageView.setVisibility(0);
            TextView textView3 = this.U;
            if (textView3 == null) {
                k0.m("mTvCurrentVersion");
            }
            textView3.setVisibility(TextUtils.isEmpty(this.d7) ? 8 : 0);
            if (J1()) {
                ImageView imageView2 = this.L;
                if (imageView2 == null) {
                    k0.m("mIvUpdateState");
                }
                imageView2.setImageResource(com.lumiunited.aqarahome.R.mipmap.iv_firmware_update_available);
                View view2 = this.M;
                if (view2 == null) {
                    k0.m("mLayoutProgress");
                }
                view2.setVisibility(8);
                TextView textView4 = this.S;
                if (textView4 == null) {
                    k0.m("mTvUpgradeState");
                }
                StringBuilder sb = new StringBuilder();
                sb.append(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_latest_version));
                String str = this.f7;
                if (str == null) {
                    k0.f();
                }
                sb.append(str);
                textView4.setText(sb.toString());
                TextView textView5 = this.T;
                if (textView5 == null) {
                    k0.m("mTvTipAndLog");
                }
                textView5.setVisibility(0);
                TextView textView6 = this.T;
                if (textView6 == null) {
                    k0.m("mTvTipAndLog");
                }
                String str2 = this.g7;
                if (str2 == null) {
                    k0.m("mUpdateLog");
                }
                textView6.setText(str2);
                TextView textView7 = this.U;
                if (textView7 == null) {
                    k0.m("mTvCurrentVersion");
                }
                StringBuilder sb2 = new StringBuilder();
                sb2.append(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_current_version));
                String str3 = this.d7;
                if (str3 == null) {
                    k0.f();
                }
                sb2.append(str3);
                textView7.setText(sb2.toString());
                TextView textView8 = this.a7;
                if (textView8 == null) {
                    k0.m("mTvOk");
                }
                textView8.setVisibility(0);
                TextView textView9 = this.a7;
                if (textView9 == null) {
                    k0.m("mTvOk");
                }
                textView9.setText(getString(com.lumiunited.aqarahome.R.string.upgrade));
                return;
            }
            ImageView imageView3 = this.L;
            if (imageView3 == null) {
                k0.m("mIvUpdateState");
            }
            imageView3.setImageResource(com.lumiunited.aqarahome.R.mipmap.iv_firmware_update_lastest);
            TextView textView10 = this.S;
            if (textView10 == null) {
                k0.m("mTvUpgradeState");
            }
            textView10.setText(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_now_is_latest));
            TextView textView11 = this.T;
            if (textView11 == null) {
                k0.m("mTvTipAndLog");
            }
            textView11.setVisibility(8);
            TextView textView12 = this.U;
            if (textView12 == null) {
                k0.m("mTvCurrentVersion");
            }
            StringBuilder sb3 = new StringBuilder();
            sb3.append(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_current_version));
            String str4 = this.d7;
            if (str4 == null) {
                k0.f();
            }
            sb3.append(str4);
            textView12.setText(sb3.toString());
            TextView textView13 = this.a7;
            if (textView13 == null) {
                k0.m("mTvOk");
            }
            textView13.setVisibility(8);
        } else if (i2 == 1) {
            ImageView imageView4 = this.L;
            if (imageView4 == null) {
                k0.m("mIvUpdateState");
            }
            imageView4.setVisibility(8);
            View view3 = this.M;
            if (view3 == null) {
                k0.m("mLayoutProgress");
            }
            view3.setVisibility(0);
            RoundProgressBar roundProgressBar = this.R;
            if (roundProgressBar == null) {
                k0.m("mRpbUpgradeProgress");
            }
            roundProgressBar.setVisibility(0);
            if (this.b7) {
                ImageView imageView5 = this.N;
                if (imageView5 == null) {
                    k0.m("mIvSubdeviceLoading");
                }
                imageView5.setVisibility(0);
                P1();
            }
            TextView textView14 = this.S;
            if (textView14 == null) {
                k0.m("mTvUpgradeState");
            }
            textView14.setVisibility(0);
            TextView textView15 = this.S;
            if (textView15 == null) {
                k0.m("mTvUpgradeState");
            }
            textView15.setText(getString(com.lumiunited.aqarahome.R.string.firmware_upgrading));
            TextView textView16 = this.U;
            if (textView16 == null) {
                k0.m("mTvCurrentVersion");
            }
            textView16.setVisibility(8);
            TextView textView17 = this.T;
            if (textView17 == null) {
                k0.m("mTvTipAndLog");
            }
            textView17.setText(getString(this.b7 ? com.lumiunited.aqarahome.R.string.tip_subdevice_firmware_upgrade : com.lumiunited.aqarahome.R.string.tip_gateway_firmware_upgrade));
            TextView textView18 = this.a7;
            if (textView18 == null) {
                k0.m("mTvOk");
            }
            textView18.setVisibility(8);
        } else if (i2 == 0) {
            Q1();
            View view4 = this.M;
            if (view4 == null) {
                k0.m("mLayoutProgress");
            }
            view4.setVisibility(8);
            ImageView imageView6 = this.L;
            if (imageView6 == null) {
                k0.m("mIvUpdateState");
            }
            imageView6.setVisibility(0);
            ImageView imageView7 = this.L;
            if (imageView7 == null) {
                k0.m("mIvUpdateState");
            }
            imageView7.setImageResource(com.lumiunited.aqarahome.R.mipmap.iv_firmware_update_lastest);
            TextView textView19 = this.S;
            if (textView19 == null) {
                k0.m("mTvUpgradeState");
            }
            textView19.setText(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_now_is_latest));
            TextView textView20 = this.T;
            if (textView20 == null) {
                k0.m("mTvTipAndLog");
            }
            textView20.setVisibility(8);
            TextView textView21 = this.U;
            if (textView21 == null) {
                k0.m("mTvCurrentVersion");
            }
            textView21.setVisibility(0);
            TextView textView22 = this.U;
            if (textView22 == null) {
                k0.m("mTvCurrentVersion");
            }
            StringBuilder sb4 = new StringBuilder();
            sb4.append(getString(com.lumiunited.aqarahome.R.string.firmware_upgrade_current_version));
            String str5 = this.d7;
            if (str5 == null) {
                k0.f();
            }
            sb4.append(str5);
            textView22.setText(sb4.toString());
            TextView textView23 = this.a7;
            if (textView23 == null) {
                k0.m("mTvOk");
            }
            textView23.setVisibility(8);
        } else if (i2 == 2) {
            Q1();
            View view5 = this.M;
            if (view5 == null) {
                k0.m("mLayoutProgress");
            }
            view5.setVisibility(8);
            ImageView imageView8 = this.L;
            if (imageView8 == null) {
                k0.m("mIvUpdateState");
            }
            imageView8.setVisibility(0);
            ImageView imageView9 = this.L;
            if (imageView9 == null) {
                k0.m("mIvUpdateState");
            }
            imageView9.setImageResource(com.lumiunited.aqarahome.R.drawable.general_fail);
            TextView textView24 = this.S;
            if (textView24 == null) {
                k0.m("mTvUpgradeState");
            }
            textView24.setText(getString(com.lumiunited.aqarahome.R.string.tip_firmware_update_fail));
            TextView textView25 = this.T;
            if (textView25 == null) {
                k0.m("mTvTipAndLog");
            }
            textView25.setVisibility(0);
            TextView textView26 = this.T;
            if (textView26 == null) {
                k0.m("mTvTipAndLog");
            }
            textView26.setText(getString(com.lumiunited.aqarahome.R.string.tip_subdevice_firmware_upgrade_fail));
            TextView textView27 = this.a7;
            if (textView27 == null) {
                k0.m("mTvOk");
            }
            textView27.setVisibility(0);
            TextView textView28 = this.a7;
            if (textView28 == null) {
                k0.m("mTvOk");
            }
            textView28.setText(getString(com.lumiunited.aqarahome.R.string.retry));
        } else if (i2 == J7) {
            ImageView imageView10 = this.L;
            if (imageView10 == null) {
                k0.m("mIvUpdateState");
            }
            imageView10.setVisibility(8);
            View view6 = this.M;
            if (view6 == null) {
                k0.m("mLayoutProgress");
            }
            view6.setVisibility(0);
            RoundProgressBar roundProgressBar2 = this.R;
            if (roundProgressBar2 == null) {
                k0.m("mRpbUpgradeProgress");
            }
            roundProgressBar2.setVisibility(0);
            if (this.b7) {
                ImageView imageView11 = this.N;
                if (imageView11 == null) {
                    k0.m("mIvSubdeviceLoading");
                }
                imageView11.setVisibility(0);
                P1();
            }
            TextView textView29 = this.S;
            if (textView29 == null) {
                k0.m("mTvUpgradeState");
            }
            textView29.setVisibility(0);
            TextView textView30 = this.S;
            if (textView30 == null) {
                k0.m("mTvUpgradeState");
            }
            textView30.setText(this.h7);
            TextView textView31 = this.U;
            if (textView31 == null) {
                k0.m("mTvCurrentVersion");
            }
            textView31.setVisibility(8);
            TextView textView32 = this.T;
            if (textView32 == null) {
                k0.m("mTvTipAndLog");
            }
            textView32.setVisibility(0);
            TextView textView33 = this.T;
            if (textView33 == null) {
                k0.m("mTvTipAndLog");
            }
            textView33.setText(getString(this.b7 ? com.lumiunited.aqarahome.R.string.tip_subdevice_firmware_upgrade : com.lumiunited.aqarahome.R.string.tip_gateway_firmware_upgrade));
            TextView textView34 = this.a7;
            if (textView34 == null) {
                k0.m("mTvOk");
            }
            textView34.setVisibility(8);
        } else if (i2 == 10) {
        } else {
            if (i2 != 5) {
                if (i2 == 6) {
                    LinearLayout linearLayout = (LinearLayout) _$_findCachedViewById(R.id.layout_update_info);
                    k0.a((Object) linearLayout, "layout_update_info");
                    linearLayout.setVisibility(8);
                    TextView textView35 = (TextView) _$_findCachedViewById(R.id.tv_ok);
                    k0.a((Object) textView35, "tv_ok");
                    textView35.setVisibility(8);
                    TextView textView36 = (TextView) _$_findCachedViewById(R.id.retry_btn);
                    k0.a((Object) textView36, "retry_btn");
                    textView36.setVisibility(8);
                    ((ImageView) _$_findCachedViewById(R.id.iv_checking_update)).setImageResource(com.lumiunited.aqarahome.R.mipmap.loading_update);
                    ImageView imageView12 = (ImageView) _$_findCachedViewById(R.id.iv_checking_update);
                    k0.a((Object) imageView12, "iv_checking_update");
                    ViewGroup.LayoutParams layoutParams = imageView12.getLayoutParams();
                    if (layoutParams != null) {
                        ((LinearLayout.LayoutParams) layoutParams).topMargin = (int) getResources().getDimension(com.lumiunited.aqarahome.R.dimen.px174);
                        TextView textView37 = (TextView) _$_findCachedViewById(R.id.id_check_txt_des);
                        k0.a((Object) textView37, "id_check_txt_des");
                        textView37.setVisibility(4);
                        TextView textView38 = (TextView) _$_findCachedViewById(R.id.id_check_txt_title);
                        k0.a((Object) textView38, "id_check_txt_title");
                        textView38.setText(getString(com.lumiunited.aqarahome.R.string.txt_checking_update));
                        return;
                    }
                    throw new p1("null cannot be cast to non-null type android.widget.LinearLayout.LayoutParams");
                }
                return;
            }
            LinearLayout linearLayout2 = (LinearLayout) _$_findCachedViewById(R.id.layout_update_info);
            k0.a((Object) linearLayout2, "layout_update_info");
            linearLayout2.setVisibility(8);
            TextView textView39 = (TextView) _$_findCachedViewById(R.id.tv_ok);
            k0.a((Object) textView39, "tv_ok");
            textView39.setVisibility(8);
            LinearLayout linearLayout3 = (LinearLayout) _$_findCachedViewById(R.id.layout_checking_update);
            k0.a((Object) linearLayout3, "layout_checking_update");
            linearLayout3.setVisibility(0);
            TextView textView40 = (TextView) _$_findCachedViewById(R.id.id_check_txt_des);
            k0.a((Object) textView40, "id_check_txt_des");
            textView40.setVisibility(0);
            ImageView imageView13 = this.J;
            if (imageView13 == null) {
                k0.m("mIvCheckingUpdate");
            }
            imageView13.setImageResource(com.lumiunited.aqarahome.R.drawable.general_fail);
            ImageView imageView14 = this.J;
            if (imageView14 == null) {
                k0.m("mIvCheckingUpdate");
            }
            imageView14.getAnimation().cancel();
            TextView textView41 = (TextView) _$_findCachedViewById(R.id.id_check_txt_title);
            k0.a((Object) textView41, "id_check_txt_title");
            textView41.setText(getString(com.lumiunited.aqarahome.R.string.txt_check_update_fail));
            TextView textView42 = (TextView) _$_findCachedViewById(R.id.id_check_txt_des);
            k0.a((Object) textView42, "id_check_txt_des");
            StringBuilder sb5 = new StringBuilder();
            sb5.append(getString(com.lumiunited.aqarahome.R.string.txt_current_version));
            String str6 = this.d7;
            if (str6 == null) {
                k0.f();
            }
            sb5.append(str6);
            textView42.setText(sb5.toString());
            ((LinearLayout) _$_findCachedViewById(R.id.layout_checking_update)).requestLayout();
        }
    }

    private final void H1() {
        this.f8954q = getIntent().getStringExtra("did");
        this.b7 = getIntent().getBooleanExtra("isSubdevice", false);
        k.u.c.i.e3.h.c.h0.a("isDownload = " + this.b7, null, 1, null);
        this.c7.add(this.f8954q);
    }

    public final void I(int i2) {
        RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(R.id.rpb_upgrade_progress);
        k0.a((Object) roundProgressBar, "rpb_upgrade_progress");
        roundProgressBar.setProgress(i2);
        if (i2 != 100 || this.b7) {
            return;
        }
        TextView textView = (TextView) _$_findCachedViewById(R.id.tv_upgrade_state);
        k0.a((Object) textView, "tv_upgrade_state");
        textView.setText(getString(com.lumiunited.aqarahome.R.string.firmware_rebooting));
        RoundProgressBar roundProgressBar2 = (RoundProgressBar) _$_findCachedViewById(R.id.rpb_upgrade_progress);
        k0.a((Object) roundProgressBar2, "rpb_upgrade_progress");
        roundProgressBar2.setVisibility(8);
        ImageView imageView = this.L;
        if (imageView == null) {
            k0.m("mIvUpdateState");
        }
        imageView.setVisibility(0);
        ImageView imageView2 = this.L;
        if (imageView2 == null) {
            k0.m("mIvUpdateState");
        }
        imageView2.setImageResource(com.lumiunited.aqarahome.R.mipmap.iv_firmware_update_lastest);
        TextView textView2 = this.T;
        if (textView2 == null) {
            k0.m("mTvTipAndLog");
        }
        textView2.setText(getString(com.lumiunited.aqarahome.R.string.tip_gateway_is_reboot));
    }

    private final void I1() {
        View findViewById = findViewById(com.lumiunited.aqarahome.R.id.layout_checking_update);
        k0.a((Object) findViewById, "findViewById(R.id.layout_checking_update)");
        this.I = (Group) findViewById;
        View findViewById2 = findViewById(com.lumiunited.aqarahome.R.id.iv_checking_update);
        k0.a((Object) findViewById2, "findViewById(R.id.iv_checking_update)");
        this.J = (ImageView) findViewById2;
        View findViewById3 = findViewById(com.lumiunited.aqarahome.R.id.layout_update_info);
        k0.a((Object) findViewById3, "findViewById(R.id.layout_update_info)");
        this.K = findViewById3;
        View findViewById4 = findViewById(com.lumiunited.aqarahome.R.id.iv_update_state);
        k0.a((Object) findViewById4, "findViewById(R.id.iv_update_state)");
        this.L = (ImageView) findViewById4;
        View findViewById5 = findViewById(com.lumiunited.aqarahome.R.id.layout_progress);
        k0.a((Object) findViewById5, "findViewById(R.id.layout_progress)");
        this.M = findViewById5;
        View findViewById6 = findViewById(com.lumiunited.aqarahome.R.id.iv_subdevice_loading);
        k0.a((Object) findViewById6, "findViewById(R.id.iv_subdevice_loading)");
        this.N = (ImageView) findViewById6;
        View findViewById7 = findViewById(com.lumiunited.aqarahome.R.id.rpb_upgrade_progress);
        k0.a((Object) findViewById7, "findViewById(R.id.rpb_upgrade_progress)");
        this.R = (RoundProgressBar) findViewById7;
        View findViewById8 = findViewById(com.lumiunited.aqarahome.R.id.tv_upgrade_state);
        k0.a((Object) findViewById8, "findViewById(R.id.tv_upgrade_state)");
        this.S = (TextView) findViewById8;
        View findViewById9 = findViewById(com.lumiunited.aqarahome.R.id.tv_tip_and_log);
        k0.a((Object) findViewById9, "findViewById(R.id.tv_tip_and_log)");
        this.T = (TextView) findViewById9;
        View findViewById10 = findViewById(com.lumiunited.aqarahome.R.id.tv_current_version);
        k0.a((Object) findViewById10, "findViewById(R.id.tv_current_version)");
        this.U = (TextView) findViewById10;
        View findViewById11 = findViewById(com.lumiunited.aqarahome.R.id.tv_ok);
        k0.a((Object) findViewById11, "findViewById(R.id.tv_ok)");
        this.a7 = (TextView) findViewById11;
        ((TextView) _$_findCachedViewById(R.id.retry_btn)).setOnClickListener(new l());
        MultiTypeAdapter multiTypeAdapter = new MultiTypeAdapter(this.u7);
        this.v7 = multiTypeAdapter;
        if (multiTypeAdapter == null) {
            k0.m("stateAdapter");
        }
        multiTypeAdapter.a(GatewayAddStatusBean.class, new k.u.c.i.a3.g0.a1.p1.b());
        RecyclerView recyclerView = (RecyclerView) _$_findCachedViewById(R.id.rv_content);
        k0.a((Object) recyclerView, "rv_content");
        MultiTypeAdapter multiTypeAdapter2 = this.v7;
        if (multiTypeAdapter2 == null) {
            k0.m("stateAdapter");
        }
        recyclerView.setAdapter(multiTypeAdapter2);
        RecyclerView recyclerView2 = (RecyclerView) _$_findCachedViewById(R.id.rv_content);
        k0.a((Object) recyclerView2, "rv_content");
        recyclerView2.setLayoutManager(new LinearLayoutManager(this));
        if (this.f8955r != null) {
            k.u.c.i.i3.e.a aVar = this.p7;
            if (aVar == null) {
                k0.m("bleManager");
            }
            BaseDeviceEntity baseDeviceEntity = this.f8955r;
            k0.a((Object) baseDeviceEntity, "mBaseDeviceInfo");
            String firmwareVersion = baseDeviceEntity.getFirmwareVersion();
            k0.a((Object) firmwareVersion, "mBaseDeviceInfo.firmwareVersion");
            aVar.a(firmwareVersion);
        }
        _$_findCachedViewById(R.id.start_ota_test).setOnClickListener(new m());
        TextView textView = this.a7;
        if (textView == null) {
            k0.m("mTvOk");
        }
        textView.setOnClickListener(this);
        D(true);
        L1();
        getWindow().addFlags(128);
    }

    private final boolean J1() {
        return (this.d7 == null || TextUtils.isEmpty(this.f7) || k0.a((Object) this.d7, (Object) this.f7)) ? false : true;
    }

    public final void K1() {
        Intent intent = new Intent();
        intent.setAction("android.settings.BLUETOOTH_SETTINGS");
        intent.setFlags(268435456);
        try {
            startActivity(intent);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public final void L1() {
        m1.d().a(this.f8954q, this.C7, new o());
        m1.d().i(this.f8954q, new p());
    }

    private final void M1() {
        String str = null;
        this.h7 = null;
        int i2 = this.k7;
        boolean z2 = true;
        if (i2 != 908) {
            int i3 = J7;
            if (i2 == i3) {
                H(i3);
                z2 = false;
            } else if (i2 == 912) {
                str = getString(com.lumiunited.aqarahome.R.string.tip_firmware_can_not_upgrade);
            } else if (i2 == 602) {
                str = getString(com.lumiunited.aqarahome.R.string.device_offline_hint);
            }
        }
        String str2 = this.n7;
        if (str2 == null) {
            k0.m("mErrorMsg");
        }
        if (!TextUtils.isEmpty(str2) && (str = this.n7) == null) {
            k0.m("mErrorMsg");
        }
        if (z2) {
            y0 a2 = new y0.c(this).d(str).b(getString(com.lumiunited.aqarahome.R.string.confirm), new q()).a();
            this.B7 = a2;
            if (a2 == null) {
                k0.f();
            }
            a2.show();
        }
    }

    public final void N1() {
        w0 a2 = new w0.b(this).g("后台升级").b("http://demo.lumiunited.com:1115/s2_plus/.bin").d(getString(17039360)).e(getString(com.lumiunited.aqarahome.R.string.confirm)).a();
        k0.a((Object) a2, "ClearableEditDialog.Buil…\n                .build()");
        this.x7 = a2;
        if (a2 == null) {
            k0.m("inputUrlDialog");
        }
        a2.setCanceledOnTouchOutside(false);
        w0 w0Var = this.x7;
        if (w0Var == null) {
            k0.m("inputUrlDialog");
        }
        w0Var.a(new r());
        w0 w0Var2 = this.x7;
        if (w0Var2 == null) {
            k0.m("inputUrlDialog");
        }
        w0Var2.show();
    }

    public final void O1() {
        ScanSettings build = new ScanSettings.Builder().setScanMode(0).build();
        ArrayList arrayList = new ArrayList();
        arrayList.add(new ScanFilter.Builder().setServiceUuid(O7).build());
        arrayList.add(new ScanFilter.Builder().setDeviceName("S2 Pro+").build());
        if (this.H == null) {
            this.H = new s();
        }
        BluetoothAdapter bluetoothAdapter = this.r7;
        if (bluetoothAdapter == null) {
            k0.m("adapter");
        }
        bluetoothAdapter.getBluetoothLeScanner().startScan(arrayList, build, this.H);
    }

    private final void P1() {
        RoundProgressBar roundProgressBar = this.R;
        if (roundProgressBar == null) {
            k0.m("mRpbUpgradeProgress");
        }
        int cricleColor = roundProgressBar.getCricleColor();
        RoundProgressBar roundProgressBar2 = this.R;
        if (roundProgressBar2 == null) {
            k0.m("mRpbUpgradeProgress");
        }
        int cricleProgressColor = roundProgressBar2.getCricleProgressColor();
        ValueAnimator ofInt = ValueAnimator.ofInt(0, 200);
        k0.a((Object) ofInt, "ValueAnimator.ofInt(0, 200)");
        this.z7 = ofInt;
        if (ofInt == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        ofInt.addUpdateListener(new t(cricleColor, cricleProgressColor));
        ValueAnimator valueAnimator = this.z7;
        if (valueAnimator == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        valueAnimator.setDuration(TooltipCompatHandler.LONG_CLICK_HIDE_TIMEOUT_MS);
        ValueAnimator valueAnimator2 = this.z7;
        if (valueAnimator2 == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        valueAnimator2.setRepeatCount(10000);
        ValueAnimator valueAnimator3 = this.z7;
        if (valueAnimator3 == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        valueAnimator3.setRepeatMode(1);
        ValueAnimator valueAnimator4 = this.z7;
        if (valueAnimator4 == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        valueAnimator4.start();
    }

    private final void Q1() {
        S1();
        p.a.u0.c cVar = this.A7;
        if (cVar != null) {
            if (cVar == null) {
                k0.f();
            }
            if (cVar.isDisposed()) {
                return;
            }
            p.a.u0.c cVar2 = this.A7;
            if (cVar2 == null) {
                k0.f();
            }
            cVar2.dispose();
        }
    }

    public final void R1() {
        BluetoothAdapter bluetoothAdapter = this.r7;
        if (bluetoothAdapter == null) {
            k0.m("adapter");
        }
        bluetoothAdapter.getBluetoothLeScanner().stopScan(this.H);
    }

    private final void S1() {
        if (this.b7) {
            ValueAnimator valueAnimator = this.z7;
            if (valueAnimator == null) {
                k0.m("mSubdeviceProgressAnimator");
            }
            if (valueAnimator != null) {
                ValueAnimator valueAnimator2 = this.z7;
                if (valueAnimator2 == null) {
                    k0.m("mSubdeviceProgressAnimator");
                }
                valueAnimator2.cancel();
            }
        }
    }

    private final void T1() {
        BluetoothAdapter bluetoothAdapter = this.r7;
        if (bluetoothAdapter == null) {
            k0.m("adapter");
        }
        if (!bluetoothAdapter.enable()) {
            y0 a2 = new y0.c(this).d(getString(com.lumiunited.aqarahome.R.string.txt_open_blue_tooth)).a(getString(17039360), new u()).c(getString(com.lumiunited.aqarahome.R.string.confirm), new v()).a();
            k0.a((Object) a2, "CustomAlertDialog.Builde…                 .build()");
            this.t7 = a2;
            if (a2 == null) {
                k0.m("openBluetoothDialog");
            }
            a2.show();
            return;
        }
        File cacheDir = getCacheDir();
        k0.a((Object) cacheDir, "cacheDir");
        String path = cacheDir.getPath();
        UpgradeFirmwareBean upgradeFirmwareBean = this.e7;
        if (upgradeFirmwareBean == null) {
            k0.f();
        }
        String downloadUrl = upgradeFirmwareBean.getDownloadUrl();
        k.u.c.i.i3.e.a aVar = this.p7;
        if (aVar == null) {
            k0.m("bleManager");
        }
        UpgradeFirmwareBean upgradeFirmwareBean2 = this.e7;
        if (upgradeFirmwareBean2 == null) {
            k0.f();
        }
        String firmwareVersion = upgradeFirmwareBean2.getFirmwareVersion();
        k0.a((Object) firmwareVersion, "mUpgradeFirmwareBean!!.firmwareVersion");
        aVar.b(firmwareVersion);
        l0.i().a(this, downloadUrl, path, new w());
    }

    public static final w0 b(UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity) {
        w0 w0Var = upgradeFirmwareByBLEActivity.x7;
        if (w0Var == null) {
            k0.m("inputUrlDialog");
        }
        return w0Var;
    }

    public static final y0 i(UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity) {
        y0 y0Var = upgradeFirmwareByBLEActivity.t7;
        if (y0Var == null) {
            k0.m("openBluetoothDialog");
        }
        return y0Var;
    }

    public static final MultiTypeAdapter j(UpgradeFirmwareByBLEActivity upgradeFirmwareByBLEActivity) {
        MultiTypeAdapter multiTypeAdapter = upgradeFirmwareByBLEActivity.v7;
        if (multiTypeAdapter == null) {
            k0.m("stateAdapter");
        }
        return multiTypeAdapter;
    }

    public final void m0(String str) {
        File cacheDir = getCacheDir();
        k0.a((Object) cacheDir, "cacheDir");
        l0.i().a(this, str, cacheDir.getPath(), new k());
    }

    public final boolean n0(String str) {
        String str2 = this.f8954q;
        k0.a((Object) str2, "mDid");
        if (str2 != null) {
            String substring = str2.substring(5);
            k0.d(substring, "(this as java.lang.String).substring(startIndex)");
            if (c0.c((CharSequence) str, (CharSequence) substring, false, 2, (Object) null)) {
                k.u.c.i.e3.h.c.h0.a("result  ---  蓝牙扫描结果:" + str + "  ----  current Serial: " + substring, null, 1, null);
                return true;
            }
            return false;
        }
        throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
    }

    @Override
    public void A(int i2) {
        H(0);
    }

    public final void D(int i2) {
        this.k7 = i2;
    }

    public final void E(int i2) {
        this.i7 = i2;
    }

    public final void F(int i2) {
        this.l7 = i2;
    }

    @Override
    public void U() {
    }

    @Override
    public void _$_clearFindViewByIdCache() {
        HashMap hashMap = this.D7;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    @Override
    public View _$_findCachedViewById(int i2) {
        if (this.D7 == null) {
            this.D7 = new HashMap();
        }
        View view = (View) this.D7.get(Integer.valueOf(i2));
        if (view == null) {
            View findViewById = findViewById(i2);
            this.D7.put(Integer.valueOf(i2), findViewById);
            return findViewById;
        }
        return view;
    }

    @x.b.a.m(threadMode = ThreadMode.MAIN)
    public final void checkFirmwareResultEvent(@NotNull CheckFirmwareResultEvent checkFirmwareResultEvent) {
        k0.f(checkFirmwareResultEvent, "event");
        StringBuilder sb = new StringBuilder();
        sb.append("loadUpgradeProgress device upgrade checkFirmwareResultEvent: ");
        String formatedString = checkFirmwareResultEvent.getFormatedString();
        if (formatedString == null) {
            k0.f();
        }
        sb.append(formatedString);
        k.u.c.i.e3.h.c.h0.a(sb.toString(), null, 1, null);
        if (!k0.a((Object) this.f8954q, (Object) checkFirmwareResultEvent.getDid())) {
            return;
        }
        if (checkFirmwareResultEvent.getUpgradeResult() == 0) {
            x.b.a.c.f().c(new k.u.c.i.g3.t(true, this.f7));
            if (this.e7 != null) {
                if (k.u.c.r.l.d.q(this)) {
                    D1();
                }
                this.d7 = this.f7;
            }
            H(0);
            return;
        }
        Q1();
        H(2);
    }

    @Override
    public void f(@Nullable String str) {
    }

    @NotNull
    public final BluetoothAdapter f1() {
        BluetoothAdapter bluetoothAdapter = this.r7;
        if (bluetoothAdapter == null) {
            k0.m("adapter");
        }
        return bluetoothAdapter;
    }

    @NotNull
    public final k.u.c.i.i3.e.a g1() {
        k.u.c.i.i3.e.a aVar = this.p7;
        if (aVar == null) {
            k0.m("bleManager");
        }
        return aVar;
    }

    public final int h1() {
        return this.k7;
    }

    public final void i0(@NotNull String str) {
        k0.f(str, "<set-?>");
        this.n7 = str;
    }

    @Nullable
    public final y0 i1() {
        return this.B7;
    }

    public final void j0(@NotNull String str) {
        k0.f(str, "<set-?>");
        this.g7 = str;
    }

    @NotNull
    public final String j1() {
        String str = this.n7;
        if (str == null) {
            k0.m("mErrorMsg");
        }
        return str;
    }

    public final void k0(@NotNull String str) {
        k0.f(str, "<set-?>");
        this.o7 = str;
    }

    @NotNull
    public final RoundProgressBar k1() {
        RoundProgressBar roundProgressBar = this.R;
        if (roundProgressBar == null) {
            k0.m("mRpbUpgradeProgress");
        }
        return roundProgressBar;
    }

    public final void l0(@Nullable String str) {
        this.m7 = str;
    }

    public final int l1() {
        return this.i7;
    }

    @NotNull
    public final ValueAnimator m1() {
        ValueAnimator valueAnimator = this.z7;
        if (valueAnimator == null) {
            k0.m("mSubdeviceProgressAnimator");
        }
        return valueAnimator;
    }

    @NotNull
    public final TextView n1() {
        TextView textView = this.U;
        if (textView == null) {
            k0.m("mTvCurrentVersion");
        }
        return textView;
    }

    @NotNull
    public final TextView o1() {
        TextView textView = this.a7;
        if (textView == null) {
            k0.m("mTvOk");
        }
        return textView;
    }

    @Override
    public void onClick(@NotNull View view) {
        k0.f(view, "v");
        if (view.getId() != com.lumiunited.aqarahome.R.id.tv_ok) {
            return;
        }
        E1();
    }

    @Override
    public void onCreate(@Nullable Bundle bundle) {
        BluetoothAdapter adapter;
        super.onCreate(bundle);
        setContentView(com.lumiunited.aqarahome.R.layout.activity_upgrade_firmware_with_ble);
        x.b.a.c.f().e(this);
        this.p7 = a.C0644a.c.a();
        H1();
        I1();
        Object systemService = getSystemService("bluetooth");
        if (!(systemService instanceof BluetoothManager)) {
            systemService = null;
        }
        BluetoothManager bluetoothManager = (BluetoothManager) systemService;
        if (bluetoothManager == null || (adapter = bluetoothManager.getAdapter()) == null) {
            return;
        }
        this.r7 = adapter;
    }

    @Override
    public void onDestroy() {
        if (x.b.a.c.f().b(this)) {
            x.b.a.c.f().g(this);
        }
        k.u.c.i.i3.e.a aVar = this.p7;
        if (aVar == null) {
            k0.m("bleManager");
        }
        aVar.d();
        getWindow().clearFlags(128);
        super.onDestroy();
    }

    @Override
    public void onRequestPermissionsResult(int i2, @NotNull String[] strArr, @NotNull int[] iArr) {
        k0.f(strArr, z.a.a.e.f33396l);
        k0.f(iArr, "grantResults");
        if (i2 == this.s7 && iArr[0] == 0) {
            T1();
        }
    }

    @NotNull
    public final TextView p1() {
        TextView textView = this.T;
        if (textView == null) {
            k0.m("mTvTipAndLog");
        }
        return textView;
    }

    @NotNull
    public final TextView q1() {
        TextView textView = this.S;
        if (textView == null) {
            k0.m("mTvUpgradeState");
        }
        return textView;
    }

    @NotNull
    public final String r1() {
        String str = this.g7;
        if (str == null) {
            k0.m("mUpdateLog");
        }
        return str;
    }

    public final int s1() {
        return this.l7;
    }

    @NotNull
    public final File t1() {
        File file = this.q7;
        if (file == null) {
            k0.m("otaFile");
        }
        return file;
    }

    @Override
    public void u(int i2) {
        this.h7 = getString(com.lumiunited.aqarahome.R.string.tip_waiting_for_upgrade);
        H(J7);
    }

    @NotNull
    public final String u1() {
        String str = this.o7;
        if (str == null) {
            k0.m("randomForOTA");
        }
        return str;
    }

    public final boolean v1() {
        return this.j7;
    }

    @Nullable
    public final String w1() {
        return this.m7;
    }

    public final boolean x1() {
        return this.q7 != null;
    }

    public final boolean y1() {
        return this.o7 != null;
    }

    private final void D(boolean z2) {
        Group group = this.I;
        if (group == null) {
            k0.m("mViewCheckingUpdate");
        }
        group.setVisibility(z2 ? 0 : 8);
        View view = this.K;
        if (view == null) {
            k0.m("mLayoutVersionInfo");
        }
        view.setVisibility(8);
        TextView textView = this.a7;
        if (textView == null) {
            k0.m("mTvOk");
        }
        textView.setVisibility(8);
        k.u.c.i.e3.h.c.h0.a("getResources().getDimensionPixelSize(R.dimen.px24) = " + getResources().getDimensionPixelSize(com.lumiunited.aqarahome.R.dimen.px24), null, 1, null);
        if (z2) {
            RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 359.0f, getResources().getDimensionPixelSize(com.lumiunited.aqarahome.R.dimen.px24), getResources().getDimensionPixelSize(com.lumiunited.aqarahome.R.dimen.px24));
            rotateAnimation.setInterpolator(new LinearInterpolator());
            rotateAnimation.setRepeatCount(-1);
            rotateAnimation.setDuration(300L);
            ImageView imageView = this.J;
            if (imageView == null) {
                k0.m("mIvCheckingUpdate");
            }
            imageView.setAnimation(rotateAnimation);
            ImageView imageView2 = this.J;
            if (imageView2 == null) {
                k0.m("mIvCheckingUpdate");
            }
            imageView2.startAnimation(rotateAnimation);
        }
    }

    @Override
    public void f(int i2) {
        k.u.c.i.e3.h.c.h0.a("loadUpgradeProgress progress = " + i2, null, 1, null);
        if (!this.u7.isEmpty()) {
            u.a.a.g gVar = this.u7;
            Object obj = gVar.get(gVar.size() - 1);
            if (obj != null) {
                if (((GatewayAddStatusBean) obj).getStatus() == 0) {
                    this.u7.add(new GatewayAddStatusBean("固件正在升级", 2));
                    MultiTypeAdapter multiTypeAdapter = this.v7;
                    if (multiTypeAdapter == null) {
                        k0.m("stateAdapter");
                    }
                    multiTypeAdapter.notifyItemInserted(this.u7.size() - 1);
                }
            } else {
                throw new p1("null cannot be cast to non-null type com.lumiunited.aqara.device.adddevicepage.gateway.view.viewbinder.GatewayAddStatusBean");
            }
        }
        F1();
        H(1);
        I(i2);
    }

    public final void d(@NotNull TextView textView) {
        k0.f(textView, "<set-?>");
        this.S = textView;
    }

    public final void c(@NotNull TextView textView) {
        k0.f(textView, "<set-?>");
        this.T = textView;
    }

    public final void b(@NotNull TextView textView) {
        k0.f(textView, "<set-?>");
        this.a7 = textView;
    }

    public final void b(File file) {
        k.u.c.i.e3.h.c.h0.a("get random num ---- start", null, 1, null);
        this.C7.clear();
        this.C7.put("lock_random_code", "s2 Pro HL");
        d("正在更新", 0);
        this.f8942e.b(m1.d().c(this.f8954q, this.C7).j().a(2L).b(2).a(p.a.s0.d.a.a()).v(c.a).p(new d()).v(new e()).B(new k.u.c.d.h.b(30, 2000)).a(p.a.s0.d.a.a()).subscribe(new f(file), new g()));
    }

    public final void a(@NotNull RoundProgressBar roundProgressBar) {
        k0.f(roundProgressBar, "<set-?>");
        this.R = roundProgressBar;
    }

    public final void a(@NotNull TextView textView) {
        k0.f(textView, "<set-?>");
        this.U = textView;
    }

    public final void a(@NotNull k.u.c.i.i3.e.a aVar) {
        k0.f(aVar, "<set-?>");
        this.p7 = aVar;
    }

    public final void a(@NotNull File file) {
        k0.f(file, "<set-?>");
        this.q7 = file;
    }

    public final void a(@NotNull BluetoothAdapter bluetoothAdapter) {
        k0.f(bluetoothAdapter, "<set-?>");
        this.r7 = bluetoothAdapter;
    }

    public final void a(@NotNull ValueAnimator valueAnimator) {
        k0.f(valueAnimator, "<set-?>");
        this.z7 = valueAnimator;
    }

    public final void a(@Nullable y0 y0Var) {
        this.B7 = y0Var;
    }

    public final void a(BluetoothDevice bluetoothDevice) {
        k.u.c.i.i3.e.a aVar = this.p7;
        if (aVar == null) {
            k0.m("bleManager");
        }
        aVar.a(new j());
        k.u.c.i.i3.e.a aVar2 = this.p7;
        if (aVar2 == null) {
            k0.m("bleManager");
        }
        aVar2.a(bluetoothDevice).a(5, 200).d(15000L).a(true).a();
        C(true);
    }

    @Override
    public void b(int i2, int i3) {
        H(2);
    }
}