package d0; import android.graphics.Rect; import android.os.Bundle; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import androidx.collection.h; import androidx.core.view.n0; import androidx.core.view.v0; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.common.api.Api; import d0.b; import java.util.ArrayList; import java.util.List; import z.a0; import z.b0; import z.c0; /* loaded from: classes.dex */ public abstract class a extends androidx.core.view.a { /* renamed from: n, reason: collision with root package name */ private static final Rect f8944n = new Rect(Api.BaseClientBuilder.API_PRIORITY_OTHER, Api.BaseClientBuilder.API_PRIORITY_OTHER, RecyclerView.UNDEFINED_DURATION, RecyclerView.UNDEFINED_DURATION); /* renamed from: o, reason: collision with root package name */ private static final b.a f8945o = new C0130a(); /* renamed from: p, reason: collision with root package name */ private static final b.InterfaceC0131b f8946p = new b(); /* renamed from: h, reason: collision with root package name */ private final AccessibilityManager f8951h; /* renamed from: i, reason: collision with root package name */ private final View f8952i; /* renamed from: j, reason: collision with root package name */ private c f8953j; /* renamed from: d, reason: collision with root package name */ private final Rect f8947d = new Rect(); /* renamed from: e, reason: collision with root package name */ private final Rect f8948e = new Rect(); /* renamed from: f, reason: collision with root package name */ private final Rect f8949f = new Rect(); /* renamed from: g, reason: collision with root package name */ private final int[] f8950g = new int[2]; /* renamed from: k, reason: collision with root package name */ int f8954k = RecyclerView.UNDEFINED_DURATION; /* renamed from: l, reason: collision with root package name */ int f8955l = RecyclerView.UNDEFINED_DURATION; /* renamed from: m, reason: collision with root package name */ private int f8956m = RecyclerView.UNDEFINED_DURATION; /* renamed from: d0.a$a, reason: collision with other inner class name */ static class C0130a implements b.a { C0130a() { } @Override // d0.b.a /* renamed from: b, reason: merged with bridge method [inline-methods] */ public void a(a0 a0Var, Rect rect) { a0Var.l(rect); } } static class b implements b.InterfaceC0131b { b() { } @Override // d0.b.InterfaceC0131b /* renamed from: c, reason: merged with bridge method [inline-methods] */ public a0 a(h hVar, int i10) { return (a0) hVar.l(i10); } @Override // d0.b.InterfaceC0131b /* renamed from: d, reason: merged with bridge method [inline-methods] */ public int b(h hVar) { return hVar.k(); } } private class c extends b0 { c() { } @Override // z.b0 public a0 b(int i10) { return a0.M(a.this.H(i10)); } @Override // z.b0 public a0 d(int i10) { int i11 = i10 == 2 ? a.this.f8954k : a.this.f8955l; if (i11 == Integer.MIN_VALUE) { return null; } return b(i11); } @Override // z.b0 public boolean f(int i10, int i11, Bundle bundle) { return a.this.P(i10, i11, bundle); } } public a(View view) { if (view == null) { throw new IllegalArgumentException("View may not be null"); } this.f8952i = view; this.f8951h = (AccessibilityManager) view.getContext().getSystemService("accessibility"); view.setFocusable(true); if (n0.z(view) == 0) { n0.w0(view, 1); } } private static Rect D(View view, int i10, Rect rect) { int width = view.getWidth(); int height = view.getHeight(); if (i10 == 17) { rect.set(width, 0, width, height); } else if (i10 == 33) { rect.set(0, height, width, height); } else if (i10 == 66) { rect.set(-1, 0, -1, height); } else { if (i10 != 130) { throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); } rect.set(0, -1, width, -1); } return rect; } private boolean E(Rect rect) { if (rect == null || rect.isEmpty() || this.f8952i.getWindowVisibility() != 0) { return false; } Object parent = this.f8952i.getParent(); while (parent instanceof View) { View view = (View) parent; if (view.getAlpha() <= 0.0f || view.getVisibility() != 0) { return false; } parent = view.getParent(); } return parent != null; } private static int F(int i10) { if (i10 == 19) { return 33; } if (i10 != 21) { return i10 != 22 ? 130 : 66; } return 17; } private boolean G(int i10, Rect rect) { a0 a0Var; h y10 = y(); int i11 = this.f8955l; int i12 = RecyclerView.UNDEFINED_DURATION; a0 a0Var2 = i11 == Integer.MIN_VALUE ? null : (a0) y10.f(i11); if (i10 == 1 || i10 == 2) { a0Var = (a0) d0.b.d(y10, f8946p, f8945o, a0Var2, i10, n0.B(this.f8952i) == 1, false); } else { if (i10 != 17 && i10 != 33 && i10 != 66 && i10 != 130) { throw new IllegalArgumentException("direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD, FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); } Rect rect2 = new Rect(); int i13 = this.f8955l; if (i13 != Integer.MIN_VALUE) { z(i13, rect2); } else if (rect != null) { rect2.set(rect); } else { D(this.f8952i, i10, rect2); } a0Var = (a0) d0.b.c(y10, f8946p, f8945o, a0Var2, rect2, i10); } if (a0Var != null) { i12 = y10.i(y10.h(a0Var)); } return T(i12); } private boolean Q(int i10, int i11, Bundle bundle) { return i11 != 1 ? i11 != 2 ? i11 != 64 ? i11 != 128 ? J(i10, i11, bundle) : n(i10) : S(i10) : o(i10) : T(i10); } private boolean R(int i10, Bundle bundle) { return n0.c0(this.f8952i, i10, bundle); } private boolean S(int i10) { int i11; if (!this.f8951h.isEnabled() || !this.f8951h.isTouchExplorationEnabled() || (i11 = this.f8954k) == i10) { return false; } if (i11 != Integer.MIN_VALUE) { n(i11); } this.f8954k = i10; this.f8952i.invalidate(); U(i10, 32768); return true; } private void V(int i10) { int i11 = this.f8956m; if (i11 == i10) { return; } this.f8956m = i10; U(i10, 128); U(i11, 256); } private boolean n(int i10) { if (this.f8954k != i10) { return false; } this.f8954k = RecyclerView.UNDEFINED_DURATION; this.f8952i.invalidate(); U(i10, 65536); return true; } private boolean p() { int i10 = this.f8955l; return i10 != Integer.MIN_VALUE && J(i10, 16, null); } private AccessibilityEvent q(int i10, int i11) { return i10 != -1 ? r(i10, i11) : s(i11); } private AccessibilityEvent r(int i10, int i11) { AccessibilityEvent obtain = AccessibilityEvent.obtain(i11); a0 H = H(i10); obtain.getText().add(H.v()); obtain.setContentDescription(H.q()); obtain.setScrollable(H.H()); obtain.setPassword(H.G()); obtain.setEnabled(H.C()); obtain.setChecked(H.A()); L(i10, obtain); if (obtain.getText().isEmpty() && obtain.getContentDescription() == null) { throw new RuntimeException("Callbacks must add text or a content description in populateEventForVirtualViewId()"); } obtain.setClassName(H.o()); c0.c(obtain, this.f8952i, i10); obtain.setPackageName(this.f8952i.getContext().getPackageName()); return obtain; } private AccessibilityEvent s(int i10) { AccessibilityEvent obtain = AccessibilityEvent.obtain(i10); this.f8952i.onInitializeAccessibilityEvent(obtain); return obtain; } private a0 t(int i10) { a0 K = a0.K(); K.c0(true); K.e0(true); K.W("android.view.View"); Rect rect = f8944n; K.S(rect); K.T(rect); K.k0(this.f8952i); N(i10, K); if (K.v() == null && K.q() == null) { throw new RuntimeException("Callbacks must add text or a content description in populateNodeForVirtualViewId()"); } K.l(this.f8948e); if (this.f8948e.equals(rect)) { throw new RuntimeException("Callbacks must set parent bounds in populateNodeForVirtualViewId()"); } int j10 = K.j(); if ((j10 & 64) != 0) { throw new RuntimeException("Callbacks must not add ACTION_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()"); } if ((j10 & 128) != 0) { throw new RuntimeException("Callbacks must not add ACTION_CLEAR_ACCESSIBILITY_FOCUS in populateNodeForVirtualViewId()"); } K.i0(this.f8952i.getContext().getPackageName()); K.p0(this.f8952i, i10); if (this.f8954k == i10) { K.Q(true); K.a(128); } else { K.Q(false); K.a(64); } boolean z10 = this.f8955l == i10; if (z10) { K.a(2); } else if (K.D()) { K.a(1); } K.f0(z10); this.f8952i.getLocationOnScreen(this.f8950g); K.m(this.f8947d); if (this.f8947d.equals(rect)) { K.l(this.f8947d); if (K.f15673b != -1) { a0 K2 = a0.K(); for (int i11 = K.f15673b; i11 != -1; i11 = K2.f15673b) { K2.l0(this.f8952i, -1); K2.S(f8944n); N(i11, K2); K2.l(this.f8948e); Rect rect2 = this.f8947d; Rect rect3 = this.f8948e; rect2.offset(rect3.left, rect3.top); } K2.O(); } this.f8947d.offset(this.f8950g[0] - this.f8952i.getScrollX(), this.f8950g[1] - this.f8952i.getScrollY()); } if (this.f8952i.getLocalVisibleRect(this.f8949f)) { this.f8949f.offset(this.f8950g[0] - this.f8952i.getScrollX(), this.f8950g[1] - this.f8952i.getScrollY()); if (this.f8947d.intersect(this.f8949f)) { K.T(this.f8947d); if (E(this.f8947d)) { K.s0(true); } } } return K; } private a0 u() { a0 L = a0.L(this.f8952i); n0.a0(this.f8952i, L); ArrayList arrayList = new ArrayList(); C(arrayList); if (L.n() > 0 && arrayList.size() > 0) { throw new RuntimeException("Views cannot have both real and virtual children"); } int size = arrayList.size(); for (int i10 = 0; i10 < size; i10++) { L.c(this.f8952i, ((Integer) arrayList.get(i10)).intValue()); } return L; } private h y() { ArrayList arrayList = new ArrayList(); C(arrayList); h hVar = new h(); for (int i10 = 0; i10 < arrayList.size(); i10++) { hVar.j(i10, t(i10)); } return hVar; } private void z(int i10, Rect rect) { H(i10).l(rect); } public final int A() { return this.f8955l; } protected abstract int B(float f10, float f11); protected abstract void C(List list); a0 H(int i10) { return i10 == -1 ? u() : t(i10); } public final void I(boolean z10, int i10, Rect rect) { int i11 = this.f8955l; if (i11 != Integer.MIN_VALUE) { o(i11); } if (z10) { G(i10, rect); } } protected abstract boolean J(int i10, int i11, Bundle bundle); protected void K(AccessibilityEvent accessibilityEvent) { } protected void L(int i10, AccessibilityEvent accessibilityEvent) { } protected abstract void M(a0 a0Var); protected abstract void N(int i10, a0 a0Var); protected abstract void O(int i10, boolean z10); boolean P(int i10, int i11, Bundle bundle) { return i10 != -1 ? Q(i10, i11, bundle) : R(i11, bundle); } public final boolean T(int i10) { int i11; if ((!this.f8952i.isFocused() && !this.f8952i.requestFocus()) || (i11 = this.f8955l) == i10) { return false; } if (i11 != Integer.MIN_VALUE) { o(i11); } this.f8955l = i10; O(i10, true); U(i10, 8); return true; } public final boolean U(int i10, int i11) { ViewParent parent; if (i10 == Integer.MIN_VALUE || !this.f8951h.isEnabled() || (parent = this.f8952i.getParent()) == null) { return false; } return v0.h(parent, this.f8952i, q(i10, i11)); } @Override // androidx.core.view.a public b0 b(View view) { if (this.f8953j == null) { this.f8953j = new c(); } return this.f8953j; } @Override // androidx.core.view.a public void f(View view, AccessibilityEvent accessibilityEvent) { super.f(view, accessibilityEvent); K(accessibilityEvent); } @Override // androidx.core.view.a public void g(View view, a0 a0Var) { super.g(view, a0Var); M(a0Var); } public final boolean o(int i10) { if (this.f8955l != i10) { return false; } this.f8955l = RecyclerView.UNDEFINED_DURATION; O(i10, false); U(i10, 8); return true; } public final boolean v(MotionEvent motionEvent) { if (!this.f8951h.isEnabled() || !this.f8951h.isTouchExplorationEnabled()) { return false; } int action = motionEvent.getAction(); if (action == 7 || action == 9) { int B = B(motionEvent.getX(), motionEvent.getY()); V(B); return B != Integer.MIN_VALUE; } if (action != 10 || this.f8956m == Integer.MIN_VALUE) { return false; } V(RecyclerView.UNDEFINED_DURATION); return true; } public final boolean w(KeyEvent keyEvent) { int i10 = 0; if (keyEvent.getAction() == 1) { return false; } int keyCode = keyEvent.getKeyCode(); if (keyCode == 61) { if (keyEvent.hasNoModifiers()) { return G(2, null); } if (keyEvent.hasModifiers(1)) { return G(1, null); } return false; } if (keyCode != 66) { switch (keyCode) { case 19: case 20: case 21: case 22: if (!keyEvent.hasNoModifiers()) { return false; } int F = F(keyCode); int repeatCount = keyEvent.getRepeatCount() + 1; boolean z10 = false; while (i10 < repeatCount && G(F, null)) { i10++; z10 = true; } return z10; case 23: break; default: return false; } } if (!keyEvent.hasNoModifiers() || keyEvent.getRepeatCount() != 0) { return false; } p(); return true; } public final int x() { return this.f8954k; } }