package com.intsig.camscanner.log; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Environment; import android.text.TextUtils; import androidx.core.net.MailTo; import com.facebook.internal.AnalyticsEvents; import com.facebook.internal.ServerProtocol; import com.intsig.app.ProgressDialog; import com.intsig.camscanner.CustomExceptionHandler; import com.intsig.camscanner.R; import com.intsig.camscanner.app.AppSwitch; import com.intsig.camscanner.app.AppUtil; import com.intsig.camscanner.app.DBUtil; import com.intsig.camscanner.capture.camera.CameraXUtilKt; import com.intsig.camscanner.launch.CsApplication; import com.intsig.camscanner.mode_ocr.OCRBalanceManager; import com.intsig.camscanner.scanner.ScannerEngineUtil; import com.intsig.camscanner.tsapp.sync.DirSyncFromServer; import com.intsig.camscanner.tsapp.sync.SyncUtil; import com.intsig.camscanner.tsapp.sync.UploadDirJson; import com.intsig.camscanner.util.PreferenceHelper; import com.intsig.camscanner.util.SDStorageManager; import com.intsig.camscanner.util.Util; import com.intsig.comm.account_data.AccountPreference; import com.intsig.log.LogUtils; import com.intsig.nativelib.BookSplitter; import com.intsig.okgo.OkGoUtils; import com.intsig.okgo.utils.GsonUtils; import com.intsig.tianshu.TianShuAPI; import com.intsig.util.PermissionUtil; import com.intsig.utils.ApplicationHelper; import com.intsig.utils.FileUtil; import com.intsig.utils.SDStorageUtil; import com.intsig.utils.ToastUtils; import io.netty.handler.codec.http.multipart.HttpPostBodyUtil; import java.io.ByteArrayOutputStream; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; public class GetLogTask extends AsyncTask<Void, Void, Uri> { /* renamed from: a reason: collision with root package name */ private final Activity f21442a; /* renamed from: b reason: collision with root package name */ private ProgressDialog f21443b; /* renamed from: c reason: collision with root package name */ private final SendLogTask f21444c; public interface IUploadCallback { void a(Activity activity, boolean z10); } public static class SendLogTask { /* renamed from: a reason: collision with root package name */ private HashMap<String, String> f21445a = null; /* renamed from: b reason: collision with root package name */ private final String f21446b; /* renamed from: c reason: collision with root package name */ private boolean f21447c; /* renamed from: d reason: collision with root package name */ private final String f21448d; /* renamed from: e reason: collision with root package name */ private String f21449e; /* renamed from: f reason: collision with root package name */ private String f21450f; /* renamed from: g reason: collision with root package name */ private String f21451g; /* renamed from: h reason: collision with root package name */ private String f21452h; /* renamed from: i reason: collision with root package name */ private boolean f21453i = false; /* renamed from: j reason: collision with root package name */ private String f21454j = ""; /* renamed from: k reason: collision with root package name */ private boolean f21455k = true; /* renamed from: l reason: collision with root package name */ private IUploadCallback f21456l; /* renamed from: m reason: collision with root package name */ private final boolean f21457m; /* renamed from: n reason: collision with root package name */ private final ArrayList<String> f21458n; /* renamed from: o reason: collision with root package name */ private final ArrayList<File> f21459o; /* renamed from: p reason: collision with root package name */ private final Context f21460p; public SendLogTask(Context context, String str, String str2, String str3, String str4, boolean z10, boolean z11, ArrayList<File> arrayList, boolean z12, ArrayList<String> arrayList2, IUploadCallback iUploadCallback) { this.f21460p = context; this.f21459o = arrayList; this.f21451g = str3; this.f21450f = str4; if (TextUtils.isEmpty(str2)) { this.f21452h = "Android_CamScanner_Feedback"; } else { this.f21452h = str2; } this.f21447c = z10; this.f21446b = str; this.f21448d = context.getString(R.string.report_email); this.f21449e = context.getString(R.string.report_subject); if (CsApplication.W()) { this.f21449e += " (full version)"; } else { this.f21449e += " (free version)"; } if ("com.intsig.camscanner_cn".equals(context.getPackageName())) { this.f21449e += "_CN"; } this.f21455k = z11; this.f21457m = z12; this.f21456l = iUploadCallback; this.f21458n = arrayList2; } private String j(ArrayList<String> arrayList) { String str = ""; if (arrayList != null) { if (arrayList.isEmpty()) { return str; } Iterator<String> it = arrayList.iterator(); while (it.hasNext()) { String next = it.next(); if (!TextUtils.isEmpty(next)) { if (TextUtils.isEmpty(str)) { str = next; } else { str = str + " | " + next; } } } } return str; } private HashMap<String, String> k(Context context, ArrayList<String> arrayList) { HashMap<String, String> hashMap = new HashMap<>(); int i10 = Build.VERSION.SDK_INT; String string = context.getString(R.string.app_version); String d10 = ApplicationHelper.d(); boolean W = CsApplication.W(); StringBuilder sb2 = new StringBuilder(); sb2.append("API "); sb2.append(i10); sb2.append(W ? "_FULL" : "_LITE"); sb2.append("("); sb2.append(Build.VERSION.RELEASE); sb2.append(") Model "); sb2.append(Build.MODEL); sb2.append(" MANUFACTURER "); sb2.append(Build.MANUFACTURER); sb2.append("\nDevice "); sb2.append(Build.DEVICE); sb2.append(" DISPLAY "); sb2.append(Build.DISPLAY); sb2.append("\nVersion name "); sb2.append(string); sb2.append("\nDevice id "); sb2.append(d10); hashMap.put("baseInfo:", sb2.toString()); hashMap.put("Login Status: ", SyncUtil.t1(context) ? "Logged in" : "NOT Logged in"); String j2 = j(arrayList); if (!TextUtils.isEmpty(j2)) { hashMap.put("UnLogin Account: ", j2); } if (SyncUtil.t1(context)) { hashMap.put("Current UID: ", SyncUtil.N0()); } hashMap.put("Past UID: ", DBUtil.X(context)); hashMap.put("Svip Flag: ", PreferenceHelper.h9() + ""); hashMap.put("isSvipUser: ", AccountPreference.q() + ""); long[] a02 = SyncUtil.a0(context, false); if (a02 == null) { hashMap.put("Cloud Limit Reached:", AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN); } else { hashMap.put("Cloud Limit Reached: ", SyncUtil.c1(a02) + ""); } hashMap.put("ScannerEngineIs64Bit: ", ScannerEngineUtil.is64BitEngine() + ""); hashMap.put("AndroidRSandboxModel: ", "sandbox"); if (SDStorageUtil.i()) { hashMap.put("isExternalStorageManager: ", Environment.isExternalStorageManager() + ""); } else { hashMap.put("AndroidRSandboxModel: ", "legacy"); } StringBuilder sb3 = new StringBuilder(); sb3.append(PreferenceHelper.t3(context) < DBUtil.K3(context)); sb3.append(""); hashMap.put("Folder Limit Reached: ", sb3.toString()); hashMap.put("Image missing: ", DBUtil.Y(context, true) + ""); hashMap.put("Permission missing: ", PermissionUtil.k(context)); hashMap.put("No keep activity: ", CustomExceptionHandler.b(context.getContentResolver()) + ""); hashMap.put("Camera launch failed: ", PreferenceHelper.A6() + ""); hashMap.put("Low Storage: ", SDStorageManager.f() + ""); hashMap.put("Cloud OCR Balance: ", n(context)); hashMap.put("Vendor: ", AppSwitch.f11946q); hashMap.put("Locale ", Locale.getDefault().toString()); hashMap.put("Real open double focus: ", PreferenceHelper.s1() + ""); hashMap.put("show auto capture: ", PreferenceHelper.n8() + ""); hashMap.put("open auto capture: ", PreferenceHelper.v() + ""); hashMap.put("useNewFindBorder: ", PreferenceHelper.ej() + ""); hashMap.put("real Camera api: ", CameraXUtilKt.n() + ""); hashMap.put("new magic: ", PreferenceHelper.C() ? "new" : "old"); boolean r10 = PreferenceHelper.r(); String str = ServerProtocol.DIALOG_RETURN_SCOPES_TRUE; hashMap.put("device supported: ", r10 ? str : "false"); if (!PreferenceHelper.q(false)) { str = "false"; } hashMap.put("moire support: ", str); try { hashMap.put("userInfo:", "TianShuAPI.getUserInfo: " + GsonUtils.e(TianShuAPI.L0())); } catch (Exception e10) { LogUtils.e("GetLogTask", e10); } LogUtils.a("GetLogTask", "getCamScannerVersionInfo\n" + hashMap); return hashMap; } private String l() { Throwable th; String str; Exception e10; ByteArrayOutputStream byteArrayOutputStream = null; try { ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(); try { OkGoUtils.a(this.f21460p, "https://www.camcard.com/site/checkcdn", byteArrayOutputStream2); str = byteArrayOutputStream2.toString(); FileUtil.c(byteArrayOutputStream2); } catch (Exception e11) { e10 = e11; byteArrayOutputStream = byteArrayOutputStream2; try { LogUtils.e("GetLogTask", e10); str = e10.getMessage(); FileUtil.c(byteArrayOutputStream); return str; } catch (Throwable th2) { th = th2; FileUtil.c(byteArrayOutputStream); throw th; } } catch (Throwable th3) { th = th3; byteArrayOutputStream = byteArrayOutputStream2; FileUtil.c(byteArrayOutputStream); throw th; } } catch (Exception e12) { e10 = e12; LogUtils.e("GetLogTask", e10); str = e10.getMessage(); FileUtil.c(byteArrayOutputStream); return str; } return str; } private String n(Context context) { OCRBalanceManager f10 = OCRBalanceManager.f(); int a10 = f10.a(); if (a10 != 200) { return "query failed, errorCode is " + a10; } return f10.c() + ""; } public Uri m() { try { HashMap<String, String> k10 = k(this.f21460p, this.f21458n); StringBuilder sb2 = new StringBuilder(256); sb2.append(k10); sb2.append("\nPackageName: " + this.f21460p.getPackageName()); sb2.append(" Full: " + CsApplication.W()); sb2.append(" Pay: " + CsApplication.X()); sb2.append(" Vip: " + SyncUtil.S1()); sb2.append("\nAlwaysFinishActivities: " + CustomExceptionHandler.b(this.f21460p.getContentResolver()) + "\n "); StringBuilder sb3 = new StringBuilder(); sb3.append(" isSandBox:"); sb3.append(CsApplication.E() == 0); sb2.append(sb3.toString()); sb2.append(" getGooglePlayServiceVersion: " + AppUtil.u(this.f21460p)); sb2.append("\n" + ((Object) Util.M(this.f21460p))); sb2.append("\nTimeZone " + TimeZone.getDefault().getDisplayName()); sb2.append("\nNetType " + Util.W(this.f21460p)); sb2.append("\nIn doc "); sb2.append(DBUtil.Z(this.f21460p, true)[2]); sb2.append("\nNot In doc "); sb2.append(DBUtil.Z(this.f21460p, false)[2]); sb2.append("\nAll account name "); sb2.append(DBUtil.W(this.f21460p)); sb2.append("\nSupported_ABIS " + Arrays.toString(Build.SUPPORTED_ABIS)); sb2.append("\nCheckcdn " + l()); sb2.append("\nedu auth: "); sb2.append(AccountPreference.D()); sb2.append("\nis edu account: "); sb2.append(SyncUtil.m1(this.f21460p)); UploadDirJson s10 = DirSyncFromServer.s(this.f21460p, null, false); if (s10 != null) { sb2.append("\nLocal Personal Dir structure: "); sb2.append(s10.toJSONObject().toString()); } try { sb2.append("\nBookSplitter GetVersion=" + BookSplitter.GetVersion()); } catch (UnsatisfiedLinkError unused) { } sb2.append("\nproxyAddress=" + System.getProperty("http.proxyHost")); sb2.append("\nproxyPort=" + System.getProperty("http.proxyPort")); sb2.append("\nUnFinishProcessImageInfo=\n" + DBUtil.r2(this.f21460p)); sb2.append("\nsignatures=" + AppUtil.C(this.f21460p.getPackageName(), this.f21460p)); LogUtils.a("GetLogTask", sb2.toString()); LogUtils.a("GetLogTask", "-----------------------------log end ------------------------"); return AppUtil.z(this.f21460p, sb2.toString(), this.f21457m); } catch (Exception e10) { LogUtils.e("GetLogTask", e10); return null; } } public Uri o() { Uri uri = null; try { this.f21445a = k(this.f21460p, this.f21458n); StringBuilder sb2 = new StringBuilder(256); sb2.append(this.f21445a); sb2.append("\nPackageName: " + this.f21460p.getPackageName()); sb2.append(" Full: " + CsApplication.W()); sb2.append(" Pay: " + CsApplication.X()); sb2.append(" Vip: " + SyncUtil.S1()); sb2.append("\nAlwaysFinishActivities: " + CustomExceptionHandler.b(this.f21460p.getContentResolver()) + "\n "); StringBuilder sb3 = new StringBuilder(); sb3.append(" isSandBox:"); sb3.append(CsApplication.E() == 0); sb2.append(sb3.toString()); sb2.append(" getGooglePlayServiceVersion: " + AppUtil.u(this.f21460p)); sb2.append("\n" + ((Object) Util.M(this.f21460p))); sb2.append("\nTimeZone " + TimeZone.getDefault().getDisplayName()); sb2.append("\nNetType " + Util.W(this.f21460p)); sb2.append("\nIn doc "); sb2.append(DBUtil.Z(this.f21460p, true)[2]); sb2.append("\nNot In doc "); sb2.append(DBUtil.Z(this.f21460p, false)[2]); sb2.append("\nAll account name "); sb2.append(DBUtil.W(this.f21460p)); sb2.append("\nSupported_ABIS " + Arrays.toString(Build.SUPPORTED_ABIS)); sb2.append("\nCheckcdn " + l()); sb2.append("\nedu auth: "); sb2.append(AccountPreference.D()); sb2.append("\nis edu account: "); sb2.append(SyncUtil.m1(this.f21460p)); UploadDirJson s10 = DirSyncFromServer.s(this.f21460p, null, false); if (s10 != null) { sb2.append("\nLocal Personal Dir structure: "); sb2.append(s10.toJSONObject().toString()); } try { sb2.append("\nBookSplitter GetVersion=" + BookSplitter.GetVersion()); } catch (UnsatisfiedLinkError unused) { } sb2.append("\nproxyAddress=" + System.getProperty("http.proxyHost")); sb2.append("\nproxyPort=" + System.getProperty("http.proxyPort")); sb2.append("\nUnFinishProcessImageInfo=\n" + DBUtil.r2(this.f21460p)); sb2.append("\nsignatures=" + AppUtil.C(this.f21460p.getPackageName(), this.f21460p)); LogUtils.a("GetLogTask", sb2.toString()); LogUtils.a("GetLogTask", "-----------------------------log end ------------------------"); uri = AppUtil.z(this.f21460p, sb2.toString(), this.f21457m); } catch (Exception e10) { LogUtils.e("GetLogTask", e10); this.f21454j = e10.getMessage(); this.f21453i = false; } if (!this.f21447c && uri != null) { String path = uri.getPath(); try { this.f21453i = FeedbackRequestUtil.a(this.f21460p, "case", this.f21446b, this.f21451g, this.f21450f, new File(path), this.f21459o, this.f21445a); FileUtil.k(path); } catch (Exception e11) { LogUtils.e("GetLogTask", e11); this.f21454j = e11.getMessage(); this.f21453i = false; } LogUtils.a("GetLogTask", "logUri = " + uri); return uri; } LogUtils.a("GetLogTask", "logUri = " + uri); return uri; } } public GetLogTask(Activity activity, String str, String str2, String str3, String str4, boolean z10) { this.f21442a = activity; this.f21444c = new SendLogTask(activity, str, str2, str3, str4, z10, true, null, false, null, null); } public GetLogTask(Activity activity, String str, String str2, String str3, String str4, boolean z10, String str5, boolean z11, ArrayList<File> arrayList, boolean z12, ArrayList<String> arrayList2, IUploadCallback iUploadCallback) { this.f21442a = activity; this.f21444c = new SendLogTask(activity, str, str2, str3, str4, z10, z11, arrayList, z12, arrayList2, iUploadCallback); } public GetLogTask(Activity activity, String str, String str2, String str3, boolean z10, String str4, boolean z11, ArrayList<File> arrayList, IUploadCallback iUploadCallback) { this(activity, str, null, str2, str3, z10, str4, z11, arrayList, false, null, iUploadCallback); } private void c(String str) { Intent intent = new Intent(); intent.setAction("android.intent.action.SEND"); intent.putExtra("android.intent.extra.TEXT", str); intent.setType(HttpPostBodyUtil.DEFAULT_TEXT_CONTENT_TYPE); Intent createChooser = Intent.createChooser(intent, this.f21442a.getString(R.string.setting_report)); createChooser.addFlags(268435456); this.f21442a.startActivity(createChooser); } /* access modifiers changed from: protected */ /* renamed from: a */ public Uri doInBackground(Void... voidArr) { return this.f21444c.o(); } /* access modifiers changed from: protected */ /* JADX WARNING: Removed duplicated region for block: B:22:0x0159 */ /* renamed from: b */ public void onPostExecute(Uri uri) { if (TextUtils.isEmpty(this.f21444c.f21454j)) { if (this.f21444c.f21447c) { Intent intent = new Intent(); intent.putExtra("android.intent.extra.SUBJECT", this.f21444c.f21449e); intent.putExtra("android.intent.extra.TEXT", this.f21444c.f21450f + "\n\n" + this.f21444c.f21445a); if (uri != null) { intent.setAction("android.intent.action.SEND"); intent.setType("application/zip"); intent.putExtra("android.intent.extra.STREAM", uri); intent.putExtra("android.intent.extra.EMAIL", new String[]{this.f21444c.f21448d}); } else { intent.setData(Uri.parse(MailTo.MAILTO_SCHEME + this.f21444c.f21448d)); intent.setAction("android.intent.action.SENDTO"); } Intent createChooser = Intent.createChooser(intent, this.f21442a.getString(R.string.a_label_send_to)); createChooser.addFlags(268435456); this.f21442a.startActivity(createChooser); } else if (this.f21444c.f21455k) { if (this.f21444c.f21453i) { ToastUtils.j(this.f21442a, R.string.a_msg_feedback_ok); } else { ToastUtils.j(this.f21442a, R.string.a_msg_feedback_send_failed); } } else if (this.f21444c.f21456l != null) { this.f21444c.f21456l.a(this.f21442a, this.f21444c.f21453i); } if (this.f21444c.f21455k) { try { this.f21443b.dismiss(); } catch (Exception e10) { LogUtils.d("GetLogTask", "Exception", e10); } this.f21442a.finish(); } } c("feedback error=" + this.f21444c.f21454j); if (this.f21444c.f21455k) { } } /* access modifiers changed from: protected */ public void onPreExecute() { if (this.f21444c.f21455k) { if (this.f21443b == null) { ProgressDialog progressDialog = new ProgressDialog(this.f21442a); this.f21443b = progressDialog; progressDialog.t(this.f21442a.getString(R.string.a_msg_checking_account)); this.f21443b.N(0); this.f21443b.setCancelable(false); } this.f21443b.show(); } } }