package c.e.i;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.WindowInsets;
import com.ifpdos.factory.R;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"PrivateConstructorForUtilityClass"})
public class l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static WeakHashMap<View, q> f5278a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static Field f5279b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static boolean f5280c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final k f5281d;

    public class a implements k {
        @Override // c.e.i.k
        public c.e.i.c a(c.e.i.c cVar) {
            return cVar;
        }
    }

    public static abstract class b<T> {

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

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final Class<T> f5283b;

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

        public b(int i2, Class<T> cls, int i3) {
            this.f5282a = i2;
            this.f5283b = cls;
            this.f5284c = i3;
        }

        public b(int i2, Class<T> cls, int i3, int i4) {
            this.f5282a = i2;
            this.f5283b = cls;
            this.f5284c = i4;
        }

        public abstract T a(View view);

        public T b(View view) {
            if (Build.VERSION.SDK_INT >= this.f5284c) {
                return a(view);
            }
            T t = (T) view.getTag(this.f5282a);
            if (this.f5283b.isInstance(t)) {
                return t;
            }
            return null;
        }
    }

    public static class c {
        public static u a(View view, u uVar, Rect rect) {
            WindowInsets windowInsetsF = uVar.f();
            if (windowInsetsF != null) {
                return u.h(view.computeSystemWindowInsets(windowInsetsF, rect), view);
            }
            rect.setEmpty();
            return uVar;
        }
    }

    public static class d {
        public static u a(View view) {
            WindowInsets rootWindowInsets = view.getRootWindowInsets();
            if (rootWindowInsets == null) {
                return null;
            }
            u uVarH = u.h(rootWindowInsets, null);
            uVarH.f5296b.l(uVarH);
            uVarH.f5296b.d(view.getRootView());
            return uVarH;
        }
    }

    public static class e {
        public static void a(View view, Context context, int[] iArr, AttributeSet attributeSet, TypedArray typedArray, int i2, int i3) {
            view.saveAttributeDataForStyleable(context, iArr, attributeSet, typedArray, i2, i3);
        }
    }

    public interface f {
        boolean a(View view, KeyEvent keyEvent);
    }

    public static class g {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final ArrayList<WeakReference<View>> f5285a = new ArrayList<>();

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public WeakHashMap<View, Boolean> f5286b = null;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public SparseArray<WeakReference<View>> f5287c = null;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public WeakReference<KeyEvent> f5288d = null;

        public final View a(View view, KeyEvent keyEvent) {
            WeakHashMap<View, Boolean> weakHashMap = this.f5286b;
            if (weakHashMap != null && weakHashMap.containsKey(view)) {
                if (view instanceof ViewGroup) {
                    ViewGroup viewGroup = (ViewGroup) view;
                    for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
                        View viewA = a(viewGroup.getChildAt(childCount), keyEvent);
                        if (viewA != null) {
                            return viewA;
                        }
                    }
                }
                if (b(view, keyEvent)) {
                    return view;
                }
            }
            return null;
        }

        public final boolean b(View view, KeyEvent keyEvent) {
            ArrayList arrayList = (ArrayList) view.getTag(R.id.tag_unhandled_key_listeners);
            if (arrayList == null) {
                return false;
            }
            for (int size = arrayList.size() - 1; size >= 0; size--) {
                if (((f) arrayList.get(size)).a(view, keyEvent)) {
                    return true;
                }
            }
            return false;
        }
    }

    static {
        new AtomicInteger(1);
        f5278a = null;
        f5280c = false;
        f5281d = new a();
        new WeakHashMap();
    }

    public static q a(View view) {
        if (f5278a == null) {
            f5278a = new WeakHashMap<>();
        }
        q qVar = f5278a.get(view);
        if (qVar != null) {
            return qVar;
        }
        q qVar2 = new q(view);
        f5278a.put(view, qVar2);
        return qVar2;
    }

    public static u b(View view, u uVar) {
        WindowInsets windowInsetsF = uVar.f();
        if (windowInsetsF != null) {
            WindowInsets windowInsetsDispatchApplyWindowInsets = view.dispatchApplyWindowInsets(windowInsetsF);
            if (!windowInsetsDispatchApplyWindowInsets.equals(windowInsetsF)) {
                return u.h(windowInsetsDispatchApplyWindowInsets, view);
            }
        }
        return uVar;
    }

    public static boolean c(View view, KeyEvent keyEvent) {
        if (Build.VERSION.SDK_INT >= 28) {
            return false;
        }
        ArrayList<WeakReference<View>> arrayList = g.f5285a;
        g gVar = (g) view.getTag(R.id.tag_unhandled_key_event_manager);
        if (gVar == null) {
            gVar = new g();
            view.setTag(R.id.tag_unhandled_key_event_manager, gVar);
        }
        if (keyEvent.getAction() == 0) {
            WeakHashMap<View, Boolean> weakHashMap = gVar.f5286b;
            if (weakHashMap != null) {
                weakHashMap.clear();
            }
            ArrayList<WeakReference<View>> arrayList2 = g.f5285a;
            if (!arrayList2.isEmpty()) {
                synchronized (arrayList2) {
                    if (gVar.f5286b == null) {
                        gVar.f5286b = new WeakHashMap<>();
                    }
                    int size = arrayList2.size();
                    while (true) {
                        size--;
                        if (size < 0) {
                            break;
                        }
                        ArrayList<WeakReference<View>> arrayList3 = g.f5285a;
                        View view2 = arrayList3.get(size).get();
                        if (view2 == null) {
                            arrayList3.remove(size);
                        } else {
                            gVar.f5286b.put(view2, Boolean.TRUE);
                            for (ViewParent parent = view2.getParent(); parent instanceof View; parent = parent.getParent()) {
                                gVar.f5286b.put((View) parent, Boolean.TRUE);
                            }
                        }
                    }
                }
            }
        }
        View viewA = gVar.a(view, keyEvent);
        if (keyEvent.getAction() == 0) {
            int keyCode = keyEvent.getKeyCode();
            if (viewA != null && !KeyEvent.isModifierKey(keyCode)) {
                if (gVar.f5287c == null) {
                    gVar.f5287c = new SparseArray<>();
                }
                gVar.f5287c.put(keyCode, new WeakReference<>(viewA));
            }
        }
        return viewA != null;
    }

    public static CharSequence d(View view) {
        return new n(R.id.tag_accessibility_pane_title, CharSequence.class, 8, 28).b(view);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static c.e.i.c e(View view, c.e.i.c cVar) {
        if (Log.isLoggable("ViewCompat", 3)) {
            Log.d("ViewCompat", "performReceiveContent: " + cVar + ", view=" + view.getClass().getSimpleName() + "[" + view.getId() + "]");
        }
        j jVar = (j) view.getTag(R.id.tag_on_receive_content_listener);
        if (jVar == null) {
            return (view instanceof k ? (k) view : f5281d).a(cVar);
        }
        c.e.i.c cVarA = jVar.a(view, cVar);
        if (cVarA == null) {
            return null;
        }
        return (view instanceof k ? (k) view : f5281d).a(cVarA);
    }

    public static void f(View view, @SuppressLint({"ContextFirst"}) Context context, int[] iArr, AttributeSet attributeSet, TypedArray typedArray, int i2, int i3) {
        if (Build.VERSION.SDK_INT >= 29) {
            e.a(view, context, iArr, attributeSet, typedArray, i2, i3);
        }
    }
}
