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

Commit c96a7b28 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "2604184 Expose hidden APIs for testing the AccessibilityManager...

Merge "2604184  Expose hidden APIs for testing the AccessibilityManager separately from the backing AccessibilityManagerServcie"
parents 038d4f43 af7adab3
Loading
Loading
Loading
Loading
+21 −4
Original line number Original line Diff line number Diff line
@@ -94,7 +94,9 @@ public final class AccessibilityManager {
    public static AccessibilityManager getInstance(Context context) {
    public static AccessibilityManager getInstance(Context context) {
        synchronized (sInstanceSync) {
        synchronized (sInstanceSync) {
            if (sInstance == null) {
            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;
        return sInstance;
@@ -104,11 +106,14 @@ public final class AccessibilityManager {
     * Create an instance.
     * Create an instance.
     *
     *
     * @param context A {@link Context}.
     * @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());
        mHandler = new MyHandler(context.getMainLooper());
        IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
        mService = service;
        mService = IAccessibilityManager.Stub.asInterface(iBinder);

        try {
        try {
            mIsEnabled = mService.addClient(mClient);
            mIsEnabled = mService.addClient(mClient);
        } catch (RemoteException re) {
        } 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
     * Sends an {@link AccessibilityEvent}. If this {@link AccessibilityManager} is not
     * enabled the call is a NOOP.
     * enabled the call is a NOOP.