package j5;

import android.os.Build;
import java.io.File;
import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: loaded from: classes.dex */
public final class t {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final boolean f28681g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final boolean f28682h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public static final File f28683i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static volatile t f28684j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static volatile int f28685k;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final boolean f28686a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f28687b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f28688c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f28689d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f28690e = true;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final AtomicBoolean f28691f = new AtomicBoolean(false);

    static {
        int i10 = Build.VERSION.SDK_INT;
        f28681g = i10 < 29;
        f28682h = i10 >= 26;
        f28683i = new File("/proc/self/fd");
        f28685k = -1;
    }

    public t() {
        boolean z10 = true;
        if (Build.VERSION.SDK_INT == 26) {
            Iterator it = Arrays.asList("SC-04J", "SM-N935", "SM-J720", "SM-G570F", "SM-G570M", "SM-G960", "SM-G965", "SM-G935", "SM-G930", "SM-A520", "SM-A720F", "moto e5", "moto e5 play", "moto e5 plus", "moto e5 cruise", "moto g(6) forge", "moto g(6) play").iterator();
            while (it.hasNext()) {
                if (Build.MODEL.startsWith((String) it.next())) {
                    break;
                }
            }
            if (Build.VERSION.SDK_INT == 27) {
                z10 = false;
            }
        } else if (Build.VERSION.SDK_INT == 27 && Arrays.asList("LG-M250", "LG-M320", "LG-Q710AL", "LG-Q710PL", "LGM-K121K", "LGM-K121L", "LGM-K121S", "LGM-X320K", "LGM-X320L", "LGM-X320S", "LGM-X401L", "LGM-X401S", "LM-Q610.FG", "LM-Q610.FGN", "LM-Q617.FG", "LM-Q617.FGN", "LM-Q710.FG", "LM-Q710.FGN", "LM-X220PM", "LM-X220QMA", "LM-X410PM").contains(Build.MODEL)) {
            z10 = false;
        }
        this.f28686a = z10;
        if (Build.VERSION.SDK_INT >= 28) {
            this.f28687b = 20000;
            this.f28688c = 0;
        } else {
            this.f28687b = 700;
            this.f28688c = 128;
        }
    }

    public static t a() {
        if (f28684j == null) {
            synchronized (t.class) {
                try {
                    if (f28684j == null) {
                        f28684j = new t();
                    }
                } finally {
                }
            }
        }
        return f28684j;
    }

    public final boolean b(int i10, int i11, boolean z10, boolean z11) {
        int i12;
        boolean z12;
        if (!z10 || !this.f28686a || !f28682h) {
            return false;
        }
        if ((f28681g && !this.f28691f.get()) || z11 || i10 < (i12 = this.f28688c) || i11 < i12) {
            return false;
        }
        synchronized (this) {
            try {
                int i13 = this.f28689d + 1;
                this.f28689d = i13;
                if (i13 >= 50) {
                    this.f28689d = 0;
                    this.f28690e = ((long) f28683i.list().length) < ((long) (f28685k != -1 ? f28685k : this.f28687b));
                }
                z12 = this.f28690e;
            } catch (Throwable th) {
                throw th;
            }
        }
        return z12;
    }
}
