package o;

import android.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Shader;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.Bundle;
import android.text.method.KeyListener;
import android.text.method.NumberKeyListener;
import android.util.AttributeSet;
import android.util.Log;
import android.view.WindowInsetsAnimation;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.AbsSeekBar;
import android.widget.EditText;
import androidx.work.impl.WorkDatabase_Impl;
import com.google.android.gms.common.ConnectionResult;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.json.JSONObject;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.yr, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public class C3040yr implements InterfaceC2439sb0, InterfaceC2956xx, IU, MZ, Mo0, InterfaceC0246Jm {

    /* renamed from: o, reason: collision with root package name */
    public static final int[] f814o = {R.attr.indeterminateDrawable, R.attr.progressDrawable};
    public final /* synthetic */ int l;
    public Object m;
    public Object n;

    public /* synthetic */ C3040yr(int i, Object obj, Object obj2) {
        this.l = i;
        this.m = obj;
        this.n = obj2;
    }

    @Override // o.Mo0
    public C2062oc0 a(InterfaceC1991no0 interfaceC1991no0) {
        C2062oc0 c2062oc0J = ((C2062oc0) this.m).j();
        c2062oc0J.m((String) this.n, interfaceC1991no0);
        return c2062oc0J;
    }

    @Override // o.MZ
    public void b(LZ lz, int i) throws IOException {
        int[] iArr = (int[]) this.n;
        try {
            lz.read((byte[]) this.m, iArr[0], i);
            iArr[0] = iArr[0] + i;
        } finally {
            lz.close();
        }
    }

    public ArrayList c(String str) {
        WorkDatabase_Impl workDatabase_Impl = (WorkDatabase_Impl) this.m;
        C1449i30 c1449i30D = C1449i30.d(1, "SELECT work_spec_id FROM dependency WHERE prerequisite_id=?");
        if (str == null) {
            c1449i30D.r(1);
        } else {
            c1449i30D.k(1, str);
        }
        workDatabase_Impl.b();
        Cursor cursorL = workDatabase_Impl.l(c1449i30D);
        try {
            ArrayList arrayList = new ArrayList(cursorL.getCount());
            while (cursorL.moveToNext()) {
                arrayList.add(cursorL.isNull(0) ? null : cursorL.getString(0));
            }
            return arrayList;
        } finally {
            cursorL.close();
            c1449i30D.release();
        }
    }

    public KeyListener d(KeyListener keyListener) {
        if (keyListener instanceof NumberKeyListener) {
            return keyListener;
        }
        ((C3031ym0) ((C0247Jn) this.n).m).getClass();
        if (keyListener instanceof C2953xv) {
            return keyListener;
        }
        if (keyListener == null) {
            return null;
        }
        return keyListener instanceof NumberKeyListener ? keyListener : new C2953xv(keyListener);
    }

    @Override // o.IU
    public List e(Integer num) {
        List listE = ((IU) this.m).e(null);
        C1365h90 c1365h90 = (C1365h90) this.n;
        int i = c1365h90.v;
        return i < 0 ? listE : AbstractC3117zi.l0(AbstractC1155f00.k(c1365h90, num, i, Integer.valueOf(c1365h90.C(c1365h90.b, i))), listE);
    }

    public InterfaceC2235qO f() {
        return (InterfaceC2235qO) ((MV) this.n).getValue();
    }

    public void g(AttributeSet attributeSet, int i) {
        switch (this.l) {
            case 1:
                AbsSeekBar absSeekBar = (AbsSeekBar) this.m;
                C70 c70R = C70.r(absSeekBar.getContext(), attributeSet, f814o, i);
                Drawable drawableN = c70R.n(0);
                if (drawableN != null) {
                    if (drawableN instanceof AnimationDrawable) {
                        AnimationDrawable animationDrawable = (AnimationDrawable) drawableN;
                        int numberOfFrames = animationDrawable.getNumberOfFrames();
                        AnimationDrawable animationDrawable2 = new AnimationDrawable();
                        animationDrawable2.setOneShot(animationDrawable.isOneShot());
                        for (int i2 = 0; i2 < numberOfFrames; i2++) {
                            Drawable drawableK = k(animationDrawable.getFrame(i2), true);
                            drawableK.setLevel(10000);
                            animationDrawable2.addFrame(drawableK, animationDrawable.getDuration(i2));
                        }
                        animationDrawable2.setLevel(10000);
                        drawableN = animationDrawable2;
                    }
                    absSeekBar.setIndeterminateDrawable(drawableN);
                }
                Drawable drawableN2 = c70R.n(1);
                if (drawableN2 != null) {
                    absSeekBar.setProgressDrawable(k(drawableN2, false));
                }
                c70R.t();
                return;
            default:
                TypedArray typedArrayObtainStyledAttributes = ((EditText) this.m).getContext().obtainStyledAttributes(attributeSet, YZ.i, i, 0);
                try {
                    boolean z = typedArrayObtainStyledAttributes.hasValue(14) ? typedArrayObtainStyledAttributes.getBoolean(14, true) : true;
                    typedArrayObtainStyledAttributes.recycle();
                    j(z);
                    return;
                } catch (Throwable th) {
                    typedArrayObtainStyledAttributes.recycle();
                    throw th;
                }
        }
    }

    @Override // o.CZ
    public Object get() {
        Context context = (Context) ((G0) this.m).m;
        return ME.m(ME.E, new C2000nt(new C1072e7(9)), C80.e((InterfaceC2747vn) ((CZ) this.n).get()), new C0626Yd(context, 1));
    }

    public C2668uv h(InputConnection inputConnection, EditorInfo editorInfo) {
        C0247Jn c0247Jn = (C0247Jn) this.n;
        if (inputConnection == null) {
            c0247Jn.getClass();
            inputConnection = null;
        } else {
            C3031ym0 c3031ym0 = (C3031ym0) c0247Jn.m;
            c3031ym0.getClass();
            if (!(inputConnection instanceof C2668uv)) {
                inputConnection = new C2668uv((EditText) c3031ym0.m, inputConnection, editorInfo);
            }
        }
        return (C2668uv) inputConnection;
    }

    public void i(DA da) {
        ExecutorC1921n20 executorC1921n20 = (ExecutorC1921n20) this.n;
        WT wt = (WT) this.m;
        int i = da.b;
        if (i != 0) {
            executorC1921n20.execute(new RunnableC1212fg(i, 0, wt));
        } else {
            executorC1921n20.execute(new RunnableC0890cD(5, wt, da.a));
        }
    }

    public void j(boolean z) {
        C0151Fv c0151Fv = (C0151Fv) ((C3031ym0) ((C0247Jn) this.n).m).n;
        if (c0151Fv.n != z) {
            if (c0151Fv.m != null) {
                C2004nv c2004nvA = C2004nv.a();
                RunnableC0125Ev runnableC0125Ev = c0151Fv.m;
                c2004nvA.getClass();
                AbstractC0249Jp.x(runnableC0125Ev, "initCallback cannot be null");
                ReentrantReadWriteLock reentrantReadWriteLock = c2004nvA.a;
                reentrantReadWriteLock.writeLock().lock();
                try {
                    c2004nvA.b.remove(runnableC0125Ev);
                } finally {
                    reentrantReadWriteLock.writeLock().unlock();
                }
            }
            c0151Fv.n = z;
            if (z) {
                C0151Fv.a(c0151Fv.l, C2004nv.a().c());
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public Drawable k(Drawable drawable, boolean z) {
        if (drawable instanceof Rm0) {
            ((Sm0) ((Rm0) drawable)).getClass();
        } else {
            if (drawable instanceof LayerDrawable) {
                LayerDrawable layerDrawable = (LayerDrawable) drawable;
                int numberOfLayers = layerDrawable.getNumberOfLayers();
                Drawable[] drawableArr = new Drawable[numberOfLayers];
                for (int i = 0; i < numberOfLayers; i++) {
                    int id = layerDrawable.getId(i);
                    drawableArr[i] = k(layerDrawable.getDrawable(i), id == 16908301 || id == 16908303);
                }
                LayerDrawable layerDrawable2 = new LayerDrawable(drawableArr);
                for (int i2 = 0; i2 < numberOfLayers; i2++) {
                    layerDrawable2.setId(i2, layerDrawable.getId(i2));
                    layerDrawable2.setLayerGravity(i2, layerDrawable.getLayerGravity(i2));
                    layerDrawable2.setLayerWidth(i2, layerDrawable.getLayerWidth(i2));
                    layerDrawable2.setLayerHeight(i2, layerDrawable.getLayerHeight(i2));
                    layerDrawable2.setLayerInsetLeft(i2, layerDrawable.getLayerInsetLeft(i2));
                    layerDrawable2.setLayerInsetRight(i2, layerDrawable.getLayerInsetRight(i2));
                    layerDrawable2.setLayerInsetTop(i2, layerDrawable.getLayerInsetTop(i2));
                    layerDrawable2.setLayerInsetBottom(i2, layerDrawable.getLayerInsetBottom(i2));
                    layerDrawable2.setLayerInsetStart(i2, layerDrawable.getLayerInsetStart(i2));
                    layerDrawable2.setLayerInsetEnd(i2, layerDrawable.getLayerInsetEnd(i2));
                }
                return layerDrawable2;
            }
            if (drawable instanceof BitmapDrawable) {
                BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
                Bitmap bitmap = bitmapDrawable.getBitmap();
                if (((Bitmap) this.n) == null) {
                    this.n = bitmap;
                }
                ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(new float[]{5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f}, null, null));
                shapeDrawable.getPaint().setShader(new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP));
                shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
                return z ? new ClipDrawable(shapeDrawable, 3, 1) : shapeDrawable;
            }
        }
        return drawable;
    }

    @Override // o.InterfaceC0246Jm
    public Object then(Pc0 pc0) {
        Bundle bundle;
        B30 b30 = (B30) this.m;
        Bundle bundle2 = (Bundle) this.n;
        b30.getClass();
        return (pc0.h() && (bundle = (Bundle) pc0.f()) != null && bundle.containsKey("google.messenger")) ? b30.a(bundle2).i(ExecutorC0614Xr.f416o, ME.N) : pc0;
    }

    public String toString() {
        switch (this.l) {
            case 14:
                return "Bounds{lower=" + ((LH) this.m) + " upper=" + ((LH) this.n) + "}";
            default:
                return super.toString();
        }
    }

    public /* synthetic */ C3040yr(int i, Object obj, Object obj2, boolean z) {
        this.l = i;
        this.n = obj;
        this.m = obj2;
    }

    public C3040yr(WorkDatabase_Impl workDatabase_Impl) {
        this.l = 0;
        this.m = workDatabase_Impl;
        this.n = new C2945xr(workDatabase_Impl, 0);
    }

    @Override // o.InterfaceC2439sb0
    public Pc0 then(Object obj) throws Throwable {
        D70 c2616uQ;
        FileWriter fileWriter;
        switch (this.l) {
            case 4:
                Boolean bool = (Boolean) obj;
                C0324Mn c0324Mn = (C0324Mn) this.n;
                if (!bool.booleanValue()) {
                    Log.isLoggable("FirebaseCrashlytics", 2);
                    Iterator it = C1533iy.e(((File) c0324Mn.g.n).listFiles(C0324Mn.r)).iterator();
                    while (it.hasNext()) {
                        ((File) it.next()).delete();
                    }
                    C1533iy c1533iy = ((C2939xo) c0324Mn.m.n).b;
                    C2939xo.a(C1533iy.e(((File) c1533iy.p).listFiles()));
                    C2939xo.a(C1533iy.e(((File) c1533iy.q).listFiles()));
                    C2939xo.a(C1533iy.e(((File) c1533iy.r).listFiles()));
                    c0324Mn.q.d(null);
                    return AbstractC0752ap.K(null);
                }
                Log.isLoggable("FirebaseCrashlytics", 3);
                boolean zBooleanValue = bool.booleanValue();
                C0637Yo c0637Yo = c0324Mn.b;
                if (zBooleanValue) {
                    c0637Yo.g.d(null);
                    return ((Pc0) this.m).i((ExecutorC0014Ao) c0324Mn.e.m, new C0247Jn(1, this));
                }
                c0637Yo.getClass();
                throw new IllegalStateException("An invalid data collection token was used.");
            default:
                C0598Xb c0598Xb = (C0598Xb) this.n;
                JSONObject jSONObject = (JSONObject) ((ExecutorC0014Ao) ((C3126zm0) this.m).f831o).l.submit(new CallableC0376On(2, this)).get();
                FileWriter fileWriter2 = null;
                if (jSONObject != null) {
                    WT wt = (WT) c0598Xb.c;
                    wt.getClass();
                    if (jSONObject.getInt("settings_version") != 3) {
                        c2616uQ = new C0688a6(15);
                    } else {
                        c2616uQ = new C2616uQ(14);
                    }
                    C2975y70 c2975y70D = c2616uQ.d((C2616uQ) wt.m, jSONObject);
                    OD od = (OD) c0598Xb.e;
                    long j = c2975y70D.c;
                    od.getClass();
                    Log.isLoggable("FirebaseCrashlytics", 2);
                    try {
                        jSONObject.put("expires_at", j);
                        fileWriter = new FileWriter((File) od.m);
                    } catch (Exception unused) {
                        fileWriter = null;
                    } catch (Throwable th) {
                        th = th;
                    }
                    try {
                        fileWriter.write(jSONObject.toString());
                        fileWriter.flush();
                    } catch (Exception unused2) {
                    } catch (Throwable th2) {
                        th = th2;
                        fileWriter2 = fileWriter;
                        C1884mi0.p(fileWriter2);
                        throw th;
                    }
                    C1884mi0.p(fileWriter);
                    jSONObject.toString();
                    Log.isLoggable("FirebaseCrashlytics", 3);
                    String str = ((F70) c0598Xb.b).f;
                    SharedPreferences.Editor editorEdit = ((Context) c0598Xb.a).getSharedPreferences("com.google.firebase.crashlytics", 0).edit();
                    editorEdit.putString("existing_instance_identifier", str);
                    editorEdit.apply();
                    ((AtomicReference) c0598Xb.h).set(c2975y70D);
                    ((Qc0) ((AtomicReference) c0598Xb.i).get()).d(c2975y70D);
                }
                return AbstractC0752ap.K(null);
        }
    }

    public C3040yr(C2420sK c2420sK, InterfaceC2235qO interfaceC2235qO) {
        this.l = 7;
        this.m = c2420sK;
        this.n = AbstractC0752ap.X(interfaceC2235qO);
    }

    public C3040yr(AbsSeekBar absSeekBar) {
        this.l = 1;
        this.m = absSeekBar;
    }

    public C3040yr(EditText editText) {
        this.l = 2;
        this.m = editText;
        this.n = new C0247Jn(editText);
    }

    public C3040yr(DH dh) throws Resources.NotFoundException, IOException {
        this.l = 5;
        Context context = (Context) dh.l;
        int iA = C1884mi0.A(context, "com.google.firebase.crashlytics.unity_version", "string");
        if (iA != 0) {
            this.m = "Unity";
            this.n = context.getResources().getString(iA);
            Log.isLoggable("FirebaseCrashlytics", 2);
            return;
        }
        if (context.getAssets() != null) {
            try {
                InputStream inputStreamOpen = context.getAssets().open("flutter_assets/NOTICES.Z");
                if (inputStreamOpen != null) {
                    inputStreamOpen.close();
                }
                this.m = "Flutter";
                this.n = null;
                Log.isLoggable("FirebaseCrashlytics", 2);
                return;
            } catch (IOException unused) {
            }
        }
        this.m = null;
        this.n = null;
    }

    public C3040yr(WindowInsetsAnimation.Bounds bounds) {
        this.l = 14;
        this.m = LH.c(bounds.getLowerBound());
        this.n = LH.c(bounds.getUpperBound());
    }

    public C3040yr(int i) {
        this.l = i;
        switch (i) {
            case ConnectionResult.LICENSE_CHECK_FAILED /* 11 */:
                this.m = new LinkedHashMap();
                this.n = new LinkedHashMap();
                break;
            default:
                this.m = new C1886mj0(0);
                this.n = new C1886mj0(0);
                break;
        }
    }
}
