Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 150b7b6e authored by Hiroki Sato's avatar Hiroki Sato Committed by Android (Google) Code Review
Browse files

Merge "Throttle content changed events only subtree changes"

parents 1d729b80 510043d4
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -14944,8 +14944,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Notifies that the accessibility state of this view changed. The change
     * is local to this view and does not represent structural changes such
     * as children and parent. For example, the view became focusable. The
     * notification is at at most once every
     * as children and parent. For example, the view became focusable. Some of
     * the notification is at at most once every
     * {@link ViewConfiguration#getSendRecurringAccessibilityEventsInterval()}
     * to avoid unnecessary load to the system. Also once a view has a pending
     * notification this method is a NOP until the notification has been sent.
@@ -15007,7 +15007,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * Notifies that the accessibility state of this view changed. The change
     * is *not* local to this view and does represent structural changes such
     * as children and parent. For example, the view size changed. The
     * as children and parent. For example, the view size changed. Some of the
     * notification is at at most once every
     * {@link ViewConfiguration#getSendRecurringAccessibilityEventsInterval()}
     * to avoid unnecessary load to the system. Also once a view has a pending
+24 −2
Original line number Diff line number Diff line
@@ -218,7 +218,6 @@ import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneFallbackEventHandler;
import com.android.internal.util.Preconditions;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.SurfaceCallbackHelper;
@@ -808,6 +807,7 @@ public final class ViewRootImpl implements ViewParent,
    final HighContrastTextManager mHighContrastTextManager;

    SendWindowContentChangedAccessibilityEvent mSendWindowContentChangedAccessibilityEvent;
    boolean mSendingAccessibilityWIndowContentChange = false;

    HashSet<View> mTempHashSet;

@@ -9867,7 +9867,29 @@ public final class ViewRootImpl implements ViewParent,

    @Override
    public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType) {
        postSendWindowContentChangedCallback(Preconditions.checkNotNull(source), changeType);
        Objects.requireNonNull(source);
        if (changeType == AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) {
            postSendWindowContentChangedCallback(source, changeType);
            return;
        }
        if (mSendingAccessibilityWIndowContentChange) {
            // This allows re-entering this method.
            // Some apps update views during an event dispatch, which triggers another a11y event.
            // In order to avoid an infinite loop, postpone second event dispatch.
            mHandler.post(() -> notifySubtreeAccessibilityStateChanged(child, source, changeType));
            return;
        }

        AccessibilityEvent event =
                new AccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        event.setContentChangeTypes(changeType);
        event.setAction(mAccessibilityManager.getPerformingAction());
        mSendingAccessibilityWIndowContentChange = true;
        try {
            source.sendAccessibilityEventUnchecked(event);
        } finally {
            mSendingAccessibilityWIndowContentChange = false;
        }
    }

    @Override