Initial commit
This commit is contained in:
154
sources/com/ubt/jimu/transport3/upgrade/BlocklyUpgrade.java
Normal file
154
sources/com/ubt/jimu/transport3/upgrade/BlocklyUpgrade.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
|
||||
import com.ubt.jimu.gen.TransportFileDao;
|
||||
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.StringUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BlocklyUpgrade {
|
||||
private final String TAG = "upgrade";
|
||||
private BlocklyProjectDbHandler programDbHandler = BlocklyProjectDbHandler.getInstance();
|
||||
private DiyDBModelDBHandler modelDBHandler = DiyDBModelDBHandler.getInstance();
|
||||
private ConfigItemDbHandler itemDbHandler = ConfigItemDbHandler.getInstance();
|
||||
private TransportFileDbHandler2 fileDbHandler = TransportFileDbHandler2.getInstance();
|
||||
private JimuSoundDbHandler soundDbHandler = JimuSoundDbHandler.getInstance();
|
||||
private JimuMotionDbHandler motionDbHandler = JimuMotionDbHandler.getInstance();
|
||||
|
||||
private static class Model {
|
||||
public String customModelId;
|
||||
public long modelId;
|
||||
|
||||
public Model(String str, long j) {
|
||||
this.customModelId = str;
|
||||
this.modelId = j;
|
||||
}
|
||||
}
|
||||
|
||||
private void tableBlockly() {
|
||||
try {
|
||||
List<BlocklyProject> selectAll = this.programDbHandler.selectAll();
|
||||
if (selectAll != null && selectAll.size() != 0) {
|
||||
List<DiyDBModel> selectAll2 = this.modelDBHandler.selectAll();
|
||||
HashMap hashMap = new HashMap();
|
||||
if (selectAll2 != null && selectAll2.size() > 0) {
|
||||
for (DiyDBModel diyDBModel : selectAll2) {
|
||||
hashMap.put(diyDBModel.getCustomModelId(), diyDBModel);
|
||||
}
|
||||
}
|
||||
long a = SystemUtils.a();
|
||||
for (BlocklyProject blocklyProject : selectAll) {
|
||||
long j = 0;
|
||||
if (StringUtils.f(blocklyProject.getCustomModelId())) {
|
||||
DiyDBModel diyDBModel2 = (DiyDBModel) hashMap.get(blocklyProject.getCustomModelId());
|
||||
if (diyDBModel2.getModelId() != null) {
|
||||
j = diyDBModel2.getModelId().intValue();
|
||||
}
|
||||
} else {
|
||||
QueryBuilder<TransportFile> queryBuilder = this.fileDbHandler.getQueryBuilder();
|
||||
queryBuilder.a(TransportFileDao.Properties.FileName.a((Object) (blocklyProject.getXmlId() + ".xml")), new WhereCondition[0]);
|
||||
List<TransportFile> query = this.fileDbHandler.query(queryBuilder);
|
||||
if (query != null && query.size() > 0) {
|
||||
j = query.get(0).getModelId();
|
||||
}
|
||||
}
|
||||
blocklyProject.setModelId(j);
|
||||
blocklyProject.setLastUploadTime(a);
|
||||
blocklyProject.setIsModify(true);
|
||||
blocklyProject.setIsUploadQiNiu(false);
|
||||
blocklyProject.setIsUploadService(false);
|
||||
blocklyProject.setIsFirst(0);
|
||||
}
|
||||
this.programDbHandler.updateInTx(selectAll);
|
||||
ALog.a("upgrade").d("编程案例升级:" + selectAll.size());
|
||||
return;
|
||||
}
|
||||
ALog.a("upgrade").d("编程案例升级:0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void tableJimuMotion() {
|
||||
try {
|
||||
List<JimuMotion> selectAll = this.motionDbHandler.selectAll();
|
||||
if (selectAll != null && selectAll.size() != 0) {
|
||||
List<Robot> selectAll2 = RobotDbHandler.getInstance().selectAll();
|
||||
List<DiyDBModel> selectAll3 = DiyDBModelDBHandler.getInstance().selectAll();
|
||||
HashMap hashMap = new HashMap();
|
||||
if (selectAll2 != null && selectAll2.size() > 0) {
|
||||
for (Robot robot : selectAll2) {
|
||||
hashMap.put(robot.getModelName(), new Model(robot.getModelName(), robot.getModelId()));
|
||||
}
|
||||
}
|
||||
if (selectAll3 != null && selectAll3.size() > 0) {
|
||||
for (DiyDBModel diyDBModel : selectAll3) {
|
||||
hashMap.put(diyDBModel.getCustomModelId(), new Model(diyDBModel.getCustomModelId(), diyDBModel.getModelId().intValue()));
|
||||
}
|
||||
}
|
||||
long a = SystemUtils.a();
|
||||
for (JimuMotion jimuMotion : selectAll) {
|
||||
jimuMotion.setLastUploadTime(a);
|
||||
jimuMotion.setIsFirst(0);
|
||||
jimuMotion.setIsUploadService(false);
|
||||
ALog.a("upgrade").d("JimuMotion: " + jimuMotion.getActionName() + " " + jimuMotion.getActionID());
|
||||
Model model = (Model) hashMap.get(jimuMotion.getCustomModelId());
|
||||
if (model != null) {
|
||||
jimuMotion.setModelId((int) model.modelId);
|
||||
}
|
||||
}
|
||||
this.motionDbHandler.updateInTx(selectAll);
|
||||
return;
|
||||
}
|
||||
ALog.a("upgrade").d("动作帧升级:0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void tableJimuSound() {
|
||||
try {
|
||||
List<JimuSound> selectAll = this.soundDbHandler.selectAll();
|
||||
if (selectAll != null && selectAll.size() != 0) {
|
||||
long a = SystemUtils.a();
|
||||
for (JimuSound jimuSound : selectAll) {
|
||||
jimuSound.setLastUploadTime(a);
|
||||
jimuSound.setUploadQiNiu(false);
|
||||
jimuSound.setSyncUbtService(false);
|
||||
jimuSound.setIsFirst(0);
|
||||
jimuSound.setAudioId(jimuSound.getKey());
|
||||
ALog.a("upgrade").d("JimuSound:" + jimuSound.getDescription() + " " + jimuSound.getKey());
|
||||
}
|
||||
this.soundDbHandler.updateInTx(selectAll);
|
||||
ALog.a("upgrade").d("录音升级:" + selectAll.size());
|
||||
return;
|
||||
}
|
||||
ALog.a("upgrade").d("录音升级:0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
tableBlockly();
|
||||
tableJimuSound();
|
||||
tableJimuMotion();
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.diy.DiyRobotDbHandler;
|
||||
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DiyDBModelUpgrade {
|
||||
private final String TAG = "upgrade";
|
||||
private DiyDBModelDBHandler modelDBHandler = DiyDBModelDBHandler.getInstance();
|
||||
|
||||
public void upgrade() {
|
||||
List<DiyDBModel> selectAll = this.modelDBHandler.selectAll();
|
||||
if (selectAll == null || selectAll.size() == 0) {
|
||||
ALog.a("upgrade").d("DIY 模型升级:0");
|
||||
return;
|
||||
}
|
||||
long a = SystemUtils.a();
|
||||
for (DiyDBModel diyDBModel : selectAll) {
|
||||
try {
|
||||
diyDBModel.setModelId(0);
|
||||
diyDBModel.setCustomModelCreatetime(SystemUtils.a(Utils.formatFileCreateTime(diyDBModel.getCustomModelId())));
|
||||
diyDBModel.setLastUploadTime(a);
|
||||
diyDBModel.setIsModify(true);
|
||||
if (!TextUtils.isEmpty(diyDBModel.getDescription())) {
|
||||
diyDBModel.setStep1state(1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(diyDBModel.getModelCreatedId())) {
|
||||
File file = new File(DiyRobotDbHandler.getCustomModelPath(diyDBModel.getModelCreatedId()) + File.separator + diyDBModel.getCustomModelId() + File.separator + "actions");
|
||||
if (file.exists() && file.listFiles().length > 0) {
|
||||
diyDBModel.setStep3state(1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.modelDBHandler.updateInTx(selectAll);
|
||||
ALog.a("upgrade").d("DIY 模型升级:" + selectAll.size());
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.gen.TransportFileDao;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.DiyModelActionDBHandler;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.transport3.model.DiyModelAction;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DiyModelActionUpgrade {
|
||||
private final String TAG = "upgrade";
|
||||
private final String REG_LIKE_ACTION = "%actions%";
|
||||
private TransportFileDbHandler2 fileDbHandler = TransportFileDbHandler2.getInstance();
|
||||
private DiyModelActionDBHandler actionDbHandler = DiyModelActionDBHandler.getInstance();
|
||||
|
||||
private DiyModelAction fromTransportFile(TransportFile transportFile) {
|
||||
DiyModelAction diyModelAction = new DiyModelAction();
|
||||
diyModelAction.setUserId(transportFile.getUserId());
|
||||
diyModelAction.setModelId(Integer.parseInt(String.valueOf(transportFile.getModelId())));
|
||||
diyModelAction.setCustomModelId(transportFile.getCustomModelId());
|
||||
diyModelAction.setModelType(Integer.parseInt(transportFile.getModelType()));
|
||||
diyModelAction.setFileUrl(transportFile.getFileUrl());
|
||||
diyModelAction.setFileName(transportFile.getFileName());
|
||||
diyModelAction.setServerId(0L);
|
||||
diyModelAction.setUploaded(false);
|
||||
diyModelAction.setModify(true);
|
||||
long a = SystemUtils.a();
|
||||
diyModelAction.setCreateTime(a);
|
||||
diyModelAction.setModifyTime(a);
|
||||
diyModelAction.setLastUploadTime(a);
|
||||
diyModelAction.setIsDeleted(transportFile.getIsDeleted() ? 1 : 0);
|
||||
String filePath = transportFile.getFilePath();
|
||||
if (!TextUtils.isEmpty(filePath)) {
|
||||
int indexOf = filePath.indexOf("/");
|
||||
int lastIndexOf = filePath.lastIndexOf("/");
|
||||
int i = indexOf + 1;
|
||||
if (i <= lastIndexOf) {
|
||||
diyModelAction.setCustomModelId(filePath.substring(i, lastIndexOf));
|
||||
}
|
||||
}
|
||||
return diyModelAction;
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
try {
|
||||
QueryBuilder<TransportFile> queryBuilder = this.fileDbHandler.getQueryBuilder();
|
||||
queryBuilder.a(TransportFileDao.Properties.FileName.a("%actions%"), TransportFileDao.Properties.FilePath.a("%actions%"));
|
||||
List<TransportFile> query = this.fileDbHandler.query(queryBuilder);
|
||||
if (query != null && query.size() != 0) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (TransportFile transportFile : query) {
|
||||
if (!transportFile.getIsDeleted()) {
|
||||
DiyModelAction fromTransportFile = fromTransportFile(transportFile);
|
||||
arrayList.add(fromTransportFile);
|
||||
ALog.a("upgrade").d("DiyModelAction: " + fromTransportFile.getUserId() + fromTransportFile.getCustomModelId() + " " + fromTransportFile.getFileName());
|
||||
}
|
||||
}
|
||||
this.actionDbHandler.insertInTx(arrayList);
|
||||
this.fileDbHandler.deleteInTx(query);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,186 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FileAndDirectoryUpgrade {
|
||||
private static final String DOT_JPG = ".jpg";
|
||||
private static final String DOT_MP4 = ".mp4";
|
||||
public static final String REG_IMAGE = ".+(.JPEG|.jpeg|.JPG|.jpg|.PNG|.png)$";
|
||||
public static final String REG_VIDEO = ".+(.mp4|.MP4)$";
|
||||
private final String TAG = "upgrade";
|
||||
private TransportFileDbHandler2 fileDbHandler = TransportFileDbHandler2.getInstance();
|
||||
private DiyDBModelDBHandler modelDBHandler = DiyDBModelDBHandler.getInstance();
|
||||
private String usersPath;
|
||||
|
||||
public FileAndDirectoryUpgrade(Context context) {
|
||||
this.usersPath = ExternalOverFroyoUtils.a(context, (ModelType) null) + "users";
|
||||
}
|
||||
|
||||
private void amendment(File file) {
|
||||
File[] listFiles;
|
||||
String str = file.getAbsolutePath() + File.separator + "playerdata";
|
||||
File file2 = new File(str);
|
||||
if (!file2.exists()) {
|
||||
ALog.a("upgrade").d("这个用户没有playerdata目录: " + str);
|
||||
return;
|
||||
}
|
||||
File[] listFiles2 = file2.listFiles();
|
||||
if (listFiles2 == null || listFiles2.length == 0) {
|
||||
ALog.a("upgrade").d("这个用户没有diy模型:" + str);
|
||||
return;
|
||||
}
|
||||
String name = file.getName();
|
||||
for (File file3 : listFiles2) {
|
||||
try {
|
||||
listFiles = file3.listFiles();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (listFiles != null && listFiles.length != 0) {
|
||||
DiyDBModel selectUnique = this.modelDBHandler.selectUnique(name, file3.getName());
|
||||
if (selectUnique == null) {
|
||||
ALog.a("upgrade").d("异常,这个模型没有记录在数据库");
|
||||
} else {
|
||||
renameLogo(selectUnique, file3);
|
||||
renameShowVideo(selectUnique, file3);
|
||||
renameShowImage(selectUnique, file3);
|
||||
}
|
||||
}
|
||||
ALog.a("upgrade").d("这个模型没有文件:" + file3.getAbsoluteFile());
|
||||
}
|
||||
}
|
||||
|
||||
private TransportFile createModelFile(DiyDBModel diyDBModel, String str, String str2, String str3, String str4) {
|
||||
long formatFileCreateTime = Utils.formatFileCreateTime(str2);
|
||||
TransportFile transportFile = new TransportFile();
|
||||
transportFile.setUserId(str);
|
||||
transportFile.setModelType(String.valueOf(2));
|
||||
transportFile.setCustomModelId(str2);
|
||||
transportFile.setFileType(str3);
|
||||
transportFile.setFilePath(TransportFileDbHandler.getFilePath(new File(str4)));
|
||||
transportFile.setFileName(FileHelper.a(str4));
|
||||
transportFile.setId(0L);
|
||||
transportFile.setIsModify(true);
|
||||
transportFile.setUploaded(false);
|
||||
transportFile.setCreateTime(SystemUtils.a(formatFileCreateTime));
|
||||
transportFile.setModifyTime(SystemUtils.a(formatFileCreateTime));
|
||||
transportFile.setLastUploadTime(SystemUtils.a(formatFileCreateTime));
|
||||
transportFile.setModelId(diyDBModel.getModelId().intValue());
|
||||
TransportFile selectUnique = this.fileDbHandler.selectUnique(transportFile);
|
||||
if (selectUnique != null) {
|
||||
transportFile.setCustomFileId(selectUnique.getCustomFileId());
|
||||
}
|
||||
this.fileDbHandler.insertOrUpdate(transportFile);
|
||||
ALog.a("upgrade").d("创建了一个新文件:" + str2 + " " + str3 + " " + transportFile.getFilePath() + " " + transportFile.getFileName());
|
||||
return transportFile;
|
||||
}
|
||||
|
||||
private boolean renameLogo(DiyDBModel diyDBModel, File file) {
|
||||
String filePath = diyDBModel.getFilePath();
|
||||
if (TextUtils.isEmpty(filePath)) {
|
||||
return false;
|
||||
}
|
||||
ALog.a("upgrade").d(filePath);
|
||||
String customModelId = diyDBModel.getCustomModelId();
|
||||
String modelCreatedId = diyDBModel.getModelCreatedId();
|
||||
if (filePath.lastIndexOf("/") < 0) {
|
||||
return false;
|
||||
}
|
||||
if (filePath.substring(filePath.lastIndexOf("/")).contains(customModelId)) {
|
||||
return true;
|
||||
}
|
||||
String str = file.getAbsolutePath() + File.separator + customModelId + DOT_JPG;
|
||||
if (!FileHelper.c(filePath, str)) {
|
||||
ALog.a("upgrade").b("重命名模型logo失败!", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
diyDBModel.setFilePath(str);
|
||||
createModelFile(diyDBModel, modelCreatedId, customModelId, "bg", str);
|
||||
ALog.a("upgrade").d("重命名了一张logo:" + diyDBModel.getModelName() + " " + diyDBModel.getCustomModelId());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean renameShowImage(DiyDBModel diyDBModel, File file) {
|
||||
String step5desc = diyDBModel.getStep5desc();
|
||||
if (TextUtils.isEmpty(step5desc)) {
|
||||
return false;
|
||||
}
|
||||
ALog.a("upgrade").d(step5desc);
|
||||
if (!new File(step5desc).exists()) {
|
||||
return false;
|
||||
}
|
||||
String customModelId = diyDBModel.getCustomModelId();
|
||||
String str = file.getAbsolutePath() + File.separator + TransportFile.MODEL_SHOW_DIR;
|
||||
File file2 = new File(str);
|
||||
if (!file2.exists()) {
|
||||
file2.mkdirs();
|
||||
}
|
||||
String str2 = str + File.separator + customModelId + DOT_JPG;
|
||||
if (!FileHelper.c(step5desc, str2)) {
|
||||
return false;
|
||||
}
|
||||
diyDBModel.setStep5desc(str2);
|
||||
ALog.a("upgrade").d("拷贝创意展示视频第一帧成功:" + diyDBModel.getModelName() + " " + diyDBModel.getCustomModelId());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean renameShowVideo(DiyDBModel diyDBModel, File file) {
|
||||
String step5PathDesc = diyDBModel.getStep5PathDesc();
|
||||
if (TextUtils.isEmpty(step5PathDesc)) {
|
||||
return false;
|
||||
}
|
||||
ALog.a("upgrade").d(step5PathDesc);
|
||||
if (!new File(step5PathDesc).exists()) {
|
||||
return false;
|
||||
}
|
||||
String modelCreatedId = diyDBModel.getModelCreatedId();
|
||||
String customModelId = diyDBModel.getCustomModelId();
|
||||
String str = file.getAbsolutePath() + File.separator + TransportFile.MODEL_SHOW_DIR;
|
||||
File file2 = new File(str);
|
||||
if (!file2.exists()) {
|
||||
file2.mkdirs();
|
||||
}
|
||||
String str2 = str + File.separator + customModelId + DOT_MP4;
|
||||
if (!FileHelper.c(step5PathDesc, str2)) {
|
||||
return false;
|
||||
}
|
||||
diyDBModel.setStep5PathDesc(str2);
|
||||
createModelFile(diyDBModel, modelCreatedId, customModelId, TransportFile.TYPE_DIY_SHOW, str2);
|
||||
ALog.a("upgrade").d("拷贝了一个创意视频:" + diyDBModel.getModelName() + " " + diyDBModel.getCustomModelId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
File file = new File(this.usersPath);
|
||||
if (!file.exists()) {
|
||||
ALog.a("upgrade").d("用户目录不存在,没有数据:" + this.usersPath);
|
||||
return;
|
||||
}
|
||||
File[] listFiles = file.listFiles();
|
||||
if (listFiles == null || listFiles.length == 0) {
|
||||
ALog.a("upgrade").d("没有任何用户的数据");
|
||||
return;
|
||||
}
|
||||
for (File file2 : listFiles) {
|
||||
try {
|
||||
amendment(file2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class TransportFileUpgrade {
|
||||
private final String TAG = "upgrade";
|
||||
private final String REG_DESC_FILE = "^(default|playerdata)/\\d{13,18}/\\d{13,18}(.xml)$";
|
||||
private final String REG_PROGRAM_FILE = "^(default|playerdata)/(\\d{13,18}|\\w+)/(\\d{13,18}|\\w+)";
|
||||
private final String REG_ACTION_FILE = "^(default|playerdata)/(\\d{13,18}|\\w+)/actions";
|
||||
private final String REG_SERVO_FILE = "^(default|playerdata)/\\d{13,18}/servos";
|
||||
TransportFileDbHandler2 fileDbHandler = TransportFileDbHandler2.getInstance();
|
||||
|
||||
private String getFileType(TransportFile transportFile) {
|
||||
String fileName = transportFile.getFileName();
|
||||
String filePath = transportFile.getFilePath();
|
||||
if (TextUtils.isEmpty(fileName) || TextUtils.isEmpty(filePath)) {
|
||||
return TransportFile.TYPE_NONE;
|
||||
}
|
||||
String str = filePath + File.separator + fileName;
|
||||
return com.ubt.jimu.utils.TextUtils.a(fileName, FileAndDirectoryUpgrade.REG_IMAGE) ? "bg" : com.ubt.jimu.utils.TextUtils.a(fileName, FileAndDirectoryUpgrade.REG_VIDEO) ? TransportFile.TYPE_DIY_SHOW : com.ubt.jimu.utils.TextUtils.a(str, "^(default|playerdata)/\\d{13,18}/servos") ? "conn" : filePath.contains(TransportFile.MODEL_CONTROLLER_DIR) ? TransportFile.TYPE_CONTROLLER : com.ubt.jimu.utils.TextUtils.a(str, "^(default|playerdata)/(\\d{13,18}|\\w+)/actions") ? "action" : com.ubt.jimu.utils.TextUtils.a(str, "^(default|playerdata)/\\d{13,18}/\\d{13,18}(.xml)$") ? "desc" : filePath.contains(TransportFileDbHandler2.DIR_SOUNDS) ? !JimuRobot.SOUNDS.equals(transportFile.getFileName()) ? "audio" : TransportFile.TYPE_NONE : com.ubt.jimu.utils.TextUtils.a(str, "^(default|playerdata)/(\\d{13,18}|\\w+)/(\\d{13,18}|\\w+)") ? TransportFile.TYPE_PROGRAM : TransportFile.TYPE_NONE;
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
List<TransportFile> selectAll = this.fileDbHandler.selectAll();
|
||||
if (selectAll == null || selectAll.size() == 0) {
|
||||
ALog.a("upgrade").d("文件表升级:0");
|
||||
return;
|
||||
}
|
||||
long a = SystemUtils.a();
|
||||
int i = 0;
|
||||
for (TransportFile transportFile : selectAll) {
|
||||
try {
|
||||
transportFile.setFileType(getFileType(transportFile));
|
||||
transportFile.setUploaded(false);
|
||||
transportFile.setIsModify(true);
|
||||
transportFile.setModifyTime(a);
|
||||
transportFile.setLastUploadTime(a);
|
||||
transportFile.setId(0L);
|
||||
String filePath = transportFile.getFilePath();
|
||||
if (!TextUtils.isEmpty(filePath)) {
|
||||
int indexOf = filePath.indexOf("/");
|
||||
int lastIndexOf = filePath.lastIndexOf("/");
|
||||
int i2 = indexOf + 1;
|
||||
if (i2 <= lastIndexOf) {
|
||||
transportFile.setCustomModelId(filePath.substring(i2, lastIndexOf));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.fileDbHandler.updateInTx(selectAll);
|
||||
ALog.a("upgrade").d("文件表升级,成功:" + i + " 总数:" + selectAll.size());
|
||||
}
|
||||
}
|
587
sources/com/ubt/jimu/transport3/upgrade/Version2DbUpgrade.java
Normal file
587
sources/com/ubt/jimu/transport3/upgrade/Version2DbUpgrade.java
Normal file
@@ -0,0 +1,587 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.text.TextUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.proxy.data.DataBaseHelper;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.ubt.jimu.diy.DiyRobotDbHandler;
|
||||
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
|
||||
import com.ubt.jimu.transport.model.ConfigItem;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Version2DbUpgrade {
|
||||
private final String TAG = Version2DbUpgrade.class.getSimpleName();
|
||||
private final String TABLE_DIY_MODEL = "CustomModelBean";
|
||||
private final String TABLE_BLOCKLY_PROJECT = "BlocklyProject";
|
||||
private final String TABLE_JIMU_MOTION = "JimuMotion";
|
||||
private final String TABLE_MODEL_FILE = "syncFile";
|
||||
private final String TABLE_CONFIG_ITEM = ConfigItem.TAG;
|
||||
private final String TABLE_ROBOT = "local_model";
|
||||
|
||||
private void close(Cursor cursor) {
|
||||
}
|
||||
|
||||
private void dropTable(SQLiteDatabase sQLiteDatabase, String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sQLiteDatabase.execSQL("drop table " + str);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, DiyDBModel> getSampleModel(SQLiteDatabase sQLiteDatabase) {
|
||||
HashMap hashMap = new HashMap();
|
||||
Cursor query = query(sQLiteDatabase, "local_model");
|
||||
if (query == null) {
|
||||
return hashMap;
|
||||
}
|
||||
int columnIndex = query.getColumnIndex(JockstickDataConverter.ID);
|
||||
int columnIndex2 = query.getColumnIndex("model_id");
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
String string = query.getString(columnIndex);
|
||||
int i = query.getInt(columnIndex2);
|
||||
DiyDBModel diyDBModel = new DiyDBModel();
|
||||
diyDBModel.setCustomModelId(string);
|
||||
diyDBModel.setModelId(Integer.valueOf(i));
|
||||
hashMap.put(string, diyDBModel);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private void migrateBlocklyProject(SQLiteDatabase sQLiteDatabase) {
|
||||
Cursor query = query(sQLiteDatabase, "BlocklyProject");
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int columnIndex = query.getColumnIndex("xmlId");
|
||||
int columnIndex2 = query.getColumnIndex("xmlName");
|
||||
int columnIndex3 = query.getColumnIndex("xmlContent");
|
||||
int columnIndex4 = query.getColumnIndex("isDefault");
|
||||
int columnIndex5 = query.getColumnIndex("blocklyVersion");
|
||||
int columnIndex6 = query.getColumnIndex("blocklyType");
|
||||
int columnIndex7 = query.getColumnIndex("userId");
|
||||
int columnIndex8 = query.getColumnIndex(UnityActivity.pModelType);
|
||||
int columnIndex9 = query.getColumnIndex("customModelId");
|
||||
int columnIndex10 = query.getColumnIndex("isDeleted");
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
try {
|
||||
BlocklyProject blocklyProject = new BlocklyProject();
|
||||
blocklyProject.setXmlId(query.getString(columnIndex));
|
||||
blocklyProject.setXmlName(query.getString(columnIndex2));
|
||||
blocklyProject.setXmlContent(query.getString(columnIndex3));
|
||||
boolean z = true;
|
||||
if (query.getInt(columnIndex4) != 1) {
|
||||
z = false;
|
||||
}
|
||||
blocklyProject.setIsDefault(z);
|
||||
blocklyProject.setBlocklyVersion(query.getString(columnIndex5));
|
||||
blocklyProject.setBlocklyType(query.getString(columnIndex6));
|
||||
blocklyProject.setUserId(query.getString(columnIndex7));
|
||||
blocklyProject.setModelType(query.getString(columnIndex8));
|
||||
blocklyProject.setCustomModelId(query.getString(columnIndex9));
|
||||
blocklyProject.setIsDeleted(query.getString(columnIndex10));
|
||||
arrayList.add(blocklyProject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
close(query);
|
||||
}
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
BlocklyProjectDbHandler.getInstance().insertOrUpdateInTx(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateConfigItem(SQLiteDatabase sQLiteDatabase) {
|
||||
int i;
|
||||
int i2;
|
||||
Version2DbUpgrade version2DbUpgrade;
|
||||
int i3;
|
||||
int i4;
|
||||
ConfigItem configItem;
|
||||
ArrayList arrayList;
|
||||
int i5;
|
||||
int i6;
|
||||
Cursor query = query(sQLiteDatabase, ConfigItem.TAG);
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
int columnIndex = query.getColumnIndex("type");
|
||||
int columnIndex2 = query.getColumnIndex("fileName");
|
||||
int columnIndex3 = query.getColumnIndex(SocialConstants.PARAM_COMMENT);
|
||||
int columnIndex4 = query.getColumnIndex("fileCreateTime");
|
||||
int columnIndex5 = query.getColumnIndex("fileModifyTime");
|
||||
int columnIndex6 = query.getColumnIndex("serverID");
|
||||
int columnIndex7 = query.getColumnIndex("isDeleted");
|
||||
int columnIndex8 = query.getColumnIndex("icon");
|
||||
int columnIndex9 = query.getColumnIndex("blocklyVersion");
|
||||
int columnIndex10 = query.getColumnIndex(UnityActivity.pModelType);
|
||||
int columnIndex11 = query.getColumnIndex("customModelId");
|
||||
int columnIndex12 = query.getColumnIndex("isDefault");
|
||||
int columnIndex13 = query.getColumnIndex("isModify");
|
||||
int columnIndex14 = query.getColumnIndex("userId");
|
||||
int columnIndex15 = query.getColumnIndex("content");
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
try {
|
||||
configItem = new ConfigItem();
|
||||
arrayList = arrayList2;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
i = columnIndex2;
|
||||
i2 = columnIndex15;
|
||||
}
|
||||
try {
|
||||
configItem.setType(query.getString(columnIndex));
|
||||
configItem.setFileName(query.getString(columnIndex2));
|
||||
configItem.setDescription(query.getString(columnIndex3));
|
||||
i5 = columnIndex;
|
||||
i = columnIndex2;
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
i = columnIndex2;
|
||||
i2 = columnIndex15;
|
||||
arrayList2 = arrayList;
|
||||
i3 = columnIndex14;
|
||||
i4 = columnIndex;
|
||||
version2DbUpgrade = this;
|
||||
try {
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i4;
|
||||
columnIndex14 = i3;
|
||||
columnIndex15 = i2;
|
||||
columnIndex2 = i;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
version2DbUpgrade.close(query);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
try {
|
||||
configItem.setFileCreateTime(query.getLong(columnIndex4));
|
||||
configItem.setFileModifyTime(query.getLong(columnIndex5));
|
||||
configItem.setServerID(query.getString(columnIndex6));
|
||||
configItem.setIsDeleted(query.getString(columnIndex7));
|
||||
configItem.setIcon(query.getString(columnIndex8));
|
||||
configItem.setBlocklyVersion(query.getString(columnIndex9));
|
||||
configItem.setModelType(query.getString(columnIndex10));
|
||||
configItem.setCustomModelId(query.getString(columnIndex11));
|
||||
configItem.setIsDefault(query.getString(columnIndex12));
|
||||
boolean z = true;
|
||||
if (query.getInt(columnIndex13) != 1) {
|
||||
z = false;
|
||||
}
|
||||
configItem.setIsModify(z);
|
||||
i6 = columnIndex14;
|
||||
try {
|
||||
configItem.setUserId(query.getString(i6));
|
||||
i4 = i5;
|
||||
i2 = columnIndex15;
|
||||
} catch (Exception e3) {
|
||||
e = e3;
|
||||
i4 = i5;
|
||||
i2 = columnIndex15;
|
||||
arrayList2 = arrayList;
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
e = e4;
|
||||
version2DbUpgrade = this;
|
||||
i2 = columnIndex15;
|
||||
i3 = columnIndex14;
|
||||
i4 = i5;
|
||||
arrayList2 = arrayList;
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i4;
|
||||
columnIndex14 = i3;
|
||||
columnIndex15 = i2;
|
||||
columnIndex2 = i;
|
||||
}
|
||||
try {
|
||||
configItem.setContent(query.getString(i2));
|
||||
arrayList2 = arrayList;
|
||||
try {
|
||||
arrayList2.add(configItem);
|
||||
i3 = i6;
|
||||
version2DbUpgrade = this;
|
||||
} catch (Exception e5) {
|
||||
e = e5;
|
||||
i3 = i6;
|
||||
version2DbUpgrade = this;
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i4;
|
||||
columnIndex14 = i3;
|
||||
columnIndex15 = i2;
|
||||
columnIndex2 = i;
|
||||
}
|
||||
} catch (Exception e6) {
|
||||
e = e6;
|
||||
i3 = i6;
|
||||
arrayList2 = arrayList;
|
||||
version2DbUpgrade = this;
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i4;
|
||||
columnIndex14 = i3;
|
||||
columnIndex15 = i2;
|
||||
columnIndex2 = i;
|
||||
}
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i4;
|
||||
columnIndex14 = i3;
|
||||
columnIndex15 = i2;
|
||||
columnIndex2 = i;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
version2DbUpgrade = this;
|
||||
version2DbUpgrade.close(query);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
if (arrayList2.size() > 0) {
|
||||
ConfigItemDbHandler.getInstance().insertOrUpdateInTx(arrayList2);
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateDiyModel(SQLiteDatabase sQLiteDatabase) {
|
||||
int i;
|
||||
int i2;
|
||||
DiyDBModel diyDBModel;
|
||||
Version2DbUpgrade version2DbUpgrade = this;
|
||||
Cursor query = version2DbUpgrade.query(sQLiteDatabase, "CustomModelBean");
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int columnIndex = query.getColumnIndex("customModelId");
|
||||
int columnIndex2 = query.getColumnIndex(UnityActivity.pModelName);
|
||||
int columnIndex3 = query.getColumnIndex("customModelCategory");
|
||||
int columnIndex4 = query.getColumnIndex("modifyTime");
|
||||
int columnIndex5 = query.getColumnIndex("isModify");
|
||||
int columnIndex6 = query.getColumnIndex("modelId");
|
||||
int columnIndex7 = query.getColumnIndex("useable");
|
||||
int columnIndex8 = query.getColumnIndex(MediationMetaData.KEY_VERSION);
|
||||
int columnIndex9 = query.getColumnIndex(SocialConstants.PARAM_COMMENT);
|
||||
int columnIndex10 = query.getColumnIndex("modelCreatedId");
|
||||
int columnIndex11 = query.getColumnIndex("compressImagePath");
|
||||
int columnIndex12 = query.getColumnIndex("uploadState");
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
try {
|
||||
diyDBModel = new DiyDBModel();
|
||||
try {
|
||||
try {
|
||||
diyDBModel.setCustomModelId(query.getString(columnIndex));
|
||||
diyDBModel.setModelName(query.getString(columnIndex2));
|
||||
diyDBModel.setCustomModelCategory(query.getInt(columnIndex3));
|
||||
i = columnIndex;
|
||||
i2 = columnIndex2;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
version2DbUpgrade = this;
|
||||
i = columnIndex;
|
||||
i2 = columnIndex2;
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
version2DbUpgrade = this;
|
||||
version2DbUpgrade.close(query);
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
try {
|
||||
diyDBModel.setModifyTime(query.getInt(columnIndex4));
|
||||
diyDBModel.setModify(Boolean.valueOf(query.getInt(columnIndex5) == 1));
|
||||
diyDBModel.setModelId(Integer.valueOf(query.getInt(columnIndex6)));
|
||||
diyDBModel.setUseable(query.getInt(columnIndex7) == 1);
|
||||
diyDBModel.setVersion(query.getString(columnIndex8));
|
||||
diyDBModel.setDescription(query.getString(columnIndex9));
|
||||
diyDBModel.setModelCreatedId(query.getString(columnIndex10));
|
||||
diyDBModel.setCompressImagePath(query.getString(columnIndex11));
|
||||
diyDBModel.setFilePath(DiyRobotDbHandler.getCustomModelPath(query.getString(columnIndex10)) + diyDBModel.getCustomModelId() + File.separator + diyDBModel.getCustomModelId() + ".jpg");
|
||||
diyDBModel.setUploadState(Integer.valueOf(query.getInt(columnIndex12)));
|
||||
arrayList.add(diyDBModel);
|
||||
version2DbUpgrade = this;
|
||||
} catch (Exception e3) {
|
||||
e = e3;
|
||||
version2DbUpgrade = this;
|
||||
e.printStackTrace();
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
}
|
||||
version2DbUpgrade.close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
DiyDBModelDBHandler.getInstance().insertOrUpdateInTx(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateJimuMotion(SQLiteDatabase sQLiteDatabase) {
|
||||
DiyDBModel diyDBModel;
|
||||
Cursor query = query(sQLiteDatabase, "JimuMotion");
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, DiyDBModel> sampleModel = getSampleModel(sQLiteDatabase);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int columnIndex = query.getColumnIndex("userId");
|
||||
int columnIndex2 = query.getColumnIndex(UnityActivity.pModelType);
|
||||
int columnIndex3 = query.getColumnIndex("customModelId");
|
||||
int columnIndex4 = query.getColumnIndex("isDeleted");
|
||||
int columnIndex5 = query.getColumnIndex("actionName");
|
||||
int columnIndex6 = query.getColumnIndex(ActionWidgetData.ACTION_ID);
|
||||
int columnIndex7 = query.getColumnIndex("actionData");
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
try {
|
||||
JimuMotion jimuMotion = new JimuMotion();
|
||||
jimuMotion.setUserId(query.getString(columnIndex));
|
||||
jimuMotion.setModelType(query.getString(columnIndex2));
|
||||
jimuMotion.setCustomModelId(query.getString(columnIndex3));
|
||||
jimuMotion.setIsDeleted(query.getString(columnIndex4));
|
||||
jimuMotion.setActionName(query.getString(columnIndex5));
|
||||
jimuMotion.setActionID(query.getString(columnIndex6));
|
||||
jimuMotion.setActionData((ArrayList) JsonHelper.a(query.getString(columnIndex7), new TypeToken<List<JimuMotion.JimuServo>>() { // from class: com.ubt.jimu.transport3.upgrade.Version2DbUpgrade.1
|
||||
}.getType()));
|
||||
if (sampleModel.size() > 0 && (diyDBModel = sampleModel.get(jimuMotion.getCustomModelId())) != null) {
|
||||
jimuMotion.setModelId(diyDBModel.getModelId().intValue());
|
||||
}
|
||||
arrayList.add(jimuMotion);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
close(query);
|
||||
}
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
JimuMotionDbHandler.getInstance().insertOrUpdateInTx(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Unreachable blocks removed: 1, instructions: 1 */
|
||||
private void migrateTransportFile(SQLiteDatabase sQLiteDatabase) {
|
||||
int i;
|
||||
int i2;
|
||||
int i3;
|
||||
int i4;
|
||||
int i5;
|
||||
int i6;
|
||||
Cursor query = query(sQLiteDatabase, "syncFile");
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int columnIndex = query.getColumnIndex("userId");
|
||||
int columnIndex2 = query.getColumnIndex("customModelId");
|
||||
int columnIndex3 = query.getColumnIndex("fileName");
|
||||
int columnIndex4 = query.getColumnIndex("filePath");
|
||||
int columnIndex5 = query.getColumnIndex("fileUrl");
|
||||
int columnIndex6 = query.getColumnIndex("filenVersion");
|
||||
int columnIndex7 = query.getColumnIndex("modelId");
|
||||
int columnIndex8 = query.getColumnIndex(UnityActivity.pModelType);
|
||||
int columnIndex9 = query.getColumnIndex("createTime");
|
||||
query.getColumnIndex("modifyTime");
|
||||
query.getColumnIndex("isDeleted");
|
||||
query.getColumnIndex("isModify");
|
||||
query.getColumnIndex("fileId");
|
||||
query.getColumnIndex(JockstickDataConverter.ID);
|
||||
query.getColumnIndex("customFileId");
|
||||
while (query.moveToNext()) {
|
||||
try {
|
||||
try {
|
||||
String string = query.getString(columnIndex2);
|
||||
String string2 = query.getString(columnIndex);
|
||||
String string3 = query.getString(columnIndex3);
|
||||
String string4 = query.getString(columnIndex4);
|
||||
String string5 = query.getString(columnIndex5);
|
||||
String string6 = query.getString(columnIndex6);
|
||||
int i7 = query.getInt(columnIndex7);
|
||||
String string7 = query.getString(columnIndex8);
|
||||
i = columnIndex;
|
||||
i2 = columnIndex2;
|
||||
try {
|
||||
long j = query.getLong(columnIndex9);
|
||||
i3 = columnIndex3;
|
||||
try {
|
||||
i4 = columnIndex4;
|
||||
i5 = columnIndex5;
|
||||
i6 = columnIndex6;
|
||||
try {
|
||||
TransportFile transportFile = new TransportFile(string2, i7, string, string7, "", string4, string3);
|
||||
transportFile.setFileUrl(string5);
|
||||
transportFile.setFileVersion(string6);
|
||||
transportFile.setCreateTime(j);
|
||||
arrayList.add(transportFile);
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
e.printStackTrace();
|
||||
close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
columnIndex3 = i3;
|
||||
columnIndex4 = i4;
|
||||
columnIndex5 = i5;
|
||||
columnIndex6 = i6;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
i4 = columnIndex4;
|
||||
i5 = columnIndex5;
|
||||
i6 = columnIndex6;
|
||||
e.printStackTrace();
|
||||
close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
columnIndex3 = i3;
|
||||
columnIndex4 = i4;
|
||||
columnIndex5 = i5;
|
||||
columnIndex6 = i6;
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
e = e3;
|
||||
i3 = columnIndex3;
|
||||
i4 = columnIndex4;
|
||||
i5 = columnIndex5;
|
||||
i6 = columnIndex6;
|
||||
e.printStackTrace();
|
||||
close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
columnIndex3 = i3;
|
||||
columnIndex4 = i4;
|
||||
columnIndex5 = i5;
|
||||
columnIndex6 = i6;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
close(query);
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
e = e4;
|
||||
i = columnIndex;
|
||||
i2 = columnIndex2;
|
||||
}
|
||||
close(query);
|
||||
columnIndex = i;
|
||||
columnIndex2 = i2;
|
||||
columnIndex3 = i3;
|
||||
columnIndex4 = i4;
|
||||
columnIndex5 = i5;
|
||||
columnIndex6 = i6;
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
TransportFileDbHandler2.getInstance().insertOrUpdateInTx(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
private Cursor query(SQLiteDatabase sQLiteDatabase, String str) {
|
||||
try {
|
||||
return sQLiteDatabase.rawQuery(String.format("SELECT * FROM %s", str), null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:17:0x005c -> B:6:0x005f). Please report as a decompilation issue!!! */
|
||||
public void migrate(Context context) {
|
||||
SQLiteDatabase sQLiteDatabase = null;
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
sQLiteDatabase = new DataBaseHelper(context).getWritableDatabase();
|
||||
migrateDiyModel(sQLiteDatabase);
|
||||
migrateBlocklyProject(sQLiteDatabase);
|
||||
migrateTransportFile(sQLiteDatabase);
|
||||
migrateJimuMotion(sQLiteDatabase);
|
||||
migrateConfigItem(sQLiteDatabase);
|
||||
if (sQLiteDatabase != null) {
|
||||
dropTable(sQLiteDatabase, "CustomModelBean");
|
||||
dropTable(sQLiteDatabase, "BlocklyProject");
|
||||
dropTable(sQLiteDatabase, "JimuMotion");
|
||||
dropTable(sQLiteDatabase, "syncFile");
|
||||
dropTable(sQLiteDatabase, ConfigItem.TAG);
|
||||
dropTable(sQLiteDatabase, "local_model");
|
||||
sQLiteDatabase.close();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
if (sQLiteDatabase != null) {
|
||||
try {
|
||||
dropTable(sQLiteDatabase, "CustomModelBean");
|
||||
dropTable(sQLiteDatabase, "BlocklyProject");
|
||||
dropTable(sQLiteDatabase, "JimuMotion");
|
||||
dropTable(sQLiteDatabase, "syncFile");
|
||||
dropTable(sQLiteDatabase, ConfigItem.TAG);
|
||||
dropTable(sQLiteDatabase, "local_model");
|
||||
sQLiteDatabase.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
if (sQLiteDatabase == null) {
|
||||
return;
|
||||
}
|
||||
dropTable(sQLiteDatabase, "CustomModelBean");
|
||||
dropTable(sQLiteDatabase, "BlocklyProject");
|
||||
dropTable(sQLiteDatabase, "JimuMotion");
|
||||
dropTable(sQLiteDatabase, "syncFile");
|
||||
dropTable(sQLiteDatabase, ConfigItem.TAG);
|
||||
dropTable(sQLiteDatabase, "local_model");
|
||||
sQLiteDatabase.close();
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
41
sources/com/ubt/jimu/transport3/upgrade/VersionUpgrade.java
Normal file
41
sources/com/ubt/jimu/transport3/upgrade/VersionUpgrade.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.ubt.jimu.transport3.upgrade;
|
||||
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VersionUpgrade {
|
||||
private final String TAG = "upgrade";
|
||||
private final String SP_KEY_UPGRADE_TO_310 = "sp_key_upgrade_to_310";
|
||||
private DiyModelActionUpgrade actionUpgrade = new DiyModelActionUpgrade();
|
||||
private FileAndDirectoryUpgrade fileUpgrade = new FileAndDirectoryUpgrade(JimuApplication.l());
|
||||
private TransportFileUpgrade transportFileUpgrade = new TransportFileUpgrade();
|
||||
private BlocklyUpgrade blocklyUpgrade = new BlocklyUpgrade();
|
||||
private DiyDBModelUpgrade modelUpgrade = new DiyDBModelUpgrade();
|
||||
|
||||
public static void doUpgrade() {
|
||||
new VersionUpgrade().upgrade();
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
boolean booleanValue = Cache.getInstance().getSettings().getBoolean("sp_key_upgrade_to_310", false).booleanValue();
|
||||
ALog.a("upgrade").d("是否需要升级数据库:upgraded=" + booleanValue);
|
||||
if (booleanValue) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
this.fileUpgrade.upgrade();
|
||||
this.modelUpgrade.upgrade();
|
||||
this.transportFileUpgrade.upgrade();
|
||||
this.actionUpgrade.upgrade();
|
||||
this.blocklyUpgrade.upgrade();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
Cache.getInstance().getSettings().put("sp_key_upgrade_to_310", true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user