Java Code Examples for android.view.accessibility.AccessibilityEvent#getWindowId()
The following examples show how to use
android.view.accessibility.AccessibilityEvent#getWindowId() .
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: ViewDebugHelperService.java From ViewDebugHelper with BSD 3-Clause "New" or "Revised" License | 6 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { event.getWindowId(); ComponentName componentName = new ComponentName(event.getPackageName().toString(), event.getClassName().toString()); ActivityInfo activityInfo = ActivityHelper.tryGetActivity(this, componentName); boolean isActivity = activityInfo != null; if (isActivity) { String activityName = componentName.flattenToString(); log("CurrentActivity" + activityName); ViewDebugHelperApplication.getInstance().setLastTopActivityName(activityName); ActivityStackManager.getInstance().offer(activityName); } } }
Example 2
Source File: AccessibilityEventUtils.java From talkback with Apache License 2.0 | 6 votes |
/** Returns window id from event, or WINDOW_ID_NONE. */ public static int getWindowId(@Nullable AccessibilityEvent event) { if (event == null) { return WINDOW_ID_NONE; } // Try to get window id from event. int windowId = event.getWindowId(); if (windowId != WINDOW_ID_NONE) { return windowId; } // Try to get window id from event source. AccessibilityNodeInfo source = event.getSource(); try { return (source == null) ? WINDOW_ID_NONE : source.getWindowId(); } finally { AccessibilityNodeInfoUtils.recycleNodes(source); } }
Example 3
Source File: InputFocusInterpreter.java From talkback with Apache License 2.0 | 5 votes |
void registerWindowStateChangeEvent(AccessibilityEvent event) { lastWindowStateChangeEventTime = event.getEventTime(); if (getLastWindowId() != event.getWindowId() && !shouldIgnoreWindowChangeEvent(event)) { setLastWindowIdFromEvent(event.getWindowId()); isFirstFocusInWindow = true; } }
Example 4
Source File: InputFocusInterpreter.java From talkback with Apache License 2.0 | 5 votes |
/** * Decides whether to ignore an event for purposes of registering the first-focus window change; * returns true events that come from non-main windows such as IMEs. */ private boolean shouldIgnoreWindowChangeEvent(AccessibilityEvent event) { // The specific SoftInputWindow check seems to be necessary for Android TV. return (event.getWindowId() < 0) || TextUtils.equals(SOFT_INPUT_WINDOW, event.getClassName()) || AccessibilityEventUtils.isNonMainWindowEvent(event); }
Example 5
Source File: InputFocusInterpreter.java From talkback with Apache License 2.0 | 5 votes |
boolean shouldProcessFocusEvent(AccessibilityEvent event) { boolean isFirstFocus = isFirstFocusInWindow; isFirstFocusInWindow = false; if (getLastWindowId() != event.getWindowId()) { setLastWindowIdFromEvent(event.getWindowId()); return false; } int focusDelay = FeatureSupport.isTv(context) ? MISS_FOCUS_DELAY_TV : MISS_FOCUS_DELAY_NORMAL; return !isFirstFocus || event.getEventTime() - lastWindowStateChangeEventTime > focusDelay; }
Example 6
Source File: WindowTransitionInfo.java From talkback with Apache License 2.0 | 5 votes |
/** * Caches window title and ID from {@link AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} or {@link * AccessibilityEvent#TYPE_WINDOWS_CHANGED} event. * * @param sourceWindow source window of the event matched from {@link * android.accessibilityservice.AccessibilityService#getWindows()}. <b>Note:</b> For alert * dialogs on pre-O devices, if we try to fetch the windowInfo right after we receive the * event, the windowInfo might be null. * @param event An {@link AccessibilityEvent#TYPE_WINDOWS_CHANGED} or {@link * AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED} event with valid window Id. */ public void updateTransitionInfoFromEvent( @Nullable AccessibilityWindowInfo sourceWindow, AccessibilityEvent event) { int windowId = event.getWindowId(); if (windowId == -1) { return; } stateChangedWindows.add(windowId); if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { cacheWindowTitleFromEvent(sourceWindow, event); } }
Example 7
Source File: AutofillManager.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public AccessibilityEvent onAccessibilityEvent(AccessibilityEvent event, boolean accessibilityEnabled, int relevantEventTypes) { final int type = event.getEventType(); if (sVerbose) { // NOTE: this is waaay spammy, but that's life. Log.v(TAG, "onAccessibilityEvent(" + AccessibilityEvent.eventTypeToString(type) + "): virtualId=" + AccessibilityNodeInfo.getVirtualDescendantId(event.getSourceNodeId()) + ", client=" + getClient()); } switch (type) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: { synchronized (mLock) { if (mFocusedWindowId == event.getWindowId() && mFocusedNodeId == event.getSourceNodeId()) { return event; } if (mFocusedWindowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID && mFocusedNodeId != AccessibilityNodeInfo.UNDEFINED_NODE_ID) { notifyViewExited(mFocusedWindowId, mFocusedNodeId); mFocusedWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID; mFocusedNodeId = AccessibilityNodeInfo.UNDEFINED_NODE_ID; mFocusedBounds.set(0, 0, 0, 0); } final int windowId = event.getWindowId(); final long nodeId = event.getSourceNodeId(); if (notifyViewEntered(windowId, nodeId, mFocusedBounds)) { mFocusedWindowId = windowId; mFocusedNodeId = nodeId; } } } break; case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: { synchronized (mLock) { if (mFocusedWindowId == event.getWindowId() && mFocusedNodeId == event.getSourceNodeId()) { notifyValueChanged(event.getWindowId(), event.getSourceNodeId()); } } } break; case AccessibilityEvent.TYPE_VIEW_CLICKED: { synchronized (mLock) { notifyViewClicked(event.getWindowId(), event.getSourceNodeId()); } } break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: { final AutofillClient client = getClient(); if (client != null) { synchronized (mLock) { if (client.autofillClientIsFillUiShowing()) { notifyViewEntered(mFocusedWindowId, mFocusedNodeId, mFocusedBounds); } updateTrackedViewsLocked(); } } } break; } return accessibilityEnabled ? event : null; }
Example 8
Source File: ScrollFeedbackManager.java From talkback with Apache License 2.0 | 4 votes |
public EventId(AccessibilityEvent event) throws InvocationTargetException, IllegalAccessException { this((long) getSourceNodeIdMethod.invoke(event), event.getWindowId()); }
Example 9
Source File: SearchScreenOverlayLayout.java From talkback with Apache License 2.0 | 4 votes |
@Override public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event) { overlayId = event.getWindowId(); return super.requestSendAccessibilityEvent(child, event); }