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;

/* renamed from: ᵦʾ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class HandlerC3557 extends Handler {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public boolean f13321;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final /* synthetic */ C1669 f13322;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public HandlerC3557(C1669 c1669, Looper looper) {
        super(looper);
        this.f13322 = c1669;
    }

    @Override // android.os.Handler
    public final void handleMessage(Message message) {
        Object objM7571;
        C0417 c0417;
        C4961 c4961 = (C4961) message.obj;
        try {
            int i = message.what;
            if (i == 1) {
                objM7571 = this.f13322.f6658.m7571((C5353) c4961.f18438);
            } else {
                if (i != 2) {
                    throw new RuntimeException();
                }
                C1669 c1669 = this.f13322;
                C1918 c1918M7572 = c1669.f6658.m7572(c1669.f6639, (C0895) c4961.f18438);
                synchronized (this.f13322.f6654) {
                    try {
                        ˑᵽʾʦ r5 = this.f13322.f6661;
                        if (r5 != null && (c0417 = c1918M7572.f7722) != null) {
                            ((C4704) r5.ᵢˇᵭ).m3197(new C0417(c0417.f2323, c0417.f2324, c0417.f2322, c0417.f2325, SystemClock.elapsedRealtime() - c4961.f18435, c0417.f2321));
                        }
                    } finally {
                    }
                }
                objM7571 = c1918M7572;
            }
        } catch (MediaDrmCallbackException e) {
            boolean zM8099 = m8099(message, e);
            objM7571 = e;
            if (zM8099) {
                return;
            }
        } catch (Exception e2) {
            ᵳʿˉ.ˁˑᵰ("Key/provisioning request produced an unexpected exception. Not retrying.", e2);
            objM7571 = e2;
        }
        C1899 c1899 = this.f13322.f6644;
        long j = c4961.f18436;
        c1899.getClass();
        synchronized (this) {
            try {
                if (!this.f13321) {
                    this.f13322.f6652.obtainMessage(message.what, Pair.create(c4961.f18438, objM7571)).sendToTarget();
                }
            } finally {
            }
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final boolean m8099(Message message, MediaDrmCallbackException mediaDrmCallbackException) {
        C4961 c4961 = (C4961) message.obj;
        if (c4961.f18437) {
            int i = c4961.f18434 + 1;
            c4961.f18434 = i;
            this.f13322.f6644.getClass();
            if (i <= 3) {
                C0417 c0417 = new C0417(mediaDrmCallbackException.f630, mediaDrmCallbackException.f629, mediaDrmCallbackException.f632, SystemClock.elapsedRealtime(), SystemClock.elapsedRealtime() - c4961.f18435, mediaDrmCallbackException.f631);
                long jM5318 = this.f13322.f6644.m5318(new C2124(c4961.f18434, 5, mediaDrmCallbackException.getCause() instanceof IOException ? (IOException) mediaDrmCallbackException.getCause() : new DefaultDrmSession$UnexpectedDrmSessionException(mediaDrmCallbackException.getCause())));
                if (jM5318 == -9223372036854775807L) {
                    return false;
                }
                synchronized (this.f13322.f6654) {
                    ˑᵽʾʦ r6 = this.f13322.f6661;
                    if (r6 != null) {
                        ((C4704) r6.ᵢˇᵭ).m3197(c0417);
                    }
                }
                synchronized (this) {
                    try {
                        if (this.f13321) {
                            return false;
                        }
                        sendMessageDelayed(Message.obtain(message), jM5318);
                        return true;
                    } catch (Throwable th) {
                        throw th;
                    }
                }
            }
        }
        return false;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final synchronized void m8100() {
        removeCallbacksAndMessages(null);
        this.f13321 = true;
    }
}
