package com.facebook.internal.instrument.threadcheck; import android.os.Looper; import android.util.Log; import androidx.annotation.RestrictTo; import com.facebook.internal.instrument.InstrumentData; import java.util.Arrays; import java.util.Locale; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.StringCompanionObject; @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP}) /* loaded from: classes2.dex */ public final class ThreadCheckHandler { public static final ThreadCheckHandler INSTANCE = new ThreadCheckHandler(); private static final String TAG = ThreadCheckHandler.class.getCanonicalName(); private static boolean enabled; public static final void enable() { enabled = true; } private ThreadCheckHandler() { } public static final void uiThreadViolationDetected(Class clazz, String methodName, String methodDesc) { Intrinsics.checkNotNullParameter(clazz, "clazz"); Intrinsics.checkNotNullParameter(methodName, "methodName"); Intrinsics.checkNotNullParameter(methodDesc, "methodDesc"); INSTANCE.log("@UiThread", clazz, methodName, methodDesc); } public static final void workerThreadViolationDetected(Class clazz, String methodName, String methodDesc) { Intrinsics.checkNotNullParameter(clazz, "clazz"); Intrinsics.checkNotNullParameter(methodName, "methodName"); Intrinsics.checkNotNullParameter(methodDesc, "methodDesc"); INSTANCE.log("@WorkerThread", clazz, methodName, methodDesc); } private final void log(String str, Class cls, String str2, String str3) { if (enabled) { StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE; String format = String.format(Locale.US, "%s annotation violation detected in %s.%s%s. Current looper is %s and main looper is %s.", Arrays.copyOf(new Object[]{str, cls.getName(), str2, str3, Looper.myLooper(), Looper.getMainLooper()}, 6)); Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(locale, format, *args)"); Exception exc = new Exception(); Log.e(TAG, format, exc); InstrumentData.Builder builder = InstrumentData.Builder.INSTANCE; InstrumentData.Builder.build(exc, InstrumentData.Type.ThreadCheck).save(); } } }