/** * Returns the {@link AccessibilityServiceInfo}s of the enabled accessibility services for a given * feedback type. * * @param feedbackTypeFlags The feedback type flags. * @return An unmodifiable list with {@link AccessibilityServiceInfo}s. * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE * @see AccessibilityServiceInfo#FEEDBACK_GENERIC * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN * @see AccessibilityServiceInfo#FEEDBACK_VISUAL * @see AccessibilityServiceInfo#FEEDBACK_BRAILLE */ public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackTypeFlags) { final IAccessibilityManager service; final int userId; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return Collections.emptyList(); } userId = mUserId; } List<AccessibilityServiceInfo> services = null; try { services = service.getEnabledAccessibilityServiceList(feedbackTypeFlags, userId); if (DEBUG) { Log.i(LOG_TAG, "Installed AccessibilityServices " + services); } } catch (RemoteException re) { Log.e(LOG_TAG, "Error while obtaining the installed AccessibilityServices. ", re); } if (services != null) { return Collections.unmodifiableList(services); } else { return Collections.emptyList(); } }
/** * Sends an {@link AccessibilityEvent}. * * @param event The event to send. * @throws IllegalStateException if accessibility is not enabled. * <p><strong>Note:</strong> The preferred mechanism for sending custom accessibility events * is through calling {@link android.view.ViewParent#requestSendAccessibilityEvent(View, * AccessibilityEvent)} instead of this method to allow predecessors to augment/filter events * sent by their descendants. */ public void sendAccessibilityEvent(AccessibilityEvent event) { final IAccessibilityManager service; final int userId; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return; } if (!mIsEnabled) { throw new IllegalStateException("Accessibility off. Did you forget to check that?"); } userId = mUserId; } boolean doRecycle = false; try { event.setEventTime(SystemClock.uptimeMillis()); // it is possible that this manager is in the same process as the service but // client using it is called through Binder from another process. Example: MMS // app adds a SMS notification and the NotificationManagerService calls this method long identityToken = Binder.clearCallingIdentity(); doRecycle = service.sendAccessibilityEvent(event, userId); Binder.restoreCallingIdentity(identityToken); if (DEBUG) { Log.i(LOG_TAG, event + " sent"); } } catch (RemoteException re) { Log.e(LOG_TAG, "Error during sending " + event + " ", re); } finally { if (doRecycle) { event.recycle(); } } }
/** * Removed an accessibility interaction connection interface for a given window. * * @param windowToken The window token to which a connection is removed. * @hide */ public void removeAccessibilityInteractionConnection(IWindow windowToken) { final IAccessibilityManager service; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return; } } try { service.removeAccessibilityInteractionConnection(windowToken); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while removing an accessibility interaction connection. ", re); } }
/** * Removed an accessibility interaction connection interface for a given window. * * @param windowToken The window token to which a connection is removed. * @hide */ public void removeAccessibilityInteractionConnection(IWindow windowToken) { try { mService.removeAccessibilityInteractionConnection(windowToken); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while removing an accessibility interaction connection. ", re); } }
/** * Adds an accessibility interaction connection interface for a given window. * * @param windowToken The window token to which a connection is added. * @param connection The connection. * @hide */ public int addAccessibilityInteractionConnection( IWindow windowToken, IAccessibilityInteractionConnection connection) { final IAccessibilityManager service; final int userId; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return View.NO_ID; } userId = mUserId; } try { return service.addAccessibilityInteractionConnection(windowToken, connection, userId); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while adding an accessibility interaction connection. ", re); } return View.NO_ID; }
/** * Adds an accessibility interaction connection interface for a given window. * * @param windowToken The window token to which a connection is added. * @param connection The connection. * @hide */ public int addAccessibilityInteractionConnection( IWindow windowToken, IAccessibilityInteractionConnection connection) { try { return mService.addAccessibilityInteractionConnection(windowToken, connection); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while adding an accessibility interaction connection. ", re); } return View.NO_ID; }
/** * Create an instance. * * @param context A {@link Context}. * @param service An interface to the backing service. * @hide */ public AccessibilityManager(Context context, IAccessibilityManager service) { mHandler = new MyHandler(context.getMainLooper()); mService = service; try { final int stateFlags = mService.addClient(mClient); setState(stateFlags); } catch (RemoteException re) { Log.e(LOG_TAG, "AccessibilityManagerService is dead", re); } }
/** * Returns the {@link AccessibilityServiceInfo}s of the enabled accessibility services for a given * feedback type. * * @param feedbackTypeFlags The feedback type flags. * @return An unmodifiable list with {@link AccessibilityServiceInfo}s. * @see AccessibilityServiceInfo#FEEDBACK_AUDIBLE * @see AccessibilityServiceInfo#FEEDBACK_GENERIC * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN * @see AccessibilityServiceInfo#FEEDBACK_VISUAL */ public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackTypeFlags) { List<AccessibilityServiceInfo> services = null; try { services = mService.getEnabledAccessibilityServiceList(feedbackTypeFlags); if (DEBUG) { Log.i(LOG_TAG, "Installed AccessibilityServices " + services); } } catch (RemoteException re) { Log.e(LOG_TAG, "Error while obtaining the installed AccessibilityServices. ", re); } return Collections.unmodifiableList(services); }
/** Requests feedback interruption from all accessibility services. */ public void interrupt() { final IAccessibilityManager service; final int userId; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return; } if (!mIsEnabled) { throw new IllegalStateException("Accessibility off. Did you forget to check that?"); } userId = mUserId; } try { service.interrupt(userId); if (DEBUG) { Log.i(LOG_TAG, "Requested interrupt from all services"); } } catch (RemoteException re) { Log.e(LOG_TAG, "Error while requesting interrupt from all services. ", re); } }
/** Requests feedback interruption from all accessibility services. */ public void interrupt() { if (!mIsEnabled) { throw new IllegalStateException("Accessibility off. Did you forget to check that?"); } try { mService.interrupt(); if (DEBUG) { Log.i(LOG_TAG, "Requested interrupt from all services"); } } catch (RemoteException re) { Log.e(LOG_TAG, "Error while requesting interrupt from all services. ", re); } }
private void tryConnectToServiceLocked(IAccessibilityManager service) { if (service == null) { IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE); if (iBinder == null) { return; } service = IAccessibilityManager.Stub.asInterface(iBinder); } try { final int stateFlags = service.addClient(mClient, mUserId); setStateLocked(stateFlags); mService = service; } catch (RemoteException re) { Log.e(LOG_TAG, "AccessibilityManagerService is dead", re); } }