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

Commit bfc3ce78 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Updating the WebView accessibility key bindings after discussion with the access-eng team

Change-Id: I39a303864b94a8a11b6cded9b8bb23041ad91502
parent 7b0f8f08
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.webkit;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
@@ -29,6 +30,8 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * This is a test for the behavior of the {@link AccessibilityInjector}
@@ -60,6 +63,17 @@ public class AccessibilityInjectorTest extends AndroidTestCase {
    /** Lock for locking the test. */
    private static final Object sTestLock = new Object();

    /** Key bindings used for testing. */
    private static final String TEST_KEY_DINDINGS =
        "0x13=0x01000100;" +
        "0x14=0x01010100;" +
        "0x15=0x04000000;" +
        "0x16=0x04000000;" +
        "0x200000013=0x03020701:0x03010201:0x03000101:0x03030001:0x03040001:0x03050001:0x03060001;" +
        "0x200000014=0x03010001:0x03020101:0x03070201:0x03030701:0x03040701:0x03050701:0x03060701;" +
        "0x200000015=0x03040301:0x03050401:0x03060501:0x03000601:0x03010601:0x03020601:0x03070601;" +
        "0x200000016=0x03050601:0x03040501:0x03030401:0x03020301:0x03070301:0x03010301:0x03000301;";

    /** Handle to the test for use by the mock service. */
    private static AccessibilityInjectorTest sInstance;

@@ -75,6 +89,9 @@ public class AccessibilityInjectorTest extends AndroidTestCase {
    /** Handle to the {@link WebView} to load data in. */
    private WebView mWebView;

    /** Used for caching the default bindings so they can be restored. */
    private String mDefaultKeyBindings;

    /** The received selection string for assertion checking. */
    private static String sReceivedSelectionString = SELECTION_STRING_UNKNOWN;

@@ -87,6 +104,7 @@ public class AccessibilityInjectorTest extends AndroidTestCase {
            // until JUnit4 comes to play with @BeforeTest
            disableAccessibilityAndMockAccessibilityService();
            enableAccessibilityAndMockAccessibilityService();
            injectTestWebContentKeyBindings();
        }
    }

@@ -98,6 +116,7 @@ public class AccessibilityInjectorTest extends AndroidTestCase {
        if (sExecutedTestCount == TEST_CASE_COUNT) {
            // until JUnit4 comes to play with @AfterTest
            disableAccessibilityAndMockAccessibilityService();
            restoreDefaultWebContentKeyBindings();
        }
        super.tearDown();
    }
@@ -851,6 +870,26 @@ public class AccessibilityInjectorTest extends AndroidTestCase {
        return mWebView;
    }

    /**
     * Injects web content key bindings used for testing. This is required
     * to ensure that this test will be agnostic to changes of the bindings.
     */
    private void injectTestWebContentKeyBindings() {
        ContentResolver contentResolver = getContext().getContentResolver();
        mDefaultKeyBindings = Settings.Secure.getString(contentResolver,
                Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS);
        Settings.Secure.putString(contentResolver,
                Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, TEST_KEY_DINDINGS);
    }

    /**
     * Restores the default web content key bindings.
     */
    private void restoreDefaultWebContentKeyBindings() {
        Settings.Secure.putString(getContext().getContentResolver(),
                Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, mDefaultKeyBindings);
    }

    /**
     * This is a worker thread responsible for creating the {@link WebView}.
     */
+26 −18
Original line number Diff line number Diff line
@@ -81,26 +81,34 @@

    <!-- Default for Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS -->
    <string name="def_accessibility_web_content_key_bindings" translatable="false">
            <!-- DPAD/Trackball UP maps to traverse previous on current axis and send an event. -->
            <!-- DPAD/Trackball UP - traverse previous on current axis and send an event. -->
            0x13=0x01000100;
            <!-- DPAD/Trackball DOWN maps to traverse next on current axis and send an event. -->
            <!-- DPAD/Trackball DOWN - traverse next on current axis and send an event. -->
            0x14=0x01010100;
            <!-- DPAD/Trackball LEFT maps to action in the android default navigation axis. -->
            0x15=0x04000100;
            <!-- DPAD/Trackball RIGHT maps to no action in the android default navigation axis. -->
            0x16=0x04010100;
            <!-- Left Alt+DPAD/Trackball UP transitions from an axis to another and sends an event. -->
            <!-- Axis transitions:  2 -> 7; 1 -> 2; 0 -> 1; 3 -> 0; 4 -> 0; 5 -> 0; 6 -> 0; -->
            0x200000013=0x03020701:0x03010201:0x03000101:0x03030001:0x03040001:0x03050001:0x03060001;
            <!-- Left Alt+DPAD/Trackball DOWN transitions from an axis to another and sends an event. -->
            <!-- Axis transitions: 1 -> 0; 2 -> 1; 7 -> 2; 3 -> 7; 4 -> 7; 5 -> 7; 6 -> 7; -->
            0x200000014=0x03010001:0x03020101:0x03070201:0x03030701:0x03040701:0x03050701:0x03060701;
            <!-- Left Alt+DPAD/Trackball LEFT transitions from an axis to another and sends an event. -->
            <!-- Axis transitions: 4 -> 3; 5 -> 4; 6 -> 5; 0 -> 6; 1 -> 6; 2 -> 6; 7 -> 6; -->
            0x200000015=0x03040301:0x03050401:0x03060501:0x03000601:0x03010601:0x03020601:0x03070601;
            <!-- Left Alt+DPAD/Trackball RIGHT transitions from an axis to another and sends an event.  -->
            <!-- Axis transitions: 5 -> 6; 4 -> 5; 3 -> 4; 2 -> 3; 7 -> 3; 1 -> 3; 0 -> 3; -->
            0x200000016=0x03050601:0x03040501:0x03030401:0x03020301:0x03070301:0x03010301:0x03000301;
            <!-- DPAD/Trackball LEFT - traverse previous on the character navigation axis and send event. -->
            0x15=0x02000001;
            <!-- DPAD/Trackball RIGHT - traverse next on the character navigation axis end send event. -->
            0x16=0x02010001;
            <!-- Alt+DPAD/Trackball UP - go to the top of the document. -->
            0x200000013=0x02000601;
            <!-- Alt+DPAD/Trackball DOWN - go to the bottom of the document. -->
            0x200000014=0x02010601;
            <!-- Alt+DPAD/Trackball LEFT - transition from an axis to another and sends an event.-->
            <!-- Axis transitions: 2 -> 1; -->
            0x200000015=0x03020101;
            <!-- Alt+DPAD/Trackball RIGHT - transition from an axis to another and sends an event. -->
            <!-- Axis transitions:  1 -> 2; -->
            0x200000016=0x03010201;
            <!-- Alt+g - go to the previous heading and send an event. -->
            0x200000023=0x02000301;
            <!-- Alt+h - go to the next heading and send an event. -->
            0x200000024=0x02010301;
            <!-- Alt+COMMA - transition to sentence navigation axis and send an event. -->
            <!-- Axis transitions:  7 -> 2; -->
            0x200000037=0x03070201;
            <!-- Alt+PERIOD - transition to default web view behavior axis and send an event. -->
            <!-- Axis transitions:  0 -> 7; 1 - > 7; 2 -> 7; -->
            0x200000038=0x03000701:0x03010701:0x03020701;
    </string>

    <!-- Default for Settings.System.USER_ROTATION -->