jimu-decompiled/sources/com/ubt/jimu/utils/ExternalOverFroyoUtils.java
2025-05-13 19:24:51 +02:00

103 lines
3.3 KiB
Java

package com.ubt.jimu.utils;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.blockly.Utils;
import com.ubt.jimu.unity.ModelType;
import com.ubtech.utils.AndroidVersionCheckUtils;
import java.io.File;
@TargetApi(9)
/* loaded from: classes2.dex */
public class ExternalOverFroyoUtils {
public enum Dir {
Model("model"),
Cache("cache"),
User("user"),
Image("image");
private String name;
Dir(String str) {
this.name = str;
}
public String getName() {
return this.name;
}
}
public static boolean a() {
if (AndroidVersionCheckUtils.b()) {
return Environment.isExternalStorageRemovable();
}
return true;
}
public static File b(Context context, String str) {
String path = context.getCacheDir().getPath();
try {
if ("mounted".equals(Environment.getExternalStorageState()) || !a()) {
path = b(context).getPath();
}
} catch (Exception e) {
Log.e("DiskCacheDir", e.getMessage() + "");
}
return new File(path + File.separator + str);
}
public static String c(Context context) {
return Environment.getExternalStorageDirectory().getPath() + File.separator + "Android" + File.separator + "data" + File.separator + context.getPackageName();
}
public static String a(Context context, ModelType modelType) {
String str = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android" + File.separator + "data" + File.separator + context.getPackageName() + File.separator + "files" + File.separator;
if (modelType == null) {
return str;
}
return str + modelType.getName() + File.separator;
}
public static String c(String str) {
return b() + File.separator + "playerdata" + File.separator + str;
}
public static String a(Context context) {
String str = Environment.getExternalStorageDirectory().getPath() + File.separator + "Android" + File.separator + "data" + File.separator + context.getPackageName() + File.separator + "apk";
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
return str;
}
public static File b(Context context) {
if (AndroidVersionCheckUtils.a()) {
return context.getExternalCacheDir();
}
return new File(Environment.getExternalStorageDirectory().getPath() + ("/Android/data/" + context.getPackageName() + "/cache/"));
}
public static File a(Context context, String str) {
return new File(c(context), str);
}
public static boolean a(String str) {
return new File(c(str) + File.separator + str + ".xml").exists();
}
public static int b(String str) {
File[] listFiles = new File(c(str) + File.separator + str + Utils.BLOCKLY_ADD_PATH).listFiles();
return (listFiles == null || listFiles.length <= 0) ? 0 : 1;
}
public static String b() {
return c(JimuApplication.l()) + File.separator + "files" + File.separator + "users" + File.separator + Cache.getInstance().getUserId();
}
}