Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 BleLockUpgradeFirmwareActivity.java 源代码,内容仅作参考
package com.lumiunited.aqara.device.lock.activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lumiunited.aqara.application.base.BaseDeviceEntity;
import com.lumiunited.aqara.common.ui.RoundProgressBar;
import com.lumiunited.aqara.common.ui.titlebar.TitleBar;
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.device.event.WifiConnectEvent;
import com.lumiunited.aqara.device.lock.activity.BleLockUpgradeFirmwareActivity;
import com.lumiunited.aqara.device.lock.bean.LockRegLoginResultEntity;
import com.lumiunited.aqara.device.lock.viewmodel.UpgradeFirmwareModel;
import com.lumiunited.aqarahome.R;
import java.util.ArrayList;
import k.t.d.b.d;
import k.u.c.d.j.i0;
import k.u.c.d.j.o;
import k.u.c.f.a.q.w0;
import k.u.c.f.a.q.y0;
import k.u.c.i.i3.d.e;
import k.u.c.i.i3.d.r;
import k.u.c.i.i3.l.k;
import k.u.c.i.j3.z;
import k.u.c.i.m1;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import x.b.a.m;
public class BleLockUpgradeFirmwareActivity extends BaseLockBleSimpleActivity implements View.OnClickListener, TitleBar.l {
public static final int O7 = 0;
public static final int P7 = 1;
public static final int Q7 = 2;
public static final int R7 = 3;
public static final int S7 = 4;
public static final int T7 = 5;
public static final int U7 = 6;
public static final int V7 = 7;
public static final int W7 = 8;
public static final int X7 = 9;
public static final int Y7 = 10;
public static final int Z7 = 1;
public static final int a8 = 2;
public static final int b8 = 3;
public static final int c8 = 4;
public static final int d8 = 5;
public static final int e8 = 6;
public static final int f8 = 7;
public static final int g8 = 8;
public TextView A7;
public Button B7;
public String C7;
public String E7;
public UpgradeFirmwareBean F7;
public String G7;
public String H7;
public UpgradeFirmwareModel J7;
public UpdatingProcessAdapter K7;
public w0 L7;
public y0 M7;
public View g7;
public View h7;
public TextView i7;
public TextView j7;
public View k7;
public TextView l7;
public TextView m7;
public TextView n7;
public TextView o7;
public TextView p7;
public View q7;
public ImageView r7;
public ImageView s7;
public FirmwareUpDatingWidget t7;
public RoundProgressBar u7;
public TextView v7;
public RecyclerView w7;
public TextView x7;
public View y7;
public TextView z7;
public boolean D7 = false;
public int I7 = 1;
public boolean N7 = false;
public class a extends o<FirmwareBean> {
public a() {
}
@Override
public void a(int i2, String str) {
if (BleLockUpgradeFirmwareActivity.this.isFinishing()) {
return;
}
BleLockUpgradeFirmwareActivity.this.f(6, "");
}
@Override
public void a(FirmwareBean firmwareBean) {
if (BleLockUpgradeFirmwareActivity.this.isFinishing()) {
return;
}
if (firmwareBean == null && BleLockUpgradeFirmwareActivity.this.V1()) {
return;
}
if (firmwareBean == null) {
BleLockUpgradeFirmwareActivity.this.f(3, "");
return;
}
BleLockUpgradeFirmwareActivity.this.G7 = firmwareBean.getUpgradeFirmware().getFirmwareVersion();
BleLockUpgradeFirmwareActivity.this.F7 = firmwareBean.getUpgradeFirmware();
BleLockUpgradeFirmwareActivity bleLockUpgradeFirmwareActivity = BleLockUpgradeFirmwareActivity.this;
bleLockUpgradeFirmwareActivity.H7 = bleLockUpgradeFirmwareActivity.F7.getUpdateLog();
if (BleLockUpgradeFirmwareActivity.this.V1()) {
return;
}
BleLockUpgradeFirmwareActivity.this.f(3, "");
}
}
public static class b {
public static final int[] a;
public static final int[] b;
static {
int[] iArr = new int[r.values().length];
b = iArr;
try {
iArr[r.TIMEOUT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
b[r.DISCONNECT.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
b[r.UNCONNECT.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
int[] iArr2 = new int[e.values().length];
a = iArr2;
try {
iArr2[e.SUCCESS.ordinal()] = 1;
} catch (NoSuchFieldError unused4) {
}
try {
a[e.UN_OPEN_GPS.ordinal()] = 2;
} catch (NoSuchFieldError unused5) {
}
}
}
private void D(int i2) {
this.u7.setProgress(i2);
}
private void F1() {
this.I7 = 4;
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(1, getString(R.string.ota_connecting_blue_tooth), 7));
this.K7.notifyDataSetChanged();
}
private void G1() {
if (this.E7 != null && !TextUtils.isEmpty(this.G7) && !this.E7.equals(this.G7)) {
this.N7 = true;
Y1();
return;
}
finish();
}
private void H1() {
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.doorlock_wifi_connects_success), 8));
this.K7.b().add(new UpdatingProcessBean(1, getString(R.string.doorlock_firmware_downloading), 9));
this.K7.notifyDataSetChanged();
}
private void I1() {
this.I7 = 5;
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(1, getString(R.string.doorlock_wifi_is_connecting), 8));
this.K7.notifyDataSetChanged();
this.J7.k();
}
private void J1() {
k.d.a.c("handleOtaReLoginStatus : " + this.I7);
int i2 = this.I7;
if (i2 == 7) {
this.J7.j();
} else if (i2 == 1 || i2 == 2) {
this.J7.j();
} else if (i2 == 5) {
this.J7.k();
}
}
private void K1() {
UpdatingProcessAdapter updatingProcessAdapter = new UpdatingProcessAdapter(this, new ArrayList());
this.K7 = updatingProcessAdapter;
this.w7.setAdapter(updatingProcessAdapter);
this.w7.setLayoutManager(new LinearLayoutManager(this));
}
private void L1() {
this.C7 = getIntent().getStringExtra("did");
}
private boolean M1() {
return (TextUtils.isEmpty(this.E7) || TextUtils.isEmpty(this.G7) || TextUtils.equals(this.E7, this.G7)) ? false : true;
}
private void N1() {
UpgradeFirmwareModel upgradeFirmwareModel = (UpgradeFirmwareModel) ViewModelProviders.of(this).get(UpgradeFirmwareModel.class);
this.J7 = upgradeFirmwareModel;
upgradeFirmwareModel.p().observe(this, new Observer() {
@Override
public final void onChanged(Object obj) {
BleLockUpgradeFirmwareActivity.this.b((Integer) obj);
}
});
this.J7.o().observe(this, new Observer() {
@Override
public final void onChanged(Object obj) {
BleLockUpgradeFirmwareActivity.this.c((Integer) obj);
}
});
this.J7.q().observe(this, new Observer() {
@Override
public final void onChanged(Object obj) {
BleLockUpgradeFirmwareActivity.this.j0((String) obj);
}
});
this.J7.i().observe(this, new Observer() {
@Override
public final void onChanged(Object obj) {
BleLockUpgradeFirmwareActivity.this.k0((String) obj);
}
});
this.J7.a(this.f8955r);
this.J7.t();
this.J7.n();
}
private void O1() {
m1.d().i(this.C7, new a());
}
private void P1() {
this.I7 = 3;
this.g7.setVisibility(8);
this.h7.setVisibility(8);
this.k7.setVisibility(0);
this.q7.setVisibility(8);
this.y7.setVisibility(8);
}
private void Q1() {
y0 a2 = new y0.c(this).d(getString(R.string.doorlock_exit_update_interrupt_process)).a(getString(R.string.cancel), new View.OnClickListener() {
@Override
public final void onClick(View view) {
BleLockUpgradeFirmwareActivity.this.g(view);
}
}).c(getString(R.string.ConfirmEnd), new View.OnClickListener() {
@Override
public final void onClick(View view) {
BleLockUpgradeFirmwareActivity.this.f(view);
}
}).a();
this.M7 = a2;
a2.show();
}
private void R1() {
this.I7 = 2;
this.g7.setVisibility(8);
this.h7.setVisibility(0);
this.k7.setVisibility(8);
this.q7.setVisibility(8);
this.y7.setVisibility(8);
}
private void S1() {
this.I7 = 1;
this.g7.setVisibility(0);
this.h7.setVisibility(8);
this.k7.setVisibility(8);
this.q7.setVisibility(8);
this.y7.setVisibility(8);
}
private void T1() {
w0 a2 = new w0.b(this).g("后台升级").b(z.B(this.f8955r.getModel()) ? "http://demo.lumiunited.com:1115/DQ1/DQ1_1.1.0_1010.zip" : "http://demo.lumiunited.com:1115/DZ1/DZ1_1.1.0_0002.zip").d(getString(17039360)).e(getString(R.string.confirm)).a(200).a();
this.L7 = a2;
a2.setCanceledOnTouchOutside(false);
this.L7.a(new w0.e() {
@Override
public final void a(String str) {
BleLockUpgradeFirmwareActivity.this.l0(str);
}
});
this.L7.show();
}
private void U1() {
new y0.c(this).d(getString(R.string.doorlock_wifi_pleaseconfigure)).a(getString(R.string.cancel), new y0.e() {
@Override
public final void a(View view, Dialog dialog) {
dialog.dismiss();
}
}).a(getString(R.string.doorlock_gotoconfigure), new y0.f() {
@Override
public final void b(View view, Dialog dialog) {
BleLockUpgradeFirmwareActivity.this.c(view, dialog);
}
}).a().show();
}
public boolean V1() {
if (this.I7 >= 7) {
if (M1()) {
f(5, getString(R.string.UpgradeFailed));
return true;
}
f(0, "");
return true;
}
return false;
}
private void W1() {
this.g7.setVisibility(8);
this.h7.setVisibility(8);
this.k7.setVisibility(8);
this.q7.setVisibility(8);
this.y7.setVisibility(0);
}
private void X1() {
this.g7.setVisibility(8);
this.h7.setVisibility(8);
this.k7.setVisibility(8);
this.q7.setVisibility(0);
this.y7.setVisibility(8);
}
private void Y1() {
this.K7.b().clear();
this.K7.notifyDataSetChanged();
this.I7 = 3;
f(1, "");
if (d.f19137o.c().h()) {
this.J7.s();
return;
}
F1();
k.f24941h.a(this.f8955r.getDid(), this.f8955r.getModel()).b(10000L);
}
public void f(int i2, String str) {
k.d.a.c("updateVerInfoUI : " + i2);
switch (i2) {
case 0:
this.I7 = 8;
W1();
k.u.c.i.i3.l.b.c.a(false);
this.A7.setVisibility(8);
this.z7.setText(getString(R.string.ota_success));
return;
case 1:
X1();
this.s7.setVisibility(8);
this.r7.setVisibility(0);
this.t7.setVisibility(0);
this.u7.setVisibility(4);
this.x7.setVisibility(8);
this.v7.setText(getString(R.string.doorlock_during_the_updating_process_place_mobile_phone_close_to_the_doorlock));
return;
case 2:
this.I7 = 8;
X1();
this.s7.setVisibility(0);
this.r7.setVisibility(4);
this.t7.setVisibility(8);
this.u7.setVisibility(4);
this.x7.setVisibility(0);
return;
case 3:
if (this.I7 >= 5) {
return;
}
if (M1()) {
P1();
this.l7.setText(String.format("%s%s", getString(R.string.firmware_upgrade_latest_version), this.G7));
this.m7.setText(getString(R.string.doorlock_during_the_updating_process_place_mobile_phone_close_to_the_doorlock));
this.n7.setText(this.H7);
this.o7.setText(String.format("%s%s", getString(R.string.firmware_upgrade_current_version), this.E7));
return;
}
W1();
this.A7.setText(String.format("%s%s", getString(R.string.firmware_upgrade_current_version), this.E7));
return;
case 4:
this.I7 = 6;
X1();
this.s7.setVisibility(8);
this.r7.setVisibility(4);
this.t7.setVisibility(8);
this.u7.setVisibility(0);
this.x7.setVisibility(8);
return;
case 5:
this.I7 = 8;
W1();
this.A7.setVisibility(0);
this.A7.setText(String.format("%s%s", getString(R.string.firmware_upgrade_current_version), this.E7));
this.z7.setText(str);
return;
case 6:
R1();
this.i7.setText(String.format("%s%s", getString(R.string.firmware_upgrade_current_version), this.E7));
return;
default:
return;
}
}
private void m0(String str) {
if (this.F7 == null) {
UpgradeFirmwareBean upgradeFirmwareBean = new UpgradeFirmwareBean();
this.F7 = upgradeFirmwareBean;
upgradeFirmwareBean.setFirmwareVersion("1.2.3.4");
}
this.F7.setDownloadUrl(str);
this.G7 = this.F7.getFirmwareVersion();
this.H7 = this.F7.getUpdateLog();
this.N7 = true;
Y1();
}
public void E1() {
if (this.N7) {
Q1();
} else {
finish();
}
}
public void c(Integer num) {
if (this.q7.getVisibility() == 8) {
f(4, "");
this.N7 = false;
H1();
}
D(num.intValue());
}
public boolean d(View view) {
T1();
return false;
}
public boolean e(View view) {
T1();
return false;
}
@Override
public void finish() {
super.finish();
if (k.u.c.i.i3.l.b.c.b()) {
k.u.c.i.i3.l.b.c.a(this);
}
}
public void g(View view) {
this.M7.dismiss();
}
public void j0(String str) {
if (this.I7 == 5) {
return;
}
this.E7 = str;
k.d.a.b(str);
O1();
}
public void k0(String str) {
f(5, str);
}
@Override
public void k1() {
this.g7 = findViewById(R.id.id_layout_checking);
this.h7 = findViewById(R.id.id_layout_check_fail);
this.i7 = (TextView) findViewById(R.id.textView2);
this.j7 = (TextView) findViewById(R.id.id_fail_retry);
this.k7 = findViewById(R.id.id_layout_updateAvable);
this.l7 = (TextView) findViewById(R.id.id_avaiable_title);
this.m7 = (TextView) findViewById(R.id.id_avaiable_des);
this.n7 = (TextView) findViewById(R.id.id_avaiable_log);
this.o7 = (TextView) findViewById(R.id.id_avaiable_small_version_des);
this.p7 = (TextView) findViewById(R.id.id_update_avaiable_sure);
this.q7 = findViewById(R.id.id_layout_updating);
this.r7 = (ImageView) findViewById(R.id.id_updating_image_update_avaiable);
this.s7 = (ImageView) findViewById(R.id.id_updating_loading_fail);
this.t7 = (FirmwareUpDatingWidget) findViewById(R.id.id_updating_loading);
this.u7 = (RoundProgressBar) findViewById(R.id.rpb_updating_upgrade_progress);
this.v7 = (TextView) findViewById(R.id.textView4);
this.w7 = (RecyclerView) findViewById(R.id.id_updating_indicator);
this.x7 = (TextView) findViewById(R.id.id_updating_retry);
this.y7 = findViewById(R.id.id_layout_updating_status);
this.z7 = (TextView) findViewById(R.id.id_status_title);
this.A7 = (TextView) findViewById(R.id.id_status_version_txt);
this.B7 = (Button) findViewById(R.id.clickMe);
this.j7.setOnClickListener(this);
this.p7.setOnClickListener(this);
this.x7.setOnClickListener(this);
this.B7.setOnClickListener(this);
this.A7.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public final boolean onLongClick(View view) {
return BleLockUpgradeFirmwareActivity.this.d(view);
}
});
this.o7.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public final boolean onLongClick(View view) {
return BleLockUpgradeFirmwareActivity.this.e(view);
}
});
((TitleBar) findViewById(R.id.title_bar)).setOnLeftClickListener(new TitleBar.j() {
@Override
public final void d() {
BleLockUpgradeFirmwareActivity.this.E1();
}
});
K1();
S1();
N1();
}
public void l0(String str) {
m0(str);
this.L7.dismiss();
}
@Override
public int m1() {
return R.layout.activity_upgrade_firmware2;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.clickMe:
T1();
return;
case R.id.id_fail_retry:
S1();
this.J7.j();
return;
case R.id.id_update_avaiable_sure:
case R.id.id_updating_retry:
G1();
return;
default:
return;
}
}
@Override
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
L1();
}
@Override
public void onDestroy() {
super.onDestroy();
this.J7.g();
}
@Override
@m(threadMode = ThreadMode.MAIN)
public void scanLoginResultEvent(LockRegLoginResultEntity lockRegLoginResultEntity) {
int i2 = b.a[lockRegLoginResultEntity.getResultCode().ordinal()];
if (i2 == 1) {
J1();
} else if (i2 != 2) {
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(2, getString(R.string.ota_connecting_bluetooth_fail), 7));
this.K7.notifyDataSetChanged();
f(2, "");
} else {
r1();
}
}
@m(threadMode = ThreadMode.MAIN)
public void wifiStatusChange(WifiConnectEvent wifiConnectEvent) {
k.d.a.c("wifiStatusChange : " + wifiConnectEvent.isBindSuccess);
if (wifiConnectEvent.isBindSuccess) {
f(3, "");
}
}
public void b(Integer num) {
switch (num.intValue()) {
case 1:
if (this.I7 >= 6 || !z1()) {
return;
}
H1();
UpgradeFirmwareBean upgradeFirmwareBean = this.F7;
if (upgradeFirmwareBean != null) {
this.N7 = false;
this.J7.a(upgradeFirmwareBean);
return;
}
return;
case 2:
if (this.I7 >= 6) {
return;
}
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(2, getString(R.string.doorlock_connect_wifi_fail), 8));
this.K7.notifyDataSetChanged();
f(2, "");
U1();
return;
case 3:
f(4, "");
D(0);
return;
case 4:
case 10:
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.doorlock_wifi_connects_success), 8));
this.K7.b().add(new UpdatingProcessBean(2, getString(R.string.ota_download_fail), 9));
this.K7.notifyDataSetChanged();
f(2, "");
return;
case 5:
if (this.I7 >= 6) {
return;
}
i0(getString(R.string.doorlock_update_failed_by_dry_cells_low));
f(5, getString(R.string.doorlock_update_failed_by_dry_cells_low));
this.N7 = false;
return;
case 6:
if (this.I7 >= 6) {
return;
}
i0(getString(R.string.doorlock_update_failed_by_lithium_battery_low));
f(5, getString(R.string.doorlock_update_failed_by_lithium_battery_low));
this.N7 = false;
return;
case 7:
if (this.I7 >= 6) {
return;
}
I1();
return;
case 8:
this.I7 = 7;
k.d.a.b("重启中...");
f(1, "");
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.doorlock_wifi_connects_success), 8));
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.DownloadFirmwareSuccessful), 9));
this.K7.b().add(new UpdatingProcessBean(1, getString(R.string.ota_rebooting), 10));
this.K7.notifyDataSetChanged();
return;
case 9:
default:
return;
case 11:
if (this.I7 >= 6) {
return;
}
this.K7.b().clear();
this.K7.b().add(new UpdatingProcessBean(0, getString(R.string.ota_connecting_bluetooth_success), 7));
this.K7.b().add(new UpdatingProcessBean(2, getString(R.string.doorlock_connect_wifi_fail), 8));
this.K7.notifyDataSetChanged();
f(2, "");
return;
}
}
public static void a(Context context, BaseDeviceEntity baseDeviceEntity) {
Intent intent = new Intent(context, BleLockUpgradeFirmwareActivity.class);
intent.putExtra("did", baseDeviceEntity.getDid());
intent.putExtra("device_info", baseDeviceEntity);
i0.a(context, intent);
}
@Override
public void c() {
finish();
}
public void c(View view, Dialog dialog) {
dialog.dismiss();
Intent intent = new Intent(this, BleLockSelectWifiActivity.class);
BaseDeviceEntity baseDeviceEntity = this.f8955r;
if (baseDeviceEntity != null) {
intent.putExtra(k.u.c.i.i3.r.z.a, baseDeviceEntity);
}
startActivity(intent);
}
public void f(View view) {
this.M7.dismiss();
finish();
}
@Override
public void b(@NotNull r rVar) {
b0();
int i2 = b.b[rVar.ordinal()];
if (i2 == 1) {
k.d.a.b(getString(R.string.doorlock_reception_timed_out_bluetooth_data));
} else if (i2 != 2) {
if (i2 != 3) {
return;
}
a(rVar);
} else if (this.I7 == 7) {
i0(getString(R.string.doorlock_disconnects_bluetooth));
k.d.a.b("BLE 下载完成后断开连接");
k.f24941h.a(this.f8955r.getDid(), this.f8955r.getModel()).b(Long.MAX_VALUE);
} else {
a(rVar);
}
}
}