package o;

import android.os.Build;
import com.google.android.gms.common.R;
import java.io.IOException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.s4, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2398s4 implements InterfaceC0987dE {
    public static boolean f = true;
    public boolean a;
    public Object b;
    public Object c;
    public Object d;
    public Object e;

    @Override // o.InterfaceC0987dE
    public void a(C1082eE c1082eE) {
        synchronized (this.c) {
            if (!c1082eE.s) {
                c1082eE.s = true;
                c1082eE.b();
            }
        }
    }

    @Override // o.InterfaceC0987dE
    public C1082eE b() {
        InterfaceC1178fE c1750lE;
        C1082eE c1082eE;
        synchronized (this.c) {
            try {
                C2207q3 c2207q3 = (C2207q3) this.b;
                int i = Build.VERSION.SDK_INT;
                if (i >= 29) {
                    c2207q3.getUniqueDrawingId();
                }
                if (i >= 29) {
                    c1750lE = new C1560jE();
                } else if (f) {
                    try {
                        c1750lE = new C1466iE((C2207q3) this.b, new C0006Ag(), new C3113zg());
                    } catch (Throwable unused) {
                        f = false;
                        c1750lE = new C1750lE(d((C2207q3) this.b));
                    }
                } else {
                    c1750lE = new C1750lE(d((C2207q3) this.b));
                }
                c1082eE = new C1082eE(c1750lE);
            } catch (Throwable th) {
                throw th;
            }
        }
        return c1082eE;
    }

    public IOException c(boolean z, boolean z2, IOException iOException) {
        if (iOException != null) {
            g(iOException);
        }
        return ((C2202q00) this.b).h(this, z2, z, iOException);
    }

    public AbstractC1810lt d(C2207q3 c2207q3) {
        C0839bk0 c0839bk0 = (C0839bk0) this.d;
        if (c0839bk0 != null) {
            return c0839bk0;
        }
        C0839bk0 c0839bk02 = new C0839bk0(c2207q3.getContext());
        c0839bk02.setClipChildren(false);
        c0839bk02.setClipToPadding(false);
        c0839bk02.setTag(R.id.hide_graphics_layer_in_inspector_tag, Boolean.TRUE);
        c2207q3.addView(c0839bk02, -1);
        this.d = c0839bk02;
        return c0839bk02;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public int e(C1390hY c1390hY, C2207q3 c2207q3, boolean z) {
        Object[] objArr;
        int i;
        int i2;
        C0988dF c0988dF = (C0988dF) this.c;
        C1275gF c1275gF = (C1275gF) this.e;
        if (this.a) {
            return 0;
        }
        try {
            this.a = true;
            C2513tI c2513tIG = ((WT) this.d).g(c1390hY, c2207q3);
            UM um = (UM) c2513tIG.c;
            int iG = um.g();
            for (int i3 = 0; i3 < iG; i3++) {
                IX ix = (IX) um.h(i3);
                if (!ix.d && !ix.h) {
                }
                objArr = false;
                break;
            }
            objArr = true;
            int iG2 = um.g();
            for (int i4 = 0; i4 < iG2; i4++) {
                IX ix2 = (IX) um.h(i4);
                if (objArr != false || As0.p(ix2)) {
                    ((C2420sK) this.b).x(ix2.c, (C1275gF) this.e, ix2.i, true);
                    if (!c1275gF.l.g()) {
                        c0988dF.a(ix2.a, c1275gF, As0.p(ix2));
                        c1275gF.clear();
                    }
                }
            }
            boolean zB = c0988dF.b(c2513tIG, z);
            if (c2513tIG.b) {
                i = 0;
            } else {
                int iG3 = um.g();
                for (int i5 = 0; i5 < iG3; i5++) {
                    IX ix3 = (IX) um.h(i5);
                    if (!C1765lT.b(As0.M(ix3, true), 0L) && ix3.b()) {
                        i = 1;
                        break;
                    }
                }
                i = 0;
            }
            int iG4 = um.g();
            int i6 = 0;
            while (true) {
                if (i6 >= iG4) {
                    i2 = 0;
                    break;
                }
                if (((IX) um.h(i6)).b()) {
                    i2 = 1;
                    break;
                }
                i6++;
            }
            int i7 = (zB ? 1 : 0) | (i << 1) | (i2 << 2);
            this.a = false;
            return i7;
        } catch (Throwable th) {
            this.a = false;
            throw th;
        }
    }

    public B20 f(boolean z) throws IOException {
        try {
            B20 b20G = ((InterfaceC0593Ww) this.d).g(z);
            if (b20G == null) {
                return b20G;
            }
            b20G.m = this;
            return b20G;
        } catch (IOException e) {
            g(e);
            throw e;
        }
    }

    public void g(IOException iOException) {
        this.a = true;
        ((C1414hl) this.c).b(iOException);
        C2486t00 c2486t00H = ((InterfaceC0593Ww) this.d).h();
        C2202q00 c2202q00 = (C2202q00) this.b;
        synchronized (c2486t00H) {
            try {
                if (!(iOException instanceof Ta0)) {
                    if (!(c2486t00H.g != null) || (iOException instanceof C1699kl)) {
                        c2486t00H.j = true;
                        if (c2486t00H.m == 0) {
                            C2486t00.d(c2202q00.l, c2486t00H.b, iOException);
                            c2486t00H.l++;
                        }
                    }
                } else if (((Ta0) iOException).l == 8) {
                    int i = c2486t00H.n + 1;
                    c2486t00H.n = i;
                    if (i > 1) {
                        c2486t00H.j = true;
                        c2486t00H.l++;
                    }
                } else if (((Ta0) iOException).l != 9 || !c2202q00.x) {
                    c2486t00H.j = true;
                    c2486t00H.l++;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
