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

Commit 72c510f1 authored by Eugene Susla's avatar Eugene Susla
Browse files

Revert "Move A11y events throttling away from View(RootImpl)"

This reverts commit e4d31b3c.

Fixes: 71904218
Test: presubmit
Change-Id: Id73bde1a0c11696cf561c84cde027cdca4c6a00f
parent f4c5faf9
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.accessibilityservice.IAccessibilityServiceConnection;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
@@ -46,14 +47,10 @@ import android.view.accessibility.AccessibilityInteractionClient;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
import android.view.accessibility.IAccessibilityInteractionConnection;

import com.android.internal.util.CollectionUtils;

import libcore.io.IoUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeoutException;

@@ -583,8 +580,6 @@ public final class UiAutomation {
        // Execute the command *without* the lock being held.
        command.run();

        List<AccessibilityEvent> eventsReceived = Collections.emptyList();

        // Acquire the lock and wait for the event.
        try {
            // Wait for the event.
@@ -605,14 +600,14 @@ public final class UiAutomation {
                    if (filter.accept(event)) {
                        return event;
                    }
                    eventsReceived = CollectionUtils.add(eventsReceived, event);
                    event.recycle();
                }
                // Check if timed out and if not wait.
                final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                final long remainingTimeMillis = timeoutMillis - elapsedTimeMillis;
                if (remainingTimeMillis <= 0) {
                    throw new TimeoutException("Expected event not received within: "
                            + timeoutMillis + " ms, among " + eventsReceived);
                            + timeoutMillis + " ms.");
                }
                synchronized (mLock) {
                    if (mEventQueue.isEmpty()) {
@@ -625,10 +620,6 @@ public final class UiAutomation {
                }
            }
        } finally {
            for (int i = 0; i < CollectionUtils.size(eventsReceived); i++) {
                AccessibilityEvent event = eventsReceived.get(i);
                event.recycle();
            }
            synchronized (mLock) {
                mWaitingForEventDelivery = false;
                mEventQueue.clear();
+151 −75

File changed.

Preview size limit exceeded, changes collapsed.

+26 −16
Original line number Diff line number Diff line
@@ -3649,34 +3649,44 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return ViewGroup.class.getName();
    }

    @Override
    public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType) {
        // If this is a live region, we should send a subtree change event
        // from this view. Otherwise, we can let it propagate up.
        if (getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE) {
            notifyViewAccessibilityStateChangedIfNeeded(
                    AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE);
        } else if (mParent != null) {
            try {
                mParent.notifySubtreeAccessibilityStateChanged(this, source, changeType);
            } catch (AbstractMethodError e) {
                Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() +
                        " does not fully implement ViewParent", e);
            }
        }
    }

    /** @hide */
    @Override
    public void notifyAccessibilitySubtreeChanged() {
    public void notifySubtreeAccessibilityStateChangedIfNeeded() {
        if (!AccessibilityManager.getInstance(mContext).isEnabled() || mAttachInfo == null) {
            return;
        }
        // If something important for a11y is happening in this subtree, make sure it's dispatched
        // from a view that is important for a11y so it doesn't get lost.
        if (getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                && !isImportantForAccessibility()
                && getChildCount() > 0) {
        if ((getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)
                && !isImportantForAccessibility() && (getChildCount() > 0)) {
            ViewParent a11yParent = getParentForAccessibility();
            if (a11yParent instanceof View) {
                ((View) a11yParent).notifyAccessibilitySubtreeChanged();
                ((View) a11yParent).notifySubtreeAccessibilityStateChangedIfNeeded();
                return;
            }
        }
        super.notifyAccessibilitySubtreeChanged();
        super.notifySubtreeAccessibilityStateChangedIfNeeded();
    }

    @Override
    public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType) {
        notifyAccessibilityStateChanged(source, changeType);
    }

    /** @hide */
    @Override
    public void resetSubtreeAccessibilityStateChanged() {
    void resetSubtreeAccessibilityStateChanged() {
        super.resetSubtreeAccessibilityStateChanged();
        View[] children = mChildren;
        final int childCount = mChildrenCount;
@@ -5088,7 +5098,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        }

        if (child.getVisibility() != View.GONE) {
            notifyAccessibilitySubtreeChanged();
            notifySubtreeAccessibilityStateChangedIfNeeded();
        }

        if (mTransientIndices != null) {
@@ -5358,7 +5368,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        dispatchViewRemoved(view);

        if (view.getVisibility() != View.GONE) {
            notifyAccessibilitySubtreeChanged();
            notifySubtreeAccessibilityStateChangedIfNeeded();
        }

        int transientCount = mTransientIndices == null ? 0 : mTransientIndices.size();
@@ -6077,7 +6087,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        if (invalidate) {
            invalidateViewProperty(false, false);
        }
        notifyAccessibilitySubtreeChanged();
        notifySubtreeAccessibilityStateChangedIfNeeded();
    }

    @Override
+125 −33

File changed.

Preview size limit exceeded, changes collapsed.

+0 −61

File deleted.

Preview size limit exceeded, changes collapsed.

Loading