package com.ubtrobot.jimu.robotapi; import android.content.Context; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.text.TextUtils; import android.util.Log; import com.ijm.dataencryption.de.DataDecryptTool; import com.ubtech.utils.FileHelper; import com.ubtech.utils.XLog; import com.ubtrobot.jimu.Firmware; import com.ubtrobot.jimu.bluetooth.Cancellable; import com.ubtrobot.jimu.bluetooth.ConnectCallback; import com.ubtrobot.jimu.bluetooth.base.IPacket; import com.ubtrobot.jimu.bluetooth.base.ProtocolPacket; import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult; import com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter; import com.ubtrobot.jimu.connection.PacketsReceiveListener; import com.ubtrobot.jimu.connection.RequestException; import com.ubtrobot.jimu.connection.RobotConnection; import java.io.File; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.Timer; /* loaded from: classes2.dex */ public class UpdateManager implements PacketsReceiveListener, ConnectCallback { private Timer a; private volatile int b; private RobotConnection c; private DeviceManager d; private JimuScanner e; private Cancellable f; private List g = new ArrayList(); private Queue h = new LinkedList(); private Firmware i; private Firmware j; private Firmware k; private UpdateProgressListener l; private int m; private HandlerThread n; private Handler o; private volatile boolean p; private int q; private BoardInfo r; public static class UpdateException extends RequestException { public static final int ERR_CODE_DISCONNECTED = -99; public static final int ERR_CODE_LOW_POWER = -102; public static final int ERR_CODE_NO_FIRMWARE = -101; public static final int ERR_CODE_STOP_UPDATE_BOARD_FAILED = -107; public static final int ERR_CODE_UPDATE_BOARD_FAILED = -103; public static final int ERR_CODE_UPDATE_CANCEL = -106; public static final int ERR_CODE_UPDATE_FAILED = -100; public static final int ERR_CODE_UPDATE_SENSOR_FAILED = -105; public static final int ERR_CODE_UPDATE_SERVO_FAILED = -104; private final IPacket response; public UpdateException(int i, String str) { this(i, str, null, null); } public IPacket getResponse() { return this.response; } public UpdateException(int i, String str, IPacket iPacket) { this(i, str, null, iPacket); } public UpdateException(int i, String str, Throwable th) { this(i, str, th, null); } public UpdateException(int i, String str, Throwable th, IPacket iPacket) { super(i, str, th); this.response = iPacket; } } public interface UpdateProgressListener { void a(int i); void a(int i, int i2); void a(int i, Object obj); void a(UpdateException updateException); void g(BoardInfo boardInfo); } public UpdateManager(Context context, RobotConnection robotConnection) { this.c = robotConnection; this.d = new DeviceManager(robotConnection); this.e = new JimuScanner(context.getApplicationContext()); } private byte[] a(long j) { return new byte[]{(byte) (j & 255), (byte) ((j >> 8) & 255), (byte) ((j >> 16) & 255), (byte) ((j >> 24) & 255)}; } private byte[] b(int i) { return new byte[]{(byte) (i & 255), (byte) ((i >> 8) & 255)}; } @Override // com.ubtrobot.jimu.bluetooth.ConnectCallback public void onSuccess() { c(7); } private void d() { XLog.a("UpdateManager", "quit update cancel=" + this.p); try { if (this.n != null) { this.n.quit(); this.n = null; this.o = null; } if (this.f == null || this.f.isCancelled()) { return; } this.f.cancel(); this.f = null; } catch (Exception e) { e.printStackTrace(); } } private void e(String str, IPacket iPacket) { byte[] g = iPacket.g(); if (g == null || g.length < 2) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "83指令返回异常")); return; } int i = g[1] & 255; Log.d("UpdateManager", String.format("%s指令返回:%s", "83", Integer.toHexString(i))); if (i == 0) { a(this.k.c(), 100); return; } if (i == 170) { this.c.a(true); a(this.k.c(), (Object) null); c(3); } else { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "83指令返回异常,传感器升级失败:" + i, iPacket)); } } /* JADX INFO: Access modifiers changed from: private */ public void f() { String b = this.c.b(); if (TextUtils.isEmpty(b)) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "新主板升级失败:mac地址为null")); } else { this.c.a(b, this); } } private int g() throws JimuException { int a = a(new ProtocolPacket(130, new byte[]{0})); XLog.a("UpdateManager", "取消传感器升级:" + a); return a; } private int h() throws JimuException { int a = a(new ProtocolPacket(37, new byte[]{0})); XLog.a("UpdateManager", "取消舵机升级:" + a); return a; } /* JADX INFO: Access modifiers changed from: private */ public void i() { this.f = this.e.a(new ScannedHubEmitter() { // from class: com.ubtrobot.jimu.robotapi.UpdateManager.2 @Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter public void a() { } @Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter public void a(int i, String str) { } @Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter public void a(ScanResult scanResult) { if (scanResult == null || scanResult.a() == null || TextUtils.isEmpty(scanResult.a().getAddress()) || !scanResult.a().getAddress().equals(UpdateManager.this.c.b())) { return; } XLog.a("UpdateManager", "新主板升级,扫描到设备,准备开始重连..."); UpdateManager.this.c(6); UpdateManager.this.f.cancel(); } }, 60000); } /* JADX INFO: Access modifiers changed from: private */ /* JADX WARN: Code restructure failed: missing block: B:30:0x007b, code lost: android.util.Log.d("UpdateManager", "total:" + (java.lang.System.currentTimeMillis() - r13) + " sleep: " + r11); */ /* JADX WARN: Code restructure failed: missing block: B:31:0x009d, code lost: if (r16 == false) goto L34; */ /* JADX WARN: Code restructure failed: missing block: B:32:0x009f, code lost: a(new com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException(com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "主板升级失败,指令1C失败")); */ /* JADX WARN: Code restructure failed: missing block: B:33:0x00a9, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:34:0x00aa, code lost: b(20L); */ /* JADX WARN: Code restructure failed: missing block: B:35:0x00af, code lost: if (r19.p == false) goto L37; */ /* JADX WARN: Code restructure failed: missing block: B:36:0x00b1, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:38:0x00b6, code lost: if (a(r4, r7) == 0) goto L41; */ /* JADX WARN: Code restructure failed: missing block: B:39:0x00b8, code lost: a(new com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException(com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException.ERR_CODE_STOP_UPDATE_BOARD_FAILED, "主板升级失败,指令1B失败")); */ /* JADX WARN: Code restructure failed: missing block: B:40:0x00c4, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:42:0x00cd, code lost: if (r19.i.c() != 113) goto L47; */ /* JADX WARN: Code restructure failed: missing block: B:43:0x00cf, code lost: a(r19.i.c(), 100); com.ubtech.utils.XLog.a("UpdateManager", "新主板升级,文件传输完毕,等待60秒重连"); r19.q = 0; */ /* JADX WARN: Code restructure failed: missing block: B:44:0x00e1, code lost: if (r19.o == null) goto L46; */ /* JADX WARN: Code restructure failed: missing block: B:45:0x00e3, code lost: r19.o.sendMessageDelayed(r19.o.obtainMessage(5), 50000); */ /* JADX WARN: Code restructure failed: missing block: B:46:?, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:47:0x00f3, code lost: a(new com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException(com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "mHandler=null")); */ /* JADX WARN: Code restructure failed: missing block: B:48:?, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:49:0x00fe, code lost: r19.c.a(false); */ /* JADX WARN: Code restructure failed: missing block: B:50:?, code lost: return; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public void j() { /* Method dump skipped, instructions count: 272 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: com.ubtrobot.jimu.robotapi.UpdateManager.j():void"); } /* JADX INFO: Access modifiers changed from: private */ /* JADX WARN: Code restructure failed: missing block: B:47:0x00d6, code lost: if (r5 == false) goto L48; */ /* JADX WARN: Code restructure failed: missing block: B:48:0x00d8, code lost: a(new com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException(com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException.ERR_CODE_UPDATE_SERVO_FAILED, "舵机升级失败,指令24失败")); */ /* JADX WARN: Code restructure failed: missing block: B:49:0x00e2, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:50:0x00e3, code lost: b(20L); */ /* JADX WARN: Code restructure failed: missing block: B:51:0x00e8, code lost: if (r11.p == false) goto L51; */ /* JADX WARN: Code restructure failed: missing block: B:52:0x00ea, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:54:0x00ef, code lost: if (b(r1, r2) == 0) goto L54; */ /* JADX WARN: Code restructure failed: missing block: B:55:0x00f1, code lost: a(new com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException(com.ubtrobot.jimu.robotapi.UpdateManager.UpdateException.ERR_CODE_UPDATE_SERVO_FAILED, "舵机升级失败,指令26失败")); */ /* JADX WARN: Code restructure failed: missing block: B:56:0x00fb, code lost: r11.c.a(false); */ /* JADX WARN: Code restructure failed: missing block: B:57:?, code lost: return; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public void k() { /* Method dump skipped, instructions count: 269 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: com.ubtrobot.jimu.robotapi.UpdateManager.k():void"); } private void b(String str, IPacket iPacket) { int i = iPacket.g()[0] & 255; Log.d("UpdateManager", String.format("%s指令返回:%s", "1E", Integer.toHexString(i))); if (i == 0) { a(this.i.c(), 100); return; } if (i == 1) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "老主控开始升级失败")); return; } if (i == 170) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "老主控开始还原主程序")); } else if (i != 238) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "老主控开始升级失败")); } else { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "老主控开始还原失败")); } } /* JADX INFO: Access modifiers changed from: private */ public void c() { XLog.a("UpdateManager", "cancel update"); this.c.b(this); try { try { if (this.m == 3) { g(); } else if (this.m == 2) { h(); } else if (this.m == 1) { b(); } } catch (Exception e) { e.printStackTrace(); } } finally { d(); } } public boolean a(BoardInfo boardInfo) { return boardInfo == null || boardInfo.c() != 0 || boardInfo.b() >= 7.4f; } public boolean a(BoardInfo boardInfo, List list, UpdateProgressListener updateProgressListener) { this.m = 0; this.l = updateProgressListener; if (list != null && list.size() != 0) { if (!a(boardInfo)) { this.p = true; a(new UpdateException(UpdateException.ERR_CODE_LOW_POWER, "电量过低(电池电压低于7.4V)")); return false; } this.r = boardInfo; this.i = null; this.j = null; this.h.clear(); this.g.clear(); this.g.addAll(list); for (Firmware firmware : list) { if (112 != firmware.c() && 113 != firmware.c()) { if (128 == firmware.c()) { this.j = firmware; } else { this.h.add(firmware); } } else { this.i = firmware; } } this.c.a(this); this.p = false; this.n = new HandlerThread("jimu_firmware_update_thread"); this.n.start(); this.o = new Handler(this.n.getLooper()) { // from class: com.ubtrobot.jimu.robotapi.UpdateManager.1 @Override // android.os.Handler public void handleMessage(Message message) { super.handleMessage(message); try { switch (message.what) { case 1: UpdateManager.this.j(); break; case 2: UpdateManager.this.k(); break; case 3: UpdateManager.this.a(true); break; case 4: UpdateManager.this.c(); break; case 5: UpdateManager.this.m = 5; UpdateManager.this.i(); break; case 6: UpdateManager.this.m = 6; UpdateManager.this.f(); break; case 7: UpdateManager.this.m = 7; UpdateManager.this.e(); break; } } catch (Exception e) { e.printStackTrace(); UpdateManager.this.a(new UpdateException(-100, "升级失败", e)); } } }; c(1); return true; } a(new UpdateException(UpdateException.ERR_CODE_NO_FIRMWARE, "需要升级的固件列表为null")); return false; } private int b(byte[] bArr, int i, int i2) throws JimuException { return a(new ProtocolPacket(28, a(bArr, i, i2))); } private void d(String str, IPacket iPacket) { int i = iPacket.g()[0] & 255; Log.d("UpdateManager", String.format("%s指令返回:%s", "26", Integer.toHexString(i))); if (i == 0) { a(PeripheralType.SERVO, 100); return; } if (i == 2) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SERVO_FAILED, "舵机升级失败: " + iPacket.g(), iPacket)); return; } if (i != 170) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SERVO_FAILED, "舵机升级失败", iPacket)); } else { this.c.a(true); c(3); } } /* JADX INFO: Access modifiers changed from: private */ public void e() { try { this.d.g(); b(20L); BoardInfo e = this.d.e(); if (e == null) { b(2000L); e = this.d.e(); } if (e != null && !TextUtils.isEmpty(e.d())) { if (!e.d().equals(this.i.d())) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "新主板升级,重连后版本信息和要升级的不一致,升级失败")); return; } Log.d("UpdateManager", "新主板升级成功,现在的版本名称为:" + e.d()); a(this.i.c(), e); c(2); this.r = e; return; } a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "新主板升级,重连后读取主板信息失败")); } catch (Exception e2) { e2.printStackTrace(); a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "新主板升级,重连后读取主板信息失败")); } } public int b() throws JimuException { int a = a(new ProtocolPacket(29, new byte[]{0})); XLog.a("UpdateManager", "取消主板升级:" + a); return a; } private void c(String str, IPacket iPacket) { int i = iPacket.g()[0] & 255; Log.d("UpdateManager", String.format("%s指令返回:%s", "1F", Integer.toHexString(i))); if (i == 0) { this.c.a(true); c(2); } else { if (i == 1) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "主控结束升级失败")); return; } if (i == 170) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "结束还原主程序成功")); } else if (i != 238) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "主控结束升级失败")); } else { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_BOARD_FAILED, "结束还原失败")); } } } private int b(byte[] bArr, int i) throws JimuException { return a(new ProtocolPacket(38, a(bArr, i, i))); } private byte[] b(Firmware firmware) throws JimuException { byte[] a; if (firmware != null && (a = a(firmware.b(), firmware.a())) != null && a.length != 0) { String a2 = FileHelper.a(firmware.b()); if (TextUtils.isEmpty(a2)) { return null; } byte[] bytes = a2.replace(".bin", "").getBytes(); byte[] bArr = new byte[bytes.length + 5]; bArr[0] = (byte) (firmware.c() & 255); bArr[1] = 0; byte[] b = b(b(a)); bArr[2] = b[0]; bArr[3] = b[1]; bArr[4] = (byte) (bytes.length & 255); System.arraycopy(bytes, 0, bArr, 5, bytes.length); byte[] b2 = b(new ProtocolPacket(PeripheralType.SERVO, bArr)); if (b2 != null && b2.length >= 2 && firmware.c() == (b2[0] & 255) && (b2[1] & 255) == 0) { return a; } } return null; } private byte[] c(Firmware firmware) throws JimuException { byte[] a; if (firmware != null && (a = a(firmware.b(), firmware.a())) != null && a.length != 0) { int length = a.length % 64; if (length != 0) { byte[] bArr = new byte[a.length + (64 - length)]; System.arraycopy(a, 0, bArr, 0, a.length); a = bArr; } byte[] bArr2 = new byte[7]; bArr2[0] = 0; System.arraycopy(b(b(a)), 0, bArr2, 1, 2); System.arraycopy(a(a(a)), 0, bArr2, 3, 4); if (a(new ProtocolPacket(35, bArr2)) == 0) { return a; } } return null; } public synchronized void a() { if (!this.p && this.n != null) { c(4); a(this.m); this.p = true; } } private int c(byte[] bArr, int i, int i2) throws JimuException { return a(new ProtocolPacket(36, a(bArr, i, i2))); } private byte[] b(int i, byte[] bArr, int i2, int i3) throws JimuException { return b(new ProtocolPacket(129, a(i, bArr, i2, i3))); } /* JADX INFO: Access modifiers changed from: private */ public void c(int i) { Handler handler = this.o; if (handler == null) { XLog.b("UpdateManager", "未知错误: mHandler==null"); d(); } else { handler.sendEmptyMessage(i); } } @Override // com.ubtrobot.jimu.connection.PacketsReceiveListener public void a(String str, IPacket iPacket) { if (iPacket == null) { return; } try { int f = iPacket.f() & 255; if (f == 30) { b(str, iPacket); } else if (f == 31) { c(str, iPacket); } else if (f == 38) { d(str, iPacket); } else if (f == 131) { e(str, iPacket); } } catch (Exception e) { a(new UpdateException(-100, "升级失败", e)); } } private void b(BoardInfo boardInfo) { this.c.b(this); if (boardInfo != null) { this.l.g(boardInfo); return; } try { try { b(3000L); this.d.g(); b(20L); BoardInfo e = this.d.e(); if (e == null) { b(2000L); e = this.d.e(); } if (e == null) { a(new UpdateException(-100, "升级完成,但是读取主板信息失败")); } else { this.r = e; this.l.g(e); } } catch (Exception e2) { e2.printStackTrace(); } d(); Timer timer = this.a; if (timer != null) { timer.cancel(); this.a = null; } } catch (Throwable th) { d(); throw th; } } @Override // com.ubtrobot.jimu.bluetooth.ConnectCallback public void a(int i, String str) { this.q++; if (this.q > 3) { a(new UpdateException(-99, "新主控升级失败,重连3次失败")); return; } Handler handler = this.o; if (handler != null) { handler.sendMessageDelayed(handler.obtainMessage(6), 3000L); } else { a(new UpdateException(-99, "新主控升级失败,重连失败")); } } /* JADX INFO: Access modifiers changed from: private */ public void a(boolean z) { boolean z2; if (this.m == 2) { if (z) { try { b(3000L); this.d.g(); b(20L); BoardInfo e = this.d.e(); if (e == null) { b(2000L); e = this.d.e(); } if (e != null && !TextUtils.isEmpty(e.j()) && e.j().equals(this.j.d())) { this.r = e; a(PeripheralType.SERVO, e); } a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SERVO_FAILED, "舵机升级完成,但是读取主板信息失败")); return; } catch (Exception e2) { e2.printStackTrace(); } } if (this.h == null || this.h.size() == 0) { b(this.r); return; } } Firmware poll = this.h.poll(); if (poll == null) { b((BoardInfo) null); return; } Log.d("UpdateManager", "升级传感器:" + poll.c()); this.m = 3; this.k = poll; try { b(20L); if (this.p) { return; } byte[] b = b(poll); if (b != null && b.length != 0) { int b2 = b(b); int i = 0; int i2 = 0; while (i < b2 - 1) { b(20L); if (!this.p) { int i3 = i + 1; byte[] b3 = b(poll.c(), b, b2, i3); if (poll.c() == (b3[0] & 255) && (b3[1] & 255) == 0) { int i4 = (i * 100) / b2; if (i2 != i4) { a(poll.c(), i4); i2 = i4; } i = i3; } z2 = true; break; } return; } z2 = false; if (z2) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "传感器升级失败,81指令调用失败")); return; } b(20L); if (this.p) { return; } if ((a(poll.c(), b, b2)[1] & 255) != 0) { a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "传感器升级失败,83指令调用失败")); } this.c.a(false); return; } a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "传感器升级失败,80指令调用失败")); } catch (Exception e3) { e3.printStackTrace(); a(new UpdateException(UpdateException.ERR_CODE_UPDATE_SENSOR_FAILED, "传感器升级失败", e3)); } } private byte[] b(ProtocolPacket protocolPacket) throws JimuException { try { byte[] g = this.c.a(protocolPacket).g(); if (g != null && g.length != 0) { return g; } throw new JimuException(-21, "指令操作失败:" + Integer.toHexString(protocolPacket.f())); } catch (RequestException e) { e.printStackTrace(); throw new JimuException(e.getCode(), e.getMessage()); } } private void b(long j) { try { Thread.sleep(j); } catch (Exception e) { e.printStackTrace(); } } private int b(byte[] bArr) { int length = bArr.length; int i = length / 100; return length % 100 > 0 ? i + 1 : i; } private byte[] a(Firmware firmware) throws JimuException { byte[] a = a(firmware.b(), firmware.a()); if (a == null) { return null; } String a2 = FileHelper.a(firmware.b()); if (TextUtils.isEmpty(a2)) { return null; } byte[] bytes = a2.getBytes(); byte[] bArr = new byte[bytes.length + 1 + 2]; bArr[0] = (byte) (bytes.length & 255); System.arraycopy(bytes, 0, bArr, 1, bytes.length); System.arraycopy(b(b(a)), 0, bArr, bytes.length + 1, 2); int a3 = a(new ProtocolPacket(26, bArr)); if (a3 == 0) { return a; } XLog.b("UpdateManager", "cmd 1A failed:" + a3); return null; } private int a(byte[] bArr, int i) throws JimuException { return a(new ProtocolPacket(27, a(bArr, i, i))); } private byte[] a(int i, byte[] bArr, int i2) throws JimuException { return b(new ProtocolPacket(131, a(i, bArr, i2, i2))); } /* JADX WARN: Removed duplicated region for block: B:14:0x0020 A[Catch: all -> 0x0068, TryCatch #0 {, blocks: (B:4:0x0003, B:12:0x001b, B:14:0x0020, B:15:0x0028, B:18:0x003a, B:19:0x0066, B:25:0x0063), top: B:3:0x0003, inners: #1 }] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private void a(final int r9, int r10) { /* r8 = this; monitor-enter(r8) int r10 = r10 * 9 int r10 = r10 / 10 r8.b = r10 // Catch: java.lang.Throwable -> L68 int r10 = r8.b // Catch: java.lang.Throwable -> L68 r0 = 90 if (r10 != r0) goto L3a r10 = 113(0x71, float:1.58E-43) if (r10 == r9) goto L19 r10 = 112(0x70, float:1.57E-43) if (r10 != r9) goto L16 goto L19 L16: r0 = 1000(0x3e8, double:4.94E-321) goto L1b L19: r0 = 7000(0x1b58, double:3.4585E-320) L1b: r6 = r0 java.util.Timer r10 = r8.a // Catch: java.lang.Throwable -> L68 if (r10 == 0) goto L28 java.util.Timer r10 = r8.a // Catch: java.lang.Throwable -> L68 r10.cancel() // Catch: java.lang.Throwable -> L68 r10 = 0 r8.a = r10 // Catch: java.lang.Throwable -> L68 L28: java.util.Timer r10 = new java.util.Timer // Catch: java.lang.Throwable -> L68 r10.() // Catch: java.lang.Throwable -> L68 r8.a = r10 // Catch: java.lang.Throwable -> L68 java.util.Timer r2 = r8.a // Catch: java.lang.Throwable -> L68 com.ubtrobot.jimu.robotapi.UpdateManager$3 r3 = new com.ubtrobot.jimu.robotapi.UpdateManager$3 // Catch: java.lang.Throwable -> L68 r3.() // Catch: java.lang.Throwable -> L68 r4 = r6 r2.scheduleAtFixedRate(r3, r4, r6) // Catch: java.lang.Throwable -> L68 L3a: com.ubtrobot.jimu.robotapi.UpdateManager$UpdateProgressListener r10 = r8.l // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 int r0 = r8.b // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 r10.a(r9, r0) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 java.lang.String r10 = "UpdateManager" java.lang.StringBuilder r0 = new java.lang.StringBuilder // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 r0.() // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 java.lang.String r1 = "updateProgress type:" r0.append(r1) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 r0.append(r9) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 java.lang.String r9 = " progress:" r0.append(r9) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 int r9 = r8.b // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 r0.append(r9) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 java.lang.String r9 = r0.toString() // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 android.util.Log.d(r10, r9) // Catch: java.lang.Exception -> L62 java.lang.Throwable -> L68 goto L66 L62: r9 = move-exception r9.printStackTrace() // Catch: java.lang.Throwable -> L68 L66: monitor-exit(r8) // Catch: java.lang.Throwable -> L68 return L68: r9 = move-exception monitor-exit(r8) // Catch: java.lang.Throwable -> L68 throw r9 */ throw new UnsupportedOperationException("Method not decompiled: com.ubtrobot.jimu.robotapi.UpdateManager.a(int, int):void"); } private void a(int i, Object obj) { try { this.l.a(i, obj); } catch (Exception e) { e.printStackTrace(); } } /* JADX INFO: Access modifiers changed from: private */ public void a(UpdateException updateException) { try { this.l.a(updateException); this.c.b(this); } catch (Exception e) { e.printStackTrace(); } try { Log.e("UpdateManager", "updateFailed:" + updateException.getMessage()); c(4); } catch (Exception e2) { e2.printStackTrace(); d(); } Timer timer = this.a; if (timer != null) { timer.cancel(); this.a = null; } } private void a(int i) { try { this.l.a(i); } catch (Exception e) { e.printStackTrace(); } } private int a(ProtocolPacket protocolPacket) throws JimuException { return b(protocolPacket)[0] & 255; } private byte[] a(byte[] bArr, int i, int i2) { int i3 = (i2 - 1) * 100; int length = (i2 == i ? bArr.length : i2 * 100) - i3; byte[] bArr2 = new byte[length + 2]; System.arraycopy(b(i2), 0, bArr2, 0, 2); System.arraycopy(bArr, i3, bArr2, 2, length); return bArr2; } private byte[] a(int i, byte[] bArr, int i2, int i3) { int i4 = (i3 - 1) * 100; int length = (i3 == i2 ? bArr.length : i3 * 100) - i4; byte[] bArr2 = new byte[length + 3]; bArr2[0] = (byte) (i & 255); System.arraycopy(b(i3), 0, bArr2, 1, 2); System.arraycopy(bArr, i4, bArr2, 3, length); return bArr2; } private byte[] a(String str, String str2) { File file = new File(str); if (file.exists() && FileHelper.a(str2, str)) { return FileHelper.b(file); } return null; } private long a(byte[] bArr) { long[] jArr = new long[DataDecryptTool.DECRYPT_ALL_FILE]; for (long j = 0; j < 256; j++) { long j2 = j; for (long j3 = 0; j3 < 8; j3++) { j2 = (j2 & 1) == 1 ? (j2 >> 1) ^ 3988292384L : j2 >> 1; } jArr[(int) j] = j2; } long j4 = 4294967295L; for (byte b : bArr) { j4 = (j4 >> 8) ^ jArr[(int) ((b ^ j4) & 255)]; } return j4; } }