package F;

import L1.Y0;
import N2.p;
import N2.q;
import P.C0168l;
import android.app.job.JobParameters;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Process;
import android.os.StrictMode;
import android.util.Log;
import android.view.Choreographer;
import androidx.fragment.app.N;
import androidx.lifecycle.G;
import com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService;
import com.google.firebase.messaging.r;
import d.C0527u;
import io.flutter.Build;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.plugin.editing.FlutterTextUtils;
import io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin;
import io.flutter.plugins.firebase.core.FlutterFirebasePluginRegistry;
import io.flutter.plugins.webviewflutter.JavaScriptChannel;
import io.sentry.C;
import io.sentry.C0709d;
import io.sentry.C0730k;
import io.sentry.C1;
import io.sentry.EnumC0738m1;
import io.sentry.M1;
import io.sentry.Q;
import io.sentry.SpotlightIntegration;
import io.sentry.android.core.AnrIntegration;
import io.sentry.android.core.SentryAndroidOptions;
import io.sentry.android.core.SystemEventsBreadcrumbsIntegration;
import io.sentry.android.core.U;
import io.sentry.android.replay.x;
import io.sentry.android.replay.z;
import io.sentry.flutter.SentryFlutterPluginKt;
import io.sentry.protocol.C0750c;
import io.sentry.protocol.E;
import io.sentry.protocol.t;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.zip.GZIPOutputStream;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class j implements Runnable {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ int f597k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final /* synthetic */ Object f598l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ Object f599m;

    public /* synthetic */ j(int i, Object obj, Object obj2) {
        this.f597k = i;
        this.f598l = obj;
        this.f599m = obj2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r6v8, types: [d4.b, java.lang.Object] */
    @Override // java.lang.Runnable
    public final void run() {
        B2.c cVar;
        int i = 1;
        boolean z5 = false;
        Object[] objArr = 0;
        switch (this.f597k) {
            case 0:
                ((b) this.f598l).f((Typeface) this.f599m);
                return;
            case 1:
                q qVar = (q) this.f598l;
                Z2.a aVar = (Z2.a) this.f599m;
                if (qVar.f2226b != q.f2224d) {
                    throw new IllegalStateException("provide() can be called only once.");
                }
                synchronized (qVar) {
                    cVar = qVar.f2225a;
                    qVar.f2225a = null;
                    qVar.f2226b = aVar;
                    break;
                }
                cVar.getClass();
                return;
            case 2:
                p pVar = (p) this.f598l;
                Z2.a aVar2 = (Z2.a) this.f599m;
                synchronized (pVar) {
                    try {
                        if (pVar.f2222b == null) {
                            pVar.f2221a.add(aVar2);
                        } else {
                            pVar.f2222b.add(aVar2.get());
                        }
                    } finally {
                    }
                }
                return;
            case 3:
                ((W2.b) ((Map.Entry) this.f598l).getKey()).a((W2.a) this.f599m);
                return;
            case 4:
                O2.a aVar3 = (O2.a) this.f598l;
                Process.setThreadPriority(aVar3.f2279c);
                StrictMode.ThreadPolicy threadPolicy = aVar3.f2280d;
                if (threadPolicy != null) {
                    StrictMode.setThreadPolicy(threadPolicy);
                }
                ((Runnable) this.f599m).run();
                return;
            case 5:
                Callable callable = (Callable) this.f598l;
                O2.i iVar = (O2.i) ((g3.c) this.f599m).f6465l;
                try {
                    iVar.j(callable.call());
                    return;
                } catch (Exception e2) {
                    iVar.k(e2);
                    return;
                }
            case 6:
                c5.f fVar = (c5.f) this.f598l;
                fVar.getClass();
                try {
                    boolean z6 = fVar.f4751l.checkCallingOrSelfPermission("android.permission.INSTALL_PACKAGES") == 0;
                    Log.d("FLUTTER OTA", "INSTALL_PACKAGES permission: " + z6);
                    z5 = z6;
                } catch (Exception e6) {
                    Log.w("FLUTTER OTA", "Error checking INSTALL_PACKAGES permission", e6);
                }
                File file = (File) this.f599m;
                if (z5) {
                    Log.d("FLUTTER OTA", "App has INSTALL_PACKAGES, using package installer");
                    fVar.c(file);
                    return;
                } else {
                    if (fVar.f4760w) {
                        fVar.c(file);
                        return;
                    }
                    Uri uriForFile = E.f.getUriForFile(fVar.f4751l, fVar.f4754o, file);
                    Intent intent = new Intent("android.intent.action.INSTALL_PACKAGE");
                    intent.setData(uriForFile);
                    intent.setFlags(1).addFlags(268435456);
                    fVar.f4751l.startActivity(intent);
                    fVar.d(true, 2, "Installation started", null, null);
                    return;
                }
            case 7:
                ((Y0) this.f598l).a((Intent) this.f599m);
                return;
            case 8:
                P1.i iVar2 = (P1.i) this.f599m;
                try {
                    iVar2.b(((r) this.f598l).a());
                    return;
                } catch (Exception e7) {
                    iVar2.a(e7);
                    return;
                }
            case AndroidTouchProcessor.PointerChange.PAN_ZOOM_END /* 9 */:
                N n5 = (N) this.f598l;
                n5.getLifecycle().a(new C0168l(i, (C0527u) this.f599m, n5));
                return;
            case FlutterTextUtils.LINE_FEED /* 10 */:
                int i5 = JobInfoSchedulerService.f4799k;
                ((JobInfoSchedulerService) this.f598l).jobFinished((JobParameters) this.f599m, false);
                return;
            case 11:
                FlutterFirebaseCorePlugin.lambda$delete$8((String) this.f598l, (P1.i) this.f599m);
                return;
            case 12:
                FlutterFirebasePluginRegistry.lambda$getPluginConstantsForFirebaseApp$0((I2.g) this.f598l, (P1.i) this.f599m);
                return;
            case FlutterTextUtils.CARRIAGE_RETURN /* 13 */:
                ((JavaScriptChannel) this.f598l).lambda$postMessage$1((String) this.f599m);
                return;
            case 14:
                ((C0730k) this.f598l).i((M1) this.f599m);
                return;
            case 15:
                ((Q) this.f599m).k(((C) this.f598l).f6869a.getShutdownTimeoutMillis());
                return;
            case SentryFlutterPluginKt.VIDEO_BLOCK_SIZE /* 16 */:
                io.sentry.internal.debugmeta.c cVar2 = (io.sentry.internal.debugmeta.c) this.f599m;
                SpotlightIntegration spotlightIntegration = (SpotlightIntegration) this.f598l;
                try {
                    C1 c12 = spotlightIntegration.f7024k;
                    if (c12 == null) {
                        throw new IllegalArgumentException("SentryOptions are required to send envelopes.");
                    }
                    HttpURLConnection httpURLConnectionE = SpotlightIntegration.e(c12.getSpotlightConnectionUrl() != null ? spotlightIntegration.f7024k.getSpotlightConnectionUrl() : io.sentry.util.e.f8197a ? "http://10.0.2.2:8969/stream" : "http://localhost:8969/stream");
                    try {
                        OutputStream outputStream = httpURLConnectionE.getOutputStream();
                        try {
                            GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
                            try {
                                spotlightIntegration.f7024k.getSerializer().e(cVar2, gZIPOutputStream);
                                gZIPOutputStream.close();
                                if (outputStream != null) {
                                    outputStream.close();
                                }
                                spotlightIntegration.f7025l.j(EnumC0738m1.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(httpURLConnectionE.getResponseCode()));
                            } finally {
                            }
                        } finally {
                            SpotlightIntegration.a(httpURLConnectionE);
                            return;
                        }
                    } catch (Throwable th) {
                        try {
                            spotlightIntegration.f7025l.p(EnumC0738m1.ERROR, "An exception occurred while submitting the envelope to the Sentry server.", th);
                            spotlightIntegration.f7025l.j(EnumC0738m1.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(httpURLConnectionE.getResponseCode()));
                        } catch (Throwable th2) {
                            spotlightIntegration.f7025l.j(EnumC0738m1.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(httpURLConnectionE.getResponseCode()));
                            SpotlightIntegration.a(httpURLConnectionE);
                            throw th2;
                        }
                    }
                    SpotlightIntegration.a(httpURLConnectionE);
                    return;
                } catch (Exception e8) {
                    spotlightIntegration.f7025l.p(EnumC0738m1.ERROR, "An exception occurred while creating the connection to spotlight.", e8);
                    return;
                }
            case 17:
                AnrIntegration anrIntegration = (AnrIntegration) this.f598l;
                SentryAndroidOptions sentryAndroidOptions = (SentryAndroidOptions) this.f599m;
                synchronized (anrIntegration.f7117m) {
                    try {
                        if (!anrIntegration.f7116l) {
                            anrIntegration.a(sentryAndroidOptions);
                        }
                    } finally {
                    }
                    break;
                }
                return;
            case 18:
                SystemEventsBreadcrumbsIntegration systemEventsBreadcrumbsIntegration = (SystemEventsBreadcrumbsIntegration) this.f598l;
                C1 c13 = (C1) this.f599m;
                synchronized (systemEventsBreadcrumbsIntegration.p) {
                    try {
                        if (!systemEventsBreadcrumbsIntegration.f7216o) {
                            systemEventsBreadcrumbsIntegration.a((SentryAndroidOptions) c13);
                        }
                    } finally {
                    }
                    break;
                }
                return;
            case 19:
                io.sentry.android.core.internal.util.m mVar = (io.sentry.android.core.internal.util.m) this.f598l;
                mVar.getClass();
                try {
                    mVar.f7379t = Choreographer.getInstance();
                    return;
                } catch (Throwable th3) {
                    ((U) this.f599m).p(EnumC0738m1.ERROR, "Error retrieving Choreographer instance. Slow and frozen frames will not be reported.", th3);
                    return;
                }
            case 20:
                z zVar = (z) this.f598l;
                AbstractC0983h.e("this$0", zVar);
                io.sentry.android.replay.viewhierarchy.e eVar = (io.sentry.android.replay.viewhierarchy.e) this.f599m;
                Bitmap bitmap = zVar.f7666s;
                Canvas canvas = new Canvas(bitmap);
                canvas.setMatrix((Matrix) zVar.f7668u.getValue());
                eVar.a(new x(objArr == true ? 1 : 0, zVar, canvas));
                zVar.f7664o.n(bitmap);
                zVar.f7671x.set(true);
                zVar.f7669v.set(false);
                return;
            case Build.API_LEVELS.API_21 /* 21 */:
                G g5 = (G) this.f598l;
                C1 c14 = (C1) this.f599m;
                try {
                    g5.run();
                    return;
                } catch (Throwable th4) {
                    c14.getLogger().p(EnumC0738m1.ERROR, "Failed to execute task ".concat("WindowRecorder.capture"), th4);
                    return;
                }
            case Build.API_LEVELS.API_22 /* 22 */:
                G g6 = (G) this.f598l;
                C1 c15 = (C1) this.f599m;
                AbstractC0983h.e("$options", c15);
                try {
                    g6.run();
                    return;
                } catch (Throwable th5) {
                    c15.getLogger().p(EnumC0738m1.ERROR, "Failed to execute task ".concat("ReplayIntegration.finalize_previous_replay"), th5);
                    return;
                }
            case Build.API_LEVELS.API_23 /* 23 */:
                ((io.sentry.cache.g) this.f598l).q("replay.json", (t) this.f599m);
                return;
            case 24:
                io.sentry.cache.g gVar = (io.sentry.cache.g) this.f598l;
                E e9 = (E) this.f599m;
                if (e9 == null) {
                    gVar.n("user.json");
                    return;
                } else {
                    gVar.q("user.json", e9);
                    return;
                }
            case Build.API_LEVELS.API_25 /* 25 */:
                C0709d c0709d = (C0709d) this.f599m;
                io.sentry.cache.g gVar2 = (io.sentry.cache.g) this.f598l;
                gVar2.getClass();
                try {
                    ((io.sentry.cache.tape.f) gVar2.f7703b.a()).a(c0709d);
                    return;
                } catch (IOException e10) {
                    gVar2.f7702a.getLogger().p(EnumC0738m1.ERROR, "Failed to add breadcrumb to file queue", e10);
                    return;
                }
            case Build.API_LEVELS.API_26 /* 26 */:
                ((io.sentry.cache.g) this.f598l).q("contexts.json", (C0750c) this.f599m);
                return;
            case Build.API_LEVELS.API_27 /* 27 */:
                io.sentry.cache.g gVar3 = (io.sentry.cache.g) this.f598l;
                String str = (String) this.f599m;
                if (str == null) {
                    gVar3.n("transaction.json");
                    return;
                } else {
                    gVar3.q("transaction.json", str);
                    return;
                }
            case Build.API_LEVELS.API_28 /* 28 */:
                Runnable runnable = (Runnable) this.f599m;
                io.sentry.cache.g gVar4 = (io.sentry.cache.g) this.f598l;
                gVar4.getClass();
                try {
                    runnable.run();
                    return;
                } catch (Throwable th6) {
                    gVar4.f7702a.getLogger().p(EnumC0738m1.ERROR, "Serialization task failed", th6);
                    return;
                }
            default:
                ((r3.b) this.f598l).f9746a.success(this.f599m);
                return;
        }
    }

    public /* synthetic */ j(c5.f fVar, Uri uri, File file) {
        this.f597k = 6;
        this.f598l = fVar;
        this.f599m = file;
    }
}
