Initial commit
This commit is contained in:
38
sources/com/ubtrobot/jimu/robotapi/BatteryInfo.java
Normal file
38
sources/com/ubtrobot/jimu/robotapi/BatteryInfo.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BatteryInfo {
|
||||
private float a;
|
||||
private float b;
|
||||
private boolean c;
|
||||
private boolean d;
|
||||
|
||||
public BatteryInfo(float f, float f2, boolean z, boolean z2) {
|
||||
this.c = false;
|
||||
this.d = false;
|
||||
this.a = f;
|
||||
this.b = f2 <= 100.0f ? f2 : 100.0f;
|
||||
this.d = z;
|
||||
this.c = z2;
|
||||
}
|
||||
|
||||
public float a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public float b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public boolean c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public boolean d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Battery voltage:" + this.a + " percentage:" + this.b + "% isPluginCharger:" + this.d + " isChargingCompleted:" + this.c;
|
||||
}
|
||||
}
|
20
sources/com/ubtrobot/jimu/robotapi/BluetoothSpeakerInfo.java
Normal file
20
sources/com/ubtrobot/jimu/robotapi/BluetoothSpeakerInfo.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BluetoothSpeakerInfo {
|
||||
private String a;
|
||||
private String b;
|
||||
|
||||
public BluetoothSpeakerInfo(String str, String str2) {
|
||||
this.a = str;
|
||||
this.b = str2;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "name:" + this.b + " mac:" + this.a;
|
||||
}
|
||||
}
|
276
sources/com/ubtrobot/jimu/robotapi/BoardInfo.java
Normal file
276
sources/com/ubtrobot/jimu/robotapi/BoardInfo.java
Normal file
@@ -0,0 +1,276 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.afunx.ble.blelitelib.utils.HexUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BoardInfo {
|
||||
private String a;
|
||||
private float c;
|
||||
private String f;
|
||||
private byte[] i;
|
||||
private int b = 0;
|
||||
private List<Integer> d = new ArrayList();
|
||||
private List<Integer> e = new ArrayList();
|
||||
private List<Integer> g = new ArrayList();
|
||||
private HashMap<Integer, SensorBoardInfo> h = new HashMap<>();
|
||||
|
||||
public class SensorBoardInfo {
|
||||
private List<Integer> a;
|
||||
private List<Integer> b;
|
||||
private String c;
|
||||
private List<Integer> d;
|
||||
|
||||
public SensorBoardInfo(BoardInfo boardInfo) {
|
||||
}
|
||||
|
||||
public List<Integer> d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public List<Integer> b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public List<Integer> a() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(int i, int i2) {
|
||||
return ((i >> i2) & 1) > 0;
|
||||
}
|
||||
|
||||
public List<Integer> a() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public float b() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public int e() {
|
||||
return (this.a.startsWith("Jimu_p") || this.a.startsWith("JIMU") || !this.a.startsWith("Jimu_b")) ? 112 : 113;
|
||||
}
|
||||
|
||||
public byte[] f() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> g() {
|
||||
List<Integer> b;
|
||||
HashMap<Integer, SensorBoardInfo> hashMap = this.h;
|
||||
if (hashMap == null || hashMap.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
HashMap hashMap2 = new HashMap(this.h.size());
|
||||
Iterator<Integer> it = this.h.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
SensorBoardInfo sensorBoardInfo = this.h.get(Integer.valueOf(intValue));
|
||||
if (sensorBoardInfo != null && (b = sensorBoardInfo.b()) != null && b.size() > 0) {
|
||||
hashMap2.put(Integer.valueOf(intValue), Integer.valueOf(b.size()));
|
||||
}
|
||||
}
|
||||
return hashMap2;
|
||||
}
|
||||
|
||||
public HashMap<Integer, SensorBoardInfo> h() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public List<Integer> i() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public String j() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public List<Integer> k() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public boolean l() {
|
||||
if (a().size() != 0) {
|
||||
return true;
|
||||
}
|
||||
Iterator<Map.Entry<Integer, SensorBoardInfo>> it = h().entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().getValue().a().size() != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<Integer> b(byte[] bArr) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int i = (bArr[3] & 255) | ((bArr[0] & 255) << 24) | ((bArr[1] & 255) << 16) | ((bArr[2] & 255) << 8);
|
||||
for (int i2 = 0; i2 < 32; i2++) {
|
||||
if (a(i, i2)) {
|
||||
arrayList.add(Integer.valueOf(i2 + 1));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public int a(byte[] bArr) {
|
||||
int i;
|
||||
this.i = bArr;
|
||||
int length = bArr.length;
|
||||
if (length == 1) {
|
||||
int i2 = bArr[0] & 255;
|
||||
if (i2 == 1) {
|
||||
XLog.d("BoardInfo", "Read board info fail!", new Object[0]);
|
||||
} else if (i2 == 238) {
|
||||
XLog.d("BoardInfo", "Read board info fail for board is initing", new Object[0]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (length < 10) {
|
||||
XLog.b("BoardInfo", "Invalid param");
|
||||
return -1;
|
||||
}
|
||||
byte[] bArr2 = new byte[10];
|
||||
System.arraycopy(bArr, 0, bArr2, 0, bArr2.length);
|
||||
try {
|
||||
this.a = new String(bArr2, "UTF-8");
|
||||
} catch (UnsupportedEncodingException unused) {
|
||||
XLog.b("BoardInfo", "Unsupported encoding board version name");
|
||||
}
|
||||
int i3 = length - 10;
|
||||
if (i3 < 1) {
|
||||
XLog.b("BoardInfo", "Board info(0x08 cmd response) not any battery info");
|
||||
return 0;
|
||||
}
|
||||
if (a(bArr[10], 7)) {
|
||||
this.b = 1;
|
||||
} else {
|
||||
this.b = 0;
|
||||
}
|
||||
this.c = (r6 & Byte.MAX_VALUE) / 10.0f;
|
||||
int i4 = i3 - 1;
|
||||
if (i4 < 16) {
|
||||
XLog.b("BoardInfo", "Board info(0x08 cmd response) not any servo info");
|
||||
return 0;
|
||||
}
|
||||
byte[] bArr3 = new byte[4];
|
||||
System.arraycopy(bArr, 11, bArr3, 0, bArr3.length);
|
||||
int length2 = 11 + bArr3.length;
|
||||
this.d = b(bArr3);
|
||||
System.arraycopy(bArr, length2, bArr3, 0, bArr3.length);
|
||||
int length3 = length2 + bArr3.length;
|
||||
this.e = b(bArr3);
|
||||
this.f = HexUtils.bytes2HexString(bArr, length3, 4);
|
||||
int i5 = length3 + 4;
|
||||
System.arraycopy(bArr, i5, bArr3, 0, bArr3.length);
|
||||
int length4 = i5 + bArr3.length;
|
||||
this.g = b(bArr3);
|
||||
int i6 = i4 - 16;
|
||||
if (i6 < 1) {
|
||||
XLog.b("BoardInfo", "Board info(0x08 cmd response) not any Flash size info");
|
||||
return 0;
|
||||
}
|
||||
int i7 = length4 + 1;
|
||||
byte b = bArr[length4];
|
||||
int i8 = (i6 - 1) / 7;
|
||||
for (int i9 = 1; i9 <= i8; i9++) {
|
||||
int a = a(i9);
|
||||
SensorBoardInfo sensorBoardInfo = new SensorBoardInfo(this);
|
||||
sensorBoardInfo.c = "";
|
||||
int i10 = i7 + 1;
|
||||
sensorBoardInfo.a = a(bArr[i7]);
|
||||
int i11 = i10 + 1;
|
||||
sensorBoardInfo.b = a(bArr[i10]);
|
||||
if (a == 10) {
|
||||
sensorBoardInfo.c = HexUtils.bytes2HexString(bArr, i11, 4);
|
||||
i = i11 + 4;
|
||||
} else {
|
||||
int i12 = i11;
|
||||
int i13 = 0;
|
||||
while (i13 < 4) {
|
||||
int i14 = i12 + 1;
|
||||
String valueOf = String.valueOf((int) bArr[i12]);
|
||||
if (valueOf.length() == 1) {
|
||||
valueOf = "0" + valueOf;
|
||||
}
|
||||
sensorBoardInfo.c += valueOf;
|
||||
i13++;
|
||||
i12 = i14;
|
||||
}
|
||||
i = i12;
|
||||
}
|
||||
sensorBoardInfo.d = a(bArr[i]);
|
||||
i7 = i + 1;
|
||||
this.h.put(Integer.valueOf(a), sensorBoardInfo);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private List<Integer> a(byte b) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (a(b, i)) {
|
||||
arrayList.add(Integer.valueOf(i + 1));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private int a(int i) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 3;
|
||||
case 3:
|
||||
return 2;
|
||||
case 4:
|
||||
return 4;
|
||||
case 5:
|
||||
return 5;
|
||||
case 6:
|
||||
return 6;
|
||||
case 7:
|
||||
return 7;
|
||||
case 8:
|
||||
return 8;
|
||||
case 9:
|
||||
return 12;
|
||||
case 10:
|
||||
return 97;
|
||||
case 11:
|
||||
return 96;
|
||||
case 12:
|
||||
return 11;
|
||||
case 13:
|
||||
return 9;
|
||||
case 14:
|
||||
return 10;
|
||||
case 15:
|
||||
return 14;
|
||||
default:
|
||||
XLog.b("BoardInfo", "INVALID SENSOR INDEX");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
160
sources/com/ubtrobot/jimu/robotapi/DeviceManager.java
Normal file
160
sources/com/ubtrobot/jimu/robotapi/DeviceManager.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.util.Log;
|
||||
import com.afunx.ble.blelitelib.utils.HexUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.bluetooth.base.IPacket;
|
||||
import com.ubtrobot.jimu.bluetooth.base.ProtocolPacket;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DeviceManager {
|
||||
private RobotConnection a;
|
||||
|
||||
public DeviceManager(RobotConnection robotConnection) {
|
||||
this.a = robotConnection;
|
||||
}
|
||||
|
||||
public void a(boolean z) throws JimuException {
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(5, z ? new byte[]{0} : new byte[]{1})).g();
|
||||
if (g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
throw new JimuException(-21, "read robot battery info fail! ErrCode:" + ((int) g[0]));
|
||||
} catch (RequestException e) {
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String b() throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(44, new byte[]{0});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g[0] != 0) {
|
||||
XLog.b("DeviceManager", "read McuId fail!");
|
||||
throw new JimuException(-21, "read McuId fail!");
|
||||
}
|
||||
byte[] bArr = new byte[g.length - 1];
|
||||
System.arraycopy(g, 1, bArr, 0, bArr.length);
|
||||
String bytes2HexString = HexUtils.bytes2HexString(bArr);
|
||||
Log.d("DeviceManager", "McuId:" + bytes2HexString);
|
||||
return bytes2HexString;
|
||||
} catch (RequestException e) {
|
||||
Log.e("DeviceManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String c() throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(54, new byte[]{0});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length <= 1) {
|
||||
return "";
|
||||
}
|
||||
if (g.length == 1 && g[0] != 0) {
|
||||
XLog.b("DeviceManager", "read device type(cmd:0x36) fail! errResult:" + ((int) g[0]));
|
||||
throw new JimuException(-21, "read device type(cmd:0x36) fail! errResult:" + ((int) g[0]));
|
||||
}
|
||||
byte[] bArr = new byte[g.length - 1];
|
||||
System.arraycopy(g, 1, bArr, 0, bArr.length);
|
||||
try {
|
||||
String str = new String(bArr, "UTF-8");
|
||||
XLog.a("DeviceManager", "productName:" + str);
|
||||
return str;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return String.valueOf(bArr);
|
||||
}
|
||||
} catch (RequestException e2) {
|
||||
Log.e("DeviceManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e2);
|
||||
throw new JimuException(e2.getCode(), e2.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BatteryInfo d() throws JimuException {
|
||||
boolean z = true;
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(39, new byte[]{0});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length != 1) {
|
||||
boolean z2 = g[0] != 0;
|
||||
if (g[1] != 1) {
|
||||
z = false;
|
||||
}
|
||||
return new BatteryInfo(g[2], g[3], z2, z);
|
||||
}
|
||||
throw new JimuException(-21, "read robot battery info fail! ErrCode:" + ((int) g[0]));
|
||||
} catch (RequestException e) {
|
||||
Log.e("DeviceManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BoardInfo e() throws JimuException {
|
||||
String str;
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(8, new byte[]{0})).g();
|
||||
if (g.length != 1) {
|
||||
BoardInfo boardInfo = new BoardInfo();
|
||||
boardInfo.a(g);
|
||||
return boardInfo;
|
||||
}
|
||||
int i = g[0] & 255;
|
||||
if (i == 1) {
|
||||
str = "Read board info fail!";
|
||||
XLog.d("DeviceManager", "Read board info fail!", new Object[0]);
|
||||
} else if (i != 238) {
|
||||
str = "Read board info fail for invalid error code!";
|
||||
XLog.d("DeviceManager", "Read board info fail for invalid error code!", new Object[0]);
|
||||
} else {
|
||||
str = "Read board info fail for board is initing!";
|
||||
XLog.d("DeviceManager", "Read board info fail for board is initing!", new Object[0]);
|
||||
}
|
||||
throw new JimuException(g[0] & 255, str);
|
||||
} catch (RequestException e) {
|
||||
Log.e("DeviceManager", "Read board info fail", e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String f() throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(43, new byte[]{7});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g[0] != 0) {
|
||||
XLog.b("DeviceManager", "read SN fail!");
|
||||
throw new JimuException(-21, "excuse cmd fail!");
|
||||
}
|
||||
byte[] bArr = new byte[g.length - 1];
|
||||
System.arraycopy(g, 1, bArr, 0, bArr.length);
|
||||
String str = new String(bArr);
|
||||
Log.d("DeviceManager", "SN:" + str);
|
||||
return str;
|
||||
} catch (RequestException e) {
|
||||
Log.e("DeviceManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public int g() throws RequestException {
|
||||
try {
|
||||
IPacket a = this.a.a(new ProtocolPacket(1, new byte[]{0}));
|
||||
if (a.g().length == 1) {
|
||||
return a.g()[0] == 0 ? 0 : -1;
|
||||
}
|
||||
return -1;
|
||||
} catch (RequestException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a() throws JimuException {
|
||||
String c = c();
|
||||
Log.d("DeviceManager", "Product type:" + c);
|
||||
return "".equals(c) || c.startsWith("JIMU") || c.startsWith("Jimu") || c.startsWith("S1JIMU");
|
||||
}
|
||||
}
|
129
sources/com/ubtrobot/jimu/robotapi/GlobalExceptionUtil.java
Normal file
129
sources/com/ubtrobot/jimu/robotapi/GlobalExceptionUtil.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.bluetooth.base.IPacket;
|
||||
import com.ubtrobot.jimu.exception.BatteryException;
|
||||
import com.ubtrobot.jimu.exception.EngineProtectException;
|
||||
import com.ubtrobot.jimu.exception.EngineVersionException;
|
||||
import com.ubtrobot.jimu.exception.RobotActiveException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class GlobalExceptionUtil {
|
||||
|
||||
public interface ExceptionCallback {
|
||||
void a(String str, RobotActiveException robotActiveException, List<Integer> list);
|
||||
}
|
||||
|
||||
private boolean a(int i, int i2) {
|
||||
return ((i >> i2) & 1) > 0;
|
||||
}
|
||||
|
||||
public RobotActiveException a(IPacket iPacket, String str) {
|
||||
byte[] g = iPacket.g();
|
||||
int i = g[0] & 255;
|
||||
XLog.a("woo", "errorCode: %d", Integer.valueOf(i));
|
||||
if (i == 0) {
|
||||
return null;
|
||||
}
|
||||
if (i == 1) {
|
||||
return new BatteryException(i, g[1] & 255, "Battery Error");
|
||||
}
|
||||
if (i == 2) {
|
||||
Map<Integer, List<Integer>> a = a(g);
|
||||
if (a == null || a.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return new EngineProtectException(i, "Servo is protected", PeripheralType.SERVO, a);
|
||||
}
|
||||
if (i == 3) {
|
||||
return new EngineVersionException(i, "The Servo version is inconformity", PeripheralType.SERVO, g[1] & 255);
|
||||
}
|
||||
if (i != 4) {
|
||||
return i != 5 ? new RobotActiveException(i, "Unknown Exception") : new EngineVersionException(i, "The Motor version is inconformity", 10, g[1] & 255);
|
||||
}
|
||||
Map<Integer, List<Integer>> a2 = a(g);
|
||||
if (a2 == null || a2.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return new EngineProtectException(i, "Motor is protected", 10, a2);
|
||||
}
|
||||
|
||||
private Map<Integer, List<Integer>> a(byte[] bArr) {
|
||||
HashMap hashMap = new HashMap();
|
||||
List<Integer> a = a(a(bArr, 1));
|
||||
if (a != null && a.size() > 0) {
|
||||
hashMap.put(1, a);
|
||||
}
|
||||
List<Integer> a2 = a(a(bArr, 5));
|
||||
if (a2 != null && a2.size() > 0) {
|
||||
hashMap.put(2, a2);
|
||||
}
|
||||
List<Integer> a3 = a(a(bArr, 9));
|
||||
if (a3 != null && a3.size() > 0) {
|
||||
hashMap.put(4, a3);
|
||||
}
|
||||
List<Integer> a4 = a(a(bArr, 13));
|
||||
if (a4 != null && a4.size() > 0) {
|
||||
hashMap.put(8, a4);
|
||||
}
|
||||
List<Integer> a5 = a(a(bArr, 17));
|
||||
if (a5 != null && a5.size() > 0) {
|
||||
hashMap.put(16, a5);
|
||||
}
|
||||
List<Integer> a6 = a(a(bArr, 21));
|
||||
if (a6 != null && a6.size() > 0) {
|
||||
hashMap.put(32, a6);
|
||||
}
|
||||
List<Integer> a7 = a(a(bArr, 25));
|
||||
if (a7 != null && a7.size() > 0) {
|
||||
hashMap.put(64, a7);
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private List<Integer> a(int i) {
|
||||
ArrayList arrayList = null;
|
||||
for (int i2 = 0; i2 < 32; i2++) {
|
||||
if (a(i, i2)) {
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
arrayList.add(Integer.valueOf(i2 + 1));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private int a(byte[] bArr, int i) {
|
||||
return bArr[i + 3] | (bArr[i] << 24) | (bArr[i + 1] << 16) | (bArr[i + 2] << 8);
|
||||
}
|
||||
|
||||
public static void a(Context context, RobotActiveException robotActiveException, ExceptionCallback exceptionCallback) {
|
||||
int errorCode = robotActiveException.getErrorCode();
|
||||
if ((errorCode == 2 || errorCode == 4) && (robotActiveException instanceof EngineProtectException)) {
|
||||
EngineProtectException engineProtectException = (EngineProtectException) robotActiveException;
|
||||
int higherExceptionCode = engineProtectException.getHigherExceptionCode();
|
||||
List<Integer> errorMapByCode = engineProtectException.getErrorMapByCode(higherExceptionCode);
|
||||
String errorMessage = engineProtectException.getErrorMessage(context, higherExceptionCode, errorMapByCode);
|
||||
if (TextUtils.isEmpty(errorMessage) || exceptionCallback == null) {
|
||||
return;
|
||||
}
|
||||
exceptionCallback.a(errorMessage, engineProtectException, errorMapByCode);
|
||||
return;
|
||||
}
|
||||
if (errorCode == 1 && (robotActiveException instanceof BatteryException)) {
|
||||
BatteryException batteryException = (BatteryException) robotActiveException;
|
||||
String errorMessage2 = batteryException.getErrorMessage(context);
|
||||
if (TextUtils.isEmpty(errorMessage2) || exceptionCallback == null) {
|
||||
return;
|
||||
}
|
||||
exceptionCallback.a(errorMessage2, batteryException, null);
|
||||
}
|
||||
}
|
||||
}
|
183
sources/com/ubtrobot/jimu/robotapi/GlobalManager.java
Normal file
183
sources/com/ubtrobot/jimu/robotapi/GlobalManager.java
Normal file
@@ -0,0 +1,183 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionStateListener;
|
||||
import com.ubtrobot.jimu.bluetooth.base.IPacket;
|
||||
import com.ubtrobot.jimu.connection.PacketsReceiveListener;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import com.ubtrobot.jimu.exception.RobotActiveException;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.Vector;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class GlobalManager implements PacketsReceiveListener, ConnectionStateListener {
|
||||
private Timer a;
|
||||
private RobotConnection b;
|
||||
private DeviceManager c;
|
||||
private Vector<IPowerStateListener> d;
|
||||
private Vector<IGlobalExceptionListener> e;
|
||||
private BatteryInfo f;
|
||||
private volatile boolean g;
|
||||
|
||||
public GlobalManager(RobotConnection robotConnection, DeviceManager deviceManager) {
|
||||
this.b = robotConnection;
|
||||
this.c = deviceManager;
|
||||
this.b.a((PacketsReceiveListener) this);
|
||||
this.b.a((ConnectionStateListener) this);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
Timer timer = this.a;
|
||||
if (timer != null) {
|
||||
try {
|
||||
timer.cancel();
|
||||
this.a = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.ConnectionStateListener
|
||||
public void onConnectionStateChange(String str, ConnectionState connectionState) {
|
||||
Vector<IPowerStateListener> vector;
|
||||
Object[] array;
|
||||
if (connectionState == null || (vector = this.d) == null || vector.size() == 0) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
array = this.d.toArray();
|
||||
}
|
||||
for (int length = array.length - 1; length >= 0; length--) {
|
||||
((IPowerStateListener) array[length]).onConnectionStateChange(str, connectionState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.connection.PacketsReceiveListener
|
||||
public void a(String str, IPacket iPacket) {
|
||||
if (iPacket == null) {
|
||||
return;
|
||||
}
|
||||
int f = iPacket.f() & 255;
|
||||
if (f == 5) {
|
||||
b(str, iPacket);
|
||||
} else {
|
||||
if (f != 39) {
|
||||
return;
|
||||
}
|
||||
a(iPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void b() {
|
||||
Timer timer = this.a;
|
||||
if (timer != null) {
|
||||
try {
|
||||
timer.cancel();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.a = new Timer();
|
||||
this.a.schedule(new TimerTask() { // from class: com.ubtrobot.jimu.robotapi.GlobalManager.1
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
if (GlobalManager.this.g) {
|
||||
return;
|
||||
}
|
||||
GlobalManager.this.c.d();
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 5000L, 30000L);
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.g = z;
|
||||
}
|
||||
|
||||
public synchronized BatteryInfo a(IPowerStateListener iPowerStateListener) {
|
||||
if (this.d == null) {
|
||||
this.d = new Vector<>();
|
||||
}
|
||||
if (!this.d.contains(iPowerStateListener)) {
|
||||
this.d.add(iPowerStateListener);
|
||||
}
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public void b(IPowerStateListener iPowerStateListener) {
|
||||
Vector<IPowerStateListener> vector = this.d;
|
||||
if (vector != null) {
|
||||
vector.removeElement(iPowerStateListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(IGlobalExceptionListener iGlobalExceptionListener) {
|
||||
Vector<IGlobalExceptionListener> vector = this.e;
|
||||
if (vector != null) {
|
||||
vector.removeElement(iGlobalExceptionListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(String str, IPacket iPacket) {
|
||||
Vector<IGlobalExceptionListener> vector;
|
||||
RobotActiveException a;
|
||||
Object[] array;
|
||||
if (iPacket == null || (vector = this.e) == null || vector.size() == 0 || (a = new GlobalExceptionUtil().a(iPacket, str)) == null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
array = this.e.toArray();
|
||||
}
|
||||
if (array == null || array.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (int length = array.length - 1; length >= 0; length--) {
|
||||
((IGlobalExceptionListener) array[length]).onGlobalException(a);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void a(IGlobalExceptionListener iGlobalExceptionListener) {
|
||||
if (this.e == null) {
|
||||
this.e = new Vector<>();
|
||||
}
|
||||
if (!this.e.contains(iGlobalExceptionListener)) {
|
||||
this.e.add(iGlobalExceptionListener);
|
||||
}
|
||||
}
|
||||
|
||||
public BatteryInfo a() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
private void a(IPacket iPacket) {
|
||||
Object[] array;
|
||||
if (iPacket == null) {
|
||||
return;
|
||||
}
|
||||
byte[] g = iPacket.g();
|
||||
if (g.length == 1) {
|
||||
return;
|
||||
}
|
||||
BatteryInfo batteryInfo = new BatteryInfo(g[2], g[3], g[0] != 0, g[1] == 1);
|
||||
BatteryInfo batteryInfo2 = this.f;
|
||||
if (batteryInfo2 != null && batteryInfo2.c() == batteryInfo.c() && this.f.d() == batteryInfo.d() && this.f.a() == batteryInfo.a() && this.f.b() == batteryInfo.b()) {
|
||||
return;
|
||||
}
|
||||
this.f = batteryInfo;
|
||||
Vector<IPowerStateListener> vector = this.d;
|
||||
if (vector == null || vector.size() == 0) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
array = this.d.toArray();
|
||||
}
|
||||
for (int length = array.length - 1; length >= 0; length--) {
|
||||
((IPowerStateListener) array[length]).onPowerStateChanged(batteryInfo);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.ubtrobot.jimu.exception.RobotActiveException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IGlobalExceptionListener {
|
||||
void onGlobalException(RobotActiveException robotActiveException);
|
||||
}
|
10
sources/com/ubtrobot/jimu/robotapi/IPowerStateListener.java
Normal file
10
sources/com/ubtrobot/jimu/robotapi/IPowerStateListener.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IPowerStateListener {
|
||||
void onConnectionStateChange(String str, ConnectionState connectionState);
|
||||
|
||||
void onPowerStateChanged(BatteryInfo batteryInfo);
|
||||
}
|
19
sources/com/ubtrobot/jimu/robotapi/JimuException.java
Normal file
19
sources/com/ubtrobot/jimu/robotapi/JimuException.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class JimuException extends RequestException {
|
||||
public static final int ERR_CODE_ARGUMENT_INVALID = -20;
|
||||
public static final int ERR_CODE_RESULT_FAIL = -21;
|
||||
public static final int ERR_CODE_RES_INVALID = -22;
|
||||
public static final String ERR_MSG_ARGUMENT_INVALID = "Argument is illegal!";
|
||||
|
||||
public JimuException(int i, String str) {
|
||||
this(i, str, null);
|
||||
}
|
||||
|
||||
public JimuException(int i, String str, Throwable th) {
|
||||
super(i, str, th);
|
||||
}
|
||||
}
|
191
sources/com/ubtrobot/jimu/robotapi/JimuManager.java
Normal file
191
sources/com/ubtrobot/jimu/robotapi/JimuManager.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectCallback;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionStateListener;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import com.ubtrobot.jimu.robotapi.UpdateManager;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class JimuManager {
|
||||
private ServoManager a;
|
||||
private MotorManager b;
|
||||
private DeviceManager c;
|
||||
private SensorManager d;
|
||||
private UpdateManager e;
|
||||
private GlobalManager f;
|
||||
private RobotConnection g;
|
||||
private String h;
|
||||
|
||||
public JimuManager(Context context) {
|
||||
this.g = new RobotConnection(context);
|
||||
this.a = new ServoManager(this.g);
|
||||
this.b = new MotorManager(this.g);
|
||||
new LedManager(this.g);
|
||||
this.c = new DeviceManager(this.g);
|
||||
this.d = new SensorManager(this.g);
|
||||
this.e = new UpdateManager(context, this.g);
|
||||
this.f = new GlobalManager(this.g, this.c);
|
||||
}
|
||||
|
||||
public void a(String str, ConnectCallback connectCallback) {
|
||||
this.g.a(str, connectCallback);
|
||||
}
|
||||
|
||||
public void b(ConnectionStateListener connectionStateListener) {
|
||||
this.g.b(connectionStateListener);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.g.a();
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return this.g.b();
|
||||
}
|
||||
|
||||
public String e() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public BatteryInfo f() {
|
||||
return this.f.a();
|
||||
}
|
||||
|
||||
public boolean g() {
|
||||
String d = d();
|
||||
return d != null && a(d) == ConnectionState.STATE_CONNECTED;
|
||||
}
|
||||
|
||||
public boolean h() throws JimuException {
|
||||
return this.c.a();
|
||||
}
|
||||
|
||||
public void i() throws JimuException {
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
public String j() throws JimuException {
|
||||
return this.c.b();
|
||||
}
|
||||
|
||||
public BatteryInfo k() throws JimuException {
|
||||
return this.c.d();
|
||||
}
|
||||
|
||||
public BoardInfo l() throws JimuException {
|
||||
return this.c.e();
|
||||
}
|
||||
|
||||
public String m() throws JimuException {
|
||||
return this.c.f();
|
||||
}
|
||||
|
||||
public int n() throws RequestException {
|
||||
return this.c.g();
|
||||
}
|
||||
|
||||
public void o() {
|
||||
this.f.b();
|
||||
}
|
||||
|
||||
public void p() {
|
||||
this.f.c();
|
||||
}
|
||||
|
||||
public void q() throws JimuException {
|
||||
this.b.a();
|
||||
}
|
||||
|
||||
public void r() throws JimuException {
|
||||
this.a.a();
|
||||
}
|
||||
|
||||
public ConnectionState a(String str) {
|
||||
return this.g.a(str);
|
||||
}
|
||||
|
||||
public ConnectionState b(String str) {
|
||||
return (!g() || str == null) ? ConnectionState.STATE_DISCONNECTED : !str.equals(e()) ? ConnectionState.STATE_DISCONNECTED : ConnectionState.STATE_CONNECTED;
|
||||
}
|
||||
|
||||
public void c(String str) {
|
||||
this.h = str;
|
||||
}
|
||||
|
||||
public void a(ConnectionStateListener connectionStateListener) {
|
||||
this.g.a(connectionStateListener);
|
||||
}
|
||||
|
||||
public boolean a(BoardInfo boardInfo, List<Firmware> list, UpdateManager.UpdateProgressListener updateProgressListener) {
|
||||
return this.e.a(boardInfo, list, updateProgressListener);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.e.a();
|
||||
}
|
||||
|
||||
public void a(boolean z) throws JimuException {
|
||||
this.c.a(z);
|
||||
}
|
||||
|
||||
public BatteryInfo a(IPowerStateListener iPowerStateListener) {
|
||||
return this.f.a(iPowerStateListener);
|
||||
}
|
||||
|
||||
public void a(IGlobalExceptionListener iGlobalExceptionListener) {
|
||||
this.f.a(iGlobalExceptionListener);
|
||||
}
|
||||
|
||||
public int b() throws JimuException {
|
||||
return this.e.b();
|
||||
}
|
||||
|
||||
public void a(int[] iArr, float[] fArr, int i, int i2) throws MotorException {
|
||||
this.a.a(iArr, fArr, i, i2);
|
||||
}
|
||||
|
||||
public void b(IPowerStateListener iPowerStateListener) {
|
||||
this.f.b(iPowerStateListener);
|
||||
}
|
||||
|
||||
public void a(int[] iArr, int i) throws MotorException {
|
||||
this.a.a(iArr, i);
|
||||
}
|
||||
|
||||
public void b(IGlobalExceptionListener iGlobalExceptionListener) {
|
||||
this.f.b(iGlobalExceptionListener);
|
||||
}
|
||||
|
||||
public List<ServoAngleReadInfo> a(int i, boolean z) throws JimuException {
|
||||
return this.a.a(i, z);
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
this.f.a(z);
|
||||
}
|
||||
|
||||
public void a(int[] iArr, int[] iArr2, int[] iArr3) throws MotorException {
|
||||
this.b.a(iArr, iArr2, iArr3);
|
||||
}
|
||||
|
||||
public ServoAngleReadInfo b(int i, boolean z) throws JimuException {
|
||||
return this.a.b(i, z);
|
||||
}
|
||||
|
||||
public int a(int i, int i2) throws JimuException {
|
||||
return this.b.a(i, i2);
|
||||
}
|
||||
|
||||
public int a(int i, List<Integer> list, boolean z) throws JimuException {
|
||||
return this.d.a(i, list, z);
|
||||
}
|
||||
|
||||
public BluetoothSpeakerInfo a(int i) throws JimuException {
|
||||
return this.d.a(i);
|
||||
}
|
||||
}
|
17
sources/com/ubtrobot/jimu/robotapi/JimuScanner.java
Normal file
17
sources/com/ubtrobot/jimu/robotapi/JimuScanner.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ubtrobot.jimu.bluetooth.Cancellable;
|
||||
import com.ubtrobot.jimu.bluetooth.JimuBluetoothManager;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class JimuScanner {
|
||||
public JimuScanner(Context context) {
|
||||
JimuBluetoothManager.d().supportsBluetooth(context);
|
||||
}
|
||||
|
||||
public Cancellable a(ScannedHubEmitter scannedHubEmitter, int i) {
|
||||
return JimuBluetoothManager.d().a(scannedHubEmitter, i);
|
||||
}
|
||||
}
|
9
sources/com/ubtrobot/jimu/robotapi/LedManager.java
Normal file
9
sources/com/ubtrobot/jimu/robotapi/LedManager.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class LedManager {
|
||||
public LedManager(RobotConnection robotConnection) {
|
||||
}
|
||||
}
|
34
sources/com/ubtrobot/jimu/robotapi/MotorException.java
Normal file
34
sources/com/ubtrobot/jimu/robotapi/MotorException.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MotorException extends JimuException {
|
||||
private ArrayList<Integer> failIds;
|
||||
private int subErrorId;
|
||||
|
||||
public MotorException(int i, String str) {
|
||||
super(i, str);
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getFailIds() {
|
||||
return this.failIds;
|
||||
}
|
||||
|
||||
public int getSubErrorId() {
|
||||
return this.subErrorId;
|
||||
}
|
||||
|
||||
public void setFailIds(ArrayList<Integer> arrayList) {
|
||||
this.failIds = arrayList;
|
||||
}
|
||||
|
||||
public void setSubErrorId(int i) {
|
||||
this.subErrorId = i;
|
||||
}
|
||||
|
||||
public MotorException(int i, String str, ArrayList<Integer> arrayList) {
|
||||
super(i, str);
|
||||
this.failIds = arrayList;
|
||||
}
|
||||
}
|
151
sources/com/ubtrobot/jimu/robotapi/MotorManager.java
Normal file
151
sources/com/ubtrobot/jimu/robotapi/MotorManager.java
Normal file
@@ -0,0 +1,151 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.util.Log;
|
||||
import com.ubtrobot.jimu.bluetooth.base.ProtocolPacket;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MotorManager {
|
||||
protected RobotConnection a;
|
||||
|
||||
public MotorManager(RobotConnection robotConnection) {
|
||||
this.a = robotConnection;
|
||||
}
|
||||
|
||||
private static byte[] b(int[] iArr, int[] iArr2, int[] iArr3) {
|
||||
if (iArr.length != iArr2.length || iArr2.length != iArr3.length) {
|
||||
Log.e("MotorManager", "Invalid arguments!");
|
||||
return null;
|
||||
}
|
||||
int length = iArr.length;
|
||||
byte[] a = a(iArr);
|
||||
byte[] bArr = new byte[a.length + (length * 4)];
|
||||
System.arraycopy(a, 0, bArr, 0, a.length);
|
||||
int length2 = a.length + 0;
|
||||
for (int i = 1; i <= length; i++) {
|
||||
int i2 = length - i;
|
||||
int i3 = iArr2[i2];
|
||||
int i4 = length2 + 1;
|
||||
bArr[length2] = (byte) ((i3 >> 8) & 255);
|
||||
int i5 = i4 + 1;
|
||||
bArr[i4] = (byte) (i3 & 255);
|
||||
int i6 = iArr3[i2];
|
||||
int i7 = i5 + 1;
|
||||
bArr[i5] = (byte) ((i6 >> 8) & 255);
|
||||
length2 = i7 + 1;
|
||||
bArr[i7] = (byte) (i6 & 255);
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
|
||||
public void a(int[] iArr, int[] iArr2, int[] iArr3) throws MotorException {
|
||||
int[] iArr4 = new int[iArr3.length];
|
||||
for (int i = 0; i < iArr3.length; i++) {
|
||||
iArr4[i] = iArr3[i] / 100;
|
||||
}
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(144, b(iArr, iArr2, iArr4))).g();
|
||||
if (g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
throw new MotorException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]), a(Arrays.copyOfRange(g, 1, g.length)));
|
||||
} catch (RequestException e) {
|
||||
throw new MotorException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public int a(int i, int i2) throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(116, new byte[]{10, (byte) i, (byte) i2});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length == 3) {
|
||||
return g[2] & 255;
|
||||
}
|
||||
throw new JimuException(-22, "res argument is err!");
|
||||
} catch (RequestException e) {
|
||||
Log.e("MotorManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void a() throws JimuException {
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(146, new byte[0])).g();
|
||||
if (g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
throw new JimuException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]));
|
||||
} catch (RequestException e) {
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] a(int[] iArr) {
|
||||
int i;
|
||||
byte[] bArr = new byte[8];
|
||||
int i2 = 0;
|
||||
byte b = 0;
|
||||
while (true) {
|
||||
i = 1;
|
||||
if (i2 >= iArr.length) {
|
||||
break;
|
||||
}
|
||||
if (iArr[i2] > 64 || iArr[i2] < 1) {
|
||||
Log.e("MotorManager", "Unsupport id! The support motor id range is 1~64");
|
||||
}
|
||||
int i3 = (iArr[i2] - 1) / 8;
|
||||
b = (byte) (b | (1 << i3));
|
||||
bArr[i3] = (byte) (((byte) (1 << ((iArr[i2] - 1) % 8))) | bArr[i3]);
|
||||
i2++;
|
||||
}
|
||||
int i4 = 0;
|
||||
for (byte b2 : bArr) {
|
||||
if (b2 != 0) {
|
||||
i4++;
|
||||
}
|
||||
}
|
||||
byte[] bArr2 = new byte[i4 + 1];
|
||||
bArr2[0] = b;
|
||||
for (int length = bArr.length - 1; length >= 0; length--) {
|
||||
if (bArr[length] != 0) {
|
||||
bArr2[i] = bArr[length];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return bArr2;
|
||||
}
|
||||
|
||||
private static ArrayList<Integer> a(byte[] bArr) {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
int i = 0;
|
||||
byte b = bArr[0];
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
for (int i2 = 7; i2 >= 0; i2--) {
|
||||
if (((1 << i2) & b & 255) != 0) {
|
||||
arrayList2.add(Integer.valueOf(i2));
|
||||
}
|
||||
}
|
||||
if (arrayList2.size() != bArr.length - 1) {
|
||||
return arrayList;
|
||||
}
|
||||
while (i < arrayList2.size()) {
|
||||
int intValue = ((Integer) arrayList2.get(i)).intValue();
|
||||
i++;
|
||||
arrayList.addAll(a(bArr[i], intValue * 8));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static ArrayList<Integer> a(byte b, int i) {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
for (int i2 = 0; i2 < 8; i2++) {
|
||||
if ((b & 255 & (1 << i2)) != 0) {
|
||||
arrayList.add(Integer.valueOf(i2 + 1 + i));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
25
sources/com/ubtrobot/jimu/robotapi/PeripheralType.java
Normal file
25
sources/com/ubtrobot/jimu/robotapi/PeripheralType.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PeripheralType {
|
||||
public static final int ATMOSPHERIC_PRESSURE = 97;
|
||||
public static final int COLOR = 9;
|
||||
public static final int COMPASS = 96;
|
||||
public static final int DIGITALTUBE = 7;
|
||||
public static final int EN_LIGHT_SENSOR = 12;
|
||||
public static final int FIREBOT_HEAD_LED = 101;
|
||||
public static final int GRAVITY = 5;
|
||||
public static final int GYRO = 3;
|
||||
public static final int INFRARED = 1;
|
||||
public static final int INVALID_PERIPHERAL_TYPE = -1;
|
||||
public static final int LED = 4;
|
||||
public static final int MOTOR = 10;
|
||||
public static final int New_MAIN_BOARD = 113;
|
||||
public static final int OLD_MAIN_BOARD = 112;
|
||||
public static final int RGB_LED = 14;
|
||||
public static final int SERVO = 128;
|
||||
public static final int SPEAKER = 8;
|
||||
public static final int TEMP = 11;
|
||||
public static final int TOUCH = 2;
|
||||
public static final int ULTRASOUND = 6;
|
||||
}
|
130
sources/com/ubtrobot/jimu/robotapi/R$string.java
Normal file
130
sources/com/ubtrobot/jimu/robotapi/R$string.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R$string {
|
||||
public static final int abc_action_bar_home_description = 2131820553;
|
||||
public static final int abc_action_bar_up_description = 2131820554;
|
||||
public static final int abc_action_menu_overflow_description = 2131820555;
|
||||
public static final int abc_action_mode_done = 2131820556;
|
||||
public static final int abc_activity_chooser_view_see_all = 2131820557;
|
||||
public static final int abc_activitychooserview_choose_application = 2131820558;
|
||||
public static final int abc_capital_off = 2131820559;
|
||||
public static final int abc_capital_on = 2131820560;
|
||||
public static final int abc_font_family_body_1_material = 2131820561;
|
||||
public static final int abc_font_family_body_2_material = 2131820562;
|
||||
public static final int abc_font_family_button_material = 2131820563;
|
||||
public static final int abc_font_family_caption_material = 2131820564;
|
||||
public static final int abc_font_family_display_1_material = 2131820565;
|
||||
public static final int abc_font_family_display_2_material = 2131820566;
|
||||
public static final int abc_font_family_display_3_material = 2131820567;
|
||||
public static final int abc_font_family_display_4_material = 2131820568;
|
||||
public static final int abc_font_family_headline_material = 2131820569;
|
||||
public static final int abc_font_family_menu_material = 2131820570;
|
||||
public static final int abc_font_family_subhead_material = 2131820571;
|
||||
public static final int abc_font_family_title_material = 2131820572;
|
||||
public static final int abc_menu_alt_shortcut_label = 2131820573;
|
||||
public static final int abc_menu_ctrl_shortcut_label = 2131820574;
|
||||
public static final int abc_menu_delete_shortcut_label = 2131820575;
|
||||
public static final int abc_menu_enter_shortcut_label = 2131820576;
|
||||
public static final int abc_menu_function_shortcut_label = 2131820577;
|
||||
public static final int abc_menu_meta_shortcut_label = 2131820578;
|
||||
public static final int abc_menu_shift_shortcut_label = 2131820579;
|
||||
public static final int abc_menu_space_shortcut_label = 2131820580;
|
||||
public static final int abc_menu_sym_shortcut_label = 2131820581;
|
||||
public static final int abc_prepend_shortcut_label = 2131820582;
|
||||
public static final int abc_search_hint = 2131820583;
|
||||
public static final int abc_searchview_description_clear = 2131820584;
|
||||
public static final int abc_searchview_description_query = 2131820585;
|
||||
public static final int abc_searchview_description_search = 2131820586;
|
||||
public static final int abc_searchview_description_submit = 2131820587;
|
||||
public static final int abc_searchview_description_voice = 2131820588;
|
||||
public static final int abc_shareactionprovider_share_with = 2131820589;
|
||||
public static final int abc_shareactionprovider_share_with_application = 2131820590;
|
||||
public static final int abc_toolbar_collapse_description = 2131820591;
|
||||
public static final int app_name = 2131820649;
|
||||
public static final int batter_high = 2131820668;
|
||||
public static final int batter_low = 2131820669;
|
||||
public static final int com_crashlytics_android_build_id = 2131820749;
|
||||
public static final int com_facebook_device_auth_instructions = 2131820750;
|
||||
public static final int com_facebook_image_download_unknown_error = 2131820751;
|
||||
public static final int com_facebook_internet_permission_error_message = 2131820752;
|
||||
public static final int com_facebook_internet_permission_error_title = 2131820753;
|
||||
public static final int com_facebook_like_button_liked = 2131820754;
|
||||
public static final int com_facebook_like_button_not_liked = 2131820755;
|
||||
public static final int com_facebook_loading = 2131820756;
|
||||
public static final int com_facebook_loginview_cancel_action = 2131820757;
|
||||
public static final int com_facebook_loginview_log_in_button = 2131820758;
|
||||
public static final int com_facebook_loginview_log_in_button_continue = 2131820759;
|
||||
public static final int com_facebook_loginview_log_in_button_long = 2131820762;
|
||||
public static final int com_facebook_loginview_log_out_action = 2131820763;
|
||||
public static final int com_facebook_loginview_log_out_button = 2131820766;
|
||||
public static final int com_facebook_loginview_logged_in_as = 2131820769;
|
||||
public static final int com_facebook_loginview_logged_in_using_facebook = 2131820772;
|
||||
public static final int com_facebook_send_button_text = 2131820775;
|
||||
public static final int com_facebook_share_button_text = 2131820778;
|
||||
public static final int com_facebook_smart_device_instructions = 2131820781;
|
||||
public static final int com_facebook_smart_device_instructions_or = 2131820782;
|
||||
public static final int com_facebook_smart_login_confirmation_cancel = 2131820783;
|
||||
public static final int com_facebook_smart_login_confirmation_continue_as = 2131820786;
|
||||
public static final int com_facebook_smart_login_confirmation_title = 2131820789;
|
||||
public static final int com_facebook_tooltip_default = 2131820792;
|
||||
public static final int comm_cancel = 2131820797;
|
||||
public static final int comm_ok = 2131820798;
|
||||
public static final int common_google_play_services_enable_button = 2131820814;
|
||||
public static final int common_google_play_services_enable_text = 2131820815;
|
||||
public static final int common_google_play_services_enable_title = 2131820816;
|
||||
public static final int common_google_play_services_install_button = 2131820817;
|
||||
public static final int common_google_play_services_install_text = 2131820818;
|
||||
public static final int common_google_play_services_install_title = 2131820819;
|
||||
public static final int common_google_play_services_notification_channel_name = 2131820820;
|
||||
public static final int common_google_play_services_notification_ticker = 2131820821;
|
||||
public static final int common_google_play_services_unknown_issue = 2131820822;
|
||||
public static final int common_google_play_services_unsupported_text = 2131820823;
|
||||
public static final int common_google_play_services_update_button = 2131820824;
|
||||
public static final int common_google_play_services_update_text = 2131820825;
|
||||
public static final int common_google_play_services_update_title = 2131820826;
|
||||
public static final int common_google_play_services_updating_text = 2131820827;
|
||||
public static final int common_google_play_services_wear_update_text = 2131820828;
|
||||
public static final int common_open_on_phone = 2131820829;
|
||||
public static final int common_signin_button_text = 2131820830;
|
||||
public static final int common_signin_button_text_long = 2131820831;
|
||||
public static final int engine_protect_electricity = 2131820978;
|
||||
public static final int engine_protect_encrypt = 2131820979;
|
||||
public static final int engine_protect_lock = 2131820980;
|
||||
public static final int engine_protect_motor_lock = 2131820981;
|
||||
public static final int engine_protect_motor_other = 2131820982;
|
||||
public static final int engine_protect_other = 2131820983;
|
||||
public static final int engine_protect_temp = 2131820984;
|
||||
public static final int jg_channel_name_p_default = 2131821170;
|
||||
public static final int jg_channel_name_p_high = 2131821171;
|
||||
public static final int jg_channel_name_p_low = 2131821172;
|
||||
public static final int jg_channel_name_p_min = 2131821173;
|
||||
public static final int kit_name = 2131821184;
|
||||
public static final int messenger_send_button_text = 2131821253;
|
||||
public static final int search_menu_title = 2131821508;
|
||||
public static final int status_bar_notification_info_overflow = 2131821607;
|
||||
public static final int tw__allow_btn_txt = 2131821703;
|
||||
public static final int tw__composer_hint = 2131821704;
|
||||
public static final int tw__install = 2131821705;
|
||||
public static final int tw__like_tweet = 2131821706;
|
||||
public static final int tw__liked_tweet = 2131821707;
|
||||
public static final int tw__loading_tweet = 2131821708;
|
||||
public static final int tw__login_btn_txt = 2131821709;
|
||||
public static final int tw__max_tweet_chars = 2131821710;
|
||||
public static final int tw__not_now_btn_txt = 2131821711;
|
||||
public static final int tw__pause = 2131821712;
|
||||
public static final int tw__play = 2131821713;
|
||||
public static final int tw__play_store = 2131821714;
|
||||
public static final int tw__post_tweet = 2131821715;
|
||||
public static final int tw__relative_date_format_long = 2131821716;
|
||||
public static final int tw__relative_date_format_short = 2131821717;
|
||||
public static final int tw__replay = 2131821718;
|
||||
public static final int tw__retweeted_by_format = 2131821719;
|
||||
public static final int tw__share_content_format = 2131821720;
|
||||
public static final int tw__share_email_desc = 2131821721;
|
||||
public static final int tw__share_email_title = 2131821722;
|
||||
public static final int tw__share_subject_format = 2131821723;
|
||||
public static final int tw__share_tweet = 2131821724;
|
||||
public static final int tw__tweet_content_description = 2131821725;
|
||||
public static final int tw__tweet_media = 2131821726;
|
||||
}
|
77
sources/com/ubtrobot/jimu/robotapi/SensorManager.java
Normal file
77
sources/com/ubtrobot/jimu/robotapi/SensorManager.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.util.Log;
|
||||
import com.ubtrobot.jimu.bluetooth.base.ProtocolPacket;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SensorManager {
|
||||
private RobotConnection a;
|
||||
|
||||
public SensorManager(RobotConnection robotConnection) {
|
||||
this.a = robotConnection;
|
||||
}
|
||||
|
||||
public int a(int i, List<Integer> list, boolean z) throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(113, new byte[]{(byte) (i & 255), a(list), !z ? 1 : 0});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length == 3) {
|
||||
return g[2] & 255;
|
||||
}
|
||||
throw new JimuException(-22, "res argument is err!");
|
||||
} catch (RequestException e) {
|
||||
Log.e("SensorManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public byte a(List<Integer> list) {
|
||||
Iterator<Integer> it = list.iterator();
|
||||
byte b = 0;
|
||||
while (it.hasNext()) {
|
||||
b = (byte) (b | (1 << (it.next().intValue() - 1)));
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public BluetoothSpeakerInfo a(int i) throws JimuException {
|
||||
if (i >= 1 && i <= 8) {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(114, new byte[]{8, (byte) (1 << (i - 1))});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
int i2 = 3;
|
||||
if (g.length > 3) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
int i3 = 0;
|
||||
while (i2 < g.length) {
|
||||
if (i3 < 6) {
|
||||
sb2.append(String.format("%02x:", Byte.valueOf(g[i2])));
|
||||
} else {
|
||||
sb.append((char) g[i2]);
|
||||
}
|
||||
i2++;
|
||||
i3++;
|
||||
}
|
||||
if (sb2.length() == 0) {
|
||||
Log.e("SensorManager", "Read speaker info fail! Mac is null!");
|
||||
return null;
|
||||
}
|
||||
sb2.deleteCharAt(sb2.length() - 1);
|
||||
return new BluetoothSpeakerInfo(sb2.toString(), sb.toString());
|
||||
}
|
||||
Log.e("SensorManager", "Read speaker info fail!");
|
||||
throw new JimuException(-21, "Read speaker info fail!");
|
||||
} catch (RequestException e) {
|
||||
Log.e("SensorManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
Log.e("SensorManager", "Invalid id");
|
||||
throw new JimuException(-20, JimuException.ERR_MSG_ARGUMENT_INVALID);
|
||||
}
|
||||
}
|
40
sources/com/ubtrobot/jimu/robotapi/ServoAngleReadInfo.java
Normal file
40
sources/com/ubtrobot/jimu/robotapi/ServoAngleReadInfo.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ServoAngleReadInfo {
|
||||
private int a;
|
||||
private float b;
|
||||
private boolean c;
|
||||
private float d;
|
||||
|
||||
public ServoAngleReadInfo(int i, boolean z, float f, float f2) {
|
||||
this.a = i;
|
||||
this.c = z;
|
||||
this.d = f;
|
||||
this.b = f2;
|
||||
}
|
||||
|
||||
public float a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public float c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ServoAngleReadInfo{id=" + this.a + ", actualAngle=" + this.b + ", isReciveSuccess=" + this.c + ", targetAngle=" + this.d + '}';
|
||||
}
|
||||
|
||||
public void a(float f) {
|
||||
this.b = f;
|
||||
}
|
||||
|
||||
public void b(float f) {
|
||||
this.d = f;
|
||||
}
|
||||
}
|
242
sources/com/ubtrobot/jimu/robotapi/ServoManager.java
Normal file
242
sources/com/ubtrobot/jimu/robotapi/ServoManager.java
Normal file
@@ -0,0 +1,242 @@
|
||||
package com.ubtrobot.jimu.robotapi;
|
||||
|
||||
import android.util.Log;
|
||||
import com.ubtrobot.jimu.bluetooth.base.IPacket;
|
||||
import com.ubtrobot.jimu.bluetooth.base.ProtocolPacket;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.connection.ResponseCallback;
|
||||
import com.ubtrobot.jimu.connection.RobotConnection;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ServoManager extends MotorManager {
|
||||
public ServoManager(RobotConnection robotConnection) {
|
||||
super(robotConnection);
|
||||
}
|
||||
|
||||
public void a(int[] iArr, float[] fArr, int i, int i2) throws MotorException {
|
||||
int length = fArr.length;
|
||||
byte[] bArr = new byte[length + 4 + 1 + 2];
|
||||
byte[] a = a(iArr);
|
||||
byte[] bArr2 = new byte[length];
|
||||
for (int i3 = 0; i3 < length; i3++) {
|
||||
bArr2[i3] = (byte) fArr[i3];
|
||||
}
|
||||
System.arraycopy(a, 0, bArr, 0, a.length);
|
||||
int length2 = a.length + 0;
|
||||
System.arraycopy(bArr2, 0, bArr, length2, bArr2.length);
|
||||
int length3 = length2 + bArr2.length;
|
||||
bArr[length3] = (byte) (i / 20);
|
||||
int i4 = length3 + 1;
|
||||
int i5 = i + i2;
|
||||
bArr[i4] = (byte) ((65280 & i5) >> 8);
|
||||
bArr[i4 + 1] = (byte) (i5 & 255);
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(9, bArr)).g();
|
||||
if (g.length == 1 && g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
if (g.length != 5) {
|
||||
throw new MotorException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]));
|
||||
}
|
||||
throw new MotorException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]), a(Arrays.copyOfRange(g, 1, g.length)));
|
||||
} catch (RequestException e) {
|
||||
throw new MotorException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void b() throws JimuException {
|
||||
b(0, false);
|
||||
}
|
||||
|
||||
public ServoAngleReadInfo b(int i, boolean z) throws JimuException {
|
||||
new ArrayList();
|
||||
byte[] bArr = new byte[2];
|
||||
bArr[0] = (byte) i;
|
||||
boolean z2 = true;
|
||||
if (z) {
|
||||
bArr[1] = 1;
|
||||
} else {
|
||||
bArr[1] = 0;
|
||||
}
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(11, bArr);
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length == 1 || g.length != 6) {
|
||||
throw new JimuException(-22, "Control fail!");
|
||||
}
|
||||
int i2 = g[0] & 255;
|
||||
if ((g[1] & 255) != 170) {
|
||||
z2 = false;
|
||||
}
|
||||
return new ServoAngleReadInfo(i2, z2, ((g[2] & 255) << 8) | (g[3] & 255), (g[5] & 255) | ((g[4] & 255) << 8));
|
||||
} catch (RequestException e) {
|
||||
Log.e("ServoManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int[] iArr, int i) throws MotorException {
|
||||
int length = iArr.length;
|
||||
byte[] bArr = new byte[length + 4];
|
||||
bArr[0] = (byte) (length & 255);
|
||||
int i2 = 0;
|
||||
while (i2 < length) {
|
||||
int i3 = i2 + 1;
|
||||
bArr[i3] = (byte) iArr[i2];
|
||||
i2 = i3;
|
||||
}
|
||||
if (i > 0) {
|
||||
bArr[length + 1] = 1;
|
||||
} else if (i < 0) {
|
||||
bArr[length + 1] = 2;
|
||||
} else {
|
||||
bArr[length + 1] = 0;
|
||||
}
|
||||
int abs = Math.abs(i);
|
||||
bArr[length + 2] = (byte) ((65280 & abs) >> 8);
|
||||
bArr[length + 3] = (byte) (abs & 255);
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(7, bArr)).g();
|
||||
if (g.length == 1 && g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
if (g.length == 5) {
|
||||
throw new MotorException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]), a(Arrays.copyOfRange(g, 1, g.length)));
|
||||
}
|
||||
throw new MotorException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]));
|
||||
} catch (RequestException e) {
|
||||
throw new MotorException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.MotorManager
|
||||
public void a() throws JimuException {
|
||||
try {
|
||||
byte[] g = this.a.a(new ProtocolPacket(59, new byte[0])).g();
|
||||
if (g[0] == 0) {
|
||||
return;
|
||||
}
|
||||
throw new JimuException(-21, "cmd result is fail! ErrCode:" + ((int) g[0]));
|
||||
} catch (RequestException e) {
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public List<ServoAngleReadInfo> a(final int i, boolean z) throws JimuException {
|
||||
final boolean[] zArr = new boolean[1];
|
||||
final boolean[] zArr2 = new boolean[1];
|
||||
final JimuException[] jimuExceptionArr = new JimuException[1];
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
byte[] bArr = new byte[2];
|
||||
bArr[0] = 0;
|
||||
if (z) {
|
||||
bArr[1] = 1;
|
||||
} else {
|
||||
bArr[1] = 0;
|
||||
}
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(11, bArr);
|
||||
this.a.a(protocolPacket, new ResponseCallback(this) { // from class: com.ubtrobot.jimu.robotapi.ServoManager.1
|
||||
@Override // com.ubtrobot.jimu.connection.ResponseCallback
|
||||
public void a(IPacket iPacket, IPacket iPacket2) {
|
||||
byte[] g = iPacket2.g();
|
||||
if (g.length == 1 || g.length != 6) {
|
||||
synchronized (zArr) {
|
||||
jimuExceptionArr[0] = new JimuException(-22, "Control fail!");
|
||||
zArr[0] = true;
|
||||
ALog.a("ServoManager").d("responded notify");
|
||||
zArr.notifyAll();
|
||||
}
|
||||
return;
|
||||
}
|
||||
ServoAngleReadInfo servoAngleReadInfo = new ServoAngleReadInfo(g[0] & 255, (g[1] & 255) == 170, ((g[2] & 255) << 8) | (g[3] & 255), (g[5] & 255) | ((g[4] & 255) << 8));
|
||||
synchronized (zArr) {
|
||||
arrayList.add(servoAngleReadInfo);
|
||||
if (arrayList.size() == i) {
|
||||
zArr2[0] = true;
|
||||
zArr[0] = true;
|
||||
Log.d("ServoManager", "responded notify");
|
||||
zArr.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.connection.ResponseCallback
|
||||
public void a(IPacket iPacket, RequestException requestException) {
|
||||
synchronized (zArr) {
|
||||
jimuExceptionArr[0] = new JimuException(requestException.getCode(), requestException.getMessage());
|
||||
zArr[0] = true;
|
||||
Log.d("ServoManager", "responded notify");
|
||||
zArr.notifyAll();
|
||||
}
|
||||
}
|
||||
}, i);
|
||||
synchronized (zArr) {
|
||||
while (!zArr[0]) {
|
||||
try {
|
||||
Log.d("ServoManager", "responded wait");
|
||||
zArr.wait();
|
||||
break;
|
||||
} catch (InterruptedException e) {
|
||||
Log.w("ServoManager", "Interrupted by someone when sync doRequest. req=" + protocolPacket + "Ignore it.", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
if (jimuExceptionArr[0] != null) {
|
||||
throw jimuExceptionArr[0];
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.MotorManager
|
||||
public int a(int i, int i2) throws JimuException {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(12, new byte[]{(byte) i, (byte) i2});
|
||||
try {
|
||||
byte[] g = this.a.a(protocolPacket).g();
|
||||
if (g.length == 1) {
|
||||
return g[0] & 255;
|
||||
}
|
||||
throw new JimuException(-22, "res argument is err!");
|
||||
} catch (RequestException e) {
|
||||
Log.e("ServoManager", "Call cmd fail! cmd:" + ((int) protocolPacket.f()), e);
|
||||
throw new JimuException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] a(int[] iArr) {
|
||||
byte[] bArr = new byte[4];
|
||||
for (int i : iArr) {
|
||||
if (i > 0 && i <= 8) {
|
||||
bArr[3] = (byte) (bArr[3] + (1 << (i - 1)));
|
||||
} else if (i > 8 && i <= 16) {
|
||||
bArr[2] = (byte) (bArr[2] + (1 << ((i - 1) - 8)));
|
||||
} else if (i > 16 && i <= 24) {
|
||||
bArr[1] = (byte) (bArr[1] + (1 << ((i - 1) - 16)));
|
||||
} else if (i >= 24 && i <= 32) {
|
||||
bArr[0] = (byte) (bArr[0] + (1 << ((i - 1) - 24)));
|
||||
}
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
|
||||
private ArrayList<Integer> a(byte[] bArr) {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
if (bArr.length != 4) {
|
||||
return arrayList;
|
||||
}
|
||||
for (int i = 0; i < bArr.length; i++) {
|
||||
int i2 = 24 - (i * 8);
|
||||
byte b = bArr[i];
|
||||
for (int i3 = 0; i3 < 8; i3++) {
|
||||
if ((b & 255 & (1 << i3)) != 0) {
|
||||
arrayList.add(Integer.valueOf(i3 + 1 + i2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
989
sources/com/ubtrobot/jimu/robotapi/UpdateManager.java
Normal file
989
sources/com/ubtrobot/jimu/robotapi/UpdateManager.java
Normal file
@@ -0,0 +1,989 @@
|
||||
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<Firmware> g = new ArrayList();
|
||||
private Queue<Firmware> 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<Firmware> 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.<init>() // 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.<init>() // 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.<init>() // 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user