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

Commit fd24f601 authored by Sally's avatar Sally
Browse files

Support separating A11yManagers by device id

An AccessibilityManagerClient is now associated with a device id.
Usually this is the default device (phone), but if a proxy is
registered for a display that belongs to a virtual device, a client
will be assosiated with that device's id, and updates will happen
based on state held by the ProxyManager.

When broadcasting to Clients, check the device id.

Clients are "moved" back to the
default device and updated with the current user state if
1. the virtual device is closed or 2.a proxy is unregistered and
there are no more active proxies belonging to that device.

onProxyChanged behaves like onClientChanged/onUserStateChanged to update
the clients and some system state (like updating window tracking). All
IAccessibilityManagerClient methods (except setUiContrast) are called
by ProxyManager.

Additional changes:

- Remove onProxyChanged/onClientChanged in ProxyManager#registerProxy.
Inform apps of a new proxy after the proxy's installed and enabled
service infos have propagated (in ProxyA11yServiceConnection).
- Call A11yInputFilter from the main thread, since it's not thread
safe.
- Add more dump logging

See video in the comments

Bug: 254545943
Test: atest AccessibilityDisplayProxyTest
Change-Id: If4be657d9fe7a3cdba1437a1f2433b3fab5193b6
parent bb99a72e
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -271,6 +271,14 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
         */
        void onClientChangeLocked(boolean serviceInfoChanged);

        /**
         * Called back to notify the system the proxy client for a device has changed.
         *
         * Changes include if the proxy is unregistered, if its service info list has changed, or if
         * its focus appearance has changed.
         */
        void onProxyChanged(int deviceId);

        int getCurrentUserIdLocked();

        Pair<float[], MagnificationSpec> getWindowTransformationMatrixAndMagnificationSpec(
@@ -315,8 +323,6 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ

        void attachAccessibilityOverlayToDisplay(int displayId, SurfaceControl sc);

        void setCurrentUserFocusAppearance(int strokeWidth, int color);

    }

    public AbstractAccessibilityServiceConnection(Context context, ComponentName componentName,
+222 −70

File changed.

Preview size limit exceeded, changes collapsed.

+51 −8

File changed.

Preview size limit exceeded, changes collapsed.

+604 −66

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import java.util.List;

public class ProxyAccessibilityServiceConnectionTest {
    private static final int DISPLAY_ID = 1000;
    private static final int DEVICE_ID = 2000;
    private static final int CONNECTION_ID = 1000;
    private static final ComponentName COMPONENT_NAME = new ComponentName(
            "com.android.server.accessibility", ".ProxyAccessibilityServiceConnectionTest");
@@ -90,7 +91,7 @@ public class ProxyAccessibilityServiceConnectionTest {
                mAccessibilityServiceInfo, CONNECTION_ID , new Handler(
                        getInstrumentation().getContext().getMainLooper()),
                mMockLock, mMockSecurityPolicy, mMockSystemSupport, mMockA11yTrace,
                mMockWindowManagerInternal, mMockA11yWindowManager, DISPLAY_ID);
                mMockWindowManagerInternal, mMockA11yWindowManager, DISPLAY_ID, DEVICE_ID);
    }

    @Test
@@ -101,7 +102,7 @@ public class ProxyAccessibilityServiceConnectionTest {

        mProxyConnection.setInstalledAndEnabledServices(infos);

        verify(mMockSystemSupport).onClientChangeLocked(true);
        verify(mMockSystemSupport).onProxyChanged(DEVICE_ID);
    }

    @Test