package B0;

import D0.RunnableC0074k;
import O1.C0225a;
import R0.C0281c;
import Z6.C0369i;
import android.app.job.JobParameters;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.graphics.Typeface;
import android.media.metrics.NetworkEvent;
import android.media.metrics.PlaybackErrorEvent;
import android.media.metrics.PlaybackMetrics;
import android.media.metrics.PlaybackStateEvent;
import android.media.metrics.TrackChangeEvent;
import android.net.Uri;
import android.os.Handler;
import android.os.Process;
import android.os.StrictMode;
import android.util.Log;
import android.view.Surface;
import android.view.View;
import androidx.media3.ui.PlayerView;
import com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService;
import d3.V0;
import e4.ScheduledFutureC0877h;
import e4.ThreadFactoryC0870a;
import e6.C0891c;
import h7.C1037b;
import h7.C1040e;
import h7.InterfaceC1041f;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import m4.C1167c;
import n4.u0;
import q4.C1463c;
import x0.AbstractC1709a;

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

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

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

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

    public /* synthetic */ A(Object obj, int i, Object obj2) {
        this.f508q = i;
        this.f509r = obj;
        this.f510s = obj2;
    }

    private final void a() {
        D0.m mVar = (D0.m) this.f509r;
        C0021h c0021h = (C0021h) this.f510s;
        mVar.getClass();
        synchronized (c0021h) {
        }
        F f3 = mVar.f1570c;
        int i = x0.v.f18553a;
        C0.f fVar = f3.f523q.f536I;
        fVar.M(fVar.I((L0.C) fVar.f1102t.f5169e), 1013, new C0.c(3));
    }

    private final void b() {
        D0.m mVar = (D0.m) this.f509r;
        C0021h c0021h = (C0021h) this.f510s;
        mVar.getClass();
        synchronized (c0021h) {
        }
        F f3 = mVar.f1570c;
        int i = x0.v.f18553a;
        C0.f fVar = f3.f523q.f536I;
        C0.a aVarI = fVar.I((L0.C) fVar.f1102t.f5169e);
        fVar.M(aVarI, 1020, new A1.G(aVarI, c0021h, 9));
    }

    private final void c() {
        D4.a aVar;
        d4.n nVar = (d4.n) this.f509r;
        D4.b bVar = (D4.b) this.f510s;
        if (nVar.f12279b != d4.n.f12277d) {
            throw new IllegalStateException("provide() can be called only once.");
        }
        synchronized (nVar) {
            aVar = nVar.f12278a;
            nVar.f12278a = null;
            nVar.f12279b = bVar;
        }
        aVar.d(bVar);
    }

    private final void d() {
        d4.m mVar = (d4.m) this.f509r;
        D4.b bVar = (D4.b) this.f510s;
        synchronized (mVar) {
            try {
                if (mVar.f12275b == null) {
                    mVar.f12274a.add(bVar);
                } else {
                    mVar.f12275b.add(bVar.get());
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        long j8;
        boolean z8;
        boolean z9 = true;
        switch (this.f508q) {
            case u0.f15495q /* 0 */:
                I i = (I) this.f509r;
                A1.x xVar = (A1.x) this.f510s;
                int i5 = i.f551Y - xVar.f358c;
                i.f551Y = i5;
                if (xVar.f359d) {
                    i.f552Z = xVar.f360e;
                    i.f553a0 = true;
                }
                if (i5 == 0) {
                    u0.S s8 = ((j0) xVar.f361f).f815a;
                    if (!i.f580w0.f815a.p() && s8.p()) {
                        i.f582x0 = -1;
                        i.f584y0 = 0L;
                    }
                    if (!s8.p()) {
                        List listAsList = Arrays.asList(((o0) s8).f867h);
                        AbstractC1709a.j(listAsList.size() == i.f534F.size());
                        for (int i8 = 0; i8 < listAsList.size(); i8++) {
                            ((H) i.f534F.get(i8)).f529b = (u0.S) listAsList.get(i8);
                        }
                    }
                    long j9 = -9223372036854775807L;
                    if (i.f553a0) {
                        if (((j0) xVar.f361f).f816b.equals(i.f580w0.f816b) && ((j0) xVar.f361f).f818d == i.f580w0.f832s) {
                            z9 = false;
                        }
                        if (z9) {
                            if (s8.p() || ((j0) xVar.f361f).f816b.b()) {
                                j9 = ((j0) xVar.f361f).f818d;
                            } else {
                                j0 j0Var = (j0) xVar.f361f;
                                L0.C c3 = j0Var.f816b;
                                long j10 = j0Var.f818d;
                                Object obj = c3.f3625a;
                                u0.P p3 = i.f533E;
                                s8.g(obj, p3);
                                j9 = j10 + p3.f17179e;
                            }
                        }
                        j8 = j9;
                        z8 = z9;
                    } else {
                        j8 = -9223372036854775807L;
                        z8 = false;
                    }
                    i.f553a0 = false;
                    i.n0((j0) xVar.f361f, 1, z8, i.f552Z, j8, -1, false);
                    return;
                }
                return;
            case 1:
                m0 m0Var = (m0) this.f510s;
                ((P) this.f509r).getClass();
                try {
                    synchronized (m0Var) {
                    }
                    try {
                        m0Var.f850a.d(m0Var.f852c, m0Var.f853d);
                        return;
                    } finally {
                        m0Var.a(true);
                    }
                } catch (C0030q e8) {
                    AbstractC1709a.p("ExoPlayerImplInternal", "Unexpected error delivering message on external thread.", e8);
                    throw new RuntimeException(e8);
                }
            case 2:
                ((C0.k) this.f509r).f1128d.reportTrackChangeEvent((TrackChangeEvent) this.f510s);
                return;
            case 3:
                ((C0.k) this.f509r).f1128d.reportNetworkEvent((NetworkEvent) this.f510s);
                return;
            case 4:
                ((C0.k) this.f509r).f1128d.reportPlaybackErrorEvent((PlaybackErrorEvent) this.f510s);
                return;
            case 5:
                ((C0.k) this.f509r).f1128d.reportPlaybackMetrics((PlaybackMetrics) this.f510s);
                return;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                ((C0.k) this.f509r).f1128d.reportPlaybackStateEvent((PlaybackStateEvent) this.f510s);
                return;
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                a();
                return;
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                D0.n nVar = (D0.n) this.f510s;
                D0.m mVar = ((D0.H) ((K4.c) this.f509r).f3604r).f1498T0;
                Handler handler = mVar.f1569b;
                if (handler != null) {
                    handler.post(new RunnableC0074k(mVar, nVar, 9));
                    return;
                }
                return;
            case 9:
                PlayerView.a((PlayerView) this.f509r, (Bitmap) this.f510s);
                return;
            case 10:
                ((E.b) this.f509r).i((Typeface) this.f510s);
                return;
            case 11:
                ((G0.b) ((F0.k) ((F0.q) this.f509r).f2406s.f3604r).f2333r.f2761t.get(((F0.j) this.f510s).f2307m)).c(true);
                return;
            case 12:
                int i9 = JobInfoSchedulerService.f9506q;
                ((JobInfoSchedulerService) this.f509r).jobFinished((JobParameters) this.f510s, false);
                return;
            case 13:
                G0.b bVar = (G0.b) this.f509r;
                bVar.f2752y = false;
                bVar.d((Uri) this.f510s);
                return;
            case 14:
                ((x0.d) this.f509r).a(this.f510s);
                return;
            case 15:
                ((L0.T) this.f509r).E((T0.z) this.f510s);
                return;
            case 16:
                Runnable runnable = (Runnable) this.f509r;
                O1.F f3 = (O1.F) this.f510s;
                try {
                    runnable.run();
                    return;
                } finally {
                    f3.a();
                }
            case 17:
                ((C0281c) ((C0225a) this.f509r).f5011s).f5874g.getClass();
                return;
            case 18:
                D0.m mVar2 = (D0.m) this.f509r;
                mVar2.getClass();
                int i10 = x0.v.f18553a;
                I i11 = mVar2.f1570c.f523q;
                u0.d0 d0Var = (u0.d0) this.f510s;
                i11.f576u0 = d0Var;
                i11.f532C.e(25, new E(d0Var));
                return;
            case 19:
                b();
                return;
            case 20:
                S0.l lVar = (S0.l) this.f509r;
                SurfaceTexture surfaceTexture = lVar.f6266w;
                Surface surface = lVar.f6267x;
                SurfaceTexture surfaceTexture2 = (SurfaceTexture) this.f510s;
                Surface surface2 = new Surface(surfaceTexture2);
                lVar.f6266w = surfaceTexture2;
                lVar.f6267x = surface2;
                Iterator it = lVar.f6260q.iterator();
                while (it.hasNext()) {
                    ((F) it.next()).f523q.j0(surface2);
                }
                if (surfaceTexture != null) {
                    surfaceTexture.release();
                }
                if (surface != null) {
                    surface.release();
                    return;
                }
                return;
            case 21:
                ((C0369i) this.f509r).E((a7.e) this.f510s);
                return;
            case 22:
                c();
                return;
            case 23:
                d();
                return;
            case 24:
                ThreadFactoryC0870a threadFactoryC0870a = (ThreadFactoryC0870a) this.f509r;
                Process.setThreadPriority(threadFactoryC0870a.f12441c);
                StrictMode.ThreadPolicy threadPolicy = threadFactoryC0870a.f12442d;
                if (threadPolicy != null) {
                    StrictMode.setThreadPolicy(threadPolicy);
                }
                ((Runnable) this.f510s).run();
                return;
            case 25:
                Callable callable = (Callable) this.f509r;
                ScheduledFutureC0877h scheduledFutureC0877h = (ScheduledFutureC0877h) ((V0) this.f510s).f11784r;
                try {
                    scheduledFutureC0877h.j(callable.call());
                    return;
                } catch (Exception e9) {
                    scheduledFutureC0877h.k(e9);
                    return;
                }
            case 26:
                h6.c cVar = (h6.c) this.f509r;
                P6.g.e(cVar, "this$0");
                View view = (View) this.f510s;
                P6.g.e(view, "$view");
                ((C0891c) cVar.f13436e).d(view);
                return;
            case 27:
                ((C1040e) ((InterfaceC1041f) this.f509r)).g((C1037b) this.f510s, A6.n.f457a);
                return;
            case 28:
                ((k4.m) this.f509r).c((String) this.f510s, Boolean.FALSE);
                return;
            default:
                k4.m mVar3 = ((k4.q) this.f509r).f13908g;
                Thread threadCurrentThread = Thread.currentThread();
                mVar3.getClass();
                long jCurrentTimeMillis = System.currentTimeMillis();
                k4.s sVar = mVar3.f13890n;
                if (sVar == null || !sVar.f13927e.get()) {
                    long j11 = jCurrentTimeMillis / 1000;
                    String strE = mVar3.e();
                    if (strE == null) {
                        Log.w("FirebaseCrashlytics", "Tried to write a non-fatal exception while no session was open.", null);
                        return;
                    }
                    C1167c c1167c = new C1167c(strE, j11, Collections.EMPTY_MAP);
                    C1463c c1463c = mVar3.f13889m;
                    c1463c.getClass();
                    String strConcat = "Persisting non-fatal event for session ".concat(strE);
                    if (Log.isLoggable("FirebaseCrashlytics", 2)) {
                        Log.v("FirebaseCrashlytics", strConcat, null);
                    }
                    c1463c.h((Throwable) this.f510s, threadCurrentThread, "error", c1167c, false);
                    return;
                }
                return;
        }
    }

    public /* synthetic */ A(k4.q qVar, Throwable th) {
        this.f508q = 29;
        Map map = Collections.EMPTY_MAP;
        this.f509r = qVar;
        this.f510s = th;
    }
}
