OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.excean.tool;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import com.android.spush.FakeServiceHelper;
import com.excean.tool.f;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
public class d {
private static volatile d f1653b;
private Context f1654a;
private String c;
private String d = "http://log.ourplay.net/tracelog.php";
private d(Context context) {
this.f1654a = context.getApplicationContext();
c();
}
public static d a(Context context) {
if (f1653b == null) {
synchronized (d.class) {
if (f1653b == null) {
f1653b = new d(context);
}
}
}
return f1653b;
}
public void a(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
this.d = str;
}
private void c() {
try {
this.c = String.valueOf(this.f1654a.getPackageManager().getPackageInfo(this.f1654a.getPackageName(), 0).versionCode);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
public String a(a aVar) {
String absolutePath = this.f1654a.getCacheDir().getAbsolutePath();
if (Environment.isExternalStorageEmulated() && this.f1654a.getExternalCacheDir() != null) {
absolutePath = this.f1654a.getExternalCacheDir().getAbsolutePath();
}
return a(aVar, absolutePath + File.separator + "anr");
}
private String a(a aVar, String str) {
String str2;
File file = new File(str);
if (!file.exists()) {
file.mkdirs();
}
try {
Bundle bundle = this.f1654a.getPackageManager().getApplicationInfo(this.f1654a.getPackageName(), 128).metaData;
str2 = bundle.getInt("MainChId") + "_" + bundle.getInt("SubChId") + "_" + this.f1654a.getPackageName() + "_" + this.c + "_" + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA).format(new Date()).toString() + ".trace";
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
str2 = "anr_" + this.c + "_" + new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA).format(new Date()).toString() + ".txt";
}
File file2 = new File(str, str2);
if (!file2.exists()) {
try {
file2.createNewFile();
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
a(printWriter);
printWriter.write("\n");
aVar.printStackTrace(printWriter);
a(stringWriter.toString().replaceAll("Caused by: \\S*: ", ""), file2);
} catch (IOException e2) {
e2.printStackTrace();
}
}
return file2.getAbsolutePath();
}
private void a(String str, File file) {
BufferedOutputStream bufferedOutputStream;
BufferedOutputStream bufferedOutputStream2 = null;
try {
try {
try {
bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
} catch (Throwable th) {
th = th;
}
} catch (IOException e) {
e = e;
}
} catch (IOException e2) {
e2.printStackTrace();
}
try {
bufferedOutputStream.write(str.getBytes());
bufferedOutputStream.flush();
bufferedOutputStream.close();
bufferedOutputStream.close();
} catch (IOException e3) {
e = e3;
bufferedOutputStream2 = bufferedOutputStream;
e.printStackTrace();
if (bufferedOutputStream2 != null) {
bufferedOutputStream2.close();
}
} catch (Throwable th2) {
th = th2;
bufferedOutputStream2 = bufferedOutputStream;
if (bufferedOutputStream2 != null) {
try {
bufferedOutputStream2.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
throw th;
}
}
public void a() {
String absolutePath = this.f1654a.getCacheDir().getAbsolutePath();
if (Environment.isExternalStorageEmulated() && this.f1654a.getExternalCacheDir() != null) {
absolutePath = this.f1654a.getExternalCacheDir().getAbsolutePath();
}
c(absolutePath + File.separator + "anr");
}
private void c(String str) {
File[] listFiles;
File file = new File(str);
if (file.exists() && file.isDirectory() && (listFiles = file.listFiles()) != null) {
for (File file2 : listFiles) {
if (!TextUtils.isEmpty(this.c) && file2.getName().contains(this.c)) {
b(file2.getAbsolutePath());
}
}
}
}
public void b(String str) {
File file = new File(str);
HashMap hashMap = new HashMap();
hashMap.put(file.getName(), file);
try {
f.a a2 = f.a(this.d, null, hashMap);
if (a2.f1659a == 1) {
Log.d("ANRReporter", String.format("ANRReporter/uploadANRFileToServer:thread(%s) filePath(%s) success", Thread.currentThread().getName(), str));
a(file);
} else {
Log.d("ANRReporter", String.format("ANRReporter/uploadANRFileToServer:thread(%s) filePath(%s) fail msg(%s)", Thread.currentThread().getName(), str, a2.f1660b));
}
} catch (IOException e) {
e.printStackTrace();
Log.e("ANRReporter", "ANRReporter/uploadANRFileToServer:" + e.toString());
}
}
private void a(File file) {
file.renameTo(new File(file.getAbsolutePath().replace(this.c, "uploaded")));
}
private void a(PrintWriter printWriter) {
PackageInfo packageInfo;
printWriter.print("pkgName: ");
printWriter.println(this.f1654a.getPackageName());
String format = new SimpleDateFormat("yyyyMMdd HH:mm:ss", Locale.CHINA).format(new Date(System.currentTimeMillis()));
printWriter.print("time: ");
printWriter.println(format);
try {
Bundle bundle = this.f1654a.getPackageManager().getApplicationInfo(this.f1654a.getPackageName(), 128).metaData;
if (bundle != null) {
int i = bundle.getInt("MainChId");
int i2 = bundle.getInt("SubChId");
printWriter.print("mainChId: ");
printWriter.print(i);
printWriter.print("subChId: ");
printWriter.println(i2);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
printWriter.print("apk: ");
try {
packageInfo = this.f1654a.getPackageManager().getPackageInfo(this.f1654a.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e2) {
e2.printStackTrace();
packageInfo = null;
}
printWriter.print(packageInfo.versionName);
printWriter.print('_');
printWriter.println(packageInfo.versionCode);
printWriter.print("net: ");
printWriter.println(b());
printWriter.print("sdk: ");
printWriter.print(Build.VERSION.RELEASE);
printWriter.print("_");
printWriter.println(Build.VERSION.SDK_INT);
printWriter.print("V: ");
printWriter.println(Build.MANUFACTURER);
printWriter.printf("B: ", new Object[0]);
printWriter.println(Build.BRAND);
printWriter.print("M: ");
printWriter.println(Build.MODEL);
printWriter.print("CPU: ");
printWriter.println(Build.CPU_ABI);
}
public String b() {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.f1654a.getSystemService(FakeServiceHelper.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (activeNetworkInfo == null) {
return "";
}
return activeNetworkInfo.getTypeName() + activeNetworkInfo.getSubtypeName();
}
}