package com.niming.weipa.utils; import android.os.Build; import android.text.TextUtils; import android.util.Log; import androidx.work.Constraints; import androidx.work.Data; import androidx.work.NetworkType; import androidx.work.OneTimeWorkRequest; import androidx.work.WorkManager; import androidx.work.WorkRequest; import com.google.android.exoplayer2.metadata.id3.InternalFrame; import com.google.gson.e; import com.niming.framework.basedb.h; import com.niming.weipa.App; import com.niming.weipa.model.UserInfo2; import com.niming.weipa.work.UploadLogWork; import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.Thread; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import kotlin.Metadata; import kotlin.io.FilesKt; import kotlin.jvm.internal.Intrinsics; import kotlin.text.StringsKt; import okhttp3.f0; import okhttp3.h0; import okhttp3.y; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @Metadata(bv = {1, 0, 3}, d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0001\u001bB\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0012\u001a\u00020\u0013H\u0002J\u0018\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u0018H\u0016J\u0010\u0010\u0019\u001a\u00020\u00132\u0006\u0010\u001a\u001a\u00020\u0006H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\t\u001a\n \n*\u0004\u0018\u00010\u00060\u0006X\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u000b\u001a\n \n*\u0004\u0018\u00010\f0\fX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u0006XD¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0010\u001a\n \n*\u0004\u0018\u00010\u00110\u0011X\u0004¢\u0006\u0002\n\u0000¨\u0006\u001c"}, d2 = {"Lcom/niming/weipa/utils/CustomizedExceptionHandler;", "Ljava/lang/Thread$UncaughtExceptionHandler;", "()V", "FORMAT", "Ljava/text/SimpleDateFormat;", "localPath", "", "mClient", "Lokhttp3/OkHttpClient;", "mDir", "kotlin.jvm.PlatformType", "mExecutor", "Ljava/util/concurrent/ExecutorService;", "mFilename", "mGson", "Lcom/google/gson/Gson;", "mUserInfo", "Lcom/niming/weipa/model/UserInfo2;", "checkAndSend", "", "uncaughtException", "t", "Ljava/lang/Thread;", "e", "", "writeToFile", "currentStacktrace", "CrashReportResult", "app_wuqudaoRelease"}, k = 1, mv = {1, 1, 15}) /* compiled from: CustomizedExceptionHandler.kt */ public final class l implements Thread.UncaughtExceptionHandler { private final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); /* renamed from: b reason: collision with root package name */ private final UserInfo2 f5336b = ((UserInfo2) h.a().a(com.niming.weipa.b.a.f4883e, UserInfo2.class)); /* renamed from: c reason: collision with root package name */ private final String f5337c; /* renamed from: d reason: collision with root package name */ private final String f5338d; /* renamed from: e reason: collision with root package name */ private final String f5339e; /* renamed from: f reason: collision with root package name */ private final e f5340f; private final ExecutorService g; private final f0 h; /* compiled from: CustomizedExceptionHandler.kt */ static final class a implements Runnable { final /* synthetic */ l t; a(l lVar) { this.t = lVar; } public final void run() { this.t.a(); } } /* compiled from: CustomizedExceptionHandler.kt */ static final class b implements Runnable { final /* synthetic */ l t; b(l lVar) { this.t = lVar; } public final void run() { try { Data build = new Data.Builder().putString("file_name", this.t.f5339e).build(); Intrinsics.checkExpressionValueIsNotNull(build, "Data.Builder().putString…name\", localPath).build()"); WorkRequest build2 = ((OneTimeWorkRequest.Builder) ((OneTimeWorkRequest.Builder) new OneTimeWorkRequest.Builder(UploadLogWork.class).setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build())).setInputData(build)).build(); Intrinsics.checkExpressionValueIsNotNull(build2, "OneTimeWorkRequest.Build… .build()"); WorkManager.getInstance().enqueue((OneTimeWorkRequest) build2); } catch (Throwable unused) { } } } /* compiled from: CustomizedExceptionHandler.kt */ public static final class c { private boolean a; public c(boolean z) { this.a = z; } public static /* synthetic */ c a(c cVar, boolean z, int i, Object obj) { if ((i & 1) != 0) { z = cVar.a; } return cVar.a(z); } @NotNull public final c a(boolean z) { return new c(z); } public final boolean a() { return this.a; } public final boolean b() { return this.a; } public boolean equals(@Nullable Object obj) { if (this != obj) { if (obj instanceof c) { if (this.a == ((c) obj).a) { return true; } } return false; } return true; } public int hashCode() { boolean z = this.a; if (z) { return 1; } return z ? 1 : 0; } @NotNull public String toString() { return "CrashReportResult(ok=" + this.a + ")"; } public final void b(boolean z) { this.a = z; } } public l() { File filesDir = App.L0.a().getFilesDir(); Intrinsics.checkExpressionValueIsNotNull(filesDir, "App.instance.filesDir"); this.f5337c = filesDir.getAbsolutePath(); this.f5338d = "Crash_Reports"; this.f5339e = this.f5337c + '/' + this.f5338d; this.f5340f = new e(); this.g = Executors.newSingleThreadExecutor(); this.h = new f0(); this.g.execute(new a(this)); this.g.execute(new b(this)); } public void uncaughtException(@NotNull Thread thread, @NotNull Throwable th) { Intrinsics.checkParameterIsNotNull(thread, "t"); Intrinsics.checkParameterIsNotNull(th, "e"); try { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); th.printStackTrace(printWriter); StringBuilder sb = new StringBuilder(); sb.append("************* Log Head ****************\nnickname :"); UserInfo2 userInfo2 = this.f5336b; if (userInfo2 == null) { Intrinsics.throwNpe(); } sb.append(userInfo2.getNick()); sb.append("\nid :"); sb.append(this.f5336b.getCode()); sb.append("\nname :"); sb.append(this.f5336b.getNick()); sb.append("\nvip_expire :"); sb.append(this.f5336b.getIs_vip()); sb.append("\nTime Of Crash : "); sb.append(this.a.format(new Date(System.currentTimeMillis()))); sb.append("\nDevice Manufacturer: "); sb.append(Build.MANUFACTURER); sb.append("\nDevice Model : "); sb.append(Build.MODEL); sb.append("\nAndroid Version : "); sb.append(Build.VERSION.RELEASE); sb.append("\nAndroid SDK : "); sb.append(Build.VERSION.SDK_INT); sb.append("\nApp VersionName : "); sb.append(com.niming.weipa.a.f4874f); sb.append("\nApp VersionCode : "); sb.append(14); sb.append("\n************* Log Head ****************\n\n"); String sb2 = sb.toString(); StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(sb2); stringBuffer.append(stringWriter.toString()); printWriter.close(); if (this.f5339e != null) { String stringBuffer2 = stringBuffer.toString(); Intrinsics.checkExpressionValueIsNotNull(stringBuffer2, "sb.toString()"); a(stringBuffer2); } } catch (Throwable th2) { Log.e(InternalFrame.D0, "--appear error: " + th2.getLocalizedMessage()); } } private final void a(String str) { try { File file = new File(this.f5337c); if (!file.exists()) { file.mkdirs(); } File file2 = new File(this.f5339e); if (!file2.exists()) { file2.createNewFile(); } FilesKt.writeText$default(file2, str, null, 2, null); } catch (Exception e2) { Log.e("----ExceptionHandler", e2.getMessage()); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private final void a() { try { File file = new File(this.f5339e); if (file.exists()) { String readText$default = FilesKt.readText$default(file, null, 1, null); if (readText$default == null) { throw new NullPointerException("null cannot be cast to non-null type kotlin.CharSequence"); } else if (!TextUtils.isEmpty(StringsKt.trim((CharSequence) readText$default).toString())) { y.a a2 = new y.a().a("chat_id", "-441545353"); y a3 = a2.a("text", "抖阴:" + readText$default).a(); Intrinsics.checkExpressionValueIsNotNull(a3, "FormBody.Builder().add(\"…text\", \"抖阴:$msg\").build()"); this.h.a(new h0.a().b("https://api.telegram.org/bot743083118:AAFcQa9POAvUhMcS2_AGFR6BKBf_nj_vGbE/sendMessage").a("POST", a3).a()).execute(); } } } catch (Exception e2) { CommonExtKt.a("--appera error: " + e2.getMessage()); } } }