package yt2; import android.annotation.SuppressLint; import android.app.Application; import android.os.Build; import android.os.Process; import com.huawei.hms.push.constant.RemoteMessageConst; import com.tencent.matrix.report.Issue; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.ArrayList; import ko2.e; import kotlin.Metadata; import kotlin.Unit; import kotlin.concurrent.ThreadsKt; import kotlin.jvm.functions.Function0; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.Lambda; import kotlin.jvm.internal.Ref; import kotlin.text.StringsKt__StringsKt; @Metadata(bv = {}, d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\f\n\u0002\b\u0005\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u000f\u0010\u0010J\u0006\u0010\u0003\u001a\u00020\u0002J\u000e\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004J\n\u0010\b\u001a\u0004\u0018\u00010\u0002H\u0003J(\u0010\u000e\u001a\u00020\u00062\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\u00022\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u0005\u001a\u00020\u0004H\u0002¨\u0006\u0011"}, d2 = {"Lyt2/b;", "", "", "c", "Lyt2/a;", "callback", "", "a", "d", "", "pid", "bufferName", "", RemoteMessageConst.Notification.PRIORITY, "b", "<init>", "()V", "xylog_release"}, k = 1, mv = {1, 4, 0}) /* compiled from: U.kt */ public final class b { /* renamed from: a reason: collision with root package name */ public static final b f159729a = new b(); @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\b\n\u0000\n\u0002\u0010\u0002\n\u0000\u0010\u0000\u001a\u00020\u0001H\n¢\u0006\u0002\b\u0002"}, d2 = {"<anonymous>", "", "invoke"}, k = 3, mv = {1, 1, 16}) /* compiled from: U.kt */ public static final class a extends Lambda implements Function0<Unit> { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ int f159730a; /* renamed from: b reason: collision with root package name */ public final /* synthetic */ String f159731b; /* renamed from: c reason: collision with root package name */ public final /* synthetic */ a f159732c; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public a(int i10, String str, a aVar) { super(0); this.f159730a = i10; this.f159731b = str; this.f159732c = aVar; } /* JADX WARNING: Removed duplicated region for block: B:28:0x00ba A[SYNTHETIC, Splitter:B:28:0x00ba] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x00c5 A[SYNTHETIC, Splitter:B:33:0x00c5] */ /* JADX WARNING: Removed duplicated region for block: B:43:? A[RETURN, SYNTHETIC] */ @Override // kotlin.jvm.functions.Function0 public final void invoke() { Throwable th3; Exception e14; boolean z14 = Build.VERSION.SDK_INT >= 24; String valueOf = String.valueOf(this.f159730a); String str = ' ' + valueOf + ' '; ArrayList arrayList = new ArrayList(); arrayList.add("/system/bin/logcat"); arrayList.add("-b"); arrayList.add(this.f159731b); arrayList.add("-v"); arrayList.add("threadtime"); if (z14) { arrayList.add("--pid"); arrayList.add(valueOf); } arrayList.add("*:D"); Ref.ObjectRef objectRef = new Ref.ObjectRef(); BufferedReader bufferedReader = null; try { Process start = new ProcessBuilder(new String[0]).command(arrayList).start(); Intrinsics.checkExpressionValueIsNotNull(start, Issue.ISSUE_REPORT_PROCESS); BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(start.getInputStream())); while (true) { try { T t14 = (T) bufferedReader2.readLine(); objectRef.element = t14; if (t14 != null) { if (!z14) { if (t14 == null) { Intrinsics.throwNpe(); } if (!(StringsKt__StringsKt.contains$default((CharSequence) t14, (CharSequence) str, false, 2, (Object) null))) { } } this.f159732c.a(((String) objectRef.element) + '\n'); } } catch (Exception e15) { e14 = e15; bufferedReader = bufferedReader2; try { e.g("InnerGetLogcat", e14); if (bufferedReader == null) { try { bufferedReader.close(); return; } catch (IOException e16) { e.g("InnerGetLogcat", e16); return; } } else { return; } } catch (Throwable th4) { th3 = th4; if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e17) { e.g("InnerGetLogcat", e17); } } throw th3; } } catch (Throwable th5) { th3 = th5; bufferedReader = bufferedReader2; if (bufferedReader != null) { } throw th3; } } } catch (Exception e18) { e14 = e18; e.g("InnerGetLogcat", e14); if (bufferedReader == null) { } } } } public final void a(a aVar) { Intrinsics.checkParameterIsNotNull(aVar, "callback"); b(Process.myPid(), "main,system,events", 'D', aVar); } public final void b(int i10, String str, char c14, a aVar) { ThreadsKt.thread$default(false, false, null, "xylog-getLogcat", 0, new a(i10, str, aVar), 23, null); } public final String c() { if (Build.VERSION.SDK_INT >= 28) { String processName = Application.getProcessName(); Intrinsics.checkExpressionValueIsNotNull(processName, "Application.getProcessName()"); return processName; } String d14 = d(); return d14 != null ? d14 : String.valueOf(Process.myPid()); } @SuppressLint({"PrivateApi", "DiscouragedPrivateApi"}) public final String d() { try { Method declaredMethod = Class.forName("android.app.ActivityThread", false, Application.class.getClassLoader()).getDeclaredMethod("currentProcessName", new Class[0]); Intrinsics.checkExpressionValueIsNotNull(declaredMethod, "Class.forName(\n …hod(\"currentProcessName\")"); declaredMethod.setAccessible(true); Object invoke = declaredMethod.invoke(null, new Object[0]); if (!(invoke instanceof String)) { invoke = null; } return (String) invoke; } catch (Throwable unused) { return null; } } }