VMOS Pro v2.9.9版本的 MD5 值为:42f292af86d02c1a08555cf2d3982a52
以下内容为反编译后的 FileUtils.java 源代码,内容仅作参考
package com.nirvana.tools.crash;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
class FileUtils {
private static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
byte[] bArr = new byte[1048576];
while (true) {
int read = inputStream.read(bArr);
if (read <= 0) {
return;
}
outputStream.write(bArr, 0, read);
}
}
public static void copyFile(File file, String str) throws IOException {
File createFileIfUnExist = createFileIfUnExist(str);
if (createFileIfUnExist == null) {
return;
}
FileInputStream fileInputStream = new FileInputStream(file);
FileOutputStream fileOutputStream = new FileOutputStream(createFileIfUnExist);
try {
byte[] bArr = new byte[1048576];
while (true) {
int read = fileInputStream.read(bArr);
if (read <= 0) {
return;
}
fileOutputStream.write(bArr, 0, read);
}
} finally {
fileInputStream.close();
fileOutputStream.flush();
fileOutputStream.close();
}
}
private static File createFileIfUnExist(String str) {
File file = new File(str);
if (file.exists()) {
return file;
}
File file2 = new File(file.getParent());
if (!file2.exists()) {
file2.mkdirs();
}
try {
if (file.createNewFile()) {
return file;
}
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static void deleteFile(File file) {
if (file == null || !file.exists()) {
return;
}
file.delete();
}
private static String fillContent(Context context, String str, String str2, String str3, long j, SdkInfo sdkInfo, String str4, Map<String, String> map, Thread thread, Throwable th) {
try {
StringBuilder sb = new StringBuilder();
sb.append("*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\nBasic Information: 'pid: ");
sb.append(Process.myPid());
sb.append("/tid: ");
sb.append(Process.myTid());
sb.append("/time: ");
sb.append(str);
sb.append("'\nCpu Information: 'abi: ");
sb.append(str2);
sb.append("/processor: ");
sb.append(CrashUploadUtils.getFieldFromCpuinfo("Processor"));
sb.append("/hardware: ");
sb.append(Build.HARDWARE);
sb.append("'\nMobile Information: 'model: ");
sb.append(Build.MODEL);
sb.append("/version: ");
sb.append(Build.VERSION.RELEASE);
sb.append("/sdk: ");
sb.append(Build.VERSION.SDK_INT);
sb.append("'\nBuild fingerprint: '");
sb.append(Build.FINGERPRINT);
sb.append("'\nRuntime Information: 'start: ");
sb.append(str3);
sb.append("/maxheap: ");
sb.append(j);
sb.append("/primaryabi: ");
String str5 = Build.CPU_ABI;
sb.append(str5);
sb.append("/ground: fg'\nApplication Information: 'version: ");
sb.append(CrashUploadUtils.getVersion(context));
sb.append("/subversion: release'\nCrashSDK Information: 'version:");
sb.append(sdkInfo.getSdkVersion());
sb.append("/arch: ");
sb.append(str5);
sb.append("/target: ");
sb.append(CrashUploadUtils.apkInDebugRelease(context));
sb.append("'\nReport Name: ");
sb.append(str4);
sb.append("\nLog Type: java\ncrash_shield_version: 2.1.3.2\ncustom_uc_upload: true");
if (map != null && !map.isEmpty()) {
for (Map.Entry<String, String> entry : map.entrySet()) {
sb.append("\n");
sb.append(entry.getKey());
sb.append(":");
sb.append(entry.getValue());
}
}
sb.append("\nActivity: (none)\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\nProcess Name: '");
sb.append(CrashUploadUtils.getCurProcessName(context));
sb.append("'\nThread Name: '");
sb.append(thread.getName());
sb.append("\nk_ac: ");
sb.append(sdkInfo.getSdkName());
sb.append("\nBack traces starts.\n");
sb.append(Log.getStackTraceString(th));
sb.append("\nBack traces ends.\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\nmeminfo:\n");
sb.append(CrashUploadUtils.getMeminfo());
sb.append("\n--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
public static String getName(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return str.substring(str.lastIndexOf(File.separatorChar) + 1);
}
public static boolean gzipCompress(File file, String str) {
GZIPOutputStream gZIPOutputStream;
File createFileIfUnExist = createFileIfUnExist(str);
if (createFileIfUnExist == null) {
return false;
}
FileInputStream fileInputStream = null;
try {
try {
try {
FileInputStream fileInputStream2 = new FileInputStream(file);
try {
file = new GZIPOutputStream(new FileOutputStream(createFileIfUnExist));
} catch (FileNotFoundException e) {
e = e;
file = null;
} catch (IOException e2) {
e = e2;
file = null;
} catch (Throwable th) {
th = th;
file = 0;
}
try {
copy(fileInputStream2, file);
file.flush();
try {
fileInputStream2.close();
file.close();
return true;
} catch (IOException unused) {
return true;
}
} catch (FileNotFoundException e3) {
e = e3;
fileInputStream = fileInputStream2;
gZIPOutputStream = file;
e.printStackTrace();
if (fileInputStream != null) {
fileInputStream.close();
}
} catch (IOException e4) {
e = e4;
fileInputStream = fileInputStream2;
gZIPOutputStream = file;
e.printStackTrace();
if (fileInputStream != null) {
fileInputStream.close();
}
} catch (Throwable th2) {
th = th2;
fileInputStream = fileInputStream2;
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException unused2) {
throw th;
}
}
if (file != 0) {
file.close();
}
throw th;
}
} catch (IOException unused3) {
return false;
}
} catch (FileNotFoundException e5) {
e = e5;
gZIPOutputStream = null;
} catch (IOException e6) {
e = e6;
gZIPOutputStream = null;
} catch (Throwable th3) {
th = th3;
file = 0;
}
} catch (Throwable th4) {
th = th4;
}
}
public static String readStringFromFile(File file) {
?? r6;
FileInputStream fileInputStream;
IOException e;
BufferedReader bufferedReader;
FileNotFoundException e2;
FileInputStream fileInputStream2 = null;
if (file == null) {
return null;
}
StringBuffer stringBuffer = new StringBuffer();
try {
try {
fileInputStream = new FileInputStream(file);
} catch (Throwable unused) {
}
} catch (FileNotFoundException e3) {
fileInputStream = null;
e2 = e3;
bufferedReader = null;
} catch (IOException e4) {
fileInputStream = null;
e = e4;
bufferedReader = null;
} catch (Throwable unused2) {
r6 = 0;
if (fileInputStream2 != null) {
try {
fileInputStream2.close();
} catch (IOException e5) {
e5.printStackTrace();
return stringBuffer.toString();
}
}
if (r6 != 0) {
r6.close();
}
return stringBuffer.toString();
}
try {
bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
while (true) {
try {
String readLine = bufferedReader.readLine();
if (readLine != null) {
stringBuffer.append(readLine);
} else {
try {
break;
} catch (IOException e6) {
e6.printStackTrace();
}
}
} catch (FileNotFoundException e7) {
e2 = e7;
e2.printStackTrace();
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e8) {
e8.printStackTrace();
return stringBuffer.toString();
}
}
if (bufferedReader != null) {
bufferedReader.close();
}
return stringBuffer.toString();
} catch (IOException e9) {
e = e9;
e.printStackTrace();
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e10) {
e10.printStackTrace();
return stringBuffer.toString();
}
}
if (bufferedReader != null) {
bufferedReader.close();
}
return stringBuffer.toString();
}
}
fileInputStream.close();
bufferedReader.close();
return stringBuffer.toString();
} catch (FileNotFoundException e11) {
e2 = e11;
bufferedReader = null;
} catch (IOException e12) {
e = e12;
bufferedReader = null;
} catch (Throwable unused3) {
file = null;
fileInputStream2 = fileInputStream;
r6 = file;
if (fileInputStream2 != null) {
}
if (r6 != 0) {
}
return stringBuffer.toString();
}
}
public static void renameFile(String str, String str2) {
new File(str).renameTo(new File(str2));
}
public static String writeSelfJavaLog(Context context, SdkInfo sdkInfo, Thread thread, Throwable th, String str, String str2, String str3, Map<String, String> map) {
String absolutePath = new File(context.getCacheDir(), "crash/".concat(String.valueOf(str3))).getAbsolutePath();
createFileIfUnExist(absolutePath);
long maxMemory = Runtime.getRuntime().maxMemory();
String join = Build.VERSION.SDK_INT >= 21 ? TextUtils.join(jo6.f22033, Build.SUPPORTED_ABIS) : Build.CPU_ABI;
try {
FileOutputStream fileOutputStream = new FileOutputStream(absolutePath);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
outputStreamWriter.append((CharSequence) fillContent(context, str, join, str2, maxMemory, sdkInfo, str3, map, thread, th));
outputStreamWriter.close();
fileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
return absolutePath;
}
}