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,30 @@
package com.ubt.jimu.base.util;
import android.database.Cursor;
import com.ubtrobot.log.ALog;
import java.io.Closeable;
/* loaded from: classes.dex */
public class Closer {
public static void close(Closeable closeable) {
if (closeable == null) {
return;
}
try {
closeable.close();
} catch (Exception e) {
ALog.a("Exception").d("printStackTrace()--->", e);
}
}
public static void close(Cursor cursor) {
if (cursor == null) {
return;
}
try {
cursor.close();
} catch (Exception e) {
ALog.a("Exception").d("printStackTrace()--->", e);
}
}
}

View File

@@ -0,0 +1,152 @@
package com.ubt.jimu.base.util;
import android.text.TextUtils;
import com.ubtrobot.log.ALog;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/* loaded from: classes.dex */
public class FileUtil {
public static final int ZIP_BUFFER_SIZE = 4096;
public static void copy(File file, File file2) {
try {
FileInputStream fileInputStream = new FileInputStream(file);
try {
FileChannel channel = fileInputStream.getChannel();
try {
FileOutputStream fileOutputStream = new FileOutputStream(file2);
try {
FileChannel channel2 = fileOutputStream.getChannel();
try {
channel2.transferFrom(channel, 0L, channel.size());
if (channel2 != null) {
channel2.close();
}
fileOutputStream.close();
if (channel != null) {
channel.close();
}
fileInputStream.close();
} finally {
}
} finally {
}
} finally {
}
} finally {
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean deleteFile(File file) {
if (file != null) {
if (file.isFile()) {
if (file.delete()) {
return true;
}
file.deleteOnExit();
return false;
}
if (file.isDirectory()) {
File[] listFiles = file.listFiles();
if (listFiles != null) {
for (File file2 : listFiles) {
deleteFile(file2);
}
}
return file.delete();
}
}
return false;
}
public static void doZip(ZipOutputStream zipOutputStream, File file, String str, byte[] bArr) throws IOException {
BufferedInputStream bufferedInputStream;
if (zipOutputStream == null || file == null) {
throw new IOException("I/O Object got NullPointerException");
}
if (!file.exists()) {
return;
}
String name = TextUtils.isEmpty(str) ? file.getName() : str + File.separator + file.getName();
if (!file.isFile()) {
if (file.isDirectory()) {
for (File file2 : file.listFiles()) {
doZip(zipOutputStream, file2, name, bArr);
}
return;
}
return;
}
try {
bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
try {
zipOutputStream.putNextEntry(new ZipEntry(name));
while (true) {
int read = bufferedInputStream.read(bArr, 0, bArr.length);
if (-1 == read) {
Closer.close(bufferedInputStream);
return;
}
zipOutputStream.write(bArr, 0, read);
}
} catch (IOException e) {
e = e;
Closer.close(bufferedInputStream);
throw e;
}
} catch (IOException e2) {
e = e2;
bufferedInputStream = null;
}
}
public static boolean zip(File[] fileArr, File file) {
boolean z = false;
if (fileArr == null || fileArr.length < 1 || file == null) {
return false;
}
ZipOutputStream zipOutputStream = null;
try {
try {
byte[] bArr = new byte[ZIP_BUFFER_SIZE];
ZipOutputStream zipOutputStream2 = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file, false)));
try {
for (File file2 : fileArr) {
doZip(zipOutputStream2, file2, null, bArr);
}
zipOutputStream2.flush();
zipOutputStream2.closeEntry();
Closer.close(zipOutputStream2);
z = true;
} catch (IOException e) {
e = e;
zipOutputStream = zipOutputStream2;
ALog.a("Exception").d("printStackTrace()--->", e);
Closer.close(zipOutputStream);
return z;
} catch (Throwable th) {
th = th;
zipOutputStream = zipOutputStream2;
Closer.close(zipOutputStream);
throw th;
}
} catch (IOException e2) {
e = e2;
}
return z;
} catch (Throwable th2) {
th = th2;
}
}
}

View File

@@ -0,0 +1,118 @@
package com.ubt.jimu.base.util;
import android.content.Context;
import android.text.TextUtils;
import com.ubt.jimu.base.entities.RobotLite;
import com.ubt.jimu.controller.data.action.ActionSequence;
import com.ubt.jimu.unity.ModelType;
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
import java.io.File;
import java.io.FilenameFilter;
/* loaded from: classes.dex */
public class PathHelper {
private static final String CONTROLLER_DIR = "ControllerData";
public static final String CONTROLLER_PREFIX = "controller_";
private static final String GAME_CONTROLLER_CONFIG_DIR = "gameControllerConfig";
private static final String GAME_CONTROLLER_KEY_MAP_FILE_NAME = "keymap.xml";
private static final String MOVE_CONFIG_NAME = "moveConfig.xml";
public static final String OLD_CONTROLLER_PREFIX = "robot_";
private static final String SOUNDS_DIR = "sounds";
private static final String SOUND_SUFFIX = ".aac";
private static final String WIDGET_CONFIG_DIR = "widgetConfig";
static /* synthetic */ boolean a(File file, String str) {
return str.startsWith(CONTROLLER_PREFIX) || str.startsWith(OLD_CONTROLLER_PREFIX);
}
public static String getActionDir(Context context, RobotLite robotLite, boolean z) {
if (robotLite == null) {
return null;
}
return getDataRootDir(context, robotLite, z) + "actions" + File.separator;
}
public static String getControllerDir(Context context, RobotLite robotLite, boolean z) {
if (robotLite == null) {
return null;
}
return getDataRootDir(context, robotLite, z) + "ControllerData" + File.separator;
}
public static String getControllerPath(String str) {
File[] listFiles;
if (TextUtils.isEmpty(str)) {
return null;
}
File file = new File(str);
if (!file.exists() || !file.isDirectory() || (listFiles = file.listFiles(new FilenameFilter() { // from class: com.ubt.jimu.base.util.a
@Override // java.io.FilenameFilter
public final boolean accept(File file2, String str2) {
return PathHelper.a(file2, str2);
}
})) == null || listFiles.length <= 0) {
return null;
}
return listFiles[0].getAbsolutePath();
}
public static String getCustomUserDir(Context context) {
return ExternalOverFroyoUtils.b() + File.separator + ModelType.PLAYER_DATA.getName() + File.separator;
}
public static String getDataRootDir(Context context, RobotLite robotLite, boolean z) {
if (robotLite == null) {
return null;
}
return (robotLite.isOfficial() ? !z ? getOfficialDir(context) : getOfficialUserDir(context) : getCustomUserDir(context)) + robotLite.getModelId() + File.separator;
}
public static String getGameControllerKeyMapDir(Context context, RobotLite robotLite) {
if (robotLite == null) {
return null;
}
return getDataRootDir(context, robotLite, true) + GAME_CONTROLLER_CONFIG_DIR + File.separator;
}
public static String getGameControllerKeyMapFilePath(Context context, RobotLite robotLite) {
String gameControllerKeyMapDir = getGameControllerKeyMapDir(context, robotLite);
if (gameControllerKeyMapDir == null) {
return null;
}
return gameControllerKeyMapDir + GAME_CONTROLLER_KEY_MAP_FILE_NAME;
}
public static String getMoveConfigPath(Context context, RobotLite robotLite, boolean z) {
if (robotLite == null) {
return null;
}
return getDataRootDir(context, robotLite, z) + "widgetConfig" + File.separator + MOVE_CONFIG_NAME;
}
public static String getOfficialDir(Context context) {
return ExternalOverFroyoUtils.a(context, ModelType.DEFAULT);
}
public static String getOfficialUserDir(Context context) {
return ExternalOverFroyoUtils.b() + File.separator + ModelType.DEFAULT.getName() + File.separator;
}
public static String getSoundPath(Context context, RobotLite robotLite, ActionSequence actionSequence) {
if (robotLite == null) {
return null;
}
String str = getDataRootDir(context, robotLite, !actionSequence.j()) + "sounds" + File.separator + actionSequence.e() + ".aac";
if (new File(str).exists()) {
return str;
}
return null;
}
public static String getUserDiyActionPath() {
return ExternalOverFroyoUtils.b() + File.separator;
}
public static String newControllerFileName(String str) {
return CONTROLLER_PREFIX + str;
}
}