package defpackage;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.util.Pair;
import androidx.media3.exoplayer.drm.DefaultDrmSession$UnexpectedDrmSessionException;
import androidx.media3.exoplayer.drm.MediaDrmCallbackException;
import java.io.IOException;

/* JADX INFO: renamed from: ᵯᵶˈ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class HandlerC4324 extends Handler {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final /* synthetic */ C2478 f16462;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public boolean f16463;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public HandlerC4324(C2478 c2478, Looper looper) {
        super(looper);
        this.f16462 = c2478;
    }

    @Override // android.os.Handler
    public final void handleMessage(Message message) {
        Object objM6014;
        C3622 c3622;
        C4426 c4426 = (C4426) message.obj;
        try {
            int i = message.what;
            if (i == 1) {
                objM6014 = this.f16462.f9640.m6014((C2538) c4426.f16836);
            } else {
                if (i != 2) {
                    throw new RuntimeException();
                }
                C2478 c2478 = this.f16462;
                C1253 c1253M6013 = c2478.f9640.m6013(c2478.f9634, (C2641) c4426.f16836);
                synchronized (this.f16462.f9633) {
                    try {
                        ˈᵷᵵᵞ r5 = this.f16462.f9632;
                        if (r5 != null && (c3622 = c1253M6013.f5294) != null) {
                            ((C3975) r5.ᵜᵪʾ).m7406(new C3622(c3622.f13746, c3622.f13743, c3622.f13744, c3622.f13747, SystemClock.elapsedRealtime() - c4426.f16833, c3622.f13748));
                        }
                    } finally {
                    }
                }
                objM6014 = c1253M6013;
            }
        } catch (MediaDrmCallbackException e) {
            boolean zM9309 = m9309(message, e);
            objM6014 = e;
            if (zM9309) {
                return;
            }
        } catch (Exception e2) {
            ˋˀᵧ.ᵠˏˏ("Key/provisioning request produced an unexpected exception. Not retrying.", e2);
            objM6014 = e2;
        }
        C1013 c1013 = this.f16462.f9642;
        long j = c4426.f16835;
        c1013.getClass();
        synchronized (this) {
            try {
                if (!this.f16463) {
                    this.f16462.f9623.obtainMessage(message.what, Pair.create(c4426.f16836, objM6014)).sendToTarget();
                }
            } finally {
            }
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final synchronized void m9308() {
        removeCallbacksAndMessages(null);
        this.f16463 = true;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final boolean m9309(Message message, MediaDrmCallbackException mediaDrmCallbackException) {
        C4426 c4426 = (C4426) message.obj;
        if (c4426.f16832) {
            int i = c4426.f16834 + 1;
            c4426.f16834 = i;
            this.f16462.f9642.getClass();
            if (i <= 3) {
                C3622 c3622 = new C3622(mediaDrmCallbackException.f629, mediaDrmCallbackException.f631, mediaDrmCallbackException.f630, SystemClock.elapsedRealtime(), SystemClock.elapsedRealtime() - c4426.f16833, mediaDrmCallbackException.f632);
                long jM3346 = this.f16462.f9642.m3346(new C1785(c4426.f16834, 5, mediaDrmCallbackException.getCause() instanceof IOException ? (IOException) mediaDrmCallbackException.getCause() : new DefaultDrmSession$UnexpectedDrmSessionException(mediaDrmCallbackException.getCause())));
                if (jM3346 == -9223372036854775807L) {
                    return false;
                }
                synchronized (this.f16462.f9633) {
                    ˈᵷᵵᵞ r6 = this.f16462.f9632;
                    if (r6 != null) {
                        ((C3975) r6.ᵜᵪʾ).m7406(c3622);
                    }
                }
                synchronized (this) {
                    try {
                        if (this.f16463) {
                            return false;
                        }
                        sendMessageDelayed(Message.obtain(message), jM3346);
                        return true;
                    } catch (Throwable th) {
                        throw th;
                    }
                }
            }
        }
        return false;
    }
}
