package defpackage;

import android.os.Build;
import android.os.Process;
import android.os.SystemClock;
import android.util.Log;
import com.bumptech.glide.load.engine.GlideException;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.function.Supplier;

/* renamed from: ᵝᵕʦ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class RunnableC2904 implements InterfaceC2983, Runnable, Comparable, InterfaceC2518 {

    /* renamed from: ˊʾˊ, reason: contains not printable characters */
    public static final C3420 f11268 = new C3420("glide_thread_priority_override", null, C3420.f12716);

    /* renamed from: ˀˁᵨ, reason: contains not printable characters */
    public int f11269;

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public InterfaceC4207 f11271;

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public C4732 f11272;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public InterfaceC4207 f11273;

    /* renamed from: ˊʽˎ, reason: contains not printable characters */
    public volatile boolean f11274;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public Thread f11275;

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public InterfaceC2918 f11276;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public EnumC5505 f11277;

    /* renamed from: ˎᵬˀ, reason: contains not printable characters */
    public boolean f11278;

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public Supplier f11279;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public InterfaceC4207 f11280;

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public C3318 f11281;

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public Object f11282;

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public Object f11283;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public C0520 f11284;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public C3718 f11285;

    /* renamed from: ᵡᵶᵡ, reason: contains not printable characters */
    public volatile boolean f11286;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final InterfaceC3956 f11289;

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public int f11290;

    /* renamed from: ᵫᵮʾ, reason: contains not printable characters */
    public int f11292;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public C3330 f11293;

    /* renamed from: ᵳᵹᵺˋ, reason: contains not printable characters */
    public volatile InterfaceC4672 f11294;

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public C0210 f11295;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public int f11296;

    /* renamed from: ᵽʛ, reason: contains not printable characters */
    public int f11297;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final C0262 f11298;

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public int f11300;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final C1101 f11291 = new C1101();

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final ArrayList f11288 = new ArrayList();

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final C4808 f11299 = new C4808();

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final ᵧˉʙ f11287 = new ᵧˉʙ(12, false);

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final C4513 f11270 = new C4513();

    public RunnableC2904(C0262 c0262, ʽᵡ r5) {
        this.f11298 = c0262;
        this.f11289 = r5;
    }

    @Override // java.lang.Comparable
    public final int compareTo(Object obj) {
        RunnableC2904 runnableC2904 = (RunnableC2904) obj;
        int iOrdinal = this.f11277.ordinal() - runnableC2904.f11277.ordinal();
        return iOrdinal == 0 ? this.f11300 - runnableC2904.f11300 : iOrdinal;
    }

    @Override // java.lang.Runnable
    public final void run() {
        InterfaceC2918 interfaceC2918 = this.f11276;
        try {
            try {
                try {
                    if (this.f11274) {
                        m7093();
                        if (interfaceC2918 != null) {
                            interfaceC2918.mo5389();
                            return;
                        }
                        return;
                    }
                    m7082();
                    if (interfaceC2918 != null) {
                        interfaceC2918.mo5389();
                    }
                } catch (C0254 e) {
                    throw e;
                }
            } catch (Throwable th) {
                Log.isLoggable("DecodeJob", 3);
                if (this.f11292 != 5) {
                    this.f11288.add(th);
                    m7093();
                }
                if (!this.f11274) {
                    throw th;
                }
                throw th;
            }
        } catch (Throwable th2) {
            if (interfaceC2918 != null) {
                interfaceC2918.mo5389();
            }
            throw th2;
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final InterfaceC1725 m7081(int i, Object obj) {
        Class<?> cls = obj.getClass();
        C1101 c1101 = this.f11291;
        C4627 c4627M3500 = c1101.m3500(cls);
        C0210 c0210 = this.f11295;
        if (Build.VERSION.SDK_INT >= 26) {
            boolean z = i == 4 || c1101.f4735;
            C3420 c3420 = C4539.f16880;
            Boolean bool = (Boolean) c0210.m1488(c3420);
            if (bool == null || (bool.booleanValue() && !z)) {
                c0210 = new C0210();
                C0154 c0154 = this.f11295.f1704;
                C0154 c01542 = c0210.f1704;
                c01542.mo1306(c0154);
                c01542.put(c3420, Boolean.valueOf(z));
            }
        }
        C0210 c02102 = c0210;
        InterfaceC2986 interfaceC2986M8177 = this.f11284.m2233().m8177(obj);
        try {
            return c4627M3500.m9813(this.f11290, this.f11296, interfaceC2986M8177, c02102, new C2124(i, 2, this));
        } finally {
            interfaceC2986M8177.mo795();
        }
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final void m7082() throws SecurityException, IllegalArgumentException {
        int iM4088 = AbstractC1327.m4088(this.f11297);
        if (iM4088 == 0) {
            this.f11292 = m7095(1);
            this.f11294 = m7084();
            m7091();
        } else if (iM4088 == 1) {
            m7091();
        } else if (iM4088 == 2) {
            m7085();
        } else {
            int i = this.f11297;
            ᵹˉᵞ.ᵳٴᵶ("Unrecognized run reason: ".concat(i != 1 ? i != 2 ? i != 3 ? "null" : "DECODE_DATA" : "SWITCH_TO_SOURCE_SERVICE" : "INITIALIZE"));
        }
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m7083() {
        boolean zM9606;
        C4513 c4513 = this.f11270;
        synchronized (c4513) {
            c4513.f16819 = true;
            zM9606 = c4513.m9606();
        }
        if (zM9606) {
            m7090();
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final InterfaceC4672 m7084() {
        int iM4088 = AbstractC1327.m4088(this.f11292);
        C1101 c1101 = this.f11291;
        if (iM4088 == 1) {
            return new C0933(c1101, this);
        }
        if (iM4088 == 2) {
            return new C2071(c1101.m3501(), c1101, this);
        }
        if (iM4088 == 3) {
            return new C5175(c1101, this);
        }
        if (iM4088 == 5) {
            return null;
        }
        ᵹˉᵞ.ᵳٴᵶ("Unrecognized stage: ".concat(AbstractC4486.m9549(this.f11292)));
        return null;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m7085() throws SecurityException, IllegalArgumentException {
        InterfaceC1725 interfaceC1725M7096;
        boolean zM9606;
        Supplier supplier;
        if (Log.isLoggable("DecodeJob", 2)) {
            String str = "data: " + this.f11283 + ", cache key: " + this.f11271 + ", fetcher: " + this.f11276;
            int i = AbstractC4846.f17991;
            SystemClock.elapsedRealtimeNanos();
            Objects.toString(this.f11293);
            ", ".concat(str);
            Thread.currentThread().getName();
        }
        C0890 c0890 = null;
        if (((Map) this.f11285.f13883).containsKey(ˀʾˀᵛ.class) && (supplier = this.f11279) != null && supplier.get() != null) {
            try {
                Process.setThreadPriority(Process.myTid(), ((Integer) this.f11279.get()).intValue());
            } catch (IllegalArgumentException | SecurityException unused) {
                this.f11279 = null;
                Log.isLoggable("DecodeJob", 2);
            }
        }
        try {
            interfaceC1725M7096 = m7096(this.f11276, this.f11283, this.f11269);
        } catch (GlideException e) {
            InterfaceC4207 interfaceC4207 = this.f11273;
            int i2 = this.f11269;
            e.f988 = interfaceC4207;
            e.f992 = i2;
            e.f991 = null;
            this.f11288.add(e);
            interfaceC1725M7096 = null;
        }
        if (interfaceC1725M7096 == null) {
            m7091();
            return;
        }
        int i3 = this.f11269;
        boolean z = this.f11278;
        if (interfaceC1725M7096 instanceof InterfaceC5397) {
            ((InterfaceC5397) interfaceC1725M7096).mo5546();
        }
        if (((C0890) this.f11287.ᵾᵬ) != null) {
            c0890 = (C0890) C0890.f4048.ˌʾˀ();
            c0890.f4051 = false;
            c0890.f4052 = true;
            c0890.f4049 = interfaceC1725M7096;
            interfaceC1725M7096 = c0890;
        }
        m7087(interfaceC1725M7096, i3, z);
        this.f11292 = 5;
        try {
            ᵧˉʙ r0 = this.f11287;
            if (((C0890) r0.ᵾᵬ) != null) {
                C0262 c0262 = this.f11298;
                C0210 c0210 = this.f11295;
                r0.getClass();
                try {
                    c0262.m1591().mo6927((InterfaceC4207) r0.ᵢˇᵭ, new ʽᵡ((InterfaceC4567) r0.ᵿʗᵝʽ, (C0890) r0.ᵾᵬ, c0210, 12));
                    ((C0890) r0.ᵾᵬ).m3007();
                } catch (Throwable th) {
                    ((C0890) r0.ᵾᵬ).m3007();
                    throw th;
                }
            }
            C4513 c4513 = this.f11270;
            synchronized (c4513) {
                c4513.f16820 = true;
                zM9606 = c4513.m9606();
            }
            if (zM9606) {
                m7090();
            }
        } finally {
            if (c0890 != null) {
                c0890.m3007();
            }
        }
    }

    @Override // defpackage.InterfaceC2983
    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void mo7086(InterfaceC4207 interfaceC4207, Exception exc, InterfaceC2918 interfaceC2918, int i) {
        interfaceC2918.mo5389();
        GlideException glideException = new GlideException("Fetching data failed", Collections.singletonList(exc));
        Class clsMo1817 = interfaceC2918.mo1817();
        glideException.f988 = interfaceC4207;
        glideException.f992 = i;
        glideException.f991 = clsMo1817;
        this.f11288.add(glideException);
        if (Thread.currentThread() == this.f11275) {
            m7091();
            return;
        }
        this.f11297 = 2;
        C4732 c4732 = this.f11272;
        (c4732.f17538 ? c4732.f17526 : c4732.f17529).execute(this);
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final void m7087(InterfaceC1725 interfaceC1725, int i, boolean z) throws SecurityException, IllegalArgumentException {
        if (((Map) this.f11285.f13883).containsKey(ˀʾˀᵛ.class)) {
            m7089();
        }
        m7088();
        C4732 c4732 = this.f11272;
        synchronized (c4732) {
            c4732.f17527 = interfaceC1725;
            c4732.f17537 = i;
        }
        c4732.m9992();
    }

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final void m7088() {
        this.f11299.m10131();
        if (this.f11286) {
            C1260.m3810("Already notified", this.f11288.isEmpty() ? null : (Throwable) AbstractC1327.m4111(1, this.f11288));
        } else {
            this.f11286 = true;
        }
    }

    @Override // defpackage.InterfaceC2518
    /* renamed from: ᵥᵯˎ */
    public final C4808 mo3004() {
        return this.f11299;
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final void m7089() throws SecurityException, IllegalArgumentException {
        if (!((Map) this.f11285.f13883).containsKey(ˀʾˀᵛ.class)) {
            ᵹˉᵞ.ᵳٴᵶ("OverrideGlideThreadPriority experiment is not enabled.");
            return;
        }
        Supplier supplier = this.f11279;
        if (supplier == null || supplier.get() == null) {
            return;
        }
        try {
            Process.setThreadPriority(Process.myTid(), 9);
        } catch (IllegalArgumentException | SecurityException unused) {
            this.f11279 = null;
            Log.isLoggable("DecodeJob", 2);
        }
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m7090() {
        C4513 c4513 = this.f11270;
        synchronized (c4513) {
            c4513.f16820 = false;
            c4513.f16819 = false;
            c4513.f16818 = false;
        }
        ᵧˉʙ r0 = this.f11287;
        r0.ᵢˇᵭ = null;
        r0.ᵿʗᵝʽ = null;
        r0.ᵾᵬ = null;
        C1101 c1101 = this.f11291;
        c1101.f4726 = null;
        c1101.f4738 = null;
        c1101.f4730 = null;
        c1101.f4724 = null;
        c1101.f4736 = null;
        c1101.f4727 = null;
        c1101.f4732 = null;
        c1101.f4734 = null;
        c1101.f4722 = null;
        c1101.f4729.clear();
        c1101.f4723 = false;
        c1101.f4733.clear();
        c1101.f4731 = false;
        this.f11286 = false;
        this.f11284 = null;
        this.f11280 = null;
        this.f11295 = null;
        this.f11277 = null;
        this.f11293 = null;
        this.f11272 = null;
        this.f11292 = 0;
        this.f11294 = null;
        this.f11275 = null;
        this.f11271 = null;
        this.f11283 = null;
        this.f11269 = 0;
        this.f11276 = null;
        this.f11274 = false;
        this.f11282 = null;
        this.f11288.clear();
        this.f11289.mo8276(this);
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final void m7091() throws SecurityException, IllegalArgumentException {
        this.f11275 = Thread.currentThread();
        int i = AbstractC4846.f17991;
        SystemClock.elapsedRealtimeNanos();
        boolean zMo3178 = false;
        while (!this.f11274 && this.f11294 != null && !(zMo3178 = this.f11294.mo3178())) {
            this.f11292 = m7095(this.f11292);
            this.f11294 = m7084();
            if (this.f11292 == 4) {
                this.f11297 = 2;
                C4732 c4732 = this.f11272;
                (c4732.f17538 ? c4732.f17526 : c4732.f17529).execute(this);
                return;
            }
        }
        if ((this.f11292 == 6 || this.f11274) && !zMo3178) {
            m7093();
        }
    }

    @Override // defpackage.InterfaceC2983
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void mo7092(InterfaceC4207 interfaceC4207, Object obj, InterfaceC2918 interfaceC2918, int i, InterfaceC4207 interfaceC42072) {
        this.f11271 = interfaceC4207;
        this.f11283 = obj;
        this.f11276 = interfaceC2918;
        this.f11269 = i;
        this.f11273 = interfaceC42072;
        this.f11278 = interfaceC4207 != this.f11291.m3501().get(0);
        if (Thread.currentThread() == this.f11275) {
            m7085();
            return;
        }
        this.f11297 = 3;
        C4732 c4732 = this.f11272;
        (c4732.f17538 ? c4732.f17526 : c4732.f17529).execute(this);
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final void m7093() throws SecurityException, IllegalArgumentException {
        if (((Map) this.f11285.f13883).containsKey(ˀʾˀᵛ.class)) {
            m7089();
        }
        m7088();
        GlideException glideException = new GlideException("Failed to load resource", new ArrayList(this.f11288));
        C4732 c4732 = this.f11272;
        synchronized (c4732) {
            c4732.f17541 = glideException;
        }
        c4732.m9985();
        m7094();
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m7094() {
        boolean zM9606;
        C4513 c4513 = this.f11270;
        synchronized (c4513) {
            c4513.f16818 = true;
            zM9606 = c4513.m9606();
        }
        if (zM9606) {
            m7090();
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final int m7095(int i) {
        int iM4088 = AbstractC1327.m4088(i);
        boolean z = false;
        if (iM4088 == 0) {
            switch (this.f11281.f12410) {
                case 0:
                case 1:
                    break;
                default:
                    z = true;
                    break;
            }
            if (z) {
                return 2;
            }
            return m7095(2);
        }
        if (iM4088 != 1) {
            if (iM4088 == 2) {
                return 4;
            }
            if (iM4088 == 3 || iM4088 == 5) {
                return 6;
            }
            ᵹˉᵞ.ˌᵜᵹᵩ("Unrecognized stage: ".concat(AbstractC4486.m9549(i)));
            return 0;
        }
        switch (this.f11281.f12410) {
            case 0:
                break;
            case 1:
            default:
                z = true;
                break;
        }
        if (z) {
            return 3;
        }
        return m7095(3);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final InterfaceC1725 m7096(InterfaceC2918 interfaceC2918, Object obj, int i) {
        if (obj == null) {
            interfaceC2918.mo5389();
            return null;
        }
        try {
            int i2 = AbstractC4846.f17991;
            SystemClock.elapsedRealtimeNanos();
            InterfaceC1725 interfaceC1725M7081 = m7081(i, obj);
            if (Log.isLoggable("DecodeJob", 2)) {
                interfaceC1725M7081.toString();
                SystemClock.elapsedRealtimeNanos();
                Objects.toString(this.f11293);
                Thread.currentThread().getName();
            }
            return interfaceC1725M7081;
        } finally {
            interfaceC2918.mo5389();
        }
    }
}
