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

Commit c52cb42e authored by Ameer Armaly's avatar Ameer Armaly
Browse files

Add API for services to turn off window animations.

Bug: 195757359
Test: atest AccessibilityWindowReportingTest
Change-Id: I5fc1c90e87de17fb770f6a3371fc341985017a61
parent d3bffe32
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3074,6 +3074,7 @@ package android.accessibilityservice {
    method public void onSystemActionsChanged();
    method public final boolean performGlobalAction(int);
    method public void setAccessibilityFocusAppearance(int, @ColorInt int);
    method public void setAnimationScale(float);
    method public boolean setCacheEnabled(boolean);
    method public void setGestureDetectionPassthroughRegion(int, @NonNull android.graphics.Region);
    method public final void setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo);
@@ -6949,6 +6950,7 @@ package android.app {
    method public boolean performGlobalAction(int);
    method public void revokeRuntimePermission(String, String);
    method public void revokeRuntimePermissionAsUser(String, String, android.os.UserHandle);
    method public void setAnimationScale(float);
    method public void setOnAccessibilityEventListener(android.app.UiAutomation.OnAccessibilityEventListener);
    method public boolean setRotation(int);
    method public void setRunAsMonkey(boolean);
+27 −0
Original line number Diff line number Diff line
@@ -3120,6 +3120,33 @@ public abstract class AccessibilityService extends Service {
        }
    }

    /**
     * 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
     * that do not respect the settings values will not be affected by this function. A lower scale
     * value results in a faster speed. A value of <code>0</code> disables animations entirely. When
     * animations are disabled services receive window change events more quickly which can reduce
     * the potential by confusion by reducing the time during which windows are in transition.
     *
     * @see AccessibilityEvent#TYPE_WINDOWS_CHANGED
     * @see AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
     * @see android.provider.Settings.Global#WINDOW_ANIMATION_SCALE
     * @see android.provider.Settings.Global#TRANSITION_ANIMATION_SCALE
     * @see android.provider.Settings.Global#ANIMATOR_DURATION_SCALE
     * @param scale The scaling factor for all animations.
     */
    public void setAnimationScale(float scale) {
        final IAccessibilityServiceConnection connection =
                AccessibilityInteractionClient.getInstance(this).getConnection(mConnectionId);
        if (connection != null) {
            try {
                connection.setAnimationScale(scale);
            } catch (RemoteException re) {
                throw new RuntimeException(re);
            }
        }
    }

    private static class AccessibilityContext extends ContextWrapper {
        private final int mConnectionId;

+2 −0
Original line number Diff line number Diff line
@@ -144,4 +144,6 @@ interface IAccessibilityServiceConnection {
    void onDoubleTap(int displayId);

    void onDoubleTapAndHold(int displayId);

    void setAnimationScale(float scale);
}
+27 −0
Original line number Diff line number Diff line
@@ -779,6 +779,33 @@ public final class UiAutomation {
        return false;
    }

    /**
     * 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
     * that do not respect the settings values will not be affected by this function. A lower scale
     * value results in a faster speed. A value of <code>0</code> disables animations entirely. When
     * animations are disabled services receive window change events more quickly which can reduce
     * the potential by confusion by reducing the time during which windows are in transition.
     *
     * @see AccessibilityEvent#TYPE_WINDOWS_CHANGED
     * @see AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
     * @see android.provider.Settings.Global#WINDOW_ANIMATION_SCALE
     * @see android.provider.Settings.Global#TRANSITION_ANIMATION_SCALE
     * @see android.provider.Settings.Global#ANIMATOR_DURATION_SCALE
     * @param scale The scaling factor for all animations.
     */
    public void setAnimationScale(float scale) {
        final IAccessibilityServiceConnection connection =
                AccessibilityInteractionClient.getInstance().getConnection(mConnectionId);
        if (connection != null) {
            try {
                connection.setAnimationScale(scale);
            } catch (RemoteException re) {
                throw new RuntimeException(re);
            }
        }
    }

    /**
     * A request for WindowManagerService to wait until all animations have completed and input
     * information has been sent from WindowManager to native InputManager.
+2 −0
Original line number Diff line number Diff line
@@ -204,4 +204,6 @@ public class AccessibilityServiceConnectionImpl extends IAccessibilityServiceCon

    public void logTrace(long timestamp, String where, long loggingTypes, String callingParams,
            int processId, long threadId, int callingUid, Bundle serializedCallingStackInBundle) {}

    public void setAnimationScale(float scale) {}
}
Loading