Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package com.ubt.jimu.connect.model;
/* loaded from: classes.dex */
public class BluetoothSpeakerComponent extends Component {
private String e;
public BluetoothSpeakerComponent(int i, ErrorType errorType) {
super(8, i, errorType);
}
public void b(String str) {
this.e = str;
}
public String f() {
return this.e;
}
}

View File

@@ -0,0 +1,102 @@
package com.ubt.jimu.connect.model;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.R;
/* loaded from: classes.dex */
public class Component {
private int a;
private int b;
private ErrorType c;
private String d;
public Component() {
}
public void a(int i) {
this.b = i;
}
public ErrorType b() {
return this.c;
}
public int c() {
return this.a;
}
public int d() {
return this.b;
}
public String e() {
return this.d;
}
public String toString() {
return "errorType:" + this.c + " type:" + this.b + " id:" + this.a + " ";
}
public Component(int i, int i2, ErrorType errorType) {
this.b = i;
this.a = i2;
this.c = errorType;
}
public void a(ErrorType errorType) {
this.c = errorType;
}
public void a(String str) {
this.d = str;
}
public String a() {
int i = this.b;
int i2 = R.string.main_board;
if (i == 14) {
i2 = R.string.unicorn_led;
} else if (i == 101) {
i2 = R.string.firebot_light;
} else if (i == 128) {
i2 = R.string.servo;
} else if (i != 112 && i != 113) {
switch (i) {
case 1:
i2 = R.string.infrared;
break;
case 2:
i2 = R.string.touch;
break;
case 3:
i2 = R.string.gyro;
break;
case 4:
i2 = R.string.led;
break;
case 5:
i2 = R.string.gravity;
break;
case 6:
i2 = R.string.ultrasound;
break;
default:
switch (i) {
case 8:
i2 = R.string.speaker;
break;
case 9:
i2 = R.string.color;
break;
case 10:
i2 = R.string.motor;
break;
default:
i2 = -1;
break;
}
}
}
return i2 == -1 ? "" : JimuApplication.l().getApplicationContext().getString(i2);
}
}

View File

@@ -0,0 +1,12 @@
package com.ubt.jimu.connect.model;
/* loaded from: classes.dex */
public enum ErrorType {
NONE,
PROMPT,
ID_DUPLICATION,
LACK,
EXTRA,
TOO_MANY,
NEED_UPDATE
}

View File

@@ -0,0 +1,26 @@
package com.ubt.jimu.connect.model;
import android.os.Environment;
/* loaded from: classes.dex */
public class FilePathUtils {
public static String a(String str) {
return (Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/default/" + str;
}
public static String b(String str, String str2) {
return a(str, str2) + "/" + str + ".xml";
}
public static String c(String str, String str2) {
return ((Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/users/" + str2 + "/") + "/default/" + str;
}
public static String a(String str, String str2) {
return ((Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/users/" + str2 + "/") + "/playerdata/" + str;
}
public static String b(String str) {
return (Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/zip/" + str;
}
}

View File

@@ -0,0 +1,16 @@
package com.ubt.jimu.connect.model;
import com.ubtrobot.jimu.Firmware;
import com.ubtrobot.jimu.robotapi.BoardInfo;
import java.util.List;
/* loaded from: classes.dex */
public interface IUpdateModel {
List<Firmware> a(BoardInfo boardInfo);
boolean b(BoardInfo boardInfo);
boolean c(BoardInfo boardInfo);
boolean d(BoardInfo boardInfo);
}

View File

@@ -0,0 +1,8 @@
package com.ubt.jimu.connect.model;
import com.ubtrobot.jimu.robotapi.BoardInfo;
/* loaded from: classes.dex */
public interface MatchResultCallback {
void a(int i, BoardInfo boardInfo);
}

View File

@@ -0,0 +1,608 @@
package com.ubt.jimu.connect.model;
import android.util.Log;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.data.ServoMode;
import com.ubt.jimu.base.db.diy.DiyDBModel;
import com.ubt.jimu.base.db.diy.DiyHelper;
import com.ubt.jimu.base.entities.User;
import com.ubt.jimu.transport3.UnityFileOperator;
import com.ubtech.utils.XLog;
import com.ubtrobot.jimu.connection.RequestException;
import com.ubtrobot.jimu.robotapi.BluetoothSpeakerInfo;
import com.ubtrobot.jimu.robotapi.BoardInfo;
import com.ubtrobot.jimu.robotapi.JimuException;
import com.ubtrobot.jimu.robotapi.JimuManager;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import com.ubtrobot.log.ALog;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public class ModelMatchModel {
private ArrayList<Component> b = new ArrayList<>();
private JimuManager a = JimuApplication.l().f();
private String c() {
User user = Cache.getInstance().getUser();
if (user == null) {
return "local";
}
return user.getUserId() + "";
}
public ArrayList<Component> a() {
return this.b;
}
public BoardInfo b() throws JimuException {
BoardInfo l;
try {
try {
if (!this.a.h()) {
this.a.c();
throw new JimuException(-1, "ERROR_CODE_NOT_JIMU_DEVICE");
}
this.a.n();
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
try {
l = this.a.l();
} catch (JimuException e2) {
XLog.b("ModelMatchModel", "Read mother board info fail! Retry one time");
try {
if (e2.getCode() == 238) {
this.a.b();
}
Thread.sleep(1000L);
} catch (InterruptedException e3) {
e3.printStackTrace();
Thread.currentThread().interrupt();
}
try {
l = this.a.l();
} catch (JimuException unused) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
throw new JimuException(-2, "MATCH_RESULT_ERROR_READ_CODE_FAIL");
}
}
if (l != null) {
return l;
}
XLog.b("ModelMatchModel", "Read mother board info fail! ");
throw new JimuException(-2, "MATCH_RESULT_ERROR_READ_CODE_FAIL");
} catch (JimuException e4) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
throw new JimuException(-2, e4.getMessage());
}
} catch (RequestException e5) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
throw new JimuException(-2, e5.getMessage());
}
}
public void a(String str, boolean z, MatchResultCallback matchResultCallback) {
BoardInfo l;
int i;
XLog.c("ModelMatchModel", "start match model");
try {
try {
if (!this.a.h()) {
this.a.c();
matchResultCallback.a(-1, null);
return;
}
this.a.n();
try {
Thread.sleep(2000L);
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
try {
l = this.a.l();
} catch (JimuException e) {
XLog.b("ModelMatchModel", "Read mother board info fail! Retry one time");
try {
if (e.getCode() == 238) {
this.a.b();
}
Thread.sleep(1000L);
} catch (InterruptedException e2) {
e2.printStackTrace();
Thread.currentThread().interrupt();
}
try {
l = this.a.l();
} catch (JimuException unused2) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
matchResultCallback.a(-2, null);
return;
}
}
if (l == null) {
XLog.b("ModelMatchModel", "Read mother board info fail! ");
matchResultCallback.a(-2, null);
return;
}
if (l.l()) {
XLog.c("ModelMatchModel", "peripheral ID duplication");
i = -4;
} else {
i = 0;
}
this.b = a(l, str, z);
Iterator<Component> it = this.b.iterator();
while (it.hasNext()) {
Component next = it.next();
if (next.b() != ErrorType.NONE) {
XLog.c("ModelMatchModel", "Has some component not match. component:" + next);
i = -3;
}
}
matchResultCallback.a(i, l);
} catch (JimuException unused3) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
matchResultCallback.a(-2, null);
}
} catch (RequestException unused4) {
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
matchResultCallback.a(-2, null);
}
}
private List<Integer> c(List<Integer> list, List<Integer> list2) {
if (list == null) {
return new ArrayList();
}
ArrayList arrayList = new ArrayList(list);
if (list2 == null) {
return arrayList;
}
arrayList.removeAll(list2);
return arrayList;
}
private List<Integer> b(List<Integer> list, List<Integer> list2) {
if (list2 == null) {
return new ArrayList();
}
ArrayList arrayList = new ArrayList(list2);
if (list == null) {
return arrayList;
}
arrayList.removeAll(list);
return arrayList;
}
public void b(BoardInfo boardInfo, String str, boolean z) {
String c = c();
if (a(z, str)) {
a(str, c, boardInfo, z);
a(str, c, boardInfo);
} else {
b(str, c, boardInfo, z);
}
}
private static void b(String str, String str2, BoardInfo boardInfo, boolean z) {
String c;
PeripheralConnections a = PeripheralConnections.a(str, str2, z);
if (a == null) {
return;
}
a.a(boardInfo);
if (z) {
c = FilePathUtils.a(str, str2);
} else {
c = FilePathUtils.c(str, str2);
}
a.b(c);
a(str, true, PeripheralConnections.d(c), 2);
}
public ArrayList<Component> a(BoardInfo boardInfo, String str, boolean z) {
String a;
ArrayList<Component> arrayList = new ArrayList<>();
if (boardInfo == null) {
XLog.b("ModelMatchModel", "Board info is null");
return arrayList;
}
if (a(z, str)) {
return a(boardInfo);
}
if (z) {
a = FilePathUtils.a(str, c());
} else {
a = FilePathUtils.a(str);
String c = FilePathUtils.c(str, c());
File file = new File(a);
File file2 = new File(c);
if (!file.exists() || (file2.exists() && file2.lastModified() > file.lastModified())) {
a = c;
}
}
XLog.c("ModelMatchModel", "Model file folder path:" + a);
XLog.c("ModelMatchModel", "robotName:" + str + " isDiyModel:" + z);
ArrayList<Component> a2 = a(boardInfo, a, str, z);
StringBuilder sb = new StringBuilder();
sb.append("componentList:");
sb.append(a(a2));
XLog.c("ModelMatchModel", sb.toString());
a(a2, boardInfo);
Iterator<Component> it = a2.iterator();
while (it.hasNext()) {
Component next = it.next();
if (next.d() == 8 && next.b() != ErrorType.LACK) {
if (next.b() == ErrorType.NONE) {
next.a(ErrorType.PROMPT);
}
try {
BluetoothSpeakerInfo a3 = this.a.a(next.c());
if (a3 == null) {
Log.w("ModelMatchModel", "Not read any speaker info, Please check has speaker connected");
} else {
((BluetoothSpeakerComponent) next).b(a3.a());
}
} catch (JimuException e) {
XLog.a("ModelMatchModel", e.getMessage(), e);
}
}
}
return a2;
}
public ArrayList<Component> a(BoardInfo boardInfo) {
ArrayList<Component> arrayList = new ArrayList<>();
arrayList.add(a(boardInfo.e(), 1, ErrorType.NONE, boardInfo.d()));
List<Integer> i = boardInfo.i();
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
a(arrayList, PeripheralType.SERVO, i, boardInfo.j());
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : h.entrySet()) {
BoardInfo.SensorBoardInfo value = entry.getValue();
if (value != null) {
a(arrayList, entry.getKey().intValue(), value.b(), value.c());
}
}
a(arrayList, boardInfo);
Iterator<Component> it = arrayList.iterator();
while (it.hasNext()) {
Component next = it.next();
if (next.d() == 8 && next.b() != ErrorType.LACK) {
try {
((BluetoothSpeakerComponent) next).b(this.a.a(next.c()).a());
} catch (JimuException e) {
XLog.a("ModelMatchModel", e.getMessage(), e);
}
}
}
return arrayList;
}
private void a(ArrayList<Component> arrayList, int i, List<Integer> list, String str) {
Iterator<Integer> it = list.iterator();
while (it.hasNext()) {
arrayList.add(a(i, it.next().intValue(), ErrorType.NONE, str));
}
}
private String a(ArrayList<Component> arrayList) {
String str = "";
for (int i = 0; i < arrayList.size(); i++) {
str = (str + arrayList.get(i)) + "\n";
}
return str;
}
private void a(ArrayList<Component> arrayList, BoardInfo boardInfo) {
if (boardInfo.a().size() != 0) {
for (Integer num : boardInfo.a()) {
Iterator<Component> it = arrayList.iterator();
while (it.hasNext()) {
Component next = it.next();
if (next.d() == 128 && next.c() == num.intValue()) {
it.remove();
}
}
arrayList.add(a(PeripheralType.SERVO, num.intValue(), ErrorType.ID_DUPLICATION));
}
}
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : boardInfo.h().entrySet()) {
if (entry.getValue().a().size() != 0) {
for (Integer num2 : entry.getValue().a()) {
Iterator<Component> it2 = arrayList.iterator();
while (it2.hasNext()) {
Component next2 = it2.next();
if (next2.d() == entry.getKey().intValue() && next2.c() == num2.intValue()) {
it2.remove();
}
}
if (entry.getKey().intValue() == 8) {
arrayList.add(a(entry.getKey().intValue(), num2.intValue(), ErrorType.TOO_MANY));
} else {
arrayList.add(a(entry.getKey().intValue(), num2.intValue(), ErrorType.ID_DUPLICATION));
}
}
}
}
}
private ArrayList<Component> a(BoardInfo boardInfo, String str, String str2, boolean z) {
int i;
HashMap<Integer, ArrayList<Integer>> b;
PeripheralConnections peripheralConnections;
String str3;
int i2;
ArrayList<Component> arrayList = new ArrayList<>();
String str4 = "ModelMatchModel";
if (boardInfo == null) {
XLog.b("ModelMatchModel", "Board is null, not compare to model file.");
return arrayList;
}
String str5 = str + "/" + str2 + ".xml";
if (!z) {
str5 = FilePathUtils.a(str2) + "/" + str2 + ".xml";
}
XLog.a("ModelMatchModel", "xmlPath:" + str5);
ModelMatchXmlFileManager modelMatchXmlFileManager = new ModelMatchXmlFileManager();
modelMatchXmlFileManager.a(str5);
List<Integer> b2 = modelMatchXmlFileManager.b();
List<Integer> a = modelMatchXmlFileManager.a();
List<Integer> i3 = boardInfo.i();
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
arrayList.add(a(boardInfo.e(), 1, ErrorType.NONE, boardInfo.d()));
Iterator<Integer> it = a(b2, i3).iterator();
while (true) {
boolean hasNext = it.hasNext();
i = PeripheralType.SERVO;
if (!hasNext) {
break;
}
arrayList.add(a(PeripheralType.SERVO, it.next().intValue(), ErrorType.NONE, boardInfo.j()));
}
for (Integer num : c(b2, i3)) {
if (boardInfo.a().contains(num)) {
Component a2 = a(PeripheralType.SERVO, num.intValue(), ErrorType.ID_DUPLICATION);
a2.a(boardInfo.j());
arrayList.add(a2);
} else {
arrayList.add(a(PeripheralType.SERVO, num.intValue(), ErrorType.LACK));
}
}
Iterator<Integer> it2 = b(b2, i3).iterator();
while (it2.hasNext()) {
Component a3 = a(PeripheralType.SERVO, it2.next().intValue(), ErrorType.EXTRA);
a3.a(boardInfo.j());
arrayList.add(a3);
}
int i4 = 10;
BoardInfo.SensorBoardInfo sensorBoardInfo = h.get(10);
List<Integer> b3 = sensorBoardInfo != null ? sensorBoardInfo.b() : null;
Iterator<Integer> it3 = a(a, b3).iterator();
while (it3.hasNext()) {
arrayList.add(a(10, it3.next().intValue(), ErrorType.NONE, sensorBoardInfo.c()));
}
Iterator<Integer> it4 = c(a, b3).iterator();
while (it4.hasNext()) {
arrayList.add(a(10, it4.next().intValue(), ErrorType.LACK));
}
List<Integer> b4 = b(a, b3);
if (b4 != null && b4.size() != 0) {
Iterator<Integer> it5 = b4.iterator();
while (it5.hasNext()) {
Component a4 = a(10, it5.next().intValue(), ErrorType.EXTRA);
if (sensorBoardInfo != null) {
a4.a(sensorBoardInfo.c());
}
arrayList.add(a4);
}
}
PeripheralConnections a5 = PeripheralConnections.a(str2, c(), z);
if (a5 == null) {
XLog.b("ModelMatchModel", "Get peripheral connections fail by read connections file!");
b = new HashMap<>();
} else {
b = a5.b();
}
HashMap<Integer, ArrayList<Integer>> hashMap = b;
Field[] declaredFields = PeripheralType.class.getDeclaredFields();
int length = declaredFields.length;
int i5 = 0;
while (i5 < length) {
try {
i2 = declaredFields[i5].getInt(PeripheralType.class);
} catch (IllegalAccessException e) {
e = e;
peripheralConnections = a5;
}
if (i2 != -1 && i2 != i4 && i2 != 112 && i2 != 113) {
ArrayList<Integer> arrayList2 = hashMap.get(Integer.valueOf(i2));
if (i2 == i && arrayList2 != null) {
Iterator<Integer> it6 = arrayList2.iterator();
while (it6.hasNext()) {
int intValue = it6.next().intValue();
ServoMode servoMode = ServoMode.SERVO_MODE_ANGLE;
if (a5 != null) {
a5.a(Integer.valueOf(intValue));
}
Iterator<Component> it7 = arrayList.iterator();
while (true) {
if (it7.hasNext()) {
Component next = it7.next();
if (i == next.d() && intValue == next.c()) {
ALog.a(str4).d("ServoId:" + intValue + " Mode:" + servoMode);
((ServoComponent) next).a(servoMode);
break;
}
i = PeripheralType.SERVO;
}
}
i = PeripheralType.SERVO;
}
} else {
BoardInfo.SensorBoardInfo sensorBoardInfo2 = h.get(Integer.valueOf(i2));
if (sensorBoardInfo2 != null) {
List<Integer> b5 = sensorBoardInfo2.b();
if (i2 == 8 && b5.size() > 1) {
Component a6 = a(i2, 1, ErrorType.TOO_MANY);
a6.a(sensorBoardInfo2.c());
arrayList.add(a6);
} else {
Iterator<Integer> it8 = a(arrayList2, b5).iterator();
while (it8.hasNext()) {
int intValue2 = it8.next().intValue();
peripheralConnections = a5;
if (i2 == 8) {
try {
str3 = str4;
if (b5.size() == 1) {
try {
arrayList.add(a(i2, intValue2, ErrorType.PROMPT, sensorBoardInfo2.c()));
a5 = peripheralConnections;
str4 = str3;
} catch (IllegalAccessException e2) {
e = e2;
e.printStackTrace();
i5++;
a5 = peripheralConnections;
str4 = str3;
i4 = 10;
i = PeripheralType.SERVO;
}
}
} catch (IllegalAccessException e3) {
e = e3;
str3 = str4;
e.printStackTrace();
i5++;
a5 = peripheralConnections;
str4 = str3;
i4 = 10;
i = PeripheralType.SERVO;
}
} else {
str3 = str4;
}
arrayList.add(a(i2, intValue2, ErrorType.NONE, sensorBoardInfo2.c()));
a5 = peripheralConnections;
str4 = str3;
}
peripheralConnections = a5;
str3 = str4;
Iterator<Integer> it9 = c(arrayList2, b5).iterator();
while (it9.hasNext()) {
arrayList.add(a(i2, it9.next().intValue(), ErrorType.LACK));
}
Iterator<Integer> it10 = b(arrayList2, b5).iterator();
while (it10.hasNext()) {
Component a7 = a(i2, it10.next().intValue(), ErrorType.EXTRA);
a7.a(sensorBoardInfo2.c());
arrayList.add(a7);
}
i5++;
a5 = peripheralConnections;
str4 = str3;
i4 = 10;
i = PeripheralType.SERVO;
}
} else if (arrayList2 != null) {
Iterator<Integer> it11 = arrayList2.iterator();
while (it11.hasNext()) {
arrayList.add(a(i2, it11.next().intValue(), ErrorType.LACK));
}
}
}
}
peripheralConnections = a5;
str3 = str4;
i5++;
a5 = peripheralConnections;
str4 = str3;
i4 = 10;
i = PeripheralType.SERVO;
}
return arrayList;
}
private Component a(int i, int i2, ErrorType errorType, String str) {
if (i == 8) {
BluetoothSpeakerComponent bluetoothSpeakerComponent = new BluetoothSpeakerComponent(i2, errorType);
bluetoothSpeakerComponent.a(str);
return bluetoothSpeakerComponent;
}
if (i == 128) {
ServoComponent servoComponent = new ServoComponent(i2, errorType);
servoComponent.a(str);
return servoComponent;
}
Component component = new Component(i, i2, errorType);
component.a(str);
return component;
}
private Component a(int i, int i2, ErrorType errorType) {
if (i == 8) {
return new BluetoothSpeakerComponent(i2, errorType);
}
if (i == 128) {
return new ServoComponent(i2, errorType);
}
return new Component(i, i2, errorType);
}
private List<Integer> a(List<Integer> list, List<Integer> list2) {
ArrayList arrayList = new ArrayList();
if (list != null && list2 != null) {
arrayList.addAll(list);
arrayList.retainAll(list2);
}
return arrayList;
}
public static boolean a(boolean z, String str) {
if (z) {
return a(str);
}
return false;
}
public static boolean a(String str) {
return !new File(FilePathUtils.b(str, Cache.getInstance().getUserId())).exists();
}
private static void a(String str, String str2, BoardInfo boardInfo) {
String str3 = FilePathUtils.a(str, str2) + "/" + str + ".xml";
new ModelMatchXmlFileManager().a(boardInfo, str3);
a(str, true, str3, 1);
}
private static void a(String str, boolean z, String str2, int i) {
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(str);
if (queryForUUid == null) {
Log.w("ModelMatchModel", "Query null for diy model " + str + " from database");
return;
}
new UnityFileOperator(queryForUUid.getModelId().intValue(), str, z ? 1 : 0, str2, i).operateFile();
}
private static void a(String str, String str2, BoardInfo boardInfo, boolean z) {
String c;
PeripheralConnections b = PeripheralConnections.b(boardInfo);
if (z) {
c = FilePathUtils.a(str, str2);
} else {
c = FilePathUtils.c(str, str2);
}
b.b(c);
a(str, true, PeripheralConnections.d(c), 1);
}
}

View File

@@ -0,0 +1,238 @@
package com.ubt.jimu.connect.model;
import android.util.Xml;
import com.ubt.jimu.base.util.PathHelper;
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
import com.ubtrobot.jimu.robotapi.BoardInfo;
import com.unity3d.ads.metadata.MediationMetaData;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.xmlpull.v1.XmlSerializer;
/* loaded from: classes.dex */
public class ModelMatchXmlFileManager {
private List<Integer> a = new ArrayList();
private List<Integer> b = new ArrayList();
public List<Integer> a() {
return this.b;
}
public List<Integer> b() {
return this.a;
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:69:0x00fb A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Type inference failed for: r8v13, types: [java.io.InputStream] */
/* JADX WARN: Type inference failed for: r8v14 */
/* JADX WARN: Type inference failed for: r8v17 */
/* JADX WARN: Type inference failed for: r8v18 */
/* JADX WARN: Type inference failed for: r8v19 */
/* JADX WARN: Type inference failed for: r8v2 */
/* JADX WARN: Type inference failed for: r8v20 */
/* JADX WARN: Type inference failed for: r8v21 */
/* JADX WARN: Type inference failed for: r8v22 */
/* JADX WARN: Type inference failed for: r8v3, types: [java.io.IOException] */
/* JADX WARN: Type inference failed for: r8v4 */
/* JADX WARN: Type inference failed for: r8v7 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void a(java.lang.String r8) {
/*
Method dump skipped, instructions count: 260
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.connect.model.ModelMatchXmlFileManager.a(java.lang.String):void");
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r10v22, types: [java.lang.String] */
public void a(BoardInfo boardInfo, String str) {
Throwable th;
FileOutputStream fileOutputStream;
if (boardInfo == null) {
return;
}
File file = new File(str);
String str2 = PathHelper.OLD_CONTROLLER_PREFIX + System.currentTimeMillis();
String property = System.getProperty("line.separator");
List<Integer> i = boardInfo.i();
BoardInfo.SensorBoardInfo sensorBoardInfo = boardInfo.h().get(10);
FileOutputStream fileOutputStream2 = null;
r10 = null;
FileOutputStream fileOutputStream3 = null;
fileOutputStream2 = null;
fileOutputStream2 = null;
fileOutputStream2 = null;
fileOutputStream2 = null;
List<Integer> b = sensorBoardInfo != null ? sensorBoardInfo.b() : null;
try {
try {
try {
FileOutputStream fileOutputStream4 = new FileOutputStream(file);
try {
XmlSerializer newSerializer = Xml.newSerializer();
newSerializer.setOutput(fileOutputStream4, "UTF-8");
int i2 = 1;
newSerializer.startDocument("UTF-8", true);
newSerializer.text(property);
newSerializer.startTag(null, "Root");
newSerializer.text(property);
newSerializer.startTag(null, "RobotID");
newSerializer.text(str2);
newSerializer.endTag(null, "RobotID");
newSerializer.text(property);
newSerializer.startTag(null, "DataType");
newSerializer.text("playerdata");
newSerializer.endTag(null, "DataType");
newSerializer.text(property);
newSerializer.startTag(null, "Level");
newSerializer.text("level");
newSerializer.endTag(null, "Level");
newSerializer.text(property);
if (i != null) {
Iterator<Integer> it = i.iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
Iterator<Integer> it2 = it;
newSerializer.startTag(null, "GO");
fileOutputStream = fileOutputStream4;
try {
newSerializer.attribute(null, JockstickDataConverter.ID, String.valueOf(i2));
newSerializer.attribute(null, "type", "seivo");
newSerializer.attribute(null, MediationMetaData.KEY_NAME, "seivo_" + intValue);
newSerializer.attribute(null, "djid", String.valueOf(intValue));
newSerializer.attribute(null, "motorID", "0");
newSerializer.attribute(null, "goPos", "(0,0,0)");
newSerializer.attribute(null, "goAngle", "(0,0,0)");
newSerializer.attribute(null, "goScale", "(1,1,1)");
newSerializer.attribute(null, "goColor", "(0,0,0,1)");
newSerializer.attribute(null, "isDP", "1");
newSerializer.endTag(null, "GO");
newSerializer.text(property);
i2++;
it = it2;
fileOutputStream4 = fileOutputStream;
fileOutputStream3 = null;
} catch (FileNotFoundException e) {
e = e;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
fileOutputStream2.close();
fileOutputStream2 = fileOutputStream2;
}
} catch (IOException e2) {
e = e2;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
fileOutputStream2.close();
fileOutputStream2 = fileOutputStream2;
}
} catch (IllegalArgumentException e3) {
e = e3;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
fileOutputStream2.close();
fileOutputStream2 = fileOutputStream2;
}
} catch (IllegalStateException e4) {
e = e4;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
fileOutputStream2.close();
fileOutputStream2 = fileOutputStream2;
}
} catch (Throwable th2) {
th = th2;
th = th;
if (fileOutputStream != null) {
try {
fileOutputStream.close();
throw th;
} catch (Exception e5) {
e5.printStackTrace();
throw th;
}
}
throw th;
}
}
}
fileOutputStream = fileOutputStream4;
if (b != null) {
Iterator<Integer> it3 = b.iterator();
fileOutputStream3 = fileOutputStream3;
while (it3.hasNext()) {
int intValue2 = it3.next().intValue();
newSerializer.startTag(null, "GO");
newSerializer.attribute(null, JockstickDataConverter.ID, String.valueOf(i2));
newSerializer.attribute(null, "type", "motor");
newSerializer.attribute(null, MediationMetaData.KEY_NAME, "motor_" + intValue2);
newSerializer.attribute(null, "djid", "0");
newSerializer.attribute(null, "motorID", String.valueOf(intValue2));
newSerializer.attribute(null, "goPos", "(0,0,0)");
newSerializer.attribute(null, "goAngle", "(0,0,0)");
newSerializer.attribute(null, "goScale", "(1,1,1)");
newSerializer.attribute(null, "goColor", "(0,0,0,1)");
newSerializer.attribute(null, "isDP", "1");
newSerializer.endTag(null, "GO");
newSerializer.text(property);
i2++;
fileOutputStream3 = "1";
}
}
newSerializer.endTag(null, "Root");
newSerializer.text(property);
newSerializer.endDocument();
newSerializer.flush();
fileOutputStream.close();
fileOutputStream2 = fileOutputStream3;
} catch (FileNotFoundException e6) {
e = e6;
fileOutputStream = fileOutputStream4;
} catch (IOException e7) {
e = e7;
fileOutputStream = fileOutputStream4;
} catch (IllegalArgumentException e8) {
e = e8;
fileOutputStream = fileOutputStream4;
} catch (IllegalStateException e9) {
e = e9;
fileOutputStream = fileOutputStream4;
} catch (Throwable th3) {
th = th3;
fileOutputStream = fileOutputStream4;
}
} catch (FileNotFoundException e10) {
e = e10;
} catch (IOException e11) {
e = e11;
} catch (IllegalArgumentException e12) {
e = e12;
} catch (IllegalStateException e13) {
e = e13;
} catch (Throwable th4) {
th = th4;
fileOutputStream = null;
}
} catch (Throwable th5) {
th = th5;
fileOutputStream = fileOutputStream2;
}
} catch (Exception e14) {
e14.printStackTrace();
}
}
}

View File

@@ -0,0 +1,498 @@
package com.ubt.jimu.connect.model;
import android.os.Environment;
import android.util.Log;
import com.ubt.jimu.base.data.ServoMode;
import com.ubt.jimu.connect.model.TopologyPartData;
import com.ubt.jimu.utils.SystemUtils;
import com.ubtech.utils.XLog;
import com.ubtrobot.jimu.robotapi.BoardInfo;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public class PeripheralConnections {
private List<TopologyPartData> a = new ArrayList();
private HashMap<Integer, List<Integer>> b;
private HashMap<Integer, ServoMode> c;
private HashMap<String, String> d;
private long e;
private HashMap<Integer, ArrayList<Integer>> f;
/* renamed from: com.ubt.jimu.connect.model.PeripheralConnections$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[TopologyPartData.TopologyPartType.values().length];
static {
try {
a[TopologyPartData.TopologyPartType.Servo.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[TopologyPartData.TopologyPartType.Motor.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[TopologyPartData.TopologyPartType.Gyro.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[TopologyPartData.TopologyPartType.Light.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[TopologyPartData.TopologyPartType.Touch.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[TopologyPartData.TopologyPartType.Color.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
a[TopologyPartData.TopologyPartType.Gravity.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
a[TopologyPartData.TopologyPartType.Speaker.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
a[TopologyPartData.TopologyPartType.Infrared.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
a[TopologyPartData.TopologyPartType.Compass.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
a[TopologyPartData.TopologyPartType.EnLight.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
a[TopologyPartData.TopologyPartType.Atmosphere.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
try {
a[TopologyPartData.TopologyPartType.Ultrasonic.ordinal()] = 13;
} catch (NoSuchFieldError unused13) {
}
try {
a[TopologyPartData.TopologyPartType.DigitalTube.ordinal()] = 14;
} catch (NoSuchFieldError unused14) {
}
try {
a[TopologyPartData.TopologyPartType.Temperature.ordinal()] = 15;
} catch (NoSuchFieldError unused15) {
}
try {
a[TopologyPartData.TopologyPartType.MainBoard.ordinal()] = 16;
} catch (NoSuchFieldError unused16) {
}
try {
a[TopologyPartData.TopologyPartType.MainBoard_new_low.ordinal()] = 17;
} catch (NoSuchFieldError unused17) {
}
try {
a[TopologyPartData.TopologyPartType.RgbLight.ordinal()] = 18;
} catch (NoSuchFieldError unused18) {
}
}
}
public PeripheralConnections() {
TopologyPartData.TopologyPartType topologyPartType = TopologyPartData.TopologyPartType.MainBoard;
this.b = new HashMap<>();
this.c = new HashMap<>();
this.d = new HashMap<>();
this.f = new HashMap<>();
}
public static String d(String str) {
return str + "/servos/servos.txt";
}
public long a() {
return this.e;
}
public HashMap<Integer, ArrayList<Integer>> b() {
return this.f;
}
public HashMap<Integer, ServoMode> c() {
return this.c;
}
public static PeripheralConnections b(BoardInfo boardInfo) {
PeripheralConnections peripheralConnections = new PeripheralConnections();
peripheralConnections.c(boardInfo);
return peripheralConnections;
}
private static PeripheralConnections c(String str) {
if (!new File(str + "/servos/servos.txt").exists()) {
return null;
}
PeripheralConnections peripheralConnections = new PeripheralConnections();
peripheralConnections.a(str);
return peripheralConnections;
}
public List<Integer> a(int i) {
HashMap<Integer, ArrayList<Integer>> hashMap = this.f;
if (hashMap == null || hashMap.size() <= 0) {
return null;
}
return this.f.get(Integer.valueOf(i));
}
private HashMap<Integer, ArrayList<Integer>> a(List<TopologyPartData> list) {
HashMap<Integer, ArrayList<Integer>> hashMap = new HashMap<>();
for (TopologyPartData topologyPartData : list) {
int a = a(topologyPartData.b);
if (a != -1) {
ArrayList<Integer> arrayList = hashMap.get(Integer.valueOf(a));
if (arrayList == null) {
arrayList = new ArrayList<>();
}
arrayList.add(Integer.valueOf(topologyPartData.a));
hashMap.put(Integer.valueOf(a), arrayList);
}
}
return hashMap;
}
private int b(TopologyPartData.TopologyPartType topologyPartType) {
switch (AnonymousClass1.a[topologyPartType.ordinal()]) {
case 1:
return PeripheralType.SERVO;
case 2:
return 10;
case 3:
return 3;
case 4:
return 4;
case 5:
return 2;
case 6:
return 9;
case 7:
return 5;
case 8:
return 8;
case 9:
return 1;
case 10:
return 96;
case 11:
return 12;
case 12:
return 97;
case 13:
return 6;
case 14:
return 7;
case 15:
return 11;
case 16:
return 112;
case 17:
return 113;
case 18:
return 14;
default:
Log.e("PeripheralConnections", "Invalid peripheral type. TopologyPartType:" + topologyPartType);
return -1;
}
}
private TopologyPartData.TopologyPartType b(int i) {
if (i == 14) {
return TopologyPartData.TopologyPartType.RgbLight;
}
if (i == 128) {
return TopologyPartData.TopologyPartType.Servo;
}
if (i == 96) {
return TopologyPartData.TopologyPartType.Compass;
}
if (i == 97) {
return TopologyPartData.TopologyPartType.Atmosphere;
}
if (i == 112) {
return TopologyPartData.TopologyPartType.MainBoard;
}
if (i != 113) {
switch (i) {
case 1:
return TopologyPartData.TopologyPartType.Infrared;
case 2:
return TopologyPartData.TopologyPartType.Touch;
case 3:
return TopologyPartData.TopologyPartType.Gyro;
case 4:
return TopologyPartData.TopologyPartType.Light;
case 5:
return TopologyPartData.TopologyPartType.Gravity;
case 6:
return TopologyPartData.TopologyPartType.Ultrasonic;
case 7:
return TopologyPartData.TopologyPartType.DigitalTube;
case 8:
return TopologyPartData.TopologyPartType.Speaker;
case 9:
return TopologyPartData.TopologyPartType.Color;
case 10:
return TopologyPartData.TopologyPartType.Motor;
case 11:
return TopologyPartData.TopologyPartType.Temperature;
case 12:
return TopologyPartData.TopologyPartType.EnLight;
default:
return TopologyPartData.TopologyPartType.None;
}
}
return TopologyPartData.TopologyPartType.MainBoard_new_low;
}
private void c(BoardInfo boardInfo) {
if (boardInfo == null) {
return;
}
this.a.add(new TopologyPartData(b(boardInfo.e()), 0, false));
for (Integer num : boardInfo.i()) {
this.c.put(num, ServoMode.SERVO_MODE_ANGLE);
this.a.add(new TopologyPartData(TopologyPartData.TopologyPartType.Servo, num.intValue(), false));
}
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : boardInfo.h().entrySet()) {
boolean z = entry.getKey().intValue() != 10;
TopologyPartData.TopologyPartType b = b(entry.getKey().intValue());
Iterator<Integer> it = entry.getValue().b().iterator();
while (it.hasNext()) {
this.a.add(new TopologyPartData(b, it.next().intValue(), z));
}
}
}
private int a(TopologyPartData.TopologyPartType topologyPartType) {
switch (AnonymousClass1.a[topologyPartType.ordinal()]) {
case 1:
return PeripheralType.SERVO;
case 2:
return 10;
case 3:
return 3;
case 4:
return 4;
case 5:
return 2;
case 6:
return 9;
case 7:
return 5;
case 8:
return 8;
case 9:
return 1;
case 10:
return 96;
case 11:
return 12;
case 12:
return 97;
case 13:
return 6;
case 14:
return 7;
case 15:
return 11;
case 16:
return 112;
case 17:
return 113;
case 18:
return 14;
default:
return -1;
}
}
public static PeripheralConnections a(String str, String str2, boolean z) {
String str3 = Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files";
String str4 = str3 + "/default/" + str;
String str5 = str3 + "/users/" + str2 + "/";
if (!z) {
String str6 = str5 + "/default/" + str;
PeripheralConnections c = c(str6);
PeripheralConnections c2 = c(str4);
if (c == null || (c2 != null && c2.a() > c.a())) {
c = c2;
}
if (c == c2) {
XLog.c("PeripheralConnections", "Connection folder:" + str4);
return c;
}
XLog.c("PeripheralConnections", "Connection folder:" + str6);
return c;
}
String str7 = str5 + "/playerdata/" + str;
PeripheralConnections c3 = c(str7);
XLog.c("PeripheralConnections", "Connection folder:" + str7);
return c3;
}
public void a(BoardInfo boardInfo) {
BoardInfo.SensorBoardInfo sensorBoardInfo;
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : h.entrySet()) {
if (entry.getKey().intValue() != 10) {
TopologyPartData.TopologyPartType b = b(entry.getKey().intValue());
Iterator<Integer> it = entry.getValue().b().iterator();
while (it.hasNext()) {
int intValue = it.next().intValue();
if (!a(b, intValue)) {
this.a.add(new TopologyPartData(b, intValue, true));
}
}
}
}
Iterator<TopologyPartData> it2 = this.a.iterator();
while (it2.hasNext()) {
TopologyPartData next = it2.next();
int b2 = b(next.b);
if (b2 != 128 && b2 != 10 && b2 != 112 && b2 != 113 && (sensorBoardInfo = h.get(Integer.valueOf(b2))) != null && !sensorBoardInfo.b().contains(Integer.valueOf(next.a)) && next.c) {
it2.remove();
}
}
}
public void b(String str) {
String str2 = str + "/servos";
File file = new File(str2);
if (!file.exists()) {
file.mkdirs();
}
File file2 = new File(str2 + "/servos.txt");
if (!file2.exists()) {
try {
file2.createNewFile();
} catch (IOException e) {
XLog.a("PeripheralConnections", "Create file fail!", e);
return;
}
}
String property = System.getProperty("line.separator");
try {
FileWriter fileWriter = new FileWriter(file2);
try {
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
try {
for (Map.Entry<Integer, List<Integer>> entry : this.b.entrySet()) {
bufferedWriter.write(entry.getKey() + " " + b(entry.getValue()) + property);
}
StringBuilder sb = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
for (Map.Entry<Integer, ServoMode> entry2 : this.c.entrySet()) {
if (entry2.getValue() == ServoMode.SERVO_MODE_ANGLE) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(entry2.getKey());
} else {
if (sb2.length() > 0) {
sb2.append(",");
}
sb2.append(entry2.getKey());
}
}
if (sb.length() > 0) {
bufferedWriter.write("angleServos:" + sb.toString() + property);
}
if (sb2.length() > 0) {
bufferedWriter.write("turnServos:" + sb2.toString() + property);
}
int size = this.a.size();
for (int i = 0; i < size; i++) {
bufferedWriter.write("partData:" + this.a.get(i).toString() + property);
}
if (this.d.size() > 0) {
StringBuilder sb3 = new StringBuilder();
for (Map.Entry<String, String> entry3 : this.d.entrySet()) {
if (sb3.length() > 0) {
sb3.append("|");
}
sb3.append(entry3.getKey());
sb3.append(",");
sb3.append(entry3.getValue());
}
bufferedWriter.write("portConnection:" + sb3.toString() + property);
}
bufferedWriter.flush();
this.e = SystemUtils.a();
bufferedWriter.close();
fileWriter.close();
} finally {
}
} finally {
}
} catch (Exception e2) {
XLog.a("PeripheralConnections", "Save file fail!", e2);
}
}
private boolean a(TopologyPartData.TopologyPartType topologyPartType, int i) {
for (TopologyPartData topologyPartData : this.a) {
if (topologyPartData.b == topologyPartType && topologyPartData.a == i) {
return true;
}
}
return false;
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:84:0x0166 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Type inference failed for: r2v0, types: [long] */
/* JADX WARN: Type inference failed for: r2v1 */
/* JADX WARN: Type inference failed for: r2v3, types: [java.io.BufferedReader] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void a(java.lang.String r13) {
/*
Method dump skipped, instructions count: 362
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.connect.model.PeripheralConnections.a(java.lang.String):void");
}
private <T> String b(List<T> list) {
StringBuffer stringBuffer = new StringBuffer();
Iterator<T> it = list.iterator();
while (it.hasNext()) {
stringBuffer.append(it.next());
stringBuffer.append(",");
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
return stringBuffer.toString();
}
public ServoMode a(Integer num) {
if (this.c.containsKey(num)) {
return this.c.get(num);
}
return ServoMode.SERVO_MODE_ANGLE;
}
public void a(Integer num, ServoMode servoMode) {
this.c.put(num, servoMode);
}
}

View File

@@ -0,0 +1,75 @@
package com.ubt.jimu.connect.model;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.data.ServoMode;
import com.ubt.jimu.base.entities.User;
import com.ubtech.utils.XLog;
import com.ubtrobot.jimu.robotapi.JimuManager;
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public class ReadAllServoModel {
private JimuManager a;
public ReadAllServoModel(JimuManager jimuManager) {
this.a = jimuManager;
}
public List<ServoAngleReadInfo> a(String str, boolean z) {
ServoAngleReadInfo servoAngleReadInfo;
PeripheralConnections a = PeripheralConnections.a(str, a(), z);
if (a == null) {
return null;
}
ArrayList arrayList = new ArrayList();
for (Map.Entry<Integer, ServoMode> entry : a.c().entrySet()) {
if (entry != null && entry.getValue() == ServoMode.SERVO_MODE_ANGLE) {
try {
servoAngleReadInfo = this.a.b(entry.getKey().intValue(), true);
} catch (Exception e) {
XLog.a("ReadAllServoModel", "Read servo " + entry.getKey() + " angle fail!", e);
servoAngleReadInfo = null;
}
if (servoAngleReadInfo != null) {
if (servoAngleReadInfo.a() < 2.0f) {
servoAngleReadInfo.b(5.0f);
arrayList.add(servoAngleReadInfo);
} else if (servoAngleReadInfo.a() > 238.0f) {
servoAngleReadInfo.b(235.0f);
arrayList.add(servoAngleReadInfo);
}
}
}
}
return arrayList;
}
public void a(List<ServoAngleReadInfo> list) {
if (list == null || list.size() == 0) {
return;
}
int[] iArr = new int[list.size()];
float[] fArr = new float[list.size()];
for (int i = 0; i < list.size(); i++) {
ServoAngleReadInfo servoAngleReadInfo = list.get(i);
iArr[i] = servoAngleReadInfo.b();
fArr[i] = servoAngleReadInfo.c();
}
try {
this.a.a(iArr, fArr, 400, 100);
} catch (Exception e) {
XLog.a("ReadAllServoModel", "setServoAngle fail", e);
}
}
private String a() {
User user = Cache.getInstance().getUser();
if (user == null) {
return "local";
}
return user.getUserId() + "";
}
}

View File

@@ -0,0 +1,22 @@
package com.ubt.jimu.connect.model;
import com.ubt.jimu.base.data.ServoMode;
import com.ubtrobot.jimu.robotapi.PeripheralType;
/* loaded from: classes.dex */
public class ServoComponent extends Component {
private ServoMode e;
public ServoComponent(int i, ErrorType errorType) {
super(PeripheralType.SERVO, i, errorType);
this.e = ServoMode.SERVO_MODE_ANGLE;
}
public void a(ServoMode servoMode) {
this.e = servoMode;
}
public ServoMode f() {
return this.e;
}
}

View File

@@ -0,0 +1,152 @@
package com.ubt.jimu.connect.model;
import com.ubtech.utils.XLog;
/* loaded from: classes.dex */
public class TopologyPartData {
public int a;
public TopologyPartType b;
public boolean c;
public int d;
public int e;
public enum TopologyPartType {
None(0),
Infrared(1),
Touch(2),
Gyro(3),
Light(4),
Gravity(5),
Ultrasonic(6),
DigitalTube(7),
Speaker(8),
EnLight(9),
Atmosphere(10),
Compass(11),
Temperature(12),
Color(13),
RgbLight(14),
Motor(15),
MainBoard(16),
MainBoard_new_low(17),
Servo(18),
Line(19),
Line_Angle(20);
private int value;
TopologyPartType(int i) {
this.value = i;
}
public static TopologyPartType getEnumType(int i) {
for (TopologyPartType topologyPartType : values()) {
if (topologyPartType.getTypeVal() == i) {
return topologyPartType;
}
}
return null;
}
public int getTypeVal() {
return this.value;
}
}
public TopologyPartData(TopologyPartType topologyPartType, int i, boolean z) {
this.a = i;
this.b = topologyPartType;
this.c = z;
this.d = 0;
this.e = 0;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.a);
sb.append(' ');
sb.append(this.b.toString());
sb.append(' ');
if (this.c) {
sb.append("True");
} else {
sb.append("False");
}
sb.append(' ');
sb.append("0,0");
sb.append(' ');
sb.append("0,0,0");
sb.append(' ');
sb.append(this.d);
sb.append(' ');
sb.append(this.e);
return sb.toString();
}
public TopologyPartData() {
this.a = 0;
this.b = TopologyPartType.Servo;
this.c = false;
this.d = 0;
this.e = 0;
}
public TopologyPartData(String str) {
try {
String[] split = str.split(" ");
int length = split.length;
for (int i = 0; i < length; i++) {
switch (i) {
case 0:
try {
this.a = Integer.valueOf(split[i]).intValue();
break;
} catch (NumberFormatException unused) {
this.a = 0;
break;
}
case 1:
try {
try {
int intValue = Integer.valueOf(split[i]).intValue();
this.b = TopologyPartType.getEnumType(intValue >= 8 ? intValue + 1 : intValue);
break;
} catch (Exception e) {
XLog.a("TopologyPartData", "get type" + split[i] + " - TopologyPartData error", e);
break;
}
} catch (NumberFormatException unused2) {
this.b = (TopologyPartType) Enum.valueOf(TopologyPartType.class, split[i]);
break;
}
case 2:
try {
this.c = Boolean.valueOf(split[i]).booleanValue();
break;
} catch (Exception unused3) {
XLog.b("TopologyPartData", "get ");
break;
}
case 5:
try {
this.d = Integer.valueOf(split[i]).intValue();
break;
} catch (Exception e2) {
XLog.a("TopologyPartData", "Get device width fail", e2);
break;
}
case 6:
try {
this.e = Integer.valueOf(split[i]).intValue();
break;
} catch (Exception e3) {
XLog.a("TopologyPartData", "Get device width fail", e3);
break;
}
}
}
} catch (Exception e4) {
XLog.a("TopologyPartData", "", e4);
}
}
}

View File

@@ -0,0 +1,347 @@
package com.ubt.jimu.connect.model;
import android.content.Context;
import android.text.TextUtils;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.R;
import com.ubt.jimu.base.db.robot.FirmwareVersionDbHandler;
import com.ubt.jimu.base.entities.FirmwareVersion;
import com.ubtech.utils.FileHelper;
import com.ubtrobot.jimu.Firmware;
import com.ubtrobot.jimu.robotapi.BoardInfo;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
/* loaded from: classes.dex */
public class UpdateModelImp implements IUpdateModel {
public static final Long b;
public static final Long c;
public static final Long d;
public static final Long e;
public static final Long f;
public static final Long g;
public static final Long h;
public static final Long i;
public static final Long j;
public static final Long k;
public static final Long l;
public static final Long m;
private boolean a;
private static class Holder {
private static final UpdateModelImp a = new UpdateModelImp();
}
static {
Long.valueOf(-1L);
b = 3L;
c = 4L;
d = 5L;
e = 101L;
f = 102L;
g = 103L;
h = 104L;
i = 105L;
j = 106L;
k = 107L;
l = 108L;
m = 109L;
}
public static int a(long j2) {
if (b.longValue() == j2) {
return 112;
}
if (d.longValue() == j2) {
return 113;
}
if (c.longValue() == j2) {
return PeripheralType.SERVO;
}
if (e.longValue() == j2) {
return 1;
}
if (f.longValue() == j2) {
return 2;
}
if (g.longValue() == j2) {
return 3;
}
if (h.longValue() == j2) {
return 4;
}
if (i.longValue() == j2) {
return 5;
}
if (j.longValue() == j2) {
return 6;
}
if (k.longValue() == j2) {
return 7;
}
if (l.longValue() == j2) {
return 8;
}
return m.longValue() == j2 ? 9 : -1;
}
public static UpdateModelImp b() {
return Holder.a;
}
@Override // com.ubt.jimu.connect.model.IUpdateModel
public boolean c(BoardInfo boardInfo) {
List<Firmware> a = a(boardInfo);
return (a == null || a.size() == 0) ? false : true;
}
@Override // com.ubt.jimu.connect.model.IUpdateModel
public boolean d(BoardInfo boardInfo) {
Iterator<Firmware> it = a(boardInfo).iterator();
while (it.hasNext()) {
if (it.next().e()) {
return true;
}
}
return false;
}
private UpdateModelImp() {
this.a = false;
}
private List<Firmware> b(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
ArrayList arrayList = new ArrayList();
HashMap<Integer, BoardInfo.SensorBoardInfo> h2 = boardInfo.h();
if (h2 != null && h2.size() != 0) {
for (Integer num : h2.keySet()) {
BoardInfo.SensorBoardInfo sensorBoardInfo = h2.get(num);
List<Integer> b2 = sensorBoardInfo.b();
List<Integer> d2 = sensorBoardInfo.d();
if ((b2 != null && b2.size() != 0) || (d2 != null && d2.size() != 0)) {
FirmwareVersion firmwareVersion = hashMap.get(num);
if (firmwareVersion != null) {
if (!firmwareVersion.getVersionName().equals(sensorBoardInfo.c())) {
ArrayList arrayList2 = new ArrayList();
if (b2 != null && b2.size() > 0) {
arrayList2.addAll(b2);
}
if (d2 != null && d2.size() > 0) {
arrayList2.addAll(d2);
}
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
arrayList.add(a(firmwareVersion, ((Integer) it.next()).intValue()));
}
} else if (d2 != null && d2.size() > 0) {
Iterator<Integer> it2 = d2.iterator();
while (it2.hasNext()) {
arrayList.add(a(firmwareVersion, it2.next().intValue()));
}
}
}
}
}
}
return arrayList;
}
private List<Firmware> c(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
ArrayList arrayList = new ArrayList();
List<Integer> k2 = boardInfo.k();
String j2 = boardInfo.j();
FirmwareVersion firmwareVersion = hashMap.get(Integer.valueOf(PeripheralType.SERVO));
if (firmwareVersion != null) {
if (!TextUtils.isEmpty(j2) && !j2.equals(firmwareVersion.getVersionName())) {
ArrayList arrayList2 = new ArrayList();
if (boardInfo.i() != null && boardInfo.i().size() > 0) {
arrayList2.addAll(boardInfo.i());
}
if (k2 != null && k2.size() > 0) {
arrayList2.addAll(boardInfo.a());
}
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
arrayList.add(a(firmwareVersion, ((Integer) it.next()).intValue()));
}
} else if (k2 != null && k2.size() > 0) {
Iterator<Integer> it2 = boardInfo.a().iterator();
while (it2.hasNext()) {
arrayList.add(a(firmwareVersion, it2.next().intValue()));
}
}
}
return arrayList;
}
public static Firmware a(FirmwareVersion firmwareVersion, int i2) {
return new Firmware(a(firmwareVersion.getVersionType().longValue()), firmwareVersion.getVersionName(), FirmwareVersion.getPath(JimuApplication.l(), firmwareVersion), firmwareVersion.getVersionCRCCode(), i2, firmwareVersion.IsForced());
}
public static String a(Context context, long j2) {
if (j2 == 112 || j2 == 113) {
return context.getString(R.string.main_board);
}
if (j2 == 128) {
return context.getString(R.string.servo);
}
if (j2 == 10) {
return context.getString(R.string.motor);
}
if (j2 == 1) {
return context.getString(R.string.infrared);
}
if (j2 == 2) {
return context.getString(R.string.touch);
}
if (j2 == 3) {
return context.getString(R.string.gyro);
}
if (j2 == 4) {
return context.getString(R.string.led);
}
if (j2 == 5) {
return context.getString(R.string.gravity);
}
if (j2 == 6) {
return context.getString(R.string.ultrasound);
}
if (j2 == 7) {
return context.getString(R.string.digitaltube);
}
if (j2 == 8) {
return context.getString(R.string.speaker);
}
if (j2 == 9) {
return context.getString(R.string.color);
}
if (j2 == 14) {
return context.getString(R.string.unicorn_led);
}
int i2 = (j2 > 11L ? 1 : (j2 == 11L ? 0 : -1));
return "";
}
@Override // com.ubt.jimu.connect.model.IUpdateModel
public boolean b(BoardInfo boardInfo) {
return boardInfo == null || boardInfo.c() != 0 || boardInfo.b() >= 7.4f;
}
@Override // com.ubt.jimu.connect.model.IUpdateModel
public List<Firmware> a(BoardInfo boardInfo) {
if (boardInfo == null) {
return null;
}
ArrayList arrayList = new ArrayList();
List<FirmwareVersion> a = a();
HashMap<Integer, FirmwareVersion> hashMap = new HashMap<>();
for (FirmwareVersion firmwareVersion : a) {
hashMap.put(Integer.valueOf(a(firmwareVersion.getVersionType().longValue())), firmwareVersion);
}
Firmware a2 = a(boardInfo, hashMap);
if (a2 != null) {
arrayList.add(a2);
}
List<Firmware> c2 = c(boardInfo, hashMap);
if (c2 != null && c2.size() > 0) {
arrayList.addAll(c2);
}
List<Firmware> b2 = b(boardInfo, hashMap);
if (b2 != null && b2.size() > 0) {
arrayList.addAll(b2);
}
return arrayList;
}
public List<Firmware> a(List<Firmware> list) {
ArrayList arrayList = new ArrayList();
if (list != null && list.size() != 0) {
Firmware firmware = null;
ArrayList arrayList2 = new ArrayList();
LinkedHashMap linkedHashMap = new LinkedHashMap();
for (Firmware firmware2 : list) {
if (firmware2.c() == 112 || firmware2.c() == 113) {
firmware = firmware2;
} else if (firmware2.c() == 128) {
arrayList2.add(firmware2);
} else {
List list2 = (List) linkedHashMap.get(Integer.valueOf(firmware2.c()));
if (list2 == null) {
list2 = new ArrayList();
linkedHashMap.put(Integer.valueOf(firmware2.c()), list2);
}
list2.add(firmware2);
}
}
if (firmware != null) {
arrayList.add(firmware);
}
if (arrayList2.size() > 0) {
Firmware firmware3 = (Firmware) arrayList2.get(0);
if (arrayList2.size() > 1) {
firmware3.a(0);
}
arrayList.add(firmware3);
}
if (linkedHashMap.size() > 0) {
Iterator it = linkedHashMap.keySet().iterator();
while (it.hasNext()) {
List list3 = (List) linkedHashMap.get((Integer) it.next());
if (list3 != null && list3.size() > 0) {
Firmware firmware4 = (Firmware) list3.get(0);
if (list3.size() > 1) {
firmware4.a(0);
}
arrayList.add(firmware4);
}
}
}
}
return arrayList;
}
private Firmware a(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
if (boardInfo == null) {
return null;
}
String d2 = boardInfo.d();
int e2 = boardInfo.e();
int i2 = 0;
if (112 == e2) {
i2 = 112;
} else if (113 == e2) {
i2 = 113;
}
FirmwareVersion firmwareVersion = hashMap.get(i2);
if (firmwareVersion == null) {
return null;
}
if (!TextUtils.isEmpty(d2) && !d2.equals(firmwareVersion.getVersionName())) {
return a(firmwareVersion, 0);
}
if (this.a) {
return a(firmwareVersion, 0);
}
return null;
}
private List<FirmwareVersion> a() {
ArrayList arrayList = new ArrayList();
List<FirmwareVersion> selectAll = FirmwareVersionDbHandler.getInstance().selectAll();
if (selectAll != null && selectAll.size() != 0) {
for (FirmwareVersion firmwareVersion : selectAll) {
String path = FirmwareVersion.getPath(JimuApplication.l(), firmwareVersion);
if (new File(path).exists() && FileHelper.a(firmwareVersion.getVersionCRCCode(), path)) {
firmwareVersion.setVersionPath(path);
arrayList.add(firmwareVersion);
}
}
}
return arrayList;
}
}