package defpackage;

import android.content.SharedPreferences;
import android.opengl.Matrix;
import android.os.Trace;
import android.util.SparseArray;
import com.bumptech.glide.ComponentCallbacks2C0017;
import java.io.File;
import java.io.IOException;
import java.net.SocketException;
import java.util.List;
import java.util.concurrent.atomic.AtomicMarkableReference;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;

/* renamed from: ᵵʔ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4699 implements InterfaceC1066, InterfaceC1982 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public Object f17372;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public boolean f17373;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public Object f17374;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public Object f17375;

    public /* synthetic */ C4699(Object obj, Object obj2, Object obj3) {
        this.f17372 = obj;
        this.f17375 = obj2;
        this.f17374 = obj3;
    }

    public C4699(InterfaceC1982 interfaceC1982, InterfaceC1889 interfaceC1889) {
        this.f17372 = interfaceC1982;
        this.f17375 = interfaceC1889;
        this.f17374 = new SparseArray();
    }

    public C4699(C2549 c2549, boolean z) {
        this.f17374 = c2549;
        this.f17375 = new AtomicReference(null);
        this.f17373 = z;
        this.f17372 = new AtomicMarkableReference(new C5158(z ? 8192 : 1024), false);
    }

    public C4699(C4035 c4035, C0867 c0867) {
        this.f17374 = c4035;
        this.f17372 = c0867;
        this.f17375 = c0867.f3939 ? null : new boolean[c4035.f15151];
    }

    public C4699(C4180 c4180, String str) {
        this.f17374 = c4180;
        ᵩʛʽ.ˏˋٴ(str);
        this.f17372 = str;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static void m9877(float[] fArr, float[] fArr2) {
        Matrix.setIdentityM(fArr, 0);
        float f = fArr2[10];
        float f2 = fArr2[8];
        float fSqrt = (float) Math.sqrt((f2 * f2) + (f * f));
        float f3 = fArr2[10] / fSqrt;
        fArr[0] = f3;
        float f4 = fArr2[8];
        fArr[2] = f4 / fSqrt;
        fArr[8] = (-f4) / fSqrt;
        fArr[10] = f3;
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static IOException m9878(C4699 c4699, boolean z, IOException iOException, int i) {
        boolean z2 = (i & 4) == 0;
        boolean z3 = (i & 8) == 0;
        if (iOException != null) {
            c4699.m9886(iOException);
        }
        return ((C1588) c4699.f17372).m4564(c4699, z3 && !z, z2 && !z, z2 && z, z3 && z, iOException);
    }

    @Override // defpackage.InterfaceC1066
    public Object get() {
        if (this.f17373) {
            ᵹˉᵞ.ᵳٴᵶ("Recursive Registry initialization! In your AppGlideModule and LibraryGlideModules, Make sure you're using the provided Registry rather calling glide.getRegistry()!");
            return null;
        }
        Trace.beginSection(ˉˇʨ.ˎˑː("Glide registry"));
        this.f17373 = true;
        try {
            return ˁـᵛ.ˏˋٴ((ComponentCallbacks2C0017) this.f17372, (List) this.f17375, (ˊˉʤﹳ) this.f17374);
        } finally {
            this.f17373 = false;
            Trace.endSection();
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public File m9879() {
        File file;
        synchronized (((C4035) this.f17374)) {
            try {
                C0867 c0867 = (C0867) this.f17372;
                if (c0867.f3941 != this) {
                    throw new IllegalStateException();
                }
                if (!c0867.f3939) {
                    ((boolean[]) this.f17375)[0] = true;
                }
                file = c0867.f3945[0];
                ((C4035) this.f17374).f15160.mkdirs();
            } catch (Throwable th) {
                throw th;
            }
        }
        return file;
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public String m9880() {
        if (!this.f17373) {
            this.f17373 = true;
            C4180 c4180 = (C4180) this.f17374;
            this.f17375 = c4180.m9104().getString((String) this.f17372, null);
        }
        return (String) this.f17375;
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public boolean m9881(int[] iArr) {
        ReentrantLock reentrantLock = (ReentrantLock) this.f17372;
        reentrantLock.lock();
        try {
            boolean z = false;
            for (int i : iArr) {
                long[] jArr = (long[]) this.f17375;
                long j = jArr[i];
                jArr[i] = j - 1;
                if (j == 1) {
                    z = true;
                    this.f17373 = true;
                }
            }
            return z;
        } finally {
            reentrantLock.unlock();
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public boolean m9882(int[] iArr) {
        ReentrantLock reentrantLock = (ReentrantLock) this.f17372;
        reentrantLock.lock();
        try {
            boolean z = false;
            for (int i : iArr) {
                long[] jArr = (long[]) this.f17375;
                long j = jArr[i];
                jArr[i] = 1 + j;
                if (j == 0) {
                    z = true;
                    this.f17373 = true;
                }
            }
            return z;
        } finally {
            reentrantLock.unlock();
        }
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public void m9883() {
        if (this.f17373) {
            ((C5073) this.f17374).m10539(new RunnableC3566(3, this));
            this.f17373 = false;
        }
    }

    @Override // defpackage.InterfaceC1982
    /* renamed from: ᵞʡ */
    public void mo4985() {
        SparseArray sparseArray = (SparseArray) this.f17374;
        ((InterfaceC1982) this.f17372).mo4985();
        if (this.f17373) {
            for (int i = 0; i < sparseArray.size(); i++) {
                ((C3775) sparseArray.valueAt(i)).f14109 = true;
            }
        }
    }

    @Override // defpackage.InterfaceC1982
    /* renamed from: ᵡⁱᵥ */
    public void mo4987(InterfaceC5013 interfaceC5013) {
        ((InterfaceC1982) this.f17372).mo4987(interfaceC5013);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public void m9884() {
        C4035.m8884((C4035) this.f17374, this, false);
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public void m9885(String str) {
        SharedPreferences.Editor editorEdit = ((C4180) this.f17374).m9104().edit();
        editorEdit.putString((String) this.f17372, str);
        editorEdit.apply();
        this.f17375 = str;
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public void m9886(IOException iOException) {
        this.f17373 = true;
        ((InterfaceC4906) this.f17374).mo1097().mo2590((C1588) this.f17372, iOException);
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public ᵪᵨ m9887() throws SocketException {
        C1588 c1588 = (C1588) this.f17372;
        if (c1588.f6295) {
            ᵹˉᵞ.ᵳٴᵶ("Check failed.");
            return null;
        }
        c1588.f6295 = true;
        c1588.f6307.m9834();
        synchronized (c1588) {
            if (c1588.f6309 == null) {
                throw new IllegalStateException("Check failed.");
            }
            if (c1588.f6306 || c1588.f6296) {
                throw new IllegalStateException("Check failed.");
            }
            if (c1588.f6304) {
                throw new IllegalStateException("Check failed.");
            }
            if (!c1588.f6302) {
                throw new IllegalStateException("Check failed.");
            }
            c1588.f6302 = false;
            c1588.f6306 = true;
            c1588.f6296 = true;
        }
        C0700 c0700 = (C0700) ((InterfaceC4906) this.f17374).mo1097();
        c0700.f3398.setSoTimeout(0);
        c0700.mo2589();
        return new ᵪᵨ(this);
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public C0446 m9888(boolean z) throws IOException {
        try {
            C0446 c0446Mo1093 = ((InterfaceC4906) this.f17374).mo1093(z);
            if (c0446Mo1093 == null) {
                return c0446Mo1093;
            }
            c0446Mo1093.f2497 = this;
            return c0446Mo1093;
        } catch (IOException e) {
            m9886(e);
            throw e;
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public C0700 m9889() {
        InterfaceC0652 interfaceC0652Mo1097 = ((InterfaceC4906) this.f17374).mo1097();
        C0700 c0700 = interfaceC0652Mo1097 instanceof C0700 ? (C0700) interfaceC0652Mo1097 : null;
        if (c0700 != null) {
            return c0700;
        }
        ᵹˉᵞ.ᵳٴᵶ("no connection for CONNECT tunnels");
        return null;
    }

    @Override // defpackage.InterfaceC1982
    /* renamed from: ᵾᵬ */
    public InterfaceC2154 mo4996(int i, int i2) {
        SparseArray sparseArray = (SparseArray) this.f17374;
        InterfaceC1982 interfaceC1982 = (InterfaceC1982) this.f17372;
        if (i2 != 3 && i2 != 5) {
            this.f17373 = true;
        }
        if (i2 != 3) {
            return interfaceC1982.mo4996(i, i2);
        }
        C3775 c3775 = (C3775) sparseArray.get(i);
        if (c3775 != null) {
            return c3775;
        }
        C3775 c37752 = new C3775(interfaceC1982.mo4996(i, i2), (InterfaceC1889) this.f17375);
        sparseArray.put(i, c37752);
        return c37752;
    }
}
