what-the-bank/sources/io/flutter/view/AccessibilityBridge.java

1848 lines
88 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.flutter.view;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.graphics.Rect;
import android.net.Uri;
import android.opengl.Matrix;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.LocaleSpan;
import android.text.style.TtsSpan;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import io.flutter.Log;
import io.flutter.embedding.engine.systemchannels.AccessibilityChannel;
import io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate;
import io.flutter.util.Predicate;
import io.flutter.util.ViewUtils;
import io.flutter.view.AccessibilityBridge;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.internal.http2.Http2Connection;
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
/* loaded from: classes6.dex */
public class AccessibilityBridge extends AccessibilityNodeProvider {
private static final int ACTION_SHOW_ON_SCREEN = 16908342;
private static final int BOLD_TEXT_WEIGHT_ADJUSTMENT = 300;
private static final int MIN_ENGINE_GENERATED_NODE_ID = 65536;
private static final int ROOT_NODE_ID = 0;
private static final float SCROLL_EXTENT_FOR_INFINITY = 100000.0f;
private static final float SCROLL_POSITION_CAP_FOR_INFINITY = 70000.0f;
private static final String TAG = "AccessibilityBridge";
private final AccessibilityChannel accessibilityChannel;
private int accessibilityFeatureFlags;
private SemanticsNode accessibilityFocusedSemanticsNode;
private final AccessibilityManager accessibilityManager;
private final AccessibilityChannel.AccessibilityMessageHandler accessibilityMessageHandler;
private final AccessibilityManager.AccessibilityStateChangeListener accessibilityStateChangeListener;
private final AccessibilityViewEmbedder accessibilityViewEmbedder;
private boolean accessibleNavigation;
private final ContentObserver animationScaleObserver;
private final ContentResolver contentResolver;
private final Map<Integer, CustomAccessibilityAction> customAccessibilityActions;
private Integer embeddedAccessibilityFocusedNodeId;
private Integer embeddedInputFocusedNodeId;
private final List<Integer> flutterNavigationStack;
private final Map<Integer, SemanticsNode> flutterSemanticsTree;
private SemanticsNode hoveredObject;
private SemanticsNode inputFocusedSemanticsNode;
private boolean isReleased;
private SemanticsNode lastInputFocusedSemanticsNode;
private Integer lastLeftFrameInset;
private OnAccessibilityChangeListener onAccessibilityChangeListener;
private final PlatformViewsAccessibilityDelegate platformViewsAccessibilityDelegate;
private int previousRouteId;
private final View rootAccessibilityView;
private final AccessibilityManager.TouchExplorationStateChangeListener touchExplorationStateChangeListener;
private static final int SCROLLABLE_ACTIONS = ((Action.SCROLL_RIGHT.value | Action.SCROLL_LEFT.value) | Action.SCROLL_UP.value) | Action.SCROLL_DOWN.value;
private static final int FOCUSABLE_FLAGS = ((((((((((Flag.HAS_CHECKED_STATE.value | Flag.IS_CHECKED.value) | Flag.IS_SELECTED.value) | Flag.IS_TEXT_FIELD.value) | Flag.IS_FOCUSED.value) | Flag.HAS_ENABLED_STATE.value) | Flag.IS_ENABLED.value) | Flag.IS_IN_MUTUALLY_EXCLUSIVE_GROUP.value) | Flag.HAS_TOGGLED_STATE.value) | Flag.IS_TOGGLED.value) | Flag.IS_FOCUSABLE.value) | Flag.IS_SLIDER.value;
private static int FIRST_RESOURCE_ID = 267386881;
/* loaded from: classes6.dex */
public interface OnAccessibilityChangeListener {
void onAccessibilityChanged(boolean z, boolean z2);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public enum StringAttributeType {
SPELLOUT,
LOCALE
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public enum TextDirection {
UNKNOWN,
LTR,
RTL;
public static TextDirection fromInt(int i) {
return i != 1 ? i != 2 ? UNKNOWN : LTR : RTL;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ boolean lambda$shouldSetCollectionInfo$0(SemanticsNode semanticsNode, SemanticsNode semanticsNode2) {
return semanticsNode2 == semanticsNode;
}
public boolean getAccessibleNavigation() {
return this.accessibleNavigation;
}
public void setOnAccessibilityChangeListener(OnAccessibilityChangeListener onAccessibilityChangeListener) {
this.onAccessibilityChangeListener = onAccessibilityChangeListener;
}
static /* synthetic */ int access$1272(AccessibilityBridge accessibilityBridge, int i) {
int i2 = i & accessibilityBridge.accessibilityFeatureFlags;
accessibilityBridge.accessibilityFeatureFlags = i2;
return i2;
}
static /* synthetic */ int access$1276(AccessibilityBridge accessibilityBridge, int i) {
int i2 = i | accessibilityBridge.accessibilityFeatureFlags;
accessibilityBridge.accessibilityFeatureFlags = i2;
return i2;
}
public int getHoveredObjectId() {
return this.hoveredObject.id;
}
/* JADX INFO: Access modifiers changed from: private */
public void setAccessibleNavigation(boolean z) {
if (this.accessibleNavigation == z) {
return;
}
this.accessibleNavigation = z;
if (z) {
this.accessibilityFeatureFlags |= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
} else {
this.accessibilityFeatureFlags &= ~AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
}
sendLatestAccessibilityFlagsToFlutter();
}
public AccessibilityBridge(View view, AccessibilityChannel accessibilityChannel, AccessibilityManager accessibilityManager, ContentResolver contentResolver, PlatformViewsAccessibilityDelegate platformViewsAccessibilityDelegate) {
this(view, accessibilityChannel, accessibilityManager, contentResolver, new AccessibilityViewEmbedder(view, 65536), platformViewsAccessibilityDelegate);
}
public AccessibilityBridge(View view, AccessibilityChannel accessibilityChannel, AccessibilityManager accessibilityManager, ContentResolver contentResolver, AccessibilityViewEmbedder accessibilityViewEmbedder, PlatformViewsAccessibilityDelegate platformViewsAccessibilityDelegate) {
this.flutterSemanticsTree = new HashMap();
this.customAccessibilityActions = new HashMap();
this.accessibilityFeatureFlags = 0;
this.flutterNavigationStack = new ArrayList();
this.previousRouteId = 0;
this.lastLeftFrameInset = 0;
this.accessibleNavigation = false;
this.isReleased = false;
this.accessibilityMessageHandler = new AccessibilityChannel.AccessibilityMessageHandler(this) { // from class: io.flutter.view.AccessibilityBridge.1
final AccessibilityBridge this$0;
{
this.this$0 = this;
}
@Override // io.flutter.embedding.engine.systemchannels.AccessibilityChannel.AccessibilityMessageHandler
public void announce(String str) {
this.this$0.rootAccessibilityView.announceForAccessibility(str);
}
@Override // io.flutter.embedding.engine.systemchannels.AccessibilityChannel.AccessibilityMessageHandler
public void onTap(int i) {
this.this$0.sendAccessibilityEvent(i, 1);
}
@Override // io.flutter.embedding.engine.systemchannels.AccessibilityChannel.AccessibilityMessageHandler
public void onLongPress(int i) {
this.this$0.sendAccessibilityEvent(i, 2);
}
@Override // io.flutter.embedding.engine.systemchannels.AccessibilityChannel.AccessibilityMessageHandler
public void onTooltip(String str) {
if (Build.VERSION.SDK_INT >= 28) {
return;
}
AccessibilityEvent obtainAccessibilityEvent = this.this$0.obtainAccessibilityEvent(0, 32);
obtainAccessibilityEvent.getText().add(str);
this.this$0.sendAccessibilityEvent(obtainAccessibilityEvent);
}
@Override // io.flutter.embedding.engine.FlutterJNI.AccessibilityDelegate
public void updateCustomAccessibilityActions(ByteBuffer byteBuffer, String[] strArr) {
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
this.this$0.updateCustomAccessibilityActions(byteBuffer, strArr);
}
@Override // io.flutter.embedding.engine.FlutterJNI.AccessibilityDelegate
public void updateSemantics(ByteBuffer byteBuffer, String[] strArr, ByteBuffer[] byteBufferArr) {
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
for (ByteBuffer byteBuffer2 : byteBufferArr) {
byteBuffer2.order(ByteOrder.LITTLE_ENDIAN);
}
this.this$0.updateSemantics(byteBuffer, strArr, byteBufferArr);
}
};
AccessibilityManager.AccessibilityStateChangeListener accessibilityStateChangeListener = new AccessibilityManager.AccessibilityStateChangeListener(this) { // from class: io.flutter.view.AccessibilityBridge.2
final AccessibilityBridge this$0;
{
this.this$0 = this;
}
@Override // android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener
public void onAccessibilityStateChanged(boolean z) {
if (this.this$0.isReleased) {
return;
}
if (z) {
this.this$0.accessibilityChannel.setAccessibilityMessageHandler(this.this$0.accessibilityMessageHandler);
this.this$0.accessibilityChannel.onAndroidAccessibilityEnabled();
} else {
this.this$0.setAccessibleNavigation(false);
this.this$0.accessibilityChannel.setAccessibilityMessageHandler(null);
this.this$0.accessibilityChannel.onAndroidAccessibilityDisabled();
}
if (this.this$0.onAccessibilityChangeListener != null) {
this.this$0.onAccessibilityChangeListener.onAccessibilityChanged(z, this.this$0.accessibilityManager.isTouchExplorationEnabled());
}
}
};
this.accessibilityStateChangeListener = accessibilityStateChangeListener;
ContentObserver contentObserver = new ContentObserver(this, new Handler()) { // from class: io.flutter.view.AccessibilityBridge.3
final AccessibilityBridge this$0;
{
this.this$0 = this;
}
@Override // android.database.ContentObserver
public void onChange(boolean z) {
onChange(z, null);
}
@Override // android.database.ContentObserver
public void onChange(boolean z, Uri uri) {
if (this.this$0.isReleased) {
return;
}
String string = Settings.Global.getString(this.this$0.contentResolver, "transition_animation_scale");
if (string != null && string.equals("0")) {
AccessibilityBridge.access$1276(this.this$0, AccessibilityFeature.DISABLE_ANIMATIONS.value);
} else {
AccessibilityBridge.access$1272(this.this$0, ~AccessibilityFeature.DISABLE_ANIMATIONS.value);
}
this.this$0.sendLatestAccessibilityFlagsToFlutter();
}
};
this.animationScaleObserver = contentObserver;
this.rootAccessibilityView = view;
this.accessibilityChannel = accessibilityChannel;
this.accessibilityManager = accessibilityManager;
this.contentResolver = contentResolver;
this.accessibilityViewEmbedder = accessibilityViewEmbedder;
this.platformViewsAccessibilityDelegate = platformViewsAccessibilityDelegate;
accessibilityStateChangeListener.onAccessibilityStateChanged(accessibilityManager.isEnabled());
accessibilityManager.addAccessibilityStateChangeListener(accessibilityStateChangeListener);
AccessibilityManager.TouchExplorationStateChangeListener touchExplorationStateChangeListener = new AccessibilityManager.TouchExplorationStateChangeListener(this, accessibilityManager) { // from class: io.flutter.view.AccessibilityBridge.4
final AccessibilityBridge this$0;
final AccessibilityManager val$accessibilityManager;
{
this.this$0 = this;
this.val$accessibilityManager = accessibilityManager;
}
@Override // android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener
public void onTouchExplorationStateChanged(boolean z) {
if (this.this$0.isReleased) {
return;
}
if (!z) {
this.this$0.setAccessibleNavigation(false);
this.this$0.onTouchExplorationExit();
}
if (this.this$0.onAccessibilityChangeListener != null) {
this.this$0.onAccessibilityChangeListener.onAccessibilityChanged(this.val$accessibilityManager.isEnabled(), z);
}
}
};
this.touchExplorationStateChangeListener = touchExplorationStateChangeListener;
touchExplorationStateChangeListener.onTouchExplorationStateChanged(accessibilityManager.isTouchExplorationEnabled());
accessibilityManager.addTouchExplorationStateChangeListener(touchExplorationStateChangeListener);
contentObserver.onChange(false);
contentResolver.registerContentObserver(Settings.Global.getUriFor("transition_animation_scale"), false, contentObserver);
if (Build.VERSION.SDK_INT >= 31) {
setBoldTextFlag();
}
platformViewsAccessibilityDelegate.attachAccessibilityBridge(this);
}
public void release() {
this.isReleased = true;
this.platformViewsAccessibilityDelegate.detachAccessibilityBridge();
setOnAccessibilityChangeListener(null);
this.accessibilityManager.removeAccessibilityStateChangeListener(this.accessibilityStateChangeListener);
this.accessibilityManager.removeTouchExplorationStateChangeListener(this.touchExplorationStateChangeListener);
this.contentResolver.unregisterContentObserver(this.animationScaleObserver);
this.accessibilityChannel.setAccessibilityMessageHandler(null);
}
public boolean isAccessibilityEnabled() {
return this.accessibilityManager.isEnabled();
}
public boolean isTouchExplorationEnabled() {
return this.accessibilityManager.isTouchExplorationEnabled();
}
/* JADX INFO: Access modifiers changed from: private */
public void sendLatestAccessibilityFlagsToFlutter() {
this.accessibilityChannel.setAccessibilityFeatures(this.accessibilityFeatureFlags);
}
private boolean shouldSetCollectionInfo(final SemanticsNode semanticsNode) {
return semanticsNode.scrollChildren > 0 && (SemanticsNode.nullableHasAncestor(this.accessibilityFocusedSemanticsNode, new Predicate(semanticsNode) { // from class: io.flutter.view.AccessibilityBridge$$ExternalSyntheticLambda0
public final AccessibilityBridge.SemanticsNode f$0;
{
this.f$0 = semanticsNode;
}
@Override // io.flutter.util.Predicate
public final boolean test(Object obj) {
return AccessibilityBridge.lambda$shouldSetCollectionInfo$0(this.f$0, (AccessibilityBridge.SemanticsNode) obj);
}
}) || !SemanticsNode.nullableHasAncestor(this.accessibilityFocusedSemanticsNode, new Predicate() { // from class: io.flutter.view.AccessibilityBridge$$ExternalSyntheticLambda1
@Override // io.flutter.util.Predicate
public final boolean test(Object obj) {
boolean hasFlag;
hasFlag = ((AccessibilityBridge.SemanticsNode) obj).hasFlag(AccessibilityBridge.Flag.HAS_IMPLICIT_SCROLLING);
return hasFlag;
}
}));
}
private void setBoldTextFlag() {
View view = this.rootAccessibilityView;
if (view == null || view.getResources() == null) {
return;
}
int i = this.rootAccessibilityView.getResources().getConfiguration().fontWeightAdjustment;
if (i != Integer.MAX_VALUE && i >= BOLD_TEXT_WEIGHT_ADJUSTMENT) {
this.accessibilityFeatureFlags |= AccessibilityFeature.BOLD_TEXT.value;
} else {
this.accessibilityFeatureFlags &= AccessibilityFeature.BOLD_TEXT.value;
}
sendLatestAccessibilityFlagsToFlutter();
}
public AccessibilityNodeInfo obtainAccessibilityNodeInfo(View view, int i) {
return AccessibilityNodeInfo.obtain(view, i);
}
@Override // android.view.accessibility.AccessibilityNodeProvider
public AccessibilityNodeInfo createAccessibilityNodeInfo(int i) {
int i2;
boolean z = true;
setAccessibleNavigation(true);
if (i >= 65536) {
return this.accessibilityViewEmbedder.createAccessibilityNodeInfo(i);
}
if (i == -1) {
AccessibilityNodeInfo obtain = AccessibilityNodeInfo.obtain(this.rootAccessibilityView);
this.rootAccessibilityView.onInitializeAccessibilityNodeInfo(obtain);
if (this.flutterSemanticsTree.containsKey(0)) {
obtain.addChild(this.rootAccessibilityView, 0);
}
return obtain;
}
SemanticsNode semanticsNode = this.flutterSemanticsTree.get(Integer.valueOf(i));
if (semanticsNode == null) {
return null;
}
if (semanticsNode.platformViewId == -1 || !this.platformViewsAccessibilityDelegate.usesVirtualDisplay(semanticsNode.platformViewId)) {
AccessibilityNodeInfo obtainAccessibilityNodeInfo = obtainAccessibilityNodeInfo(this.rootAccessibilityView, i);
obtainAccessibilityNodeInfo.setViewIdResourceName("");
obtainAccessibilityNodeInfo.setPackageName(this.rootAccessibilityView.getContext().getPackageName());
obtainAccessibilityNodeInfo.setClassName("android.view.View");
obtainAccessibilityNodeInfo.setSource(this.rootAccessibilityView, i);
obtainAccessibilityNodeInfo.setFocusable(semanticsNode.isFocusable());
SemanticsNode semanticsNode2 = this.inputFocusedSemanticsNode;
if (semanticsNode2 != null) {
obtainAccessibilityNodeInfo.setFocused(semanticsNode2.id == i);
}
SemanticsNode semanticsNode3 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode3 != null) {
obtainAccessibilityNodeInfo.setAccessibilityFocused(semanticsNode3.id == i);
}
if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
obtainAccessibilityNodeInfo.setPassword(semanticsNode.hasFlag(Flag.IS_OBSCURED));
if (!semanticsNode.hasFlag(Flag.IS_READ_ONLY)) {
obtainAccessibilityNodeInfo.setClassName("android.widget.EditText");
}
obtainAccessibilityNodeInfo.setEditable(!semanticsNode.hasFlag(Flag.IS_READ_ONLY));
if (semanticsNode.textSelectionBase != -1 && semanticsNode.textSelectionExtent != -1) {
obtainAccessibilityNodeInfo.setTextSelection(semanticsNode.textSelectionBase, semanticsNode.textSelectionExtent);
}
SemanticsNode semanticsNode4 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode4 != null && semanticsNode4.id == i) {
obtainAccessibilityNodeInfo.setLiveRegion(1);
}
if (semanticsNode.hasAction(Action.MOVE_CURSOR_FORWARD_BY_CHARACTER)) {
obtainAccessibilityNodeInfo.addAction(256);
i2 = 1;
} else {
i2 = 0;
}
if (semanticsNode.hasAction(Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER)) {
obtainAccessibilityNodeInfo.addAction(512);
i2 = 1;
}
if (semanticsNode.hasAction(Action.MOVE_CURSOR_FORWARD_BY_WORD)) {
obtainAccessibilityNodeInfo.addAction(256);
i2 |= 2;
}
if (semanticsNode.hasAction(Action.MOVE_CURSOR_BACKWARD_BY_WORD)) {
obtainAccessibilityNodeInfo.addAction(512);
i2 |= 2;
}
obtainAccessibilityNodeInfo.setMovementGranularities(i2);
if (semanticsNode.maxValueLength >= 0) {
int length = semanticsNode.value == null ? 0 : semanticsNode.value.length();
int unused = semanticsNode.currentValueLength;
int unused2 = semanticsNode.maxValueLength;
obtainAccessibilityNodeInfo.setMaxTextLength((length - semanticsNode.currentValueLength) + semanticsNode.maxValueLength);
}
}
if (semanticsNode.hasAction(Action.SET_SELECTION)) {
obtainAccessibilityNodeInfo.addAction(131072);
}
if (semanticsNode.hasAction(Action.COPY)) {
obtainAccessibilityNodeInfo.addAction(16384);
}
if (semanticsNode.hasAction(Action.CUT)) {
obtainAccessibilityNodeInfo.addAction(65536);
}
if (semanticsNode.hasAction(Action.PASTE)) {
obtainAccessibilityNodeInfo.addAction(32768);
}
if (semanticsNode.hasAction(Action.SET_TEXT)) {
obtainAccessibilityNodeInfo.addAction(PKIFailureInfo.badSenderNonce);
}
if (semanticsNode.hasFlag(Flag.IS_BUTTON) || semanticsNode.hasFlag(Flag.IS_LINK)) {
obtainAccessibilityNodeInfo.setClassName("android.widget.Button");
}
if (semanticsNode.hasFlag(Flag.IS_IMAGE)) {
obtainAccessibilityNodeInfo.setClassName("android.widget.ImageView");
}
if (semanticsNode.hasAction(Action.DISMISS)) {
obtainAccessibilityNodeInfo.setDismissable(true);
obtainAccessibilityNodeInfo.addAction(PKIFailureInfo.badCertTemplate);
}
if (semanticsNode.parent == null) {
obtainAccessibilityNodeInfo.setParent(this.rootAccessibilityView);
} else {
obtainAccessibilityNodeInfo.setParent(this.rootAccessibilityView, semanticsNode.parent.id);
}
if (semanticsNode.previousNodeId != -1) {
obtainAccessibilityNodeInfo.setTraversalAfter(this.rootAccessibilityView, semanticsNode.previousNodeId);
}
Rect globalRect = semanticsNode.getGlobalRect();
if (semanticsNode.parent == null) {
obtainAccessibilityNodeInfo.setBoundsInParent(globalRect);
} else {
Rect globalRect2 = semanticsNode.parent.getGlobalRect();
Rect rect = new Rect(globalRect);
rect.offset(-globalRect2.left, -globalRect2.top);
obtainAccessibilityNodeInfo.setBoundsInParent(rect);
}
obtainAccessibilityNodeInfo.setBoundsInScreen(getBoundsInScreen(globalRect));
obtainAccessibilityNodeInfo.setVisibleToUser(true);
obtainAccessibilityNodeInfo.setEnabled(!semanticsNode.hasFlag(Flag.HAS_ENABLED_STATE) || semanticsNode.hasFlag(Flag.IS_ENABLED));
if (semanticsNode.hasAction(Action.TAP)) {
if (semanticsNode.onTapOverride != null) {
obtainAccessibilityNodeInfo.addAction(new AccessibilityNodeInfo.AccessibilityAction(16, semanticsNode.onTapOverride.hint));
obtainAccessibilityNodeInfo.setClickable(true);
} else {
obtainAccessibilityNodeInfo.addAction(16);
obtainAccessibilityNodeInfo.setClickable(true);
}
}
if (semanticsNode.hasAction(Action.LONG_PRESS)) {
if (semanticsNode.onLongPressOverride != null) {
obtainAccessibilityNodeInfo.addAction(new AccessibilityNodeInfo.AccessibilityAction(32, semanticsNode.onLongPressOverride.hint));
obtainAccessibilityNodeInfo.setLongClickable(true);
} else {
obtainAccessibilityNodeInfo.addAction(32);
obtainAccessibilityNodeInfo.setLongClickable(true);
}
}
if (semanticsNode.hasAction(Action.SCROLL_LEFT) || semanticsNode.hasAction(Action.SCROLL_UP) || semanticsNode.hasAction(Action.SCROLL_RIGHT) || semanticsNode.hasAction(Action.SCROLL_DOWN)) {
obtainAccessibilityNodeInfo.setScrollable(true);
if (semanticsNode.hasFlag(Flag.HAS_IMPLICIT_SCROLLING)) {
if (semanticsNode.hasAction(Action.SCROLL_LEFT) || semanticsNode.hasAction(Action.SCROLL_RIGHT)) {
if (shouldSetCollectionInfo(semanticsNode)) {
obtainAccessibilityNodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(0, semanticsNode.scrollChildren, false));
} else {
obtainAccessibilityNodeInfo.setClassName("android.widget.HorizontalScrollView");
}
} else if (shouldSetCollectionInfo(semanticsNode)) {
obtainAccessibilityNodeInfo.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(semanticsNode.scrollChildren, 0, false));
} else {
obtainAccessibilityNodeInfo.setClassName("android.widget.ScrollView");
}
}
if (semanticsNode.hasAction(Action.SCROLL_LEFT) || semanticsNode.hasAction(Action.SCROLL_UP)) {
obtainAccessibilityNodeInfo.addAction(4096);
}
if (semanticsNode.hasAction(Action.SCROLL_RIGHT) || semanticsNode.hasAction(Action.SCROLL_DOWN)) {
obtainAccessibilityNodeInfo.addAction(8192);
}
}
if (semanticsNode.hasAction(Action.INCREASE) || semanticsNode.hasAction(Action.DECREASE)) {
obtainAccessibilityNodeInfo.setClassName("android.widget.SeekBar");
if (semanticsNode.hasAction(Action.INCREASE)) {
obtainAccessibilityNodeInfo.addAction(4096);
}
if (semanticsNode.hasAction(Action.DECREASE)) {
obtainAccessibilityNodeInfo.addAction(8192);
}
}
if (semanticsNode.hasFlag(Flag.IS_LIVE_REGION)) {
obtainAccessibilityNodeInfo.setLiveRegion(1);
}
if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
obtainAccessibilityNodeInfo.setText(semanticsNode.getValue());
if (Build.VERSION.SDK_INT >= 28) {
obtainAccessibilityNodeInfo.setHintText(semanticsNode.getTextFieldHint());
}
} else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) {
CharSequence valueLabelHint = semanticsNode.getValueLabelHint();
if (Build.VERSION.SDK_INT < 28 && semanticsNode.tooltip != null) {
valueLabelHint = ((Object) (valueLabelHint != null ? valueLabelHint : "")) + "\n" + semanticsNode.tooltip;
}
if (valueLabelHint != null) {
obtainAccessibilityNodeInfo.setContentDescription(valueLabelHint);
}
}
if (Build.VERSION.SDK_INT >= 28 && semanticsNode.tooltip != null) {
obtainAccessibilityNodeInfo.setTooltipText(semanticsNode.tooltip);
}
boolean hasFlag = semanticsNode.hasFlag(Flag.HAS_CHECKED_STATE);
boolean hasFlag2 = semanticsNode.hasFlag(Flag.HAS_TOGGLED_STATE);
if (!hasFlag && !hasFlag2) {
z = false;
}
obtainAccessibilityNodeInfo.setCheckable(z);
if (hasFlag) {
obtainAccessibilityNodeInfo.setChecked(semanticsNode.hasFlag(Flag.IS_CHECKED));
if (semanticsNode.hasFlag(Flag.IS_IN_MUTUALLY_EXCLUSIVE_GROUP)) {
obtainAccessibilityNodeInfo.setClassName("android.widget.RadioButton");
} else {
obtainAccessibilityNodeInfo.setClassName("android.widget.CheckBox");
}
} else if (hasFlag2) {
obtainAccessibilityNodeInfo.setChecked(semanticsNode.hasFlag(Flag.IS_TOGGLED));
obtainAccessibilityNodeInfo.setClassName("android.widget.Switch");
}
obtainAccessibilityNodeInfo.setSelected(semanticsNode.hasFlag(Flag.IS_SELECTED));
if (Build.VERSION.SDK_INT >= 28) {
obtainAccessibilityNodeInfo.setHeading(semanticsNode.hasFlag(Flag.IS_HEADER));
}
SemanticsNode semanticsNode5 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode5 != null && semanticsNode5.id == i) {
obtainAccessibilityNodeInfo.addAction(128);
} else {
obtainAccessibilityNodeInfo.addAction(64);
}
if (semanticsNode.customAccessibilityActions != null) {
for (CustomAccessibilityAction customAccessibilityAction : semanticsNode.customAccessibilityActions) {
obtainAccessibilityNodeInfo.addAction(new AccessibilityNodeInfo.AccessibilityAction(customAccessibilityAction.resourceId, customAccessibilityAction.label));
}
}
for (SemanticsNode semanticsNode6 : semanticsNode.childrenInTraversalOrder) {
if (!semanticsNode6.hasFlag(Flag.IS_HIDDEN)) {
if (semanticsNode6.platformViewId != -1) {
View platformViewById = this.platformViewsAccessibilityDelegate.getPlatformViewById(semanticsNode6.platformViewId);
if (!this.platformViewsAccessibilityDelegate.usesVirtualDisplay(semanticsNode6.platformViewId)) {
obtainAccessibilityNodeInfo.addChild(platformViewById);
}
}
obtainAccessibilityNodeInfo.addChild(this.rootAccessibilityView, semanticsNode6.id);
}
}
return obtainAccessibilityNodeInfo;
}
View platformViewById2 = this.platformViewsAccessibilityDelegate.getPlatformViewById(semanticsNode.platformViewId);
if (platformViewById2 == null) {
return null;
}
return this.accessibilityViewEmbedder.getRootNode(platformViewById2, semanticsNode.id, semanticsNode.getGlobalRect());
}
private Rect getBoundsInScreen(Rect rect) {
Rect rect2 = new Rect(rect);
int[] iArr = new int[2];
this.rootAccessibilityView.getLocationOnScreen(iArr);
rect2.offset(iArr[0], iArr[1]);
return rect2;
}
@Override // android.view.accessibility.AccessibilityNodeProvider
public boolean performAction(int i, int i2, Bundle bundle) {
if (i >= 65536) {
boolean performAction = this.accessibilityViewEmbedder.performAction(i, i2, bundle);
if (performAction && i2 == 128) {
this.embeddedAccessibilityFocusedNodeId = null;
}
return performAction;
}
SemanticsNode semanticsNode = this.flutterSemanticsTree.get(Integer.valueOf(i));
if (semanticsNode == null) {
return false;
}
switch (i2) {
case 16:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.TAP);
return true;
case 32:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.LONG_PRESS);
return true;
case 64:
if (this.accessibilityFocusedSemanticsNode == null) {
this.rootAccessibilityView.invalidate();
}
this.accessibilityFocusedSemanticsNode = semanticsNode;
this.accessibilityChannel.dispatchSemanticsAction(i, Action.DID_GAIN_ACCESSIBILITY_FOCUS);
sendAccessibilityEvent(i, 32768);
if (semanticsNode.hasAction(Action.INCREASE) || semanticsNode.hasAction(Action.DECREASE)) {
sendAccessibilityEvent(i, 4);
}
return true;
case 128:
SemanticsNode semanticsNode2 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode2 != null && semanticsNode2.id == i) {
this.accessibilityFocusedSemanticsNode = null;
}
Integer num = this.embeddedAccessibilityFocusedNodeId;
if (num != null && num.intValue() == i) {
this.embeddedAccessibilityFocusedNodeId = null;
}
this.accessibilityChannel.dispatchSemanticsAction(i, Action.DID_LOSE_ACCESSIBILITY_FOCUS);
sendAccessibilityEvent(i, 65536);
return true;
case 256:
return performCursorMoveAction(semanticsNode, i, bundle, true);
case 512:
return performCursorMoveAction(semanticsNode, i, bundle, false);
case 4096:
if (semanticsNode.hasAction(Action.SCROLL_UP)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SCROLL_UP);
} else if (semanticsNode.hasAction(Action.SCROLL_LEFT)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SCROLL_LEFT);
} else {
if (!semanticsNode.hasAction(Action.INCREASE)) {
return false;
}
semanticsNode.value = semanticsNode.increasedValue;
semanticsNode.valueAttributes = semanticsNode.increasedValueAttributes;
sendAccessibilityEvent(i, 4);
this.accessibilityChannel.dispatchSemanticsAction(i, Action.INCREASE);
}
return true;
case 8192:
if (semanticsNode.hasAction(Action.SCROLL_DOWN)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SCROLL_DOWN);
} else if (semanticsNode.hasAction(Action.SCROLL_RIGHT)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SCROLL_RIGHT);
} else {
if (!semanticsNode.hasAction(Action.DECREASE)) {
return false;
}
semanticsNode.value = semanticsNode.decreasedValue;
semanticsNode.valueAttributes = semanticsNode.decreasedValueAttributes;
sendAccessibilityEvent(i, 4);
this.accessibilityChannel.dispatchSemanticsAction(i, Action.DECREASE);
}
return true;
case 16384:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.COPY);
return true;
case 32768:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.PASTE);
return true;
case 65536:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.CUT);
return true;
case 131072:
HashMap hashMap = new HashMap();
if (bundle != null && bundle.containsKey("ACTION_ARGUMENT_SELECTION_START_INT") && bundle.containsKey("ACTION_ARGUMENT_SELECTION_END_INT")) {
hashMap.put("base", Integer.valueOf(bundle.getInt("ACTION_ARGUMENT_SELECTION_START_INT")));
hashMap.put("extent", Integer.valueOf(bundle.getInt("ACTION_ARGUMENT_SELECTION_END_INT")));
} else {
hashMap.put("base", Integer.valueOf(semanticsNode.textSelectionExtent));
hashMap.put("extent", Integer.valueOf(semanticsNode.textSelectionExtent));
}
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SET_SELECTION, hashMap);
SemanticsNode semanticsNode3 = this.flutterSemanticsTree.get(Integer.valueOf(i));
semanticsNode3.textSelectionBase = ((Integer) hashMap.get("base")).intValue();
semanticsNode3.textSelectionExtent = ((Integer) hashMap.get("extent")).intValue();
return true;
case PKIFailureInfo.badCertTemplate /* 1048576 */:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.DISMISS);
return true;
case PKIFailureInfo.badSenderNonce /* 2097152 */:
return performSetText(semanticsNode, i, bundle);
case 16908342:
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SHOW_ON_SCREEN);
return true;
default:
CustomAccessibilityAction customAccessibilityAction = this.customAccessibilityActions.get(Integer.valueOf(i2 - FIRST_RESOURCE_ID));
if (customAccessibilityAction == null) {
return false;
}
this.accessibilityChannel.dispatchSemanticsAction(i, Action.CUSTOM_ACTION, Integer.valueOf(customAccessibilityAction.id));
return true;
}
}
private boolean performCursorMoveAction(SemanticsNode semanticsNode, int i, Bundle bundle, boolean z) {
int i2 = bundle.getInt("ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT");
boolean z2 = bundle.getBoolean("ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN");
int i3 = semanticsNode.textSelectionBase;
int i4 = semanticsNode.textSelectionExtent;
predictCursorMovement(semanticsNode, i2, z, z2);
if (i3 != semanticsNode.textSelectionBase || i4 != semanticsNode.textSelectionExtent) {
String str = semanticsNode.value != null ? semanticsNode.value : "";
AccessibilityEvent obtainAccessibilityEvent = obtainAccessibilityEvent(semanticsNode.id, 8192);
obtainAccessibilityEvent.getText().add(str);
obtainAccessibilityEvent.setFromIndex(semanticsNode.textSelectionBase);
obtainAccessibilityEvent.setToIndex(semanticsNode.textSelectionExtent);
obtainAccessibilityEvent.setItemCount(str.length());
sendAccessibilityEvent(obtainAccessibilityEvent);
}
if (i2 == 1) {
if (z && semanticsNode.hasAction(Action.MOVE_CURSOR_FORWARD_BY_CHARACTER)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.MOVE_CURSOR_FORWARD_BY_CHARACTER, Boolean.valueOf(z2));
return true;
}
if (z || !semanticsNode.hasAction(Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER)) {
return false;
}
this.accessibilityChannel.dispatchSemanticsAction(i, Action.MOVE_CURSOR_BACKWARD_BY_CHARACTER, Boolean.valueOf(z2));
return true;
}
if (i2 != 2) {
return i2 == 4 || i2 == 8 || i2 == 16;
}
if (z && semanticsNode.hasAction(Action.MOVE_CURSOR_FORWARD_BY_WORD)) {
this.accessibilityChannel.dispatchSemanticsAction(i, Action.MOVE_CURSOR_FORWARD_BY_WORD, Boolean.valueOf(z2));
return true;
}
if (z || !semanticsNode.hasAction(Action.MOVE_CURSOR_BACKWARD_BY_WORD)) {
return false;
}
this.accessibilityChannel.dispatchSemanticsAction(i, Action.MOVE_CURSOR_BACKWARD_BY_WORD, Boolean.valueOf(z2));
return true;
}
private void predictCursorMovement(SemanticsNode semanticsNode, int i, boolean z, boolean z2) {
if (semanticsNode.textSelectionExtent < 0 || semanticsNode.textSelectionBase < 0) {
return;
}
if (i != 1) {
if (i != 2) {
if (i != 4) {
if (i == 8 || i == 16) {
if (z) {
semanticsNode.textSelectionExtent = semanticsNode.value.length();
} else {
semanticsNode.textSelectionExtent = 0;
}
}
} else if (!z || semanticsNode.textSelectionExtent >= semanticsNode.value.length()) {
if (!z && semanticsNode.textSelectionExtent > 0) {
Matcher matcher = Pattern.compile("(?s:.*)(\\n)").matcher(semanticsNode.value.substring(0, semanticsNode.textSelectionExtent));
if (matcher.find()) {
semanticsNode.textSelectionExtent = matcher.start(1);
} else {
semanticsNode.textSelectionExtent = 0;
}
}
} else {
Matcher matcher2 = Pattern.compile("(?!^)(\\n)").matcher(semanticsNode.value.substring(semanticsNode.textSelectionExtent));
if (matcher2.find()) {
SemanticsNode.access$2212(semanticsNode, matcher2.start(1));
} else {
semanticsNode.textSelectionExtent = semanticsNode.value.length();
}
}
} else if (!z || semanticsNode.textSelectionExtent >= semanticsNode.value.length()) {
if (!z && semanticsNode.textSelectionExtent > 0) {
Matcher matcher3 = Pattern.compile("(?s:.*)(\\b)\\p{L}").matcher(semanticsNode.value.substring(0, semanticsNode.textSelectionExtent));
if (matcher3.find()) {
semanticsNode.textSelectionExtent = matcher3.start(1);
}
}
} else {
Matcher matcher4 = Pattern.compile("\\p{L}(\\b)").matcher(semanticsNode.value.substring(semanticsNode.textSelectionExtent));
matcher4.find();
if (matcher4.find()) {
SemanticsNode.access$2212(semanticsNode, matcher4.start(1));
} else {
semanticsNode.textSelectionExtent = semanticsNode.value.length();
}
}
} else if (z && semanticsNode.textSelectionExtent < semanticsNode.value.length()) {
SemanticsNode.access$2212(semanticsNode, 1);
} else if (!z && semanticsNode.textSelectionExtent > 0) {
SemanticsNode.access$2220(semanticsNode, 1);
}
if (z2) {
return;
}
semanticsNode.textSelectionBase = semanticsNode.textSelectionExtent;
}
private boolean performSetText(SemanticsNode semanticsNode, int i, Bundle bundle) {
String string = (bundle == null || !bundle.containsKey("ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE")) ? "" : bundle.getString("ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE");
this.accessibilityChannel.dispatchSemanticsAction(i, Action.SET_TEXT, string);
semanticsNode.value = string;
semanticsNode.valueAttributes = null;
return true;
}
@Override // android.view.accessibility.AccessibilityNodeProvider
public AccessibilityNodeInfo findFocus(int i) {
if (i == 1) {
SemanticsNode semanticsNode = this.inputFocusedSemanticsNode;
if (semanticsNode != null) {
return createAccessibilityNodeInfo(semanticsNode.id);
}
Integer num = this.embeddedInputFocusedNodeId;
if (num != null) {
return createAccessibilityNodeInfo(num.intValue());
}
} else if (i != 2) {
return null;
}
SemanticsNode semanticsNode2 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode2 != null) {
return createAccessibilityNodeInfo(semanticsNode2.id);
}
Integer num2 = this.embeddedAccessibilityFocusedNodeId;
if (num2 != null) {
return createAccessibilityNodeInfo(num2.intValue());
}
return null;
}
private SemanticsNode getRootSemanticsNode() {
return this.flutterSemanticsTree.get(0);
}
/* JADX INFO: Access modifiers changed from: private */
public SemanticsNode getOrCreateSemanticsNode(int i) {
SemanticsNode semanticsNode = this.flutterSemanticsTree.get(Integer.valueOf(i));
if (semanticsNode != null) {
return semanticsNode;
}
SemanticsNode semanticsNode2 = new SemanticsNode(this);
semanticsNode2.id = i;
this.flutterSemanticsTree.put(Integer.valueOf(i), semanticsNode2);
return semanticsNode2;
}
/* JADX INFO: Access modifiers changed from: private */
public CustomAccessibilityAction getOrCreateAccessibilityAction(int i) {
CustomAccessibilityAction customAccessibilityAction = this.customAccessibilityActions.get(Integer.valueOf(i));
if (customAccessibilityAction != null) {
return customAccessibilityAction;
}
CustomAccessibilityAction customAccessibilityAction2 = new CustomAccessibilityAction();
customAccessibilityAction2.id = i;
customAccessibilityAction2.resourceId = FIRST_RESOURCE_ID + i;
this.customAccessibilityActions.put(Integer.valueOf(i), customAccessibilityAction2);
return customAccessibilityAction2;
}
public boolean onAccessibilityHoverEvent(MotionEvent motionEvent) {
return onAccessibilityHoverEvent(motionEvent, false);
}
public boolean onAccessibilityHoverEvent(MotionEvent motionEvent, boolean z) {
if (!this.accessibilityManager.isTouchExplorationEnabled() || this.flutterSemanticsTree.isEmpty()) {
return false;
}
SemanticsNode hitTest = getRootSemanticsNode().hitTest(new float[]{motionEvent.getX(), motionEvent.getY(), BitmapDescriptorFactory.HUE_RED, 1.0f}, z);
if (hitTest != null && hitTest.platformViewId != -1) {
if (z) {
return false;
}
return this.accessibilityViewEmbedder.onAccessibilityHoverEvent(hitTest.id, motionEvent);
}
if (motionEvent.getAction() == 9 || motionEvent.getAction() == 7) {
handleTouchExploration(motionEvent.getX(), motionEvent.getY(), z);
} else if (motionEvent.getAction() == 10) {
onTouchExplorationExit();
} else {
Log.d("flutter", "unexpected accessibility hover event: " + motionEvent);
return false;
}
return true;
}
/* JADX INFO: Access modifiers changed from: private */
public void onTouchExplorationExit() {
SemanticsNode semanticsNode = this.hoveredObject;
if (semanticsNode != null) {
sendAccessibilityEvent(semanticsNode.id, 256);
this.hoveredObject = null;
}
}
private void handleTouchExploration(float f, float f2, boolean z) {
SemanticsNode hitTest;
if (this.flutterSemanticsTree.isEmpty() || (hitTest = getRootSemanticsNode().hitTest(new float[]{f, f2, BitmapDescriptorFactory.HUE_RED, 1.0f}, z)) == this.hoveredObject) {
return;
}
if (hitTest != null) {
sendAccessibilityEvent(hitTest.id, 128);
}
SemanticsNode semanticsNode = this.hoveredObject;
if (semanticsNode != null) {
sendAccessibilityEvent(semanticsNode.id, 256);
}
this.hoveredObject = hitTest;
}
void updateCustomAccessibilityActions(ByteBuffer byteBuffer, String[] strArr) {
while (byteBuffer.hasRemaining()) {
CustomAccessibilityAction orCreateAccessibilityAction = getOrCreateAccessibilityAction(byteBuffer.getInt());
orCreateAccessibilityAction.overrideId = byteBuffer.getInt();
int i = byteBuffer.getInt();
String str = null;
orCreateAccessibilityAction.label = i == -1 ? null : strArr[i];
int i2 = byteBuffer.getInt();
if (i2 != -1) {
str = strArr[i2];
}
orCreateAccessibilityAction.hint = str;
}
}
void updateSemantics(ByteBuffer byteBuffer, String[] strArr, ByteBuffer[] byteBufferArr) {
SemanticsNode semanticsNode;
SemanticsNode semanticsNode2;
float f;
float f2;
WindowInsets rootWindowInsets;
View platformViewById;
ArrayList arrayList = new ArrayList();
while (byteBuffer.hasRemaining()) {
SemanticsNode orCreateSemanticsNode = getOrCreateSemanticsNode(byteBuffer.getInt());
orCreateSemanticsNode.updateWith(byteBuffer, strArr, byteBufferArr);
if (!orCreateSemanticsNode.hasFlag(Flag.IS_HIDDEN)) {
if (orCreateSemanticsNode.hasFlag(Flag.IS_FOCUSED)) {
this.inputFocusedSemanticsNode = orCreateSemanticsNode;
}
if (orCreateSemanticsNode.hadPreviousConfig) {
arrayList.add(orCreateSemanticsNode);
}
if (orCreateSemanticsNode.platformViewId != -1 && !this.platformViewsAccessibilityDelegate.usesVirtualDisplay(orCreateSemanticsNode.platformViewId) && (platformViewById = this.platformViewsAccessibilityDelegate.getPlatformViewById(orCreateSemanticsNode.platformViewId)) != null) {
platformViewById.setImportantForAccessibility(0);
}
}
}
HashSet hashSet = new HashSet();
SemanticsNode rootSemanticsNode = getRootSemanticsNode();
ArrayList<SemanticsNode> arrayList2 = new ArrayList();
if (rootSemanticsNode != null) {
float[] fArr = new float[16];
Matrix.setIdentityM(fArr, 0);
if ((Build.VERSION.SDK_INT < 28 || doesLayoutInDisplayCutoutModeRequireLeftInset()) && (rootWindowInsets = this.rootAccessibilityView.getRootWindowInsets()) != null) {
if (!this.lastLeftFrameInset.equals(Integer.valueOf(rootWindowInsets.getSystemWindowInsetLeft()))) {
rootSemanticsNode.globalGeometryDirty = true;
rootSemanticsNode.inverseTransformDirty = true;
}
this.lastLeftFrameInset = Integer.valueOf(rootWindowInsets.getSystemWindowInsetLeft());
Matrix.translateM(fArr, 0, r4.intValue(), BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED);
}
rootSemanticsNode.updateRecursively(fArr, hashSet, false);
rootSemanticsNode.collectRoutes(arrayList2);
}
SemanticsNode semanticsNode3 = null;
for (SemanticsNode semanticsNode4 : arrayList2) {
if (!this.flutterNavigationStack.contains(Integer.valueOf(semanticsNode4.id))) {
semanticsNode3 = semanticsNode4;
}
}
if (semanticsNode3 == null && arrayList2.size() > 0) {
semanticsNode3 = (SemanticsNode) arrayList2.get(arrayList2.size() - 1);
}
if (semanticsNode3 != null && (semanticsNode3.id != this.previousRouteId || arrayList2.size() != this.flutterNavigationStack.size())) {
this.previousRouteId = semanticsNode3.id;
onWindowNameChange(semanticsNode3);
}
this.flutterNavigationStack.clear();
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
this.flutterNavigationStack.add(Integer.valueOf(((SemanticsNode) it.next()).id));
}
Iterator<Map.Entry<Integer, SemanticsNode>> it2 = this.flutterSemanticsTree.entrySet().iterator();
while (it2.hasNext()) {
SemanticsNode value = it2.next().getValue();
if (!hashSet.contains(value)) {
willRemoveSemanticsNode(value);
it2.remove();
}
}
sendWindowContentChangeEvent(0);
Iterator it3 = arrayList.iterator();
while (it3.hasNext()) {
SemanticsNode semanticsNode5 = (SemanticsNode) it3.next();
if (semanticsNode5.didScroll()) {
AccessibilityEvent obtainAccessibilityEvent = obtainAccessibilityEvent(semanticsNode5.id, 4096);
float f3 = semanticsNode5.scrollPosition;
float f4 = semanticsNode5.scrollExtentMax;
if (Float.isInfinite(semanticsNode5.scrollExtentMax)) {
if (f3 > SCROLL_POSITION_CAP_FOR_INFINITY) {
f3 = 70000.0f;
}
f4 = 100000.0f;
}
if (Float.isInfinite(semanticsNode5.scrollExtentMin)) {
f = f4 + SCROLL_EXTENT_FOR_INFINITY;
if (f3 < -70000.0f) {
f3 = -70000.0f;
}
f2 = f3 + SCROLL_EXTENT_FOR_INFINITY;
} else {
f = f4 - semanticsNode5.scrollExtentMin;
f2 = f3 - semanticsNode5.scrollExtentMin;
}
if (semanticsNode5.hadAction(Action.SCROLL_UP) || semanticsNode5.hadAction(Action.SCROLL_DOWN)) {
obtainAccessibilityEvent.setScrollY((int) f2);
obtainAccessibilityEvent.setMaxScrollY((int) f);
} else if (semanticsNode5.hadAction(Action.SCROLL_LEFT) || semanticsNode5.hadAction(Action.SCROLL_RIGHT)) {
obtainAccessibilityEvent.setScrollX((int) f2);
obtainAccessibilityEvent.setMaxScrollX((int) f);
}
if (semanticsNode5.scrollChildren > 0) {
obtainAccessibilityEvent.setItemCount(semanticsNode5.scrollChildren);
obtainAccessibilityEvent.setFromIndex(semanticsNode5.scrollIndex);
Iterator it4 = semanticsNode5.childrenInHitTestOrder.iterator();
int i = 0;
while (it4.hasNext()) {
if (!((SemanticsNode) it4.next()).hasFlag(Flag.IS_HIDDEN)) {
i++;
}
}
obtainAccessibilityEvent.setToIndex((semanticsNode5.scrollIndex + i) - 1);
}
sendAccessibilityEvent(obtainAccessibilityEvent);
}
if (semanticsNode5.hasFlag(Flag.IS_LIVE_REGION) && semanticsNode5.didChangeLabel()) {
sendWindowContentChangeEvent(semanticsNode5.id);
}
SemanticsNode semanticsNode6 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode6 != null && semanticsNode6.id == semanticsNode5.id && !semanticsNode5.hadFlag(Flag.IS_SELECTED) && semanticsNode5.hasFlag(Flag.IS_SELECTED)) {
AccessibilityEvent obtainAccessibilityEvent2 = obtainAccessibilityEvent(semanticsNode5.id, 4);
obtainAccessibilityEvent2.getText().add(semanticsNode5.label);
sendAccessibilityEvent(obtainAccessibilityEvent2);
}
SemanticsNode semanticsNode7 = this.inputFocusedSemanticsNode;
if (semanticsNode7 != null && semanticsNode7.id == semanticsNode5.id && ((semanticsNode2 = this.lastInputFocusedSemanticsNode) == null || semanticsNode2.id != this.inputFocusedSemanticsNode.id)) {
this.lastInputFocusedSemanticsNode = this.inputFocusedSemanticsNode;
sendAccessibilityEvent(obtainAccessibilityEvent(semanticsNode5.id, 8));
} else if (this.inputFocusedSemanticsNode == null) {
this.lastInputFocusedSemanticsNode = null;
}
SemanticsNode semanticsNode8 = this.inputFocusedSemanticsNode;
if (semanticsNode8 != null && semanticsNode8.id == semanticsNode5.id && semanticsNode5.hadFlag(Flag.IS_TEXT_FIELD) && semanticsNode5.hasFlag(Flag.IS_TEXT_FIELD) && ((semanticsNode = this.accessibilityFocusedSemanticsNode) == null || semanticsNode.id == this.inputFocusedSemanticsNode.id)) {
String str = semanticsNode5.previousValue != null ? semanticsNode5.previousValue : "";
String str2 = semanticsNode5.value != null ? semanticsNode5.value : "";
AccessibilityEvent createTextChangedEvent = createTextChangedEvent(semanticsNode5.id, str, str2);
if (createTextChangedEvent != null) {
sendAccessibilityEvent(createTextChangedEvent);
}
if (semanticsNode5.previousTextSelectionBase != semanticsNode5.textSelectionBase || semanticsNode5.previousTextSelectionExtent != semanticsNode5.textSelectionExtent) {
AccessibilityEvent obtainAccessibilityEvent3 = obtainAccessibilityEvent(semanticsNode5.id, 8192);
obtainAccessibilityEvent3.getText().add(str2);
obtainAccessibilityEvent3.setFromIndex(semanticsNode5.textSelectionBase);
obtainAccessibilityEvent3.setToIndex(semanticsNode5.textSelectionExtent);
obtainAccessibilityEvent3.setItemCount(str2.length());
sendAccessibilityEvent(obtainAccessibilityEvent3);
}
}
}
}
private AccessibilityEvent createTextChangedEvent(int i, String str, String str2) {
AccessibilityEvent obtainAccessibilityEvent = obtainAccessibilityEvent(i, 16);
obtainAccessibilityEvent.setBeforeText(str);
obtainAccessibilityEvent.getText().add(str2);
int i2 = 0;
while (i2 < str.length() && i2 < str2.length() && str.charAt(i2) == str2.charAt(i2)) {
i2++;
}
if (i2 >= str.length() && i2 >= str2.length()) {
return null;
}
obtainAccessibilityEvent.setFromIndex(i2);
int length = str.length() - 1;
int length2 = str2.length() - 1;
while (length >= i2 && length2 >= i2 && str.charAt(length) == str2.charAt(length2)) {
length--;
length2--;
}
obtainAccessibilityEvent.setRemovedCount((length - i2) + 1);
obtainAccessibilityEvent.setAddedCount((length2 - i2) + 1);
return obtainAccessibilityEvent;
}
/* JADX INFO: Access modifiers changed from: private */
public void sendAccessibilityEvent(int i, int i2) {
if (this.accessibilityManager.isEnabled()) {
sendAccessibilityEvent(obtainAccessibilityEvent(i, i2));
}
}
/* JADX INFO: Access modifiers changed from: private */
public void sendAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
if (this.accessibilityManager.isEnabled()) {
this.rootAccessibilityView.getParent().requestSendAccessibilityEvent(this.rootAccessibilityView, accessibilityEvent);
}
}
private void onWindowNameChange(SemanticsNode semanticsNode) {
String routeName = semanticsNode.getRouteName();
if (routeName == null) {
routeName = " ";
}
if (Build.VERSION.SDK_INT >= 28) {
setAccessibilityPaneTitle(routeName);
return;
}
AccessibilityEvent obtainAccessibilityEvent = obtainAccessibilityEvent(semanticsNode.id, 32);
obtainAccessibilityEvent.getText().add(routeName);
sendAccessibilityEvent(obtainAccessibilityEvent);
}
private void setAccessibilityPaneTitle(String str) {
this.rootAccessibilityView.setAccessibilityPaneTitle(str);
}
private void sendWindowContentChangeEvent(int i) {
AccessibilityEvent obtainAccessibilityEvent = obtainAccessibilityEvent(i, 2048);
obtainAccessibilityEvent.setContentChangeTypes(1);
sendAccessibilityEvent(obtainAccessibilityEvent);
}
/* JADX INFO: Access modifiers changed from: private */
public AccessibilityEvent obtainAccessibilityEvent(int i, int i2) {
AccessibilityEvent obtain = AccessibilityEvent.obtain(i2);
obtain.setPackageName(this.rootAccessibilityView.getContext().getPackageName());
obtain.setSource(this.rootAccessibilityView, i);
return obtain;
}
private boolean doesLayoutInDisplayCutoutModeRequireLeftInset() {
int i;
Activity activity = ViewUtils.getActivity(this.rootAccessibilityView.getContext());
return (activity == null || activity.getWindow() == null || ((i = activity.getWindow().getAttributes().layoutInDisplayCutoutMode) != 2 && i != 0)) ? false : true;
}
private void willRemoveSemanticsNode(SemanticsNode semanticsNode) {
View platformViewById;
Integer num;
semanticsNode.parent = null;
if (semanticsNode.platformViewId != -1 && (num = this.embeddedAccessibilityFocusedNodeId) != null && this.accessibilityViewEmbedder.platformViewOfNode(num.intValue()) == this.platformViewsAccessibilityDelegate.getPlatformViewById(semanticsNode.platformViewId)) {
sendAccessibilityEvent(this.embeddedAccessibilityFocusedNodeId.intValue(), 65536);
this.embeddedAccessibilityFocusedNodeId = null;
}
if (semanticsNode.platformViewId != -1 && (platformViewById = this.platformViewsAccessibilityDelegate.getPlatformViewById(semanticsNode.platformViewId)) != null) {
platformViewById.setImportantForAccessibility(4);
}
SemanticsNode semanticsNode2 = this.accessibilityFocusedSemanticsNode;
if (semanticsNode2 == semanticsNode) {
sendAccessibilityEvent(semanticsNode2.id, 65536);
this.accessibilityFocusedSemanticsNode = null;
}
if (this.inputFocusedSemanticsNode == semanticsNode) {
this.inputFocusedSemanticsNode = null;
}
if (this.hoveredObject == semanticsNode) {
this.hoveredObject = null;
}
}
public void reset() {
this.flutterSemanticsTree.clear();
SemanticsNode semanticsNode = this.accessibilityFocusedSemanticsNode;
if (semanticsNode != null) {
sendAccessibilityEvent(semanticsNode.id, 65536);
}
this.accessibilityFocusedSemanticsNode = null;
this.hoveredObject = null;
sendWindowContentChangeEvent(0);
}
/* loaded from: classes6.dex */
public enum Action {
TAP(1),
LONG_PRESS(2),
SCROLL_LEFT(4),
SCROLL_RIGHT(8),
SCROLL_UP(16),
SCROLL_DOWN(32),
INCREASE(64),
DECREASE(128),
SHOW_ON_SCREEN(256),
MOVE_CURSOR_FORWARD_BY_CHARACTER(512),
MOVE_CURSOR_BACKWARD_BY_CHARACTER(1024),
SET_SELECTION(2048),
COPY(4096),
CUT(8192),
PASTE(16384),
DID_GAIN_ACCESSIBILITY_FOCUS(32768),
DID_LOSE_ACCESSIBILITY_FOCUS(65536),
CUSTOM_ACTION(131072),
DISMISS(262144),
MOVE_CURSOR_FORWARD_BY_WORD(524288),
MOVE_CURSOR_BACKWARD_BY_WORD(PKIFailureInfo.badCertTemplate),
SET_TEXT(PKIFailureInfo.badSenderNonce);
public final int value;
Action(int i) {
this.value = i;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public enum Flag {
HAS_CHECKED_STATE(1),
IS_CHECKED(2),
IS_SELECTED(4),
IS_BUTTON(8),
IS_TEXT_FIELD(16),
IS_FOCUSED(32),
HAS_ENABLED_STATE(64),
IS_ENABLED(128),
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(256),
IS_HEADER(512),
IS_OBSCURED(1024),
SCOPES_ROUTE(2048),
NAMES_ROUTE(4096),
IS_HIDDEN(8192),
IS_IMAGE(16384),
IS_LIVE_REGION(32768),
HAS_TOGGLED_STATE(65536),
IS_TOGGLED(131072),
HAS_IMPLICIT_SCROLLING(262144),
IS_MULTILINE(524288),
IS_READ_ONLY(PKIFailureInfo.badCertTemplate),
IS_FOCUSABLE(PKIFailureInfo.badSenderNonce),
IS_LINK(4194304),
IS_SLIDER(8388608),
IS_KEYBOARD_KEY(Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE),
IS_CHECK_STATE_MIXED(33554432);
final int value;
Flag(int i) {
this.value = i;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public enum AccessibilityFeature {
ACCESSIBLE_NAVIGATION(1),
INVERT_COLORS(2),
DISABLE_ANIMATIONS(4),
BOLD_TEXT(8),
REDUCE_MOTION(16),
HIGH_CONTRAST(32),
ON_OFF_SWITCH_LABELS(64);
final int value;
AccessibilityFeature(int i) {
this.value = i;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class CustomAccessibilityAction {
private String hint;
private String label;
private int resourceId = -1;
private int id = -1;
private int overrideId = -1;
CustomAccessibilityAction() {
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class StringAttribute {
int end;
int start;
StringAttributeType type;
private StringAttribute() {
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class SpellOutStringAttribute extends StringAttribute {
private SpellOutStringAttribute() {
super();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class LocaleStringAttribute extends StringAttribute {
String locale;
private LocaleStringAttribute() {
super();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static class SemanticsNode {
final AccessibilityBridge accessibilityBridge;
private int actions;
private float bottom;
private int currentValueLength;
private List<CustomAccessibilityAction> customAccessibilityActions;
private String decreasedValue;
private List<StringAttribute> decreasedValueAttributes;
private int flags;
private Rect globalRect;
private float[] globalTransform;
private String hint;
private List<StringAttribute> hintAttributes;
private String increasedValue;
private List<StringAttribute> increasedValueAttributes;
private float[] inverseTransform;
private String label;
private List<StringAttribute> labelAttributes;
private float left;
private int maxValueLength;
private CustomAccessibilityAction onLongPressOverride;
private CustomAccessibilityAction onTapOverride;
private SemanticsNode parent;
private int platformViewId;
private int previousActions;
private int previousFlags;
private String previousLabel;
private float previousScrollExtentMax;
private float previousScrollExtentMin;
private float previousScrollPosition;
private int previousTextSelectionBase;
private int previousTextSelectionExtent;
private String previousValue;
private float right;
private int scrollChildren;
private float scrollExtentMax;
private float scrollExtentMin;
private int scrollIndex;
private float scrollPosition;
private TextDirection textDirection;
private int textSelectionBase;
private int textSelectionExtent;
private String tooltip;
private float top;
private float[] transform;
private String value;
private List<StringAttribute> valueAttributes;
private int id = -1;
private int previousNodeId = -1;
private boolean hadPreviousConfig = false;
private List<SemanticsNode> childrenInTraversalOrder = new ArrayList();
private List<SemanticsNode> childrenInHitTestOrder = new ArrayList();
private boolean inverseTransformDirty = true;
private boolean globalGeometryDirty = true;
/* JADX INFO: Access modifiers changed from: private */
public Rect getGlobalRect() {
return this.globalRect;
}
private void log(String str, boolean z) {
}
static /* synthetic */ int access$2212(SemanticsNode semanticsNode, int i) {
int i2 = semanticsNode.textSelectionExtent + i;
semanticsNode.textSelectionExtent = i2;
return i2;
}
static /* synthetic */ int access$2220(SemanticsNode semanticsNode, int i) {
int i2 = semanticsNode.textSelectionExtent - i;
semanticsNode.textSelectionExtent = i2;
return i2;
}
/* JADX INFO: Access modifiers changed from: private */
public static boolean nullableHasAncestor(SemanticsNode semanticsNode, Predicate<SemanticsNode> predicate) {
return (semanticsNode == null || semanticsNode.getAncestor(predicate) == null) ? false : true;
}
SemanticsNode(AccessibilityBridge accessibilityBridge) {
this.accessibilityBridge = accessibilityBridge;
}
private SemanticsNode getAncestor(Predicate<SemanticsNode> predicate) {
for (SemanticsNode semanticsNode = this.parent; semanticsNode != null; semanticsNode = semanticsNode.parent) {
if (predicate.test(semanticsNode)) {
return semanticsNode;
}
}
return null;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean hasAction(Action action) {
return (action.value & this.actions) != 0;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean hadAction(Action action) {
return (action.value & this.previousActions) != 0;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean hasFlag(Flag flag) {
return (flag.value & this.flags) != 0;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean hadFlag(Flag flag) {
return (flag.value & this.previousFlags) != 0;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean didScroll() {
return (Float.isNaN(this.scrollPosition) || Float.isNaN(this.previousScrollPosition) || this.previousScrollPosition == this.scrollPosition) ? false : true;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean didChangeLabel() {
String str;
String str2 = this.label;
if (str2 == null && this.previousLabel == null) {
return false;
}
return str2 == null || (str = this.previousLabel) == null || !str2.equals(str);
}
/* JADX INFO: Access modifiers changed from: private */
public void updateWith(ByteBuffer byteBuffer, String[] strArr, ByteBuffer[] byteBufferArr) {
this.hadPreviousConfig = true;
this.previousValue = this.value;
this.previousLabel = this.label;
this.previousFlags = this.flags;
this.previousActions = this.actions;
this.previousTextSelectionBase = this.textSelectionBase;
this.previousTextSelectionExtent = this.textSelectionExtent;
this.previousScrollPosition = this.scrollPosition;
this.previousScrollExtentMax = this.scrollExtentMax;
this.previousScrollExtentMin = this.scrollExtentMin;
this.flags = byteBuffer.getInt();
this.actions = byteBuffer.getInt();
this.maxValueLength = byteBuffer.getInt();
this.currentValueLength = byteBuffer.getInt();
this.textSelectionBase = byteBuffer.getInt();
this.textSelectionExtent = byteBuffer.getInt();
this.platformViewId = byteBuffer.getInt();
this.scrollChildren = byteBuffer.getInt();
this.scrollIndex = byteBuffer.getInt();
this.scrollPosition = byteBuffer.getFloat();
this.scrollExtentMax = byteBuffer.getFloat();
this.scrollExtentMin = byteBuffer.getFloat();
int i = byteBuffer.getInt();
this.label = i == -1 ? null : strArr[i];
this.labelAttributes = getStringAttributesFromBuffer(byteBuffer, byteBufferArr);
int i2 = byteBuffer.getInt();
this.value = i2 == -1 ? null : strArr[i2];
this.valueAttributes = getStringAttributesFromBuffer(byteBuffer, byteBufferArr);
int i3 = byteBuffer.getInt();
this.increasedValue = i3 == -1 ? null : strArr[i3];
this.increasedValueAttributes = getStringAttributesFromBuffer(byteBuffer, byteBufferArr);
int i4 = byteBuffer.getInt();
this.decreasedValue = i4 == -1 ? null : strArr[i4];
this.decreasedValueAttributes = getStringAttributesFromBuffer(byteBuffer, byteBufferArr);
int i5 = byteBuffer.getInt();
this.hint = i5 == -1 ? null : strArr[i5];
this.hintAttributes = getStringAttributesFromBuffer(byteBuffer, byteBufferArr);
int i6 = byteBuffer.getInt();
this.tooltip = i6 == -1 ? null : strArr[i6];
this.textDirection = TextDirection.fromInt(byteBuffer.getInt());
this.left = byteBuffer.getFloat();
this.top = byteBuffer.getFloat();
this.right = byteBuffer.getFloat();
this.bottom = byteBuffer.getFloat();
if (this.transform == null) {
this.transform = new float[16];
}
for (int i7 = 0; i7 < 16; i7++) {
this.transform[i7] = byteBuffer.getFloat();
}
this.inverseTransformDirty = true;
this.globalGeometryDirty = true;
int i8 = byteBuffer.getInt();
this.childrenInTraversalOrder.clear();
this.childrenInHitTestOrder.clear();
for (int i9 = 0; i9 < i8; i9++) {
SemanticsNode orCreateSemanticsNode = this.accessibilityBridge.getOrCreateSemanticsNode(byteBuffer.getInt());
orCreateSemanticsNode.parent = this;
this.childrenInTraversalOrder.add(orCreateSemanticsNode);
}
for (int i10 = 0; i10 < i8; i10++) {
SemanticsNode orCreateSemanticsNode2 = this.accessibilityBridge.getOrCreateSemanticsNode(byteBuffer.getInt());
orCreateSemanticsNode2.parent = this;
this.childrenInHitTestOrder.add(orCreateSemanticsNode2);
}
int i11 = byteBuffer.getInt();
if (i11 == 0) {
this.customAccessibilityActions = null;
return;
}
List<CustomAccessibilityAction> list = this.customAccessibilityActions;
if (list == null) {
this.customAccessibilityActions = new ArrayList(i11);
} else {
list.clear();
}
for (int i12 = 0; i12 < i11; i12++) {
CustomAccessibilityAction orCreateAccessibilityAction = this.accessibilityBridge.getOrCreateAccessibilityAction(byteBuffer.getInt());
if (orCreateAccessibilityAction.overrideId == Action.TAP.value) {
this.onTapOverride = orCreateAccessibilityAction;
} else if (orCreateAccessibilityAction.overrideId == Action.LONG_PRESS.value) {
this.onLongPressOverride = orCreateAccessibilityAction;
} else {
this.customAccessibilityActions.add(orCreateAccessibilityAction);
}
this.customAccessibilityActions.add(orCreateAccessibilityAction);
}
}
private List<StringAttribute> getStringAttributesFromBuffer(ByteBuffer byteBuffer, ByteBuffer[] byteBufferArr) {
int i = byteBuffer.getInt();
if (i == -1) {
return null;
}
ArrayList arrayList = new ArrayList(i);
for (int i2 = 0; i2 < i; i2++) {
int i3 = byteBuffer.getInt();
int i4 = byteBuffer.getInt();
StringAttributeType stringAttributeType = StringAttributeType.values()[byteBuffer.getInt()];
int i5 = AnonymousClass5.$SwitchMap$io$flutter$view$AccessibilityBridge$StringAttributeType[stringAttributeType.ordinal()];
if (i5 == 1) {
byteBuffer.getInt();
SpellOutStringAttribute spellOutStringAttribute = new SpellOutStringAttribute();
spellOutStringAttribute.start = i3;
spellOutStringAttribute.end = i4;
spellOutStringAttribute.type = stringAttributeType;
arrayList.add(spellOutStringAttribute);
} else if (i5 == 2) {
ByteBuffer byteBuffer2 = byteBufferArr[byteBuffer.getInt()];
LocaleStringAttribute localeStringAttribute = new LocaleStringAttribute();
localeStringAttribute.start = i3;
localeStringAttribute.end = i4;
localeStringAttribute.type = stringAttributeType;
localeStringAttribute.locale = Charset.forName("UTF-8").decode(byteBuffer2).toString();
arrayList.add(localeStringAttribute);
}
}
return arrayList;
}
private void ensureInverseTransform() {
if (this.inverseTransformDirty) {
this.inverseTransformDirty = false;
if (this.inverseTransform == null) {
this.inverseTransform = new float[16];
}
if (Matrix.invertM(this.inverseTransform, 0, this.transform, 0)) {
return;
}
Arrays.fill(this.inverseTransform, BitmapDescriptorFactory.HUE_RED);
}
}
/* JADX INFO: Access modifiers changed from: private */
public SemanticsNode hitTest(float[] fArr, boolean z) {
float f = fArr[3];
boolean z2 = false;
float f2 = fArr[0] / f;
float f3 = fArr[1] / f;
if (f2 >= this.left && f2 < this.right && f3 >= this.top && f3 < this.bottom) {
float[] fArr2 = new float[4];
for (SemanticsNode semanticsNode : this.childrenInHitTestOrder) {
if (!semanticsNode.hasFlag(Flag.IS_HIDDEN)) {
semanticsNode.ensureInverseTransform();
Matrix.multiplyMV(fArr2, 0, semanticsNode.inverseTransform, 0, fArr, 0);
SemanticsNode hitTest = semanticsNode.hitTest(fArr2, z);
if (hitTest != null) {
return hitTest;
}
}
}
if (z && this.platformViewId != -1) {
z2 = true;
}
if (isFocusable() || z2) {
return this;
}
}
return null;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean isFocusable() {
String str;
String str2;
String str3;
if (hasFlag(Flag.SCOPES_ROUTE)) {
return false;
}
if (hasFlag(Flag.IS_FOCUSABLE)) {
return true;
}
return ((this.actions & (~AccessibilityBridge.SCROLLABLE_ACTIONS)) == 0 && (this.flags & AccessibilityBridge.FOCUSABLE_FLAGS) == 0 && ((str = this.label) == null || str.isEmpty()) && (((str2 = this.value) == null || str2.isEmpty()) && ((str3 = this.hint) == null || str3.isEmpty()))) ? false : true;
}
/* JADX INFO: Access modifiers changed from: private */
public void collectRoutes(List<SemanticsNode> list) {
if (hasFlag(Flag.SCOPES_ROUTE)) {
list.add(this);
}
Iterator<SemanticsNode> it = this.childrenInTraversalOrder.iterator();
while (it.hasNext()) {
it.next().collectRoutes(list);
}
}
/* JADX INFO: Access modifiers changed from: private */
public String getRouteName() {
String str;
if (hasFlag(Flag.NAMES_ROUTE) && (str = this.label) != null && !str.isEmpty()) {
return this.label;
}
Iterator<SemanticsNode> it = this.childrenInTraversalOrder.iterator();
while (it.hasNext()) {
String routeName = it.next().getRouteName();
if (routeName != null && !routeName.isEmpty()) {
return routeName;
}
}
return null;
}
/* JADX INFO: Access modifiers changed from: private */
public void updateRecursively(float[] fArr, Set<SemanticsNode> set, boolean z) {
set.add(this);
if (this.globalGeometryDirty) {
z = true;
}
if (z) {
if (this.globalTransform == null) {
this.globalTransform = new float[16];
}
if (this.transform == null) {
this.transform = new float[16];
}
Matrix.multiplyMM(this.globalTransform, 0, fArr, 0, this.transform, 0);
float[] fArr2 = new float[4];
float[] fArr3 = new float[4];
float[] fArr4 = new float[4];
float[] fArr5 = new float[4];
float[] fArr6 = {this.left, this.top, BitmapDescriptorFactory.HUE_RED, 1.0f};
transformPoint(fArr2, this.globalTransform, fArr6);
fArr6[0] = this.right;
fArr6[1] = this.top;
transformPoint(fArr3, this.globalTransform, fArr6);
fArr6[0] = this.right;
fArr6[1] = this.bottom;
transformPoint(fArr4, this.globalTransform, fArr6);
fArr6[0] = this.left;
fArr6[1] = this.bottom;
transformPoint(fArr5, this.globalTransform, fArr6);
if (this.globalRect == null) {
this.globalRect = new Rect();
}
this.globalRect.set(Math.round(min(fArr2[0], fArr3[0], fArr4[0], fArr5[0])), Math.round(min(fArr2[1], fArr3[1], fArr4[1], fArr5[1])), Math.round(max(fArr2[0], fArr3[0], fArr4[0], fArr5[0])), Math.round(max(fArr2[1], fArr3[1], fArr4[1], fArr5[1])));
this.globalGeometryDirty = false;
}
int i = -1;
for (SemanticsNode semanticsNode : this.childrenInTraversalOrder) {
semanticsNode.previousNodeId = i;
i = semanticsNode.id;
semanticsNode.updateRecursively(this.globalTransform, set, z);
}
}
private void transformPoint(float[] fArr, float[] fArr2, float[] fArr3) {
Matrix.multiplyMV(fArr, 0, fArr2, 0, fArr3, 0);
float f = fArr[3];
fArr[0] = fArr[0] / f;
fArr[1] = fArr[1] / f;
fArr[2] = fArr[2] / f;
fArr[3] = 0.0f;
}
private float min(float f, float f2, float f3, float f4) {
return Math.min(f, Math.min(f2, Math.min(f3, f4)));
}
private float max(float f, float f2, float f3, float f4) {
return Math.max(f, Math.max(f2, Math.max(f3, f4)));
}
/* JADX INFO: Access modifiers changed from: private */
public CharSequence getValue() {
return createSpannableString(this.value, this.valueAttributes);
}
private CharSequence getLabel() {
return createSpannableString(this.label, this.labelAttributes);
}
private CharSequence getHint() {
return createSpannableString(this.hint, this.hintAttributes);
}
/* JADX INFO: Access modifiers changed from: private */
public CharSequence getValueLabelHint() {
CharSequence[] charSequenceArr = {getValue(), getLabel(), getHint()};
CharSequence charSequence = null;
for (int i = 0; i < 3; i++) {
CharSequence charSequence2 = charSequenceArr[i];
if (charSequence2 != null && charSequence2.length() > 0) {
charSequence = (charSequence == null || charSequence.length() == 0) ? charSequence2 : TextUtils.concat(charSequence, ", ", charSequence2);
}
}
return charSequence;
}
/* JADX INFO: Access modifiers changed from: private */
public CharSequence getTextFieldHint() {
CharSequence[] charSequenceArr = {getLabel(), getHint()};
CharSequence charSequence = null;
for (int i = 0; i < 2; i++) {
CharSequence charSequence2 = charSequenceArr[i];
if (charSequence2 != null && charSequence2.length() > 0) {
charSequence = (charSequence == null || charSequence.length() == 0) ? charSequence2 : TextUtils.concat(charSequence, ", ", charSequence2);
}
}
return charSequence;
}
private SpannableString createSpannableString(String str, List<StringAttribute> list) {
if (str == null) {
return null;
}
SpannableString spannableString = new SpannableString(str);
if (list != null) {
for (StringAttribute stringAttribute : list) {
int i = AnonymousClass5.$SwitchMap$io$flutter$view$AccessibilityBridge$StringAttributeType[stringAttribute.type.ordinal()];
if (i == 1) {
spannableString.setSpan(new TtsSpan.Builder("android.type.verbatim").build(), stringAttribute.start, stringAttribute.end, 0);
} else if (i == 2) {
spannableString.setSpan(new LocaleSpan(Locale.forLanguageTag(((LocaleStringAttribute) stringAttribute).locale)), stringAttribute.start, stringAttribute.end, 0);
}
}
}
return spannableString;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: io.flutter.view.AccessibilityBridge$5, reason: invalid class name */
/* loaded from: classes6.dex */
public static /* synthetic */ class AnonymousClass5 {
static final int[] $SwitchMap$io$flutter$view$AccessibilityBridge$StringAttributeType;
static {
int[] iArr = new int[StringAttributeType.values().length];
$SwitchMap$io$flutter$view$AccessibilityBridge$StringAttributeType = iArr;
try {
iArr[StringAttributeType.SPELLOUT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$io$flutter$view$AccessibilityBridge$StringAttributeType[StringAttributeType.LOCALE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public boolean externalViewRequestSendAccessibilityEvent(View view, View view2, AccessibilityEvent accessibilityEvent) {
Integer recordFlutterId;
if (!this.accessibilityViewEmbedder.requestSendAccessibilityEvent(view, view2, accessibilityEvent) || (recordFlutterId = this.accessibilityViewEmbedder.getRecordFlutterId(view, accessibilityEvent)) == null) {
return false;
}
int eventType = accessibilityEvent.getEventType();
if (eventType == 8) {
this.embeddedInputFocusedNodeId = recordFlutterId;
this.inputFocusedSemanticsNode = null;
return true;
}
if (eventType == 128) {
this.hoveredObject = null;
return true;
}
if (eventType == 32768) {
this.embeddedAccessibilityFocusedNodeId = recordFlutterId;
this.accessibilityFocusedSemanticsNode = null;
return true;
}
if (eventType != 65536) {
return true;
}
this.embeddedInputFocusedNodeId = null;
this.embeddedAccessibilityFocusedNodeId = null;
return true;
}
}