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

Commit 83e20e86 authored by Daniel Norman's avatar Daniel Norman
Browse files

Add a new @TestApi to inject InputEvents to the input filter.

This is used by end-to-end tests exercising the input filter for generic
motion events.

Bug: 247550565
Test: atest AccessibilityEndToEndTest, using the dependent change topic
Change-Id: I2695ecb3919d8336dc3f6df1a525a53d84c03fec
parent ad961027
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -440,6 +440,7 @@ package android.app {
    method @NonNull public java.util.Set<java.lang.String> getAdoptedShellPermissions();
    method @Deprecated public boolean grantRuntimePermission(String, String, android.os.UserHandle);
    method public boolean injectInputEvent(@NonNull android.view.InputEvent, boolean, boolean);
    method public void injectInputEventToInputFilter(@NonNull android.view.InputEvent);
    method @Deprecated public boolean revokeRuntimePermission(String, String, android.os.UserHandle);
    method public void syncInputTransactions();
    method public void syncInputTransactions(boolean);
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ interface IUiAutomationConnection {
    void connect(IAccessibilityServiceClient client, int flags);
    void disconnect();
    boolean injectInputEvent(in InputEvent event, boolean sync, boolean waitForAnimations);
    void injectInputEventToInputFilter(in InputEvent event);
    void syncInputTransactions(boolean waitForAnimations);
    boolean setRotation(int rotation);
    Bitmap takeScreenshot(in Rect crop);
+18 −0
Original line number Diff line number Diff line
@@ -792,6 +792,24 @@ public final class UiAutomation {
        return false;
    }

    /**
     * Injects an arbitrary {@link InputEvent} to the accessibility input filter, for use in testing
     * the accessibility input filter.
     *
     * Events injected to the input subsystem using the standard {@link #injectInputEvent} method
     * skip the accessibility input filter to avoid feedback loops.
     *
     * @hide
     */
    @TestApi
    public void injectInputEventToInputFilter(@NonNull InputEvent event) {
        try {
            mUiAutomationConnection.injectInputEventToInputFilter(event);
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error while injecting input event to input filter", re);
        }
    }

    /**
     * Sets the system settings values that control the scaling factor for animations. The scale
     * controls the animation playback speed for animations that respect these settings. Animations
+5 −0
Original line number Diff line number Diff line
@@ -177,6 +177,11 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        return false;
    }

    @Override
    public void injectInputEventToInputFilter(InputEvent event) throws RemoteException {
        mAccessibilityManager.injectInputEventToInputFilter(event);
    }

    @Override
    public void syncInputTransactions(boolean waitForAnimations) {
        synchronized (mLock) {
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.accessibility.IAccessibilityInteractionConnection;
import android.view.accessibility.IAccessibilityManagerClient;
import android.view.accessibility.AccessibilityWindowAttributes;
import android.view.accessibility.IWindowMagnificationConnection;
import android.view.InputEvent;
import android.view.IWindow;

/**
@@ -114,4 +115,7 @@ interface IAccessibilityManager {

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MANAGE_ACCESSIBILITY)")
    boolean unregisterProxyForDisplay(int displayId);

    // Used by UiAutomation for tests on the InputFilter
    void injectInputEventToInputFilter(in InputEvent event);
}
Loading