Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 UpgradeFirmwareByBLEActivity2.java 源代码,内容仅作参考
package com.lumiunited.aqara.device.devicepage.gateway.firmware;
import android.animation.ValueAnimator;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.BluetoothLeScanner;
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.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
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.alibaba.fastjson.JSONObject;
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.bean.UpdatingProcessBean;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.bean.FirmwareBean;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.bean.UpgradeFirmwareBean;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.viewholder.UpdatingProcessAdapter;
import com.lumiunited.aqara.device.devicepage.gateway.firmware.widget.FirmwareUpDatingWidget;
import com.lumiunited.aqara.web.event.CheckFirmwareResultEvent;
import com.lumiunited.aqarahome.R;
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.Map;
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.e3.h.c.a0;
import k.u.c.i.e3.h.c.g0;
import k.u.c.i.i3.e.a;
import k.u.c.i.m1;
import kotlin.reflect.KDeclarationContainer;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import p.a.b0;
import s.b3.w.f0;
import s.b3.w.k0;
import s.b3.w.k1;
import s.h0;
import s.i3.c0;
import s.n1;
import s.r2.b1;
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\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\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\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u000b\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\u0010i\u001a\u00020j2\u0006\u0010k\u001a\u00020lH\u0002J \u0010m\u001a\u00020j2\u0006\u0010n\u001a\u00020\b2\u0006\u0010o\u001a\u00020\b2\u0006\u0010p\u001a\u00020#H\u0002J\u0010\u0010q\u001a\u00020j2\u0006\u0010r\u001a\u00020sH\u0002J\u0010\u0010t\u001a\u00020j2\u0006\u0010u\u001a\u00020vH\u0007J\u0010\u0010t\u001a\u00020j2\u0006\u0010u\u001a\u00020wH\u0007J\b\u0010x\u001a\u00020jH\u0002J\u0010\u0010y\u001a\u00020j2\u0006\u0010z\u001a\u00020UH\u0002J\b\u0010{\u001a\u00020jH\u0002J\u0010\u0010|\u001a\u00020j2\u0006\u0010}\u001a\u00020~H\u0002J\b\u0010\u007f\u001a\u00020jH\u0002J\u0012\u0010\u0080\u0001\u001a\u00020j2\u0007\u0010\u0081\u0001\u001a\u00020#H\u0002J\t\u0010\u0082\u0001\u001a\u00020jH\u0002J\t\u0010\u0083\u0001\u001a\u00020'H\u0002J\u0012\u0010\u0084\u0001\u001a\u00020'2\u0007\u0010\u0085\u0001\u001a\u00020#H\u0002J\t\u0010\u0086\u0001\u001a\u00020jH\u0002J\t\u0010\u0087\u0001\u001a\u00020jH\u0002J\u0007\u0010\u0088\u0001\u001a\u00020'J\u0007\u0010\u0089\u0001\u001a\u00020'J\u0012\u0010\u008a\u0001\u001a\u00020j2\u0007\u0010\u008b\u0001\u001a\u00020\bH\u0002J\u0011\u0010\u008c\u0001\u001a\u00020j2\u0006\u0010)\u001a\u00020'H\u0002J\u0012\u0010\u008d\u0001\u001a\u00020j2\u0007\u0010\u008e\u0001\u001a\u00020sH\u0016J\u0015\u0010\u008f\u0001\u001a\u00020j2\n\u0010\u0090\u0001\u001a\u0005\u0018\u00010\u0091\u0001H\u0014J\t\u0010\u0092\u0001\u001a\u00020jH\u0014J\u001b\u0010\u0093\u0001\u001a\u00020j2\u0007\u0010\u0094\u0001\u001a\u00020\b2\u0007\u0010\u0095\u0001\u001a\u00020\bH\u0016J\u0014\u0010\u0096\u0001\u001a\u00020j2\t\u0010\u0097\u0001\u001a\u0004\u0018\u00010#H\u0016J\u0012\u0010\u0098\u0001\u001a\u00020j2\u0007\u0010u\u001a\u00030\u0099\u0001H\u0007J\u0012\u0010\u009a\u0001\u001a\u00020j2\u0007\u0010\u009b\u0001\u001a\u00020\bH\u0016J\t\u0010\u009c\u0001\u001a\u00020jH\u0016J4\u0010\u009d\u0001\u001a\u00020j2\u0007\u0010\u009e\u0001\u001a\u00020\b2\u0010\u0010\u009f\u0001\u001a\u000b\u0012\u0006\b\u0001\u0012\u00020#0 \u00012\b\u0010¡\u0001\u001a\u00030¢\u0001H\u0016¢\u0006\u0003\u0010£\u0001J\u0011\u0010¤\u0001\u001a\u00020j2\u0006\u0010o\u001a\u00020\bH\u0016J\u0011\u0010¥\u0001\u001a\u00020j2\u0006\u0010o\u001a\u00020\bH\u0016J\t\u0010¦\u0001\u001a\u00020jH\u0002J\t\u0010§\u0001\u001a\u00020jH\u0002J\t\u0010¨\u0001\u001a\u00020jH\u0002J\u0012\u0010©\u0001\u001a\u00020j2\u0007\u0010u\u001a\u00030ª\u0001H\u0007J\t\u0010«\u0001\u001a\u00020jH\u0002J\t\u0010¬\u0001\u001a\u00020jH\u0002J\t\u0010\u00ad\u0001\u001a\u00020jH\u0002J\t\u0010®\u0001\u001a\u00020jH\u0002J\t\u0010¯\u0001\u001a\u00020jH\u0002J\t\u0010°\u0001\u001a\u00020jH\u0002J\t\u0010±\u0001\u001a\u00020jH\u0002J\u0012\u0010²\u0001\u001a\u00020j2\u0007\u0010³\u0001\u001a\u00020\bH\u0002R\u0014\u0010\u0007\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\nR\u0014\u0010\u000b\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\f\u0010\nR\u0014\u0010\r\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u000e\u0010\nR\u0014\u0010\u000f\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\nR\u000e\u0010\u0011\u001a\u00020\bX\u0082D¢\u0006\u0002\n\u0000R\u001a\u0010\u0012\u001a\u00020\u0013X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0014\u0010\u0015\"\u0004\b\u0016\u0010\u0017R\u000e\u0010\u0018\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u001aX\u0082.¢\u0006\u0002\n\u0000R\u001a\u0010\u001b\u001a\u00020\u001cX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\u001d\u0010\u001e\"\u0004\b\u001f\u0010 R\u001a\u0010!\u001a\u000e\u0012\u0004\u0012\u00020#\u0012\u0004\u0012\u00020#0\"X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010$\u001a\u0004\u0018\u00010%X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010&\u001a\u00020'8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b&\u0010(R\u000e\u0010)\u001a\u00020'X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010*\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010+\u001a\u0012\u0012\u0004\u0012\u00020#0,j\b\u0012\u0004\u0012\u00020#`-X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010.\u001a\u0004\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010/\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b0\u0010\n\"\u0004\b1\u00102R\u001c\u00103\u001a\u0004\u0018\u000104X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b5\u00106\"\u0004\b7\u00108R\u001a\u00109\u001a\u00020#X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b:\u0010;\"\u0004\b<\u0010=R\u000e\u0010>\u001a\u00020'X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010?\u001a\u00020@X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010A\u001a\u00020\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bB\u0010\n\"\u0004\bC\u00102R\u001a\u0010D\u001a\u00020EX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bF\u0010G\"\u0004\bH\u0010IR\u001a\u0010J\u001a\u00020#X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bK\u0010;\"\u0004\bL\u0010=R\u0010\u0010M\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010N\u001a\u0004\u0018\u00010OX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010P\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010Q\u001a\u000204X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010R\u001a\u000204X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010S\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010T\u001a\u00020UX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\bV\u0010W\"\u0004\bX\u0010YR\u0010\u0010Z\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010[\u001a\u00020#X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\\\u0010;\"\u0004\b]\u0010=R\u000e\u0010^\u001a\u00020_X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010`\u001a\u0004\u0018\u00010aX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010b\u001a\u00020'X\u0086D¢\u0006\b\n\u0000\u001a\u0004\bc\u0010(R\u001c\u0010d\u001a\u0004\u0018\u00010#X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\be\u0010;\"\u0004\bf\u0010=R\u000e\u0010g\u001a\u00020hX\u0082.¢\u0006\u0002\n\u0000¨\u0006µ\u0001"}, d2 = {"Lcom/lumiunited/aqara/device/devicepage/gateway/firmware/UpgradeFirmwareByBLEActivity2;", "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", "ACTION_TYPE__CONNECT_BLUETOOTH", "", "getACTION_TYPE__CONNECT_BLUETOOTH", "()I", "ACTION_TYPE__DOWLOAD_OTA", "getACTION_TYPE__DOWLOAD_OTA", "ACTION_TYPE__REBOOT", "getACTION_TYPE__REBOOT", "ACTION_TYPE__TRANSLATING_OTA", "getACTION_TYPE__TRANSLATING_OTA", "CODE_GETFINELOCATION", "adapter", "Landroid/bluetooth/BluetoothAdapter;", "getAdapter", "()Landroid/bluetooth/BluetoothAdapter;", "setAdapter", "(Landroid/bluetooth/BluetoothAdapter;)V", "backgroundUpdateCount", "bleConnectCountDown", "Lio/reactivex/disposables/Disposable;", "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;", "Lkotlin/collections/ArrayList;", "mDisposable", "mErrorCode", "getMErrorCode", "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", "mShowItems", "Lme/drakeet/multitype/Items;", "mSubdeviceProgress", "getMSubdeviceProgress", "setMSubdeviceProgress", "mSubdeviceProgressAnimator", "Landroid/animation/ValueAnimator;", "getMSubdeviceProgressAnimator", "()Landroid/animation/ValueAnimator;", "setMSubdeviceProgressAnimator", "(Landroid/animation/ValueAnimator;)V", "mUpdateLog", "getMUpdateLog", "setMUpdateLog", "mUpdateState", "mUpgradeFirmwareBean", "Lcom/lumiunited/aqara/device/devicepage/gateway/firmware/bean/UpgradeFirmwareBean;", "mUpgradeFirmwareVersion", "openBluetoothDialog", "openLocationDialog", "otaDownloadURL", "otaFile", "Ljava/io/File;", "getOtaFile", "()Ljava/io/File;", "setOtaFile", "(Ljava/io/File;)V", "otaLocalDownLoadUrl", "randomForOTA", "getRandomForOTA", "setRandomForOTA", "rotate", "Landroid/view/animation/Animation;", "scanCallback", "Landroid/bluetooth/le/ScanCallback;", "showOriginalVersion", "getShowOriginalVersion", "tempRandomNum", "getTempRandomNum", "setTempRandomNum", "updatingProcessAdapter", "Lcom/lumiunited/aqara/device/devicepage/gateway/firmware/viewholder/UpdatingProcessAdapter;", "bleUnReachedCheck", "", "time", "", "changeUpdatingStatus", "actionType", "status", "text", "changeVisable", "view", "Landroid/view/View;", "checkFirmwareResultEvent", "event", "Lcom/lumiunited/aqara/device/event/ScanResultEvent;", "Lcom/lumiunited/aqara/web/event/CheckFirmwareResultEvent;", "checkSupportMiApp", "checkUpdateBLERandom", "file", "clickTvOk", "connectBle", "bledevice", "Landroid/bluetooth/BluetoothDevice;", "dismissErrorDialog", "downloadOTAwithBg", "otaUrl", "formatVersion", "hasOpenBlueThooth", "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, "onOTAListener", "Lcom/lumiunited/aqara/device/event/BleOTAProcessListenerEvent;", "onProcess", UMModuleRegister.PROCESS, "onProcessStart", "onRequestPermissionsResult", z.a.a.e.f33395k, z.a.a.e.f33396l, "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onUpdateSuccess", "onWaiting", "openSetting", "queryUpdateAvailable", "reUpdating", "scanFailedEvent", "Lcom/lumiunited/aqara/device/event/ScanFailedEvent;", "showDisconnectNote", "showErrorDialog", "showInputOTAUrlDialog", "startScan", "stopScan", "updateVerInfoUI", "upgradeFirmware", "upgradeProgress", "progress", "Companion", "app_homekitRelease"}, k = 1, mv = {1, 1, 15})
public final class UpgradeFirmwareByBLEActivity2 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 B7 = "lock_random_code";
public static final int C7 = 0;
public static final int D7 = 1;
public static final int E7 = 2;
public static final int F7 = 3;
public static final int H7 = 10;
public static final int I7 = 908;
public static final int J7 = 912;
public static final int K7 = 602;
public static final int O7 = 5;
public static final int P7 = 6;
public HashMap A7;
public ScanCallback J;
public boolean K;
public UpgradeFirmwareBean N;
@NotNull
public String S;
public String T;
public int U;
@Nullable
public String c7;
@NotNull
public String d7;
@NotNull
public String e7;
@NotNull
public k.u.c.i.i3.e.a f7;
@NotNull
public File g7;
@NotNull
public BluetoothAdapter h7;
public y0 j7;
public y0 k7;
public p.a.u0.c l7;
public w0 o7;
public UpdatingProcessAdapter p7;
public Animation q7;
public final int r7;
@NotNull
public ValueAnimator w7;
public p.a.u0.c x7;
@Nullable
public y0 y7;
public static final a Q7 = new a(null);
public static final int G7 = 4;
@NotNull
public static final ParcelUuid L7 = new ParcelUuid(UUID.fromString("0000ffa0-2333-5b1e-9d7c-c687fd2f04f2"));
@NotNull
public static final ParcelUuid M7 = new ParcelUuid(UUID.fromString("0000ffb1-2333-5b1e-9d7c-c687fd2f04f2"));
@NotNull
public static final ParcelUuid N7 = new ParcelUuid(UUID.fromString("0000ffb2-2333-5b1e-9d7c-c687fd2f04f2"));
public String H = "";
public String I = "";
public final ArrayList<String> L = new ArrayList<>();
public String M = "";
public String R = "";
public final boolean a7 = true;
public int b7 = -1;
public final int i7 = 101;
public u.a.a.g m7 = new u.a.a.g();
public int n7 = 10;
public final int s7 = 1;
public final int t7 = 2;
public final int u7 = 3;
public boolean v7 = true;
public final HashMap<String, String> z7 = new HashMap<>();
public static final class a {
public a() {
}
public final int a() {
return UpgradeFirmwareByBLEActivity2.G7;
}
@NotNull
public final ParcelUuid b() {
return UpgradeFirmwareByBLEActivity2.M7;
}
@NotNull
public final ParcelUuid c() {
return UpgradeFirmwareByBLEActivity2.L7;
}
@NotNull
public final ParcelUuid d() {
return UpgradeFirmwareByBLEActivity2.N7;
}
public a(s.b3.w.w wVar) {
this();
}
}
@h0(bv = {1, 0, 3}, d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\u0010\u0000\u001a\u00020\u00012\u000e\u0010\u0002\u001a\n \u0004*\u0004\u0018\u00010\u00030\u0003H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"<anonymous>", "", "it", "", "kotlin.jvm.PlatformType", c0.b.b.b.f1630i, "(Ljava/lang/Long;)V"}, k = 3, mv = {1, 1, 15})
public static final class b<T> implements p.a.x0.g<Long> {
public final long b;
public static final class a implements Runnable {
public final int b;
public a(int i2) {
this.b = i2;
}
@Override
public final void run() {
int i2 = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().get(this.b - 1).actionType;
if (i2 == UpgradeFirmwareByBLEActivity2.this.f1()) {
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
upgradeFirmwareByBLEActivity2.a(f1, 2, string);
} else if (i2 == UpgradeFirmwareByBLEActivity2.this.h1() || i2 == UpgradeFirmwareByBLEActivity2.this.i1()) {
UpgradeFirmwareByBLEActivity2.this.b(0, 0);
}
}
}
public b(long j2) {
this.b = j2;
}
@Override
public final void accept(Long l2) {
if (l2.longValue() < this.b - 1 || UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().size() == 0) {
return;
}
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new a(UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().size()));
}
}
public static final class c extends k.u.c.d.j.o<Boolean> {
public c() {
}
@Override
public void a(int i2, @NotNull String str) {
k0.f(str, "errorMessage");
}
@Override
public void a(@Nullable Boolean bool) {
if (UpgradeFirmwareByBLEActivity2.this.isDestroyed() || bool != null) {
return;
}
k0.f();
}
}
public static final class d extends f0 implements s.b3.v.l<String, JSONObject> {
public static final d a = new d();
public d() {
super(1);
}
@Override
public final String getName() {
return "parseObject";
}
@Override
public final KDeclarationContainer getOwner() {
return k1.b(JSON.class);
}
@Override
public final String getSignature() {
return "parseObject(Ljava/lang/String;)Lcom/alibaba/fastjson/JSONObject;";
}
@Override
public final JSONObject invoke(String str) {
return JSON.parseObject(str);
}
}
public static final class e<T> implements p.a.x0.g<JSONObject> {
public e() {
}
@Override
public final void accept(JSONObject jSONObject) {
UpgradeFirmwareByBLEActivity2.this.l0(jSONObject.getString("lock_random_code"));
}
}
public static final class f<T> implements p.a.x0.g<Throwable> {
public f() {
}
@Override
public final void accept(Throwable th) {
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
upgradeFirmwareByBLEActivity2.a(f1, 2, string);
if (th instanceof k.u.c.d.d.r0.c) {
UpgradeFirmwareByBLEActivity2.this.g0(th.getMessage());
UpgradeFirmwareByBLEActivity2.this.l(((k.u.c.d.d.r0.c) th).a(), th.getMessage());
}
}
}
public static final class g<T, R> implements p.a.x0.o<T, R> {
public static final g a = new g();
@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 h<T, R> implements p.a.x0.o<T, x.g.c<? extends R>> {
public h() {
}
@Override
public final p.a.l<String> apply(@NotNull String str) {
k0.f(str, "s");
ArrayList arrayList = new ArrayList();
arrayList.add("lock_random_code");
return m1.d().a(UpgradeFirmwareByBLEActivity2.this.f8954q, arrayList).n();
}
}
public static final class i<T, R> implements p.a.x0.o<T, R> {
public i() {
}
@Override
public final String apply(@NotNull String str) {
k0.f(str, "s");
String string = JSON.parseObject(str).getString("lock_random_code");
if (!TextUtils.isEmpty(UpgradeFirmwareByBLEActivity2.this.u1()) && TextUtils.equals(UpgradeFirmwareByBLEActivity2.this.u1(), string)) {
UpgradeFirmwareByBLEActivity2.this.l0(string);
throw new k.u.c.d.d.r0.c(4, "error attr");
} else if (!TextUtils.isEmpty(UpgradeFirmwareByBLEActivity2.this.u1())) {
if (TextUtils.isEmpty(UpgradeFirmwareByBLEActivity2.this.u1()) || TextUtils.equals(UpgradeFirmwareByBLEActivity2.this.u1(), string)) {
return "";
}
UpgradeFirmwareByBLEActivity2.this.P1();
return string;
} else {
UpgradeFirmwareByBLEActivity2.this.l0(string);
throw new k.u.c.d.d.r0.c(4, "error attr");
}
}
}
public static final class j<T> implements p.a.x0.g<String> {
public final File b;
public j(File file) {
this.b = file;
}
@Override
public final void accept(String str) {
if (TextUtils.isEmpty(str.toString())) {
UpgradeFirmwareByBLEActivity2.this.g0("随机数获取失败");
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
upgradeFirmwareByBLEActivity2.a(f1, 2, string);
return;
}
UpgradeFirmwareByBLEActivity2.this.k0(str.toString());
UpgradeFirmwareByBLEActivity2.this.a(this.b);
}
}
public static final class k<T> implements p.a.x0.g<Throwable> {
public k() {
}
@Override
public final void accept(Throwable th) {
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
upgradeFirmwareByBLEActivity2.a(f1, 2, string);
if (th instanceof k.u.c.d.d.r0.c) {
UpgradeFirmwareByBLEActivity2.this.g0(th.getMessage());
UpgradeFirmwareByBLEActivity2.this.l(((k.u.c.d.d.r0.c) th).a(), th.getMessage());
}
}
}
public static final class l implements View.OnClickListener {
public l() {
}
@Override
public final void onClick(View view) {
UpgradeFirmwareByBLEActivity2.j(UpgradeFirmwareByBLEActivity2.this).dismiss();
}
}
public static final class m implements View.OnClickListener {
public m() {
}
@Override
public final void onClick(View view) {
k.u.c.i.o3.q.c(UpgradeFirmwareByBLEActivity2.this);
}
}
public static final class n implements h2 {
public n() {
}
@Override
public void a(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@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, @NotNull String str, int i2) {
k0.f(bluetoothDevice, "device");
k0.f(str, "message");
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
upgradeFirmwareByBLEActivity2.a(f1, 2, string);
}
@Override
public void a(@NotNull BluetoothDevice bluetoothDevice, boolean z2) {
k0.f(bluetoothDevice, "device");
}
@Override
public void b(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void c(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
String address = bluetoothDevice.getAddress();
k0.a((Object) address, "device.address");
k.u.c.i.e3.h.c.h0.a("设备连接", address);
UpgradeFirmwareByBLEActivity2.b(UpgradeFirmwareByBLEActivity2.this).dispose();
UpgradeFirmwareByBLEActivity2.this.b0();
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int f1 = upgradeFirmwareByBLEActivity2.f1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_connecting_bluetooth_success);
k0.a((Object) string, "getString(R.string.ota_c…ecting_bluetooth_success)");
upgradeFirmwareByBLEActivity2.a(f1, 0, string);
}
@Override
public void d(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void e(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void f(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void g(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void h(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
}
@Override
public void i(@NotNull BluetoothDevice bluetoothDevice) {
k0.f(bluetoothDevice, "device");
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
UpgradeFirmwareByBLEActivity2.this.k1().i();
UpgradeFirmwareByBLEActivity2.this.P1();
RoundProgressBar roundProgressBar = (RoundProgressBar) UpgradeFirmwareByBLEActivity2.this._$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
if (roundProgressBar.getProgress() != 99) {
UpgradeFirmwareByBLEActivity2.this.a(31L);
return;
}
UpdatingProcessBean b = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.i1());
if (b != null) {
b.resState = 0;
}
if (UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.h1()) == null) {
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().add(new UpdatingProcessBean(1, UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_rebooting), UpgradeFirmwareByBLEActivity2.this.h1()));
}
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).notifyDataSetChanged();
UpgradeFirmwareByBLEActivity2.this.a(120L);
}
@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);
UpgradeFirmwareByBLEActivity2.this.M1();
UpgradeFirmwareByBLEActivity2.this.k1().i();
UpgradeFirmwareByBLEActivity2.this.P1();
}
@Override
@Deprecated
public boolean k(@NonNull BluetoothDevice bluetoothDevice) {
return g2.a(this, bluetoothDevice);
}
}
public static final class o implements v.a.a.a.n3.e {
public o() {
}
@Override
public void a(@NotNull BluetoothDevice bluetoothDevice, int i2) {
k0.f(bluetoothDevice, "device");
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
if (UpgradeFirmwareByBLEActivity2.this.l7 != null) {
UpgradeFirmwareByBLEActivity2.b(UpgradeFirmwareByBLEActivity2.this).dispose();
}
if (i2 == -5) {
UpgradeFirmwareByBLEActivity2.this.b(0, 0);
}
}
}
@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/UpgradeFirmwareByBLEActivity2$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 p 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 (UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().isEmpty()) {
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().add(new UpdatingProcessBean(1, UpgradeFirmwareByBLEActivity2.this.getString(R.string.downloading), UpgradeFirmwareByBLEActivity2.this.g1()));
}
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
int g1 = upgradeFirmwareByBLEActivity2.g1();
String string = UpgradeFirmwareByBLEActivity2.this.getString(R.string.ota_download_fail);
k0.a((Object) string, "getString(R.string.ota_download_fail)");
upgradeFirmwareByBLEActivity2.a(g1, 2, string);
}
}
public static final class b implements Runnable {
public final String b;
public b(String str) {
this.b = str;
}
@Override
public final void run() {
UpdatingProcessBean b = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b != null) {
b.resState = 0;
}
UpdatingProcessBean b2 = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b2 != null) {
b2.txt = UpgradeFirmwareByBLEActivity2.this.getString(R.string.DownloadFirmwareSuccessful);
}
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).notifyDataSetChanged();
UpgradeFirmwareByBLEActivity2.this.b(new File(this.b));
}
}
public static final class c implements Runnable {
public c() {
}
@Override
public final void run() {
if (UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().isEmpty()) {
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().add(new UpdatingProcessBean(1, UpgradeFirmwareByBLEActivity2.this.getString(R.string.downloading), UpgradeFirmwareByBLEActivity2.this.g1()));
}
}
}
public p() {
}
@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) {
UpgradeFirmwareByBLEActivity2.this.K = false;
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new b(str));
}
@Override
public void a(int i2) {
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new c());
}
@Override
public void a(int i2, @Nullable String str) {
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new a());
}
}
public static final class q implements View.OnClickListener {
public q() {
}
@Override
public void onClick(@Nullable View view) {
UpgradeFirmwareByBLEActivity2.i(UpgradeFirmwareByBLEActivity2.this).dismiss();
}
}
public static final class r implements View.OnClickListener {
public r() {
}
@Override
public void onClick(@Nullable View view) {
UpgradeFirmwareByBLEActivity2.this.J1();
}
}
public static final class s implements View.OnClickListener {
public s() {
}
@Override
public final void onClick(View view) {
UpgradeFirmwareByBLEActivity2.this.O1();
}
}
public static final class t<T> implements p.a.x0.g<Long> {
public t() {
}
@Override
public final void accept(Long l2) {
UpgradeFirmwareByBLEActivity2.this.C(false);
}
}
public static final class u extends k.u.c.d.j.o<FirmwareBean> {
public u() {
}
@Override
public void a(int i2, @NotNull String str) {
k0.f(str, "errorMessage");
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
View _$_findCachedViewById = upgradeFirmwareByBLEActivity2._$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_check_fail);
k0.a((Object) _$_findCachedViewById, "id_layout_check_fail");
upgradeFirmwareByBLEActivity2.d(_$_findCachedViewById);
}
@Override
public void a(@Nullable FirmwareBean firmwareBean) {
if (UpgradeFirmwareByBLEActivity2.this.isFinishing()) {
return;
}
if (firmwareBean == null) {
UpgradeFirmwareByBLEActivity2.this.A(0);
return;
}
k.u.c.i.i3.e.a k1 = UpgradeFirmwareByBLEActivity2.this.k1();
String firmwareVersion = firmwareBean.getFirmwareVersion();
k0.a((Object) firmwareVersion, "bean.firmwareVersion");
k1.b(firmwareVersion);
UpgradeFirmwareByBLEActivity2.this.M = firmwareBean.getFirmwareVersion();
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
UpgradeFirmwareBean upgradeFirmware = firmwareBean.getUpgradeFirmware();
k0.a((Object) upgradeFirmware, "bean.upgradeFirmware");
upgradeFirmwareByBLEActivity2.R = upgradeFirmware.getFirmwareVersion();
UpgradeFirmwareByBLEActivity2.this.N = firmwareBean.getUpgradeFirmware();
UpgradeFirmwareByBLEActivity2.this.R1();
}
}
public static final class v implements View.OnClickListener {
public v() {
}
@Override
public final void onClick(View view) {
UpgradeFirmwareByBLEActivity2.i(UpgradeFirmwareByBLEActivity2.this).dismiss();
}
}
public static final class w implements View.OnClickListener {
public w() {
}
@Override
public final void onClick(View view) {
UpgradeFirmwareByBLEActivity2.this.J1();
}
}
public static final class x implements View.OnClickListener {
public x() {
}
@Override
public final void onClick(View view) {
y0 m1 = UpgradeFirmwareByBLEActivity2.this.m1();
if (m1 == null) {
k0.f();
}
m1.dismiss();
}
}
public static final class y implements w0.e {
public y() {
}
@Override
public final void a(String str) {
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2 = UpgradeFirmwareByBLEActivity2.this;
View _$_findCachedViewById = upgradeFirmwareByBLEActivity2._$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating);
k0.a((Object) _$_findCachedViewById, "id_layout_updating");
upgradeFirmwareByBLEActivity2.d(_$_findCachedViewById);
if (UpgradeFirmwareByBLEActivity2.this.F1()) {
UpgradeFirmwareByBLEActivity2.this.H = str;
UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity22 = UpgradeFirmwareByBLEActivity2.this;
k0.a((Object) str, "editTextContent");
upgradeFirmwareByBLEActivity22.m0(str);
w0 w0Var = UpgradeFirmwareByBLEActivity2.this.o7;
if (w0Var != null) {
w0Var.dismiss();
}
}
}
}
private final void B1() {
boolean z2;
String str = this.M;
if (str == null) {
k0.f();
}
if (str.compareTo("1.3.0") < 0) {
String str2 = this.R;
if (str2 == null) {
k0.f();
}
if (str2.compareTo("1.3.0") >= 0) {
z2 = true;
if (z2) {
return;
}
m1.d().l(this.f8954q, new c());
return;
}
}
z2 = false;
if (z2) {
}
}
public final void C(boolean z2) {
if (isFinishing()) {
return;
}
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
aVar.a(new k.u.c.i.e3.h.c.v());
}
private final void C1() {
if (this.M != null && !TextUtils.isEmpty(this.R) && !k0.a((Object) this.M, (Object) this.R)) {
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")) {
y0 a2 = new y0.c(this).a(getString(R.string.ota_scan_location_note)).d(getString(R.string.txt_open_blue_tooth)).a(getString(17039360), new l()).c(getString(R.string.confirm), new m()).a();
k0.a((Object) a2, "CustomAlertDialog.Builde… .build()");
this.k7 = a2;
if (a2 == null) {
k0.m("openLocationDialog");
}
a2.show();
}
requestPermissions(new String[]{"android.permission.ACCESS_FINE_LOCATION"}, this.i7);
return;
}
S1();
return;
}
S1();
return;
}
finish();
}
private final void D1() {
y0 y0Var = this.y7;
if (y0Var != null) {
if (y0Var == null) {
k0.f();
}
if (y0Var.isShowing()) {
y0 y0Var2 = this.y7;
if (y0Var2 == null) {
k0.f();
}
y0Var2.dismiss();
}
}
}
private final void E1() {
this.M = this.a7 ? this.M : k.u.c.i.o3.m.a(this.M);
UpgradeFirmwareBean upgradeFirmwareBean = this.N;
if (upgradeFirmwareBean != null) {
if (upgradeFirmwareBean == null) {
k0.f();
}
this.R = upgradeFirmwareBean.getFirmwareVersion();
UpgradeFirmwareBean upgradeFirmwareBean2 = this.N;
if (upgradeFirmwareBean2 == null) {
k0.f();
}
String updateLog = upgradeFirmwareBean2.getUpdateLog();
k0.a((Object) updateLog, "mUpgradeFirmwareBean!!.updateLog");
this.S = updateLog;
}
}
private final void F(int i2) {
p.a.u0.c cVar = this.x7;
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 t());
this.x7 = subscribe;
p.a.u0.b bVar2 = this.f8942e;
if (subscribe == null) {
k0.f();
}
bVar2.b(subscribe);
}
public final boolean F1() {
BluetoothAdapter bluetoothAdapter = this.h7;
if (bluetoothAdapter == null) {
k0.m("adapter");
}
if (bluetoothAdapter.enable()) {
return true;
}
y0 a2 = new y0.c(this).d(getString(R.string.txt_open_blue_tooth)).a(getString(17039360), new q()).c(getString(R.string.confirm), new r()).a();
k0.a((Object) a2, "CustomAlertDialog.Builde… .build()");
this.j7 = a2;
if (a2 == null) {
k0.m("openBluetoothDialog");
}
a2.show();
return false;
}
private final void G(int i2) {
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setVisibility(0);
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(4);
FirmwareUpDatingWidget firmwareUpDatingWidget = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget, "id_updating_loading");
firmwareUpDatingWidget.setVisibility(4);
RoundProgressBar roundProgressBar2 = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar2, "rpb_updating_upgrade_progress");
roundProgressBar2.setProgress(i2);
if (i2 != 100 || this.K) {
return;
}
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating_status);
k0.a((Object) _$_findCachedViewById, "id_layout_updating_status");
d(_$_findCachedViewById);
}
private final void G1() {
this.f8954q = getIntent().getStringExtra("did");
this.K = getIntent().getBooleanExtra("isSubdevice", false);
k.u.c.i.e3.h.c.h0.a("isDownload = " + this.K, null, 1, null);
String stringExtra = getIntent().getStringExtra(k.u.c.i.o3.h.a);
this.M = stringExtra;
this.R = stringExtra;
this.L.add(this.f8954q);
}
private final void H1() {
this.p7 = new UpdatingProcessAdapter(this, new ArrayList());
((TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_fail_retry)).setOnClickListener(this);
((TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_update_avaiable_sure)).setOnClickListener(this);
((TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_retry)).setOnClickListener(this);
RecyclerView recyclerView = (RecyclerView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_indicator);
k0.a((Object) recyclerView, "id_updating_indicator");
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
recyclerView.setAdapter(updatingProcessAdapter);
RecyclerView recyclerView2 = (RecyclerView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_indicator);
k0.a((Object) recyclerView2, "id_updating_indicator");
recyclerView2.setLayoutManager(new LinearLayoutManager(this));
if (this.f8955r != null) {
k.u.c.i.i3.e.a aVar = this.f7;
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);
}
((Button) _$_findCachedViewById(com.lumiunited.aqara.R.id.clickMe)).setOnClickListener(new s());
RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 359.0f, getResources().getDimensionPixelSize(R.dimen.px24), getResources().getDimensionPixelSize(R.dimen.px24));
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setRepeatCount(-1);
rotateAnimation.setDuration(300L);
ProgressBar progressBar = (ProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_cheking_img);
k0.a((Object) progressBar, "id_cheking_img");
progressBar.setAnimation(rotateAnimation);
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_checking);
k0.a((Object) _$_findCachedViewById, "id_layout_checking");
d(_$_findCachedViewById);
K1();
getWindow().addFlags(128);
}
private final boolean I1() {
return (this.M == null || TextUtils.isEmpty(this.R) || k0.a((Object) this.M, (Object) this.R)) ? false : true;
}
public final void J1() {
Intent intent = new Intent();
intent.setAction("android.settings.BLUETOOTH_SETTINGS");
intent.setFlags(268435456);
try {
BluetoothAdapter bluetoothAdapter = this.h7;
if (bluetoothAdapter == null) {
k0.m("adapter");
}
if (!bluetoothAdapter.enable()) {
startActivity(intent);
} else {
P1();
}
} catch (Exception e2) {
e2.printStackTrace();
}
y0 y0Var = this.j7;
if (y0Var != null) {
if (y0Var == null) {
k0.m("openBluetoothDialog");
}
y0Var.dismiss();
}
}
private final void K1() {
m1.d().i(this.f8954q, new u());
}
private final void L1() {
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar != null) {
if (aVar == null) {
k0.m("bleManager");
}
aVar.b(true);
}
this.v7 = true;
TextView textView = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_retry);
k0.a((Object) textView, "id_updating_retry");
textView.setVisibility(4);
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter.b().clear();
((ImageView) findViewById(R.id.id_updating_image_update_avaiable)).setImageResource(R.mipmap.device_upload);
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setProgress(0);
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(0);
RoundProgressBar roundProgressBar2 = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar2, "rpb_updating_upgrade_progress");
roundProgressBar2.setVisibility(4);
if (TextUtils.isEmpty(this.H)) {
S1();
return;
}
String str = this.H;
if (str != null) {
m0(str);
}
}
public final void M1() {
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
int progress = roundProgressBar.getProgress();
if (1 <= progress && 98 >= progress) {
y0 a2 = new y0.c(this).a(getString(R.string.ota_open_bluetooth_first)).a(getString(17039360), new v()).c(getString(R.string.confirm), new w()).a();
k0.a((Object) a2, "CustomAlertDialog.Builde… .build()");
this.j7 = a2;
if (a2 == null) {
k0.m("openBluetoothDialog");
}
a2.show();
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b2 = updatingProcessAdapter.b(this.s7);
if (b2 != null) {
b2.resState = 1;
}
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b3 = updatingProcessAdapter2.b(this.s7);
if (b3 != null) {
b3.txt = getString(R.string.ota_connecting_blue_tooth);
}
UpdatingProcessAdapter updatingProcessAdapter3 = this.p7;
if (updatingProcessAdapter3 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter3.notifyDataSetChanged();
} else if (progress == 99) {
UpdatingProcessAdapter updatingProcessAdapter4 = this.p7;
if (updatingProcessAdapter4 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b4 = updatingProcessAdapter4.b(this.t7);
if (b4 != null) {
b4.resState = 0;
}
UpdatingProcessAdapter updatingProcessAdapter5 = this.p7;
if (updatingProcessAdapter5 == null) {
k0.m("updatingProcessAdapter");
}
if (updatingProcessAdapter5.b(this.u7) == null) {
UpdatingProcessAdapter updatingProcessAdapter6 = this.p7;
if (updatingProcessAdapter6 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter6.b().add(new UpdatingProcessBean(1, getString(R.string.ota_rebooting), this.u7));
}
} else {
UpdatingProcessAdapter updatingProcessAdapter7 = this.p7;
if (updatingProcessAdapter7 == null) {
k0.m("updatingProcessAdapter");
}
int size = updatingProcessAdapter7.b().size();
int i2 = this.s7;
String string = getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
if (size > 0) {
UpdatingProcessAdapter updatingProcessAdapter8 = this.p7;
if (updatingProcessAdapter8 == null) {
k0.m("updatingProcessAdapter");
}
int i3 = size - 1;
i2 = updatingProcessAdapter8.b().get(i3).actionType;
UpdatingProcessAdapter updatingProcessAdapter9 = this.p7;
if (updatingProcessAdapter9 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter9.b().get(i3).resState = 2;
for (Map.Entry entry : b1.d(n1.a(Integer.valueOf(this.r7), getString(R.string.DownloadFirmwareFailed)), n1.a(Integer.valueOf(this.s7), getString(R.string.ota_connecting_bluetooth_fail)), n1.a(Integer.valueOf(this.t7), getString(R.string.ota_translating_fail)), n1.a(Integer.valueOf(this.u7), getString(R.string.ota_translating_fail))).entrySet()) {
int intValue = ((Number) entry.getKey()).intValue();
UpdatingProcessAdapter updatingProcessAdapter10 = this.p7;
if (updatingProcessAdapter10 == null) {
k0.m("updatingProcessAdapter");
}
if (intValue == updatingProcessAdapter10.b().get(i3).actionType) {
UpdatingProcessAdapter updatingProcessAdapter11 = this.p7;
if (updatingProcessAdapter11 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter11.b().get(i3).txt = (String) entry.getValue();
Object value = entry.getValue();
k0.a(value, "it.value");
string = (String) value;
}
}
} else {
UpdatingProcessAdapter updatingProcessAdapter12 = this.p7;
if (updatingProcessAdapter12 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter12.b().add(new UpdatingProcessBean(2, getString(R.string.ota_connecting_bluetooth_fail), this.s7));
}
a(i2, 2, string);
}
}
private final void N1() {
String str = null;
this.T = null;
int i2 = this.b7;
boolean z2 = true;
if (i2 != 908) {
if (i2 == G7) {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updateAvable);
k0.a((Object) _$_findCachedViewById, "id_layout_updateAvable");
d(_$_findCachedViewById);
z2 = false;
} else if (i2 == 912) {
str = getString(R.string.tip_firmware_can_not_upgrade);
} else if (i2 == 602) {
str = getString(R.string.device_offline_hint);
}
}
String str2 = this.d7;
if (str2 == null) {
k0.m("mErrorMsg");
}
if (!TextUtils.isEmpty(str2) && (str = this.d7) == null) {
k0.m("mErrorMsg");
}
if (z2) {
y0 a2 = new y0.c(this).d(str).b(getString(R.string.confirm), new x()).a();
this.y7 = a2;
if (a2 == null) {
k0.f();
}
a2.show();
}
}
public final void O1() {
w0 a2 = new w0.b(this).g("后台升级").b("http://demo.lumiunited.com:1115/s2_plus/.bin").a(500).d(getString(17039360)).e(getString(R.string.confirm)).a();
this.o7 = a2;
if (a2 != null) {
a2.setCanceledOnTouchOutside(false);
}
w0 w0Var = this.o7;
if (w0Var != null) {
w0Var.a(new y());
}
w0 w0Var2 = this.o7;
if (w0Var2 != null) {
w0Var2.show();
}
}
public final void P1() {
ScanSettings build = new ScanSettings.Builder().setScanMode(0).build();
ArrayList arrayList = new ArrayList();
arrayList.add(new ScanFilter.Builder().setServiceUuid(L7).build());
arrayList.add(new ScanFilter.Builder().setDeviceName("S2 Pro+").build());
if (this.J == null) {
this.J = new k.u.c.i.e3.h.c.w();
}
BluetoothAdapter bluetoothAdapter = this.h7;
if (bluetoothAdapter == null) {
k0.m("adapter");
}
BluetoothLeScanner bluetoothLeScanner = bluetoothAdapter.getBluetoothLeScanner();
if (bluetoothLeScanner != null) {
bluetoothLeScanner.startScan(arrayList, build, this.J);
}
a(31L);
}
private final void Q1() {
BluetoothAdapter bluetoothAdapter = this.h7;
if (bluetoothAdapter == null) {
k0.m("adapter");
}
bluetoothAdapter.getBluetoothLeScanner().stopScan(this.J);
}
public final void R1() {
if (I1()) {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updateAvable);
k0.a((Object) _$_findCachedViewById, "id_layout_updateAvable");
d(_$_findCachedViewById);
TextView textView = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_avaiable_title);
k0.a((Object) textView, "id_avaiable_title");
StringBuilder sb = new StringBuilder();
sb.append(getString(R.string.firmware_upgrade_latest_version));
String str = this.R;
if (str == null) {
k0.f();
}
sb.append(str);
textView.setText(sb.toString());
((TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_avaiable_des)).setText(getString(R.string.CloseDeviceTips));
TextView textView2 = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_avaiable_log);
k0.a((Object) textView2, "id_avaiable_log");
UpgradeFirmwareBean upgradeFirmwareBean = this.N;
if (upgradeFirmwareBean == null) {
k0.f();
}
textView2.setText(upgradeFirmwareBean.getUpdateLog());
TextView textView3 = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_avaiable_small_version_des);
k0.a((Object) textView3, "id_avaiable_small_version_des");
StringBuilder sb2 = new StringBuilder();
sb2.append(getString(R.string.firmware_upgrade_current_version));
String str2 = this.M;
if (str2 == null) {
k0.f();
}
sb2.append(str2);
textView3.setText(sb2.toString());
return;
}
View _$_findCachedViewById2 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating_status);
k0.a((Object) _$_findCachedViewById2, "id_layout_updating_status");
d(_$_findCachedViewById2);
}
private final void S1() {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating);
k0.a((Object) _$_findCachedViewById, "id_layout_updating");
d(_$_findCachedViewById);
if (F1()) {
File cacheDir = getCacheDir();
k0.a((Object) cacheDir, "cacheDir");
String path = cacheDir.getPath();
UpgradeFirmwareBean upgradeFirmwareBean = this.N;
if (upgradeFirmwareBean == null) {
k0.f();
}
String downloadUrl = upgradeFirmwareBean.getDownloadUrl();
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
UpgradeFirmwareBean upgradeFirmwareBean2 = this.N;
if (upgradeFirmwareBean2 == null) {
k0.f();
}
String firmwareVersion = upgradeFirmwareBean2.getFirmwareVersion();
k0.a((Object) firmwareVersion, "mUpgradeFirmwareBean!!.firmwareVersion");
aVar.b(firmwareVersion);
UpgradeFirmwareBean upgradeFirmwareBean3 = this.N;
if (upgradeFirmwareBean3 == null) {
k0.f();
}
this.H = upgradeFirmwareBean3.getDownloadUrl();
l0.i().a(this, downloadUrl, path, new z());
}
}
public static final p.a.u0.c b(UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2) {
p.a.u0.c cVar = upgradeFirmwareByBLEActivity2.l7;
if (cVar == null) {
k0.m("bleConnectCountDown");
}
return cVar;
}
public static final y0 i(UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2) {
y0 y0Var = upgradeFirmwareByBLEActivity2.j7;
if (y0Var == null) {
k0.m("openBluetoothDialog");
}
return y0Var;
}
public static final y0 j(UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2) {
y0 y0Var = upgradeFirmwareByBLEActivity2.k7;
if (y0Var == null) {
k0.m("openLocationDialog");
}
return y0Var;
}
public static final UpdatingProcessAdapter m(UpgradeFirmwareByBLEActivity2 upgradeFirmwareByBLEActivity2) {
UpdatingProcessAdapter updatingProcessAdapter = upgradeFirmwareByBLEActivity2.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
return updatingProcessAdapter;
}
public final void m0(String str) {
File cacheDir = getCacheDir();
k0.a((Object) cacheDir, "cacheDir");
String path = cacheDir.getPath();
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
int b2 = c0.b((CharSequence) str, "/", 0, false, 6, (Object) null) + 1;
int length = str.length() - 4;
if (str != null) {
String substring = str.substring(b2, length);
k0.d(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
aVar.b(substring);
l0.i().a(k.u.c.d.a.p.a(), str, path, new p());
return;
}
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
private 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)");
return c0.c((CharSequence) str, (CharSequence) substring, false, 2, (Object) null);
}
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
@Override
public void A(int i2) {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating_status);
k0.a((Object) _$_findCachedViewById, "id_layout_updating_status");
d(_$_findCachedViewById);
((ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_status_result_image)).setImageResource(R.mipmap.iv_firmware_update_lastest);
TextView textView = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_status_title);
k0.a((Object) textView, "id_status_title");
textView.setText(getString(R.string.ota_is_already_latest));
TextView textView2 = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_status_version_txt);
k0.a((Object) textView2, "id_status_version_txt");
StringBuilder sb = new StringBuilder();
sb.append(getString(R.string.firmware_upgrade_latest_version));
String str = this.R;
if (str == null) {
k0.f();
}
sb.append(str);
textView2.setText(sb.toString());
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
aVar.i();
}
public final void D(int i2) {
this.b7 = i2;
}
public final void E(int i2) {
this.U = i2;
}
@Override
public void U() {
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
if (updatingProcessAdapter.b(this.t7) == null) {
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(4);
((FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading)).a();
FirmwareUpDatingWidget firmwareUpDatingWidget = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget, "id_updating_loading");
firmwareUpDatingWidget.setVisibility(4);
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setVisibility(0);
((RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress)).invalidate();
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter2.b().add(new UpdatingProcessBean(1, getString(R.string.ota_translating), this.t7));
this.v7 = false;
UpdatingProcessAdapter updatingProcessAdapter3 = this.p7;
if (updatingProcessAdapter3 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter3.notifyDataSetChanged();
return;
}
UpdatingProcessAdapter updatingProcessAdapter4 = this.p7;
if (updatingProcessAdapter4 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b2 = updatingProcessAdapter4.b(this.t7);
if (b2 != null) {
b2.resState = 1;
}
UpdatingProcessAdapter updatingProcessAdapter5 = this.p7;
if (updatingProcessAdapter5 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b3 = updatingProcessAdapter5.b(this.t7);
if (b3 != null) {
b3.txt = getString(R.string.ota_translating);
}
UpdatingProcessAdapter updatingProcessAdapter6 = this.p7;
if (updatingProcessAdapter6 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter6.notifyDataSetChanged();
}
@Override
public void _$_clearFindViewByIdCache() {
HashMap hashMap = this.A7;
if (hashMap != null) {
hashMap.clear();
}
}
@Override
public View _$_findCachedViewById(int i2) {
if (this.A7 == null) {
this.A7 = new HashMap();
}
View view = (View) this.A7.get(Integer.valueOf(i2));
if (view == null) {
View findViewById = findViewById(i2);
this.A7.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");
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.R));
if (this.N != null) {
if (k.u.c.r.l.d.q(this)) {
B1();
}
this.M = this.R;
}
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating_status);
k0.a((Object) _$_findCachedViewById, "id_layout_updating_status");
d(_$_findCachedViewById);
return;
}
View _$_findCachedViewById2 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating);
k0.a((Object) _$_findCachedViewById2, "id_layout_updating");
d(_$_findCachedViewById2);
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_upgrade_progress");
roundProgressBar.setVisibility(8);
((ImageView) findViewById(R.id.id_image_update_avaiable)).setImageResource(R.mipmap.general_fail);
}
@Override
public void f(@Nullable String str) {
}
public final int f1() {
return this.s7;
}
public final int g1() {
return this.r7;
}
public final int h1() {
return this.u7;
}
public final void i0(@NotNull String str) {
k0.f(str, "<set-?>");
this.d7 = str;
}
public final int i1() {
return this.t7;
}
public final void j0(@NotNull String str) {
k0.f(str, "<set-?>");
this.S = str;
}
@NotNull
public final BluetoothAdapter j1() {
BluetoothAdapter bluetoothAdapter = this.h7;
if (bluetoothAdapter == null) {
k0.m("adapter");
}
return bluetoothAdapter;
}
public final void k0(@NotNull String str) {
k0.f(str, "<set-?>");
this.e7 = str;
}
@NotNull
public final k.u.c.i.i3.e.a k1() {
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
return aVar;
}
public final void l0(@Nullable String str) {
this.c7 = str;
}
public final int l1() {
return this.b7;
}
@Nullable
public final y0 m1() {
return this.y7;
}
@NotNull
public final String n1() {
String str = this.d7;
if (str == null) {
k0.m("mErrorMsg");
}
return str;
}
public final int o1() {
return this.U;
}
@Override
public void onClick(@NotNull View view) {
k0.f(view, "v");
int id = view.getId();
if (id == R.id.id_fail_retry) {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_checking);
k0.a((Object) _$_findCachedViewById, "id_layout_checking");
d(_$_findCachedViewById);
K1();
} else if (id == R.id.id_update_avaiable_sure) {
View _$_findCachedViewById2 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updateAvable);
k0.a((Object) _$_findCachedViewById2, "id_layout_updateAvable");
d(_$_findCachedViewById2);
C1();
} else if (id != R.id.id_updating_retry) {
} else {
View _$_findCachedViewById3 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating);
k0.a((Object) _$_findCachedViewById3, "id_layout_updating");
d(_$_findCachedViewById3);
L1();
}
}
@Override
public void onCreate(@Nullable Bundle bundle) {
BluetoothAdapter adapter;
super.onCreate(bundle);
setContentView(R.layout.activity_upgrade_firmware2);
x.b.a.c.f().e(this);
this.f7 = a.C0644a.c.a();
G1();
H1();
Object systemService = getSystemService("bluetooth");
if (!(systemService instanceof BluetoothManager)) {
systemService = null;
}
BluetoothManager bluetoothManager = (BluetoothManager) systemService;
if (bluetoothManager == null || (adapter = bluetoothManager.getAdapter()) == null) {
return;
}
this.h7 = 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.f7;
if (aVar == null) {
k0.m("bleManager");
}
aVar.d();
getWindow().clearFlags(128);
k.u.c.i.i3.e.a aVar2 = this.f7;
if (aVar2 == null) {
k0.m("bleManager");
}
aVar2.b(true);
this.I = "";
this.f8942e.dispose();
this.f8942e.b();
this.c7 = "";
this.J = null;
w0 w0Var = this.o7;
if (w0Var != null) {
if (w0Var != null) {
w0Var.dismiss();
}
this.o7 = null;
}
super.onDestroy();
}
@x.b.a.m(threadMode = ThreadMode.MAIN)
public final void onOTAListener(@NotNull k.u.c.i.g3.c cVar) {
k0.f(cVar, "event");
switch (a0.a[cVar.h().ordinal()]) {
case 1:
U();
return;
case 2:
Integer g2 = cVar.g();
if (g2 != null) {
f(g2.intValue());
return;
}
return;
case 3:
Integer g3 = cVar.g();
if (g3 != null) {
u(g3.intValue());
return;
}
return;
case 4:
String e2 = cVar.e();
if (e2 != null) {
f(e2);
return;
}
return;
case 5:
Integer g4 = cVar.g();
if (g4 != null) {
A(g4.intValue());
return;
}
return;
case 6:
if (cVar.g() == null || cVar.f() == null) {
return;
}
Integer g5 = cVar.g();
if (g5 == null) {
k0.f();
}
int intValue = g5.intValue();
Integer f2 = cVar.f();
if (f2 == null) {
k0.f();
}
b(intValue, f2.intValue());
return;
default:
return;
}
}
@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.i7 && iArr[0] == 0) {
S1();
}
}
@NotNull
public final ValueAnimator p1() {
ValueAnimator valueAnimator = this.w7;
if (valueAnimator == null) {
k0.m("mSubdeviceProgressAnimator");
}
return valueAnimator;
}
@NotNull
public final String q1() {
String str = this.S;
if (str == null) {
k0.m("mUpdateLog");
}
return str;
}
@NotNull
public final File r1() {
File file = this.g7;
if (file == null) {
k0.m("otaFile");
}
return file;
}
@NotNull
public final String s1() {
String str = this.e7;
if (str == null) {
k0.m("randomForOTA");
}
return str;
}
@x.b.a.m(threadMode = ThreadMode.MAIN)
public final void scanFailedEvent(@NotNull k.u.c.i.g3.o oVar) {
k0.f(oVar, "event");
p.a.u0.c cVar = this.l7;
if (cVar == null) {
k0.m("bleConnectCountDown");
}
cVar.dispose();
int i2 = this.s7;
String string = getString(R.string.ota_connecting_bluetooth_fail);
k0.a((Object) string, "getString(R.string.ota_connecting_bluetooth_fail)");
a(i2, 2, string);
}
public final boolean t1() {
return this.a7;
}
@Override
public void u(int i2) {
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b2 = updatingProcessAdapter.b(this.t7);
if (b2 != null) {
b2.resState = 1;
}
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter2.notifyDataSetChanged();
}
@Nullable
public final String u1() {
return this.c7;
}
public final boolean v1() {
return this.g7 != null;
}
public final boolean w1() {
return this.e7 != null;
}
@h0(bv = {1, 0, 3}, d1 = {"\u0000\u001f\n\u0000\n\u0002\u0018\u0002\n\u0000\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\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007H\u0016J\u0012\u0010\b\u001a\u00020\u00032\b\u0010\t\u001a\u0004\u0018\u00010\u0007H\u0016J\u0010\u0010\n\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\u0005H\u0016¨\u0006\f"}, d2 = {"com/lumiunited/aqara/device/devicepage/gateway/firmware/UpgradeFirmwareByBLEActivity2$upgradeFirmware$1", "Lcom/lumiunited/aqara/application/helper/HttpHelper$OnDownloadListener;", "onDownloadFailed", "", "code", "", "error", "", "onDownloadSuccess", "path", "onDownloading", "progress", "app_homekitRelease"}, k = 1, mv = {1, 1, 15})
public static final class z implements l0.l {
public static final class a implements Runnable {
public a() {
}
@Override
public final void run() {
UpdatingProcessBean b = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b != null) {
b.resState = 2;
}
UpdatingProcessBean b2 = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b2 != null) {
b2.txt = UpgradeFirmwareByBLEActivity2.this.getString(R.string.DownloadFirmwareFailed);
}
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).notifyDataSetChanged();
}
}
public static final class b implements Runnable {
public final String b;
public b(String str) {
this.b = str;
}
@Override
public final void run() {
ImageView imageView = (ImageView) UpgradeFirmwareByBLEActivity2.this._$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(0);
UpdatingProcessBean b = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b != null) {
b.resState = 0;
}
UpdatingProcessBean b2 = UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b(UpgradeFirmwareByBLEActivity2.this.g1());
if (b2 != null) {
b2.txt = UpgradeFirmwareByBLEActivity2.this.getString(R.string.DownloadFirmwareSuccessful);
}
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).notifyDataSetChanged();
UpgradeFirmwareByBLEActivity2.this.I = this.b;
UpgradeFirmwareByBLEActivity2.this.b(new File(this.b));
}
}
public static final class c implements Runnable {
public c() {
}
@Override
public final void run() {
if (UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().isEmpty()) {
UpgradeFirmwareByBLEActivity2.m(UpgradeFirmwareByBLEActivity2.this).b().add(new UpdatingProcessBean(1, UpgradeFirmwareByBLEActivity2.this.getString(R.string.downloading), UpgradeFirmwareByBLEActivity2.this.g1()));
}
}
}
public z() {
}
@Override
public void a(@Nullable String str) {
UpgradeFirmwareByBLEActivity2.this.K = false;
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new b(str));
}
@Override
public void a(int i2) {
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new c());
}
@Override
public void a(int i2, @Nullable String str) {
UpgradeFirmwareByBLEActivity2.this.runOnUiThread(new a());
}
}
public final void d(View view) {
View _$_findCachedViewById = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_checking);
k0.a((Object) _$_findCachedViewById, "id_layout_checking");
View _$_findCachedViewById2 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_check_fail);
k0.a((Object) _$_findCachedViewById2, "id_layout_check_fail");
View _$_findCachedViewById3 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updateAvable);
k0.a((Object) _$_findCachedViewById3, "id_layout_updateAvable");
View _$_findCachedViewById4 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating);
k0.a((Object) _$_findCachedViewById4, "id_layout_updating");
View _$_findCachedViewById5 = _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_updating_status);
k0.a((Object) _$_findCachedViewById5, "id_layout_updating_status");
for (View view2 : s.r2.x.e(_$_findCachedViewById, _$_findCachedViewById2, _$_findCachedViewById3, _$_findCachedViewById4, _$_findCachedViewById5)) {
view2.setVisibility(k0.a(view2, view) ? 0 : 8);
}
if (k0.a(view, _$_findCachedViewById(com.lumiunited.aqara.R.id.id_layout_checking))) {
ProgressBar progressBar = (ProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_cheking_img);
k0.a((Object) progressBar, "id_cheking_img");
Animation animation = progressBar.getAnimation();
if (animation != null) {
animation.start();
return;
}
return;
}
ProgressBar progressBar2 = (ProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_cheking_img);
k0.a((Object) progressBar2, "id_cheking_img");
Animation animation2 = progressBar2.getAnimation();
if (animation2 != null) {
animation2.cancel();
}
}
@Override
public void f(int i2) {
if (this.v7) {
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
if (updatingProcessAdapter.b(this.t7) == null) {
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(4);
((FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading)).a();
FirmwareUpDatingWidget firmwareUpDatingWidget = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget, "id_updating_loading");
firmwareUpDatingWidget.setVisibility(4);
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setVisibility(0);
((RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress)).invalidate();
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter2.b().add(new UpdatingProcessBean(1, getString(R.string.ota_translating), this.t7));
this.v7 = false;
UpdatingProcessAdapter updatingProcessAdapter3 = this.p7;
if (updatingProcessAdapter3 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter3.notifyDataSetChanged();
}
}
D1();
G(i2);
}
public final void b(File file) {
int i2 = this.s7;
String string = getString(R.string.ota_connecting_blue_tooth);
k0.a((Object) string, "getString(R.string.ota_connecting_blue_tooth)");
a(i2, 1, string);
ArrayList arrayList = new ArrayList();
arrayList.add("lock_random_code");
p.a.u0.b bVar = this.f8942e;
p.a.k0<String> j2 = m1.d().a(this.f8954q, arrayList).j();
d dVar = d.a;
if (dVar != null) {
dVar = new g0(dVar);
}
bVar.b(j2.i((p.a.x0.o) dVar).q().observeOn(p.a.s0.d.a.a()).subscribe(new e(), new f()));
this.z7.clear();
this.z7.put("lock_random_code", "s2 Pro HL");
this.f8942e.b(m1.d().c(this.f8954q, this.z7).j().a(2L).b(2).a(p.a.s0.d.a.a()).v(g.a).p(new h()).v(new i()).B(new k.u.c.d.h.b(20, 3000)).a(p.a.s0.d.a.a()).subscribe(new j(file), new k()));
}
@x.b.a.m(threadMode = ThreadMode.MAIN)
public final void checkFirmwareResultEvent(@NotNull k.u.c.i.g3.p pVar) {
ScanRecord scanRecord;
k0.f(pVar, "event");
if (!isFinishing() && Build.VERSION.SDK_INT >= 21) {
ScanResult d2 = pVar.d();
byte[] bArr = null;
BluetoothDevice device = d2 != null ? d2.getDevice() : null;
if (device != null) {
ScanResult d3 = pVar.d();
if (d3 != null && (scanRecord = d3.getScanRecord()) != null) {
bArr = scanRecord.getBytes();
}
byte[] d4 = k.u.c.i.i3.r.s.d(k.u.c.i.i3.r.c.a(bArr));
String a2 = k.u.c.i.i3.r.c.a(k.u.c.i.i3.r.v.a(d4, d4.length, false));
k0.a((Object) a2, com.umeng.commonsdk.statistics.idtracking.i.a);
if (n0(a2)) {
Q1();
if (v1() && w1()) {
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
File file = this.g7;
if (file == null) {
k0.m("otaFile");
}
aVar.b(file);
k.u.c.i.i3.e.a aVar2 = this.f7;
if (aVar2 == null) {
k0.m("bleManager");
}
String str = this.e7;
if (str == null) {
k0.m("randomForOTA");
}
aVar2.c(str);
p.a.u0.c cVar = this.l7;
if (cVar == null) {
k0.m("bleConnectCountDown");
}
cVar.dispose();
a(device);
}
}
}
}
}
public final void a(@NotNull k.u.c.i.i3.e.a aVar) {
k0.f(aVar, "<set-?>");
this.f7 = aVar;
}
public final void a(@NotNull File file) {
k0.f(file, "<set-?>");
this.g7 = file;
}
public final void a(@NotNull BluetoothAdapter bluetoothAdapter) {
k0.f(bluetoothAdapter, "<set-?>");
this.h7 = bluetoothAdapter;
}
public final void a(@NotNull ValueAnimator valueAnimator) {
k0.f(valueAnimator, "<set-?>");
this.w7 = valueAnimator;
}
public final void a(@Nullable y0 y0Var) {
this.y7 = y0Var;
}
public final void a(int i2, int i3, String str) {
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b2 = updatingProcessAdapter.b(i2);
if (b2 != null) {
b2.txt = str;
}
if (b2 != null) {
b2.resState = i3;
}
if (b2 == null) {
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter2.b().add(new UpdatingProcessBean(i3, str, i2));
}
TextView textView = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_retry);
k0.a((Object) textView, "id_updating_retry");
textView.setVisibility(i3 == 2 ? 0 : 4);
((ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable)).setImageResource(i3 == 2 ? R.mipmap.general_fail : R.mipmap.device_upload);
if (i3 == 2) {
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(0);
((FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading)).a();
FirmwareUpDatingWidget firmwareUpDatingWidget = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget, "id_updating_loading");
firmwareUpDatingWidget.setVisibility(4);
} else {
ImageView imageView2 = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView2, "id_updating_image_update_avaiable");
imageView2.setVisibility(i2 == this.t7 ? 4 : 0);
}
FirmwareUpDatingWidget firmwareUpDatingWidget2 = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget2, "id_updating_loading");
firmwareUpDatingWidget2.setVisibility(i3 == 2 ? 4 : 0);
FirmwareUpDatingWidget firmwareUpDatingWidget3 = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget3, "id_updating_loading");
if (firmwareUpDatingWidget3.getVisibility() == 0) {
((FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading)).b();
}
if (i3 == 2) {
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setVisibility(4);
} else {
RoundProgressBar roundProgressBar2 = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar2, "rpb_updating_upgrade_progress");
FirmwareUpDatingWidget firmwareUpDatingWidget4 = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget4, "id_updating_loading");
roundProgressBar2.setVisibility(firmwareUpDatingWidget4.getVisibility() == 0 ? 4 : 0);
}
UpdatingProcessAdapter updatingProcessAdapter3 = this.p7;
if (updatingProcessAdapter3 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter3.notifyDataSetChanged();
}
private final void a(BluetoothDevice bluetoothDevice) {
k.u.c.i.i3.e.a aVar = this.f7;
if (aVar == null) {
k0.m("bleManager");
}
aVar.a(new n());
k.u.c.i.i3.e.a aVar2 = this.f7;
if (aVar2 == null) {
k0.m("bleManager");
}
aVar2.a(bluetoothDevice).a(35, 300).d(15000L).a((v.a.a.a.n3.e) new o()).a();
C(true);
a(31L);
}
@Override
public void b(int i2, int i3) {
k.u.c.i.e3.h.c.h0.a("传输失败,收到失败的会掉函数", null, 1, null);
UpdatingProcessAdapter updatingProcessAdapter = this.p7;
if (updatingProcessAdapter == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b2 = updatingProcessAdapter.b(this.u7);
if (b2 != null) {
UpdatingProcessAdapter updatingProcessAdapter2 = this.p7;
if (updatingProcessAdapter2 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter2.b().remove(b2);
}
UpdatingProcessAdapter updatingProcessAdapter3 = this.p7;
if (updatingProcessAdapter3 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b3 = updatingProcessAdapter3.b(this.t7);
if (b3 != null) {
b3.resState = 2;
}
UpdatingProcessAdapter updatingProcessAdapter4 = this.p7;
if (updatingProcessAdapter4 == null) {
k0.m("updatingProcessAdapter");
}
UpdatingProcessBean b4 = updatingProcessAdapter4.b(this.t7);
if (b4 != null) {
b4.txt = getString(R.string.ota_translating_fail);
}
UpdatingProcessAdapter updatingProcessAdapter5 = this.p7;
if (updatingProcessAdapter5 == null) {
k0.m("updatingProcessAdapter");
}
updatingProcessAdapter5.notifyDataSetChanged();
FirmwareUpDatingWidget firmwareUpDatingWidget = (FirmwareUpDatingWidget) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_loading);
k0.a((Object) firmwareUpDatingWidget, "id_updating_loading");
firmwareUpDatingWidget.setVisibility(4);
RoundProgressBar roundProgressBar = (RoundProgressBar) _$_findCachedViewById(com.lumiunited.aqara.R.id.rpb_updating_upgrade_progress);
k0.a((Object) roundProgressBar, "rpb_updating_upgrade_progress");
roundProgressBar.setVisibility(4);
ImageView imageView = (ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable);
k0.a((Object) imageView, "id_updating_image_update_avaiable");
imageView.setVisibility(0);
((ImageView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_image_update_avaiable)).setImageResource(R.mipmap.general_fail);
TextView textView = (TextView) _$_findCachedViewById(com.lumiunited.aqara.R.id.id_updating_retry);
k0.a((Object) textView, "id_updating_retry");
textView.setVisibility(0);
}
public final void a(long j2) {
p.a.u0.c subscribe = b0.interval(0L, 1L, TimeUnit.SECONDS).take(j2).subscribe(new b(j2));
k0.a((Object) subscribe, "Observable.interval(0, 1… }\n\n } })");
this.l7 = subscribe;
}
}