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;

/* JADX INFO: renamed from: ˁᵵ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0764 implements InterfaceC0333, InterfaceC4550 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public boolean f3426;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public Object f3427;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public Object f3428;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public Object f3429;

    public /* synthetic */ C0764(Object obj, Object obj2, Object obj3) {
        this.f3428 = obj;
        this.f3427 = obj2;
        this.f3429 = obj3;
    }

    public C0764(C1356 c1356, boolean z) {
        this.f3429 = c1356;
        this.f3427 = new AtomicReference(null);
        this.f3426 = z;
        this.f3428 = new AtomicMarkableReference(new C0107(z ? 8192 : 1024), false);
    }

    public C0764(C2899 c2899, C3299 c3299) {
        this.f3429 = c2899;
        this.f3428 = c3299;
        this.f3427 = c3299.f12704 ? null : new boolean[c2899.f11136];
    }

    public C0764(C3740 c3740, String str) {
        this.f3429 = c3740;
        ᵘᵞʿⁱ.ˊᵫᵗ(str);
        this.f3428 = str;
    }

    public C0764(InterfaceC4550 interfaceC4550, InterfaceC1471 interfaceC1471) {
        this.f3428 = interfaceC4550;
        this.f3427 = interfaceC1471;
        this.f3429 = new SparseArray();
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static IOException m2737(C0764 c0764, boolean z, IOException iOException, int i) {
        boolean z2 = (i & 4) == 0;
        boolean z3 = (i & 8) == 0;
        if (iOException != null) {
            c0764.m2750(iOException);
        }
        if (z3) {
            AbstractC0396 abstractC0396 = ((C4778) c0764.f3428).f18181;
            if (iOException != null) {
                abstractC0396.getClass();
            } else {
                abstractC0396.getClass();
            }
        }
        if (z2) {
            AbstractC0396 abstractC03962 = ((C4778) c0764.f3428).f18181;
            if (iOException != null) {
                abstractC03962.getClass();
            } else {
                abstractC03962.getClass();
            }
        }
        return ((C4778) c0764.f3428).m9966(c0764, z3 && !z, z2 && !z, z2 && z, z3 && z, iOException);
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static void m2738(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;
    }

    @Override // defpackage.InterfaceC0333
    public Object get() {
        if (this.f3426) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("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.f3426 = true;
        try {
            return ᵹˊᵫˋ.ᵨᵣ((ComponentCallbacks2C0017) this.f3428, (List) this.f3427, (ᵱˉˈ) this.f3429);
        } finally {
            this.f3426 = false;
            Trace.endSection();
        }
    }

    @Override // defpackage.InterfaceC4550
    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public void mo2739(InterfaceC5517 interfaceC5517) {
        ((InterfaceC4550) this.f3428).mo2739(interfaceC5517);
    }

    @Override // defpackage.InterfaceC4550
    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public void mo2740() {
        SparseArray sparseArray = (SparseArray) this.f3429;
        ((InterfaceC4550) this.f3428).mo2740();
        if (this.f3426) {
            for (int i = 0; i < sparseArray.size(); i++) {
                ((C4068) sparseArray.valueAt(i)).f15632 = true;
            }
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public C4891 m2741(C1120 c1120) throws IOException {
        C0764 c0764;
        String strM2425;
        long jMo1605;
        try {
            strM2425 = c1120.f4792.m2425("Content-Type");
            if (strM2425 == null) {
                strM2425 = null;
            }
            jMo1605 = ((InterfaceC0340) this.f3429).mo1605(c1120);
            c0764 = this;
        } catch (IOException e) {
            e = e;
            c0764 = this;
        }
        try {
            return new C4891(strM2425, jMo1605, new C1978(new C3941(c0764, ((InterfaceC0340) this.f3429).mo1596(c1120), jMo1605, false)));
        } catch (IOException e2) {
            e = e2;
            IOException iOException = e;
            ((C4778) c0764.f3428).f18181.getClass();
            c0764.m2750(iOException);
            throw iOException;
        }
    }

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public void m2742(String str) {
        SharedPreferences.Editor editorEdit = ((C3740) this.f3429).m8407().edit();
        editorEdit.putString((String) this.f3428, str);
        editorEdit.apply();
        this.f3427 = str;
    }

    @Override // defpackage.InterfaceC4550
    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public InterfaceC5226 mo2743(int i, int i2) {
        SparseArray sparseArray = (SparseArray) this.f3429;
        InterfaceC4550 interfaceC4550 = (InterfaceC4550) this.f3428;
        if (i2 != 3 && i2 != 5) {
            this.f3426 = true;
        }
        if (i2 != 3) {
            return interfaceC4550.mo2743(i, i2);
        }
        C4068 c4068 = (C4068) sparseArray.get(i);
        if (c4068 != null) {
            return c4068;
        }
        C4068 c40682 = new C4068(interfaceC4550.mo2743(i, i2), (InterfaceC1471) this.f3427);
        sparseArray.put(i, c40682);
        return c40682;
    }

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public String m2744() {
        if (!this.f3426) {
            this.f3426 = true;
            C3740 c3740 = (C3740) this.f3429;
            this.f3427 = c3740.m8407().getString((String) this.f3428, null);
        }
        return (String) this.f3427;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public File m2745() {
        File file;
        synchronized (((C2899) this.f3429)) {
            try {
                C3299 c3299 = (C3299) this.f3428;
                if (c3299.f12708 != this) {
                    throw new IllegalStateException();
                }
                if (!c3299.f12704) {
                    ((boolean[]) this.f3427)[0] = true;
                }
                file = c3299.f12707[0];
                ((C2899) this.f3429).f11138.mkdirs();
            } catch (Throwable th) {
                throw th;
            }
        }
        return file;
    }

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public C0767 m2746() throws SocketException {
        C4778 c4778 = (C4778) this.f3428;
        if (c4778.f18176) {
            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Check failed.");
            return null;
        }
        c4778.f18176 = true;
        c4778.f18182.m10665();
        synchronized (c4778) {
            if (c4778.f18178 == null) {
                throw new IllegalStateException("Check failed.");
            }
            if (c4778.f18169 || c4778.f18168) {
                throw new IllegalStateException("Check failed.");
            }
            if (c4778.f18180) {
                throw new IllegalStateException("Check failed.");
            }
            if (!c4778.f18171) {
                throw new IllegalStateException("Check failed.");
            }
            c4778.f18171 = false;
            c4778.f18169 = true;
            c4778.f18168 = true;
        }
        C4013 c4013 = (C4013) ((InterfaceC0340) this.f3429).mo1604();
        c4013.f15416.setSoTimeout(0);
        c4013.mo8822();
        return new C0767(this);
    }

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public void m2747() {
        if (this.f3426) {
            ((C3086) this.f3429).m7175(new RunnableC2846(3, this));
            this.f3426 = false;
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public void m2748() {
        C2899.m6950((C2899) this.f3429, this, false);
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public boolean m2749(int[] iArr) {
        ReentrantLock reentrantLock = (ReentrantLock) this.f3428;
        reentrantLock.lock();
        try {
            boolean z = false;
            for (int i : iArr) {
                long[] jArr = (long[]) this.f3427;
                long j = jArr[i];
                jArr[i] = j - 1;
                if (j == 1) {
                    z = true;
                    this.f3426 = true;
                }
            }
            return z;
        } finally {
            reentrantLock.unlock();
        }
    }

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public void m2750(IOException iOException) {
        this.f3426 = true;
        ((InterfaceC0340) this.f3429).mo1604().mo8827((C4778) this.f3428, iOException);
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public C4013 m2751() {
        InterfaceC4678 interfaceC4678Mo1604 = ((InterfaceC0340) this.f3429).mo1604();
        C4013 c4013 = interfaceC4678Mo1604 instanceof C4013 ? (C4013) interfaceC4678Mo1604 : null;
        if (c4013 != null) {
            return c4013;
        }
        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("no connection for CONNECT tunnels");
        return null;
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public C2651 m2752(boolean z) throws IOException {
        try {
            C2651 c2651Mo1599 = ((InterfaceC0340) this.f3429).mo1599(z);
            if (c2651Mo1599 == null) {
                return c2651Mo1599;
            }
            c2651Mo1599.f10271 = this;
            return c2651Mo1599;
        } catch (IOException e) {
            ((C4778) this.f3428).f18181.getClass();
            m2750(e);
            throw e;
        }
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean m2753(int[] iArr) {
        ReentrantLock reentrantLock = (ReentrantLock) this.f3428;
        reentrantLock.lock();
        try {
            boolean z = false;
            for (int i : iArr) {
                long[] jArr = (long[]) this.f3427;
                long j = jArr[i];
                jArr[i] = 1 + j;
                if (j == 0) {
                    z = true;
                    this.f3426 = true;
                }
            }
            return z;
        } finally {
            reentrantLock.unlock();
        }
    }
}
