예제 #1
0
 @Override
 protected void onServiceConnected() {
   System.out.println("onServiceConnected");
   AccessibilityServiceInfo info = new AccessibilityServiceInfo();
   info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
   info.notificationTimeout = 100;
   info.feedbackType = AccessibilityEvent.TYPES_ALL_MASK;
   setServiceInfo(info);
 }
예제 #2
0
 /**
  * Sets the {@link AccessibilityServiceInfo} which informs the system how to handle this {@link
  * AccessibilityService}.
  *
  * @param feedbackType The type of feedback this service will provide. Note: The feedbackType
  *     parameter is an bitwise or of all feedback types this service would like to provide.
  */
 private void setServiceInfo(int feedbackType) {
   AccessibilityServiceInfo info = new AccessibilityServiceInfo();
   // we are interested in all types of accessibility events
   info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
   // we want to provide specific type of feedback
   info.feedbackType = feedbackType;
   // we want to receive events in a certain interval
   info.notificationTimeout = EVENT_NOTIFICATION_TIMEOUT_MILLIS;
   // we want to receive accessibility events only from certain packages
   info.packageNames = PACKAGE_NAMES;
   setServiceInfo(info);
 }
  // set the accessibility filter to
  // watch only for google voice notifications
  @Override
  protected void onServiceConnected() {
    super.onServiceConnected();
    connected = true;

    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    // We are interested in all types of accessibility events.
    info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
    // We want to provide specific type of feedback.
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    // We want to receive events in a certain interval.
    info.notificationTimeout = 100;
    // We want to receive accessibility events only from certain packages.
    info.packageNames = new String[] {Helper.GOOGLE_VOICE_PACKAGE};
    setServiceInfo(info);
  }
 private void registerUiTestAutomationServiceLocked(IAccessibilityServiceClient client) {
   IAccessibilityManager manager =
       IAccessibilityManager.Stub.asInterface(
           ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
   AccessibilityServiceInfo info = new AccessibilityServiceInfo();
   info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
   info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
   info.flags |=
       AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
           | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
   info.setCapabilities(
       AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
           | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
           | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
           | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
   try {
     // Calling out with a lock held is fine since if the system
     // process is gone the client calling in will be killed.
     manager.registerUiTestAutomationService(mToken, client, info);
     mClient = client;
   } catch (RemoteException re) {
     throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
   }
 }