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

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

2604184 Expose hidden APIs for testing the AccessibilityManager separately...

2604184  Expose hidden APIs for testing the AccessibilityManager separately from the backing AccessibilityManagerServcie

Change-Id: Ief5df31baa3c0990467625977e97cd066a671959
parent 5a2e428c
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -94,7 +94,9 @@ public final class AccessibilityManager {
    public static AccessibilityManager getInstance(Context context) {
        synchronized (sInstanceSync) {
            if (sInstance == null) {
                sInstance = new AccessibilityManager(context);
                IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
                IAccessibilityManager service = IAccessibilityManager.Stub.asInterface(iBinder);
                sInstance = new AccessibilityManager(context, service);
            }
        }
        return sInstance;
@@ -104,11 +106,14 @@ public final class AccessibilityManager {
     * Create an instance.
     *
     * @param context A {@link Context}.
     * @param service An interface to the backing service.
     *
     * @hide
     */
    private AccessibilityManager(Context context) {
    public AccessibilityManager(Context context, IAccessibilityManager service) {
        mHandler = new MyHandler(context.getMainLooper());
        IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
        mService = IAccessibilityManager.Stub.asInterface(iBinder);
        mService = service;

        try {
            mIsEnabled = mService.addClient(mClient);
        } catch (RemoteException re) {
@@ -127,6 +132,18 @@ public final class AccessibilityManager {
        }
    }

    /**
     * Returns the client interface this instance registers in
     * the centralized accessibility manager service.
     *
     * @return The client.
     *
     * @hide
     */
    public IAccessibilityManagerClient getClient() {
       return (IAccessibilityManagerClient) mClient.asBinder(); 
    }

    /**
     * Sends an {@link AccessibilityEvent}. If this {@link AccessibilityManager} is not
     * enabled the call is a NOOP.