Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 LogCollector.java 源代码,内容仅作参考
package com.perm.kate;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import com.perm.utils.ProxyManager;
import com.perm.utils.TimeFix;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class LogCollector {
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
final Context context;
private CollectLogTask mCollectLogTask;
private ProgressDialog mProgressDialog;
private String message_text = null;
public class CollectLogTask extends AsyncTask {
private CollectLogTask() {
}
@Override
public StringBuilder doInBackground(Void... voidArr) {
StringBuilder sb = new StringBuilder();
try {
ArrayList arrayList = new ArrayList();
arrayList.add("logcat");
arrayList.add("-d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec((String[]) arrayList.toArray(new String[0])).getInputStream()), 8192);
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
sb.append(LogCollector.LINE_SEPARATOR);
}
} catch (Exception e) {
e.printStackTrace();
}
return sb;
}
@Override
public void onPostExecute(StringBuilder sb) {
LogCollector.this.sendLogs(sb.toString());
LogCollector.this.dismissProgressDialog();
((Activity) LogCollector.this.context).finish();
}
@Override
protected void onPreExecute() {
LogCollector logCollector = LogCollector.this;
logCollector.showProgressDialog(logCollector.context.getString(R.string.please_wait));
}
}
public LogCollector(Context context) {
this.context = context;
}
public void dismissProgressDialog() {
ProgressDialog progressDialog = this.mProgressDialog;
if (progressDialog == null || !progressDialog.isShowing()) {
return;
}
this.mProgressDialog.dismiss();
this.mProgressDialog = null;
}
void cancellCollectTask() {
CollectLogTask collectLogTask = this.mCollectLogTask;
if (collectLogTask == null || collectLogTask.getStatus() != AsyncTask.Status.RUNNING) {
return;
}
this.mCollectLogTask.cancel(true);
this.mCollectLogTask = null;
}
public void execute(String str) {
this.message_text = "User message: " + str + "\n";
this.mCollectLogTask = (CollectLogTask) new CollectLogTask().execute(new Void[0]);
}
public File saveLogToFile(String str) {
if (Environment.getExternalStorageState().equals("mounted")) {
File externalCacheDir = KApplication.current.getExternalCacheDir();
if (!externalCacheDir.exists()) {
externalCacheDir.mkdirs();
}
File file = new File(externalCacheDir, "log.txt");
if (file.exists()) {
file.delete();
}
try {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
bufferedWriter.write(str);
bufferedWriter.flush();
bufferedWriter.close();
return file;
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
return null;
}
}
return null;
}
public void sendLogs(String str) {
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("plain/text");
intent.putExtra("android.intent.extra.EMAIL", new String[]{"katemobile.android@gmail.com"});
intent.putExtra("android.intent.extra.SUBJECT", "Kate log");
String str2 = (((this.message_text + "Device: " + Build.MODEL + "\nAndroid Version: " + Build.VERSION.RELEASE + "\nApplication Version: " + Helper.getVersion() + "\nPackage: " + this.context.getPackageName() + "\nProxy enabled: " + ProxyManager.getEnabled() + "\nProxy type: " + ProxyManager.getProxyType() + "\nLog size: " + str.length() + "\n") + "Image cache dir: " + KApplication.getImageLoader().getCacheDir().getAbsolutePath() + "\n") + "Free space on external storage: " + ImageLoader.getFreeSpace() + " MB\n") + "Num files in cache: " + KApplication.getImageLoader().getCacheDir().listFiles().length + "\n";
long j = PreferenceManager.getDefaultSharedPreferences(this.context).getLong("last_cache_check_1", 0L);
String str3 = (((str2 + "last clean: " + ((((System.currentTimeMillis() - j) / 1000) / 60) / 60) + " hours ago\n") + "Download images: " + KApplication.getImageLoader().download_images + "\n") + "Time fix: " + TimeFix.get() + "\n") + "sh: " + Helper.getSigHash() + "\n";
if (PlaybackService.useExo()) {
str3 = str3 + "exo: " + PlaybackService.exoEnabled() + "\n";
}
String str4 = (str3 + "mic: " + Settings.getPrefferedMic() + "\n") + "finish: " + Helper.isFinishActivitiesOptionEnabled(KApplication.current) + "\n";
if (Build.VERSION.SDK_INT >= 19) {
str4 = str4 + "getExternalFilesDirs:\n";
File[] externalFilesDirsWithReflect = FileManager.getExternalFilesDirsWithReflect(this.context, null);
if (externalFilesDirsWithReflect != null) {
for (File file : externalFilesDirsWithReflect) {
str4 = str4 + file.getAbsolutePath() + "\n";
}
}
}
if (!Environment.getExternalStorageState().equals("mounted")) {
str4 = str4 + "\nНе могу прикрепить файл потому что SD карта не подключена";
}
File saveLogToFile = saveLogToFile(str);
if (saveLogToFile != null) {
Uri fromFile = Uri.fromFile(saveLogToFile);
if (Build.VERSION.SDK_INT >= 24) {
fromFile = FileProvider.getUriForFile(this.context, "com.perm.kate.provider", saveLogToFile);
}
intent.putExtra("android.intent.extra.STREAM", fromFile);
}
intent.putExtra("android.intent.extra.TEXT", saveLogToFile != null ? str4 + "\nЛог прикреплён" : str4 + "\nНе удалось прикрепить лог");
this.context.startActivity(intent);
} catch (ActivityNotFoundException unused) {
Toast.makeText(this.context.getApplicationContext(), (int) R.string.no_email, 0).show();
} catch (Throwable th) {
Helper.reportError(th);
th.printStackTrace();
}
}
void showProgressDialog(String str) {
ProgressDialog progressDialog = new ProgressDialog(this.context);
this.mProgressDialog = progressDialog;
progressDialog.setIndeterminate(true);
this.mProgressDialog.setMessage(str);
this.mProgressDialog.setCancelable(true);
this.mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
LogCollector.this.cancellCollectTask();
}
});
this.mProgressDialog.show();
}
}