Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED

The following examples show how to use android.view.accessibility.AccessibilityEvent#TYPE_WINDOWS_CHANGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public void setMonitorEventTypesAll() {
    Ln.d("SERVICE: setMonitorEventTypesAll");

    int mask = AccessibilityEvent.TYPE_WINDOWS_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_SCROLLED;

    String packagename = mCore.getCurrentPackageName();

    if (packagename == null || mDb.isShowInfoOnTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_CLICKED;
    }
    if (packagename == null || mDb.isShowInfoOnLongTap(packagename) || mDb.isToggleEncryptButtonOnLongTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_LONG_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_LONG_CLICKED;
    }

    boolean includeNotImportantViews = packagename == null ? true : mDb.isIncludeNonImportantViews(packagename);

    setMonitorEventTypes(mask, includeNotImportantViews, true);


}
 
Example 2
Source File: UiChangeDetector.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
  if (event == null) {
    return;
  }
  int eventType = event.getEventType();
  boolean willClearFocus =
      (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
          || (eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED)
          || (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED);

  if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
    /* Ignore changes that don't affect the view hierarchy */
    int changeTypes = event.getContentChangeTypes();
    changeTypes &= ~AccessibilityEvent.CONTENT_CHANGE_TYPE_TEXT;
    changeTypes &= ~AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION;
    willClearFocus = (changeTypes != 0);
  }

  if (willClearFocus) {
    listener.onPossibleChangeToUi(event);
  }
}
 
Example 3
Source File: ContentChangeWatcher.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
@Subscriber(@Param(value = Constant.EVENT_ACCESSIBILITY_EVENT, sticky = false))
public void onAccessibilityEvent(UniversalEventBean eventBean) {
    Integer eventType = eventBean.getParam(Constant.KEY_ACCESSIBILITY_TYPE);
    LogUtil.d(TAG, "【ChangeWatcher】收到辅助功能事件=%d", eventType);
    if (eventType != null) {
        switch (eventType) {
            case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
            case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
                lastWatchingTime = System.currentTimeMillis();
                break;
        }
    }
}
 
Example 4
Source File: WindowChangeEventProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
public void handleAccessibilityEvent(AccessibilityEvent event, AccessibilityNodeInfo rootNode){
    int eventType = event.getEventType();
    if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
            || eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            || eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED
            || eventType == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED)
    {
        this.output(new AccEvent(event, rootNode));
    }

}
 
Example 5
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
public static int[] getAllEventTypes() {
  return new int[] {
    AccessibilityEvent.TYPE_ANNOUNCEMENT,
    AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_END,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
    AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED,
    AccessibilityEvent.TYPE_VIEW_CLICKED,
    AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED,
    AccessibilityEvent.TYPE_VIEW_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
    AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
    AccessibilityEvent.TYPE_VIEW_LONG_CLICKED,
    AccessibilityEvent.TYPE_VIEW_SCROLLED,
    AccessibilityEvent.TYPE_VIEW_SELECTED,
    AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
    AccessibilityEvent.TYPE_WINDOWS_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
  };
}
 
Example 6
Source File: WindowEventInterpreter.java    From talkback with Apache License 2.0 5 votes vote down vote up
private String stateChangesToString() {
  switch (eventType) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
      return contentChangeTypesToString(changeTypes);
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
      return windowChangeTypesToString(changeTypes);
    default:
      return null;
  }
}
 
Example 7
Source File: ScreenStateMonitor.java    From talkback with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.P)
private boolean shouldIgnoreEvent(AccessibilityEvent event) {
  // Starting from P, we only care about certain types of window changes.
  return BuildVersionUtils.isAtLeastP()
      && (event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED)
      && ((event.getWindowChanges() & WINDOW_CHANGES_MASK) == 0);
}
 
Example 8
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static String typeToString(int eventType) {
  switch (eventType) {
    case AccessibilityEvent.TYPE_ANNOUNCEMENT:
      return "TYPE_ANNOUNCEMENT";
    case AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT:
      return "TYPE_ASSIST_READING_CONTEXT";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
      return "TYPE_GESTURE_DETECTION_END";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_START:
      return "TYPE_GESTURE_DETECTION_START";
    case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
      return "TYPE_NOTIFICATION_STATE_CHANGED";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_END";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_START";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      return "TYPE_TOUCH_INTERACTION_END";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      return "TYPE_TOUCH_INTERACTION_START";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
      return "TYPE_VIEW_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED:
      return "TYPE_VIEW_CONTEXT_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
      return "TYPE_VIEW_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
      return "TYPE_VIEW_HOVER_ENTER";
    case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT:
      return "TYPE_VIEW_HOVER_EXIT";
    case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED:
      return "TYPE_VIEW_LONG_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
      return "TYPE_VIEW_SCROLLED";
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
      return "TYPE_VIEW_SELECTED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
      return "TYPE_VIEW_TEXT_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
      return "TYPE_VIEW_TEXT_SELECTION_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
      return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY";
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
      return "TYPE_WINDOWS_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
      return "TYPE_WINDOW_CONTENT_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
      return "TYPE_WINDOW_STATE_CHANGED";
    default:
      return "(unhandled)";
  }
}
 
Example 9
Source File: AccessibilityEventProcessor.java    From talkback with Apache License 2.0 4 votes vote down vote up
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {

    if (testingListener != null) {
      testingListener.onAccessibilityEvent(event);
    }

    if ((dumpEventMask & event.getEventType()) != 0) {
      LogUtils.v(TAG, DUMP_EVENT_LOG_FORMAT, event);
    }

    if (shouldDropRefocusEvent(event)) {
      return;
    }

    if (shouldDropEvent(event)) {
      return;
    }

    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
      lastWindowStateChanged = SystemClock.uptimeMillis();
    }

    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
        || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
        || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) {
      service.setRootDirty(true);
    }

    // We need to save the last focused event so that we can filter out related selected events.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
      if (lastFocusedEvent != null) {
        lastFocusedEvent.recycle();
      }

      lastFocusedEvent = AccessibilityEvent.obtain(event);
    }

    if (AccessibilityEventUtils.eventMatchesAnyType(event, MASK_DELAYED_EVENT_TYPES)) {
      handler.postProcessEvent(event, eventId);
    } else {
      processEvent(event, eventId);
    }

    if (testingListener != null) {
      testingListener.afterAccessibilityEvent(event);
    }
  }