package g.i.a.c.w;

import g.i.a.c.q.h;
import g.i.a.c.q.i;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

/* JADX INFO: loaded from: classes.dex */
public class b extends g.i.a.c.o.a {
    public static int m(int i2, g.i.a.c.l.e.a aVar, i iVar) {
        if (iVar == null) {
            return 1;
        }
        int i3 = aVar.f5573x;
        int i4 = iVar.f5674j;
        if (i4 == 4 || i4 == 6 || i4 == 7 || i4 == 8) {
            List<h> list = iVar.Q;
            if (list != null && list.size() > 0) {
                Iterator<h> it = list.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    h next = it.next();
                    if (next.f5725f == i2) {
                        int i5 = next.f5729p;
                        if (i5 > 0 && i3 > i5) {
                            g.h.a.i.W3(String.format(Locale.US, "image size is %d exceed the limit of the section size %d", Integer.valueOf(i3), Integer.valueOf(next.f5729p)));
                            return 2;
                        }
                        g.a.a.a.a.b0("section size validate ok: ", i3);
                    }
                }
            }
        } else {
            StringBuilder sbF = g.a.a.a.a.F("not support section size check for ic:");
            sbF.append(iVar.f5674j);
            g.h.a.i.V3(true, sbF.toString());
        }
        return 1;
    }

    public static int n(g.i.a.c.l.e.a aVar, i iVar) {
        if (iVar == null) {
            return 1;
        }
        int i2 = aVar.f5575z;
        int i3 = aVar.f5573x;
        g.i.a.c.l.a aVar2 = null;
        int i4 = iVar.f5674j;
        if (i4 == 4 || i4 == 6 || i4 == 7 || i4 == 8) {
            Iterator<g.i.a.c.l.a> it = g.i.a.c.l.a.f5506c.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                g.i.a.c.l.a next = it.next();
                if (next.f5511h == i2) {
                    if (next.f5512i) {
                        aVar2 = next;
                    }
                }
            }
            if (aVar2 != null) {
                g.h.a.i.w0(aVar2.toString());
                List<h> list = iVar.Q;
                if (list != null && list.size() > 0) {
                    Iterator<h> it2 = list.iterator();
                    while (true) {
                        if (!it2.hasNext()) {
                            break;
                        }
                        h next2 = it2.next();
                        if (next2.f5725f == aVar2.f5508e) {
                            int i5 = next2.f5729p;
                            if (i5 > 0 && i3 > i5) {
                                g.h.a.i.W3(String.format(Locale.US, "image size is %d exceed the limit of the section size %d", Integer.valueOf(i3), Integer.valueOf(next2.f5729p)));
                                return 2;
                            }
                            g.a.a.a.a.b0("section size validate ok: ", i3);
                        }
                    }
                }
            }
        } else {
            StringBuilder sbF = g.a.a.a.a.F("not support section size check for ic:");
            sbF.append(iVar.f5674j);
            g.h.a.i.V3(true, sbF.toString());
        }
        return 1;
    }
}
