package a3;

import android.media.MediaCodec;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.preference.PreferenceFragment;
import androidx.preference.PreferenceScreen;
import com.google.android.gms.internal.ads.gn2;
import com.google.android.gms.internal.ads.hn2;
import java.util.ArrayDeque;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes.dex */
public final class u extends Handler {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f279a = 0;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public u(hn2 hn2Var, Looper looper) {
        super(looper);
        this.f280b = hn2Var;
    }

    @Override // android.os.Handler
    public final void handleMessage(Message message) {
        switch (this.f279a) {
            case 0:
                if (message.what != 1) {
                    return;
                }
                PreferenceFragment preferenceFragment = (PreferenceFragment) this.f280b;
                PreferenceScreen preferenceScreen = preferenceFragment.f3602b.f253e;
                if (preferenceScreen != null) {
                    preferenceFragment.f3603c.setAdapter(new z(preferenceScreen));
                    preferenceScreen.l();
                    return;
                }
                return;
            default:
                hn2 hn2Var = (hn2) this.f280b;
                hn2Var.getClass();
                int i10 = message.what;
                gn2 gn2Var = null;
                if (i10 == 1) {
                    gn2 gn2Var2 = (gn2) message.obj;
                    try {
                        hn2Var.f12200a.queueInputBuffer(gn2Var2.f11804a, 0, gn2Var2.f11805b, gn2Var2.f11807d, gn2Var2.f11808e);
                        break;
                    } catch (RuntimeException e10) {
                        AtomicReference atomicReference = hn2Var.f12203d;
                        while (!atomicReference.compareAndSet(null, e10) && atomicReference.get() == null) {
                        }
                    }
                    gn2Var = gn2Var2;
                } else if (i10 == 2) {
                    gn2 gn2Var3 = (gn2) message.obj;
                    int i11 = gn2Var3.f11804a;
                    MediaCodec.CryptoInfo cryptoInfo = gn2Var3.f11806c;
                    long j10 = gn2Var3.f11807d;
                    int i12 = gn2Var3.f11808e;
                    try {
                        synchronized (hn2.f12199h) {
                            hn2Var.f12200a.queueSecureInputBuffer(i11, 0, cryptoInfo, j10, i12);
                            break;
                        }
                    } catch (RuntimeException e11) {
                        AtomicReference atomicReference2 = hn2Var.f12203d;
                        while (!atomicReference2.compareAndSet(null, e11) && atomicReference2.get() == null) {
                        }
                    }
                    gn2Var = gn2Var3;
                } else if (i10 == 3) {
                    hn2Var.f12204e.a();
                } else if (i10 != 4) {
                    AtomicReference atomicReference3 = hn2Var.f12203d;
                    IllegalStateException illegalStateException = new IllegalStateException(String.valueOf(message.what));
                    while (!atomicReference3.compareAndSet(null, illegalStateException) && atomicReference3.get() == null) {
                    }
                } else {
                    try {
                        hn2Var.f12200a.setParameters((Bundle) message.obj);
                        break;
                    } catch (RuntimeException e12) {
                        AtomicReference atomicReference4 = hn2Var.f12203d;
                        while (!atomicReference4.compareAndSet(null, e12) && atomicReference4.get() == null) {
                        }
                    }
                }
                if (gn2Var != null) {
                    ArrayDeque arrayDeque = hn2.f12198g;
                    synchronized (arrayDeque) {
                        arrayDeque.add(gn2Var);
                        break;
                    }
                    return;
                }
                return;
        }
    }

    public u(PreferenceFragment preferenceFragment) {
        this.f280b = preferenceFragment;
    }
}
