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

Commit ae6b03f8 authored by Daniel Norman's avatar Daniel Norman
Browse files

Removes isAccessibilityTool from dynamically-configurable properties.

AccessibilityServiceInfo#setAccessibilityTool() is already a hidden
method but reflection techniques may be able to bypass this. So, we
shouldn't allow this property to be modified at runtime by an
a11yservice after the service info is parsed from the XML.

This field was originally added to configurable properties to allow
modification during CTS tests.

This change replaces dynamic configuration with a flag in UiAutomation
that is used when connecting a new UiAutomation instance. CTS tests
which wish to change isAccessibilityTool mid-test can reconnect their
UiAutomation with a new flag value. The flag is @TestApi since it is
unlikely non-CTS developers will want it for their own tests.

Fix: 248335757
Test: atest AccessibilityEndToEndTest
Change-Id: I6ca3d9e6fb94207897cdfc94925bbd4d54348a29
parent 67457fc6
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -444,6 +444,7 @@ package android.app {
    method public void syncInputTransactions();
    method public void syncInputTransactions();
    method public void syncInputTransactions(boolean);
    method public void syncInputTransactions(boolean);
    field @NonNull public static final java.util.Set<java.lang.String> ALL_PERMISSIONS;
    field @NonNull public static final java.util.Set<java.lang.String> ALL_PERMISSIONS;
    field public static final int FLAG_NOT_ACCESSIBILITY_TOOL = 4; // 0x4
  }
  }


  public class UiModeManager {
  public class UiModeManager {
+0 −1
Original line number Original line Diff line number Diff line
@@ -784,7 +784,6 @@ public class AccessibilityServiceInfo implements Parcelable {
        mNonInteractiveUiTimeout = other.mNonInteractiveUiTimeout;
        mNonInteractiveUiTimeout = other.mNonInteractiveUiTimeout;
        mInteractiveUiTimeout = other.mInteractiveUiTimeout;
        mInteractiveUiTimeout = other.mInteractiveUiTimeout;
        flags = other.flags;
        flags = other.flags;
        mIsAccessibilityTool = other.mIsAccessibilityTool;
    }
    }


    private boolean isRequestAccessibilityButtonChangeEnabled(IPlatformCompat platformCompat) {
    private boolean isRequestAccessibilityButtonChangeEnabled(IPlatformCompat platformCompat) {
+9 −0
Original line number Original line Diff line number Diff line
@@ -172,6 +172,15 @@ public final class UiAutomation {
     */
     */
    public static final int FLAG_DONT_USE_ACCESSIBILITY = 0x00000002;
    public static final int FLAG_DONT_USE_ACCESSIBILITY = 0x00000002;


    /**
     * UiAutomation sets {@link AccessibilityServiceInfo#isAccessibilityTool()} true by default.
     * This flag provides the option to set this field false for tests exercising that property.
     *
     * @hide
     */
    @TestApi
    public static final int FLAG_NOT_ACCESSIBILITY_TOOL = 0x00000004;

    /**
    /**
     * Returned by {@link #getAdoptedShellPermissions} to indicate that all permissions have been
     * Returned by {@link #getAdoptedShellPermissions} to indicate that all permissions have been
     * adopted using {@link #adoptShellPermissionIdentity}.
     * adopted using {@link #adoptShellPermissionIdentity}.
+3 −1
Original line number Original line Diff line number Diff line
@@ -558,7 +558,9 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
        info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
        info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
                | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
        if ((flags & UiAutomation.FLAG_NOT_ACCESSIBILITY_TOOL) == 0) {
            info.setAccessibilityTool(true);
            info.setAccessibilityTool(true);
        }
        try {
        try {
            // Calling out with a lock held is fine since if the system
            // Calling out with a lock held is fine since if the system
            // process is gone the client calling in will be killed.
            // process is gone the client calling in will be killed.