Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED
The following examples show how to use
android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED .
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: RadioPreference.java From Noyze with Apache License 2.0 | 7 votes |
@Override protected void onBindView(View view) { super.onBindView(view); View checkboxView = view.findViewById(android.R.id.checkbox); if (checkboxView != null && checkboxView instanceof Checkable) { ((Checkable) checkboxView).setChecked(mChecked); if (mSendAccessibilityEventViewClickedType && mAccessibilityManager.isEnabled() && checkboxView.isEnabled()) { mSendAccessibilityEventViewClickedType = false; int eventType = AccessibilityEvent.TYPE_VIEW_CLICKED; checkboxView.sendAccessibilityEventUnchecked(AccessibilityEvent.obtain(eventType)); } } }
Example 2
Source File: RadioPreference.java From Noyze with Apache License 2.0 | 6 votes |
@Override protected void onBindView(View view) { super.onBindView(view); View checkboxView = view.findViewById(android.R.id.checkbox); if (checkboxView != null && checkboxView instanceof Checkable) { ((Checkable) checkboxView).setChecked(mChecked); if (mSendAccessibilityEventViewClickedType && mAccessibilityManager.isEnabled() && checkboxView.isEnabled()) { mSendAccessibilityEventViewClickedType = false; int eventType = AccessibilityEvent.TYPE_VIEW_CLICKED; checkboxView.sendAccessibilityEventUnchecked(AccessibilityEvent.obtain(eventType)); } } }
Example 3
Source File: OversecAccessibilityService.java From oversec with GNU General Public License v3.0 | 6 votes |
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 4
Source File: ViewDelegate.java From android_viewtracker with Apache License 2.0 | 5 votes |
public void sendAccessibilityEvent(View clickView, int eventType) { TrackerLog.d("eventType: " + eventType); if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED) { TrackerLog.d("click: " + clickView); DataProcess.processClickParams(commonInfo, clickView); } super.sendAccessibilityEvent(clickView, eventType); }
Example 5
Source File: CallSwipeView.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent ev) { if (isEnabled() && ev.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) { listener.onDragComplete(); } super.onPopulateAccessibilityEvent(ev); }
Example 6
Source File: CallSwipeView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent ev) { if (isEnabled() && ev.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) { listener.onDragComplete(); } super.onPopulateAccessibilityEvent(ev); }
Example 7
Source File: GridItemExercise.java From talkback with Apache License 2.0 | 5 votes |
@Override public void sendAccessibilityEvent(View host, int eventType) { super.sendAccessibilityEvent(host, eventType); if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { onAccessibilityFocused(index); } else if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED) { onAccessibilityClicked(index); } }
Example 8
Source File: AccessibilityEventUtils.java From talkback with Apache License 2.0 | 5 votes |
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 9
Source File: MainService.java From Anti-recall with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { try { if (event.getPackageName() == null) { Log.d(TAG, "onAccessibilityEvent: package name is null, return"); return; } packageName = event.getPackageName() + ""; // if (!(packageName.equals(pkgTim) || packageName.equals(pkgQQ) || packageName.equals(pkgWX))) // return; // NodesInfo.show(event.getSource(), TAG, "d"); // NodesInfo.show(root, TAG, "d"); int eventType = event.getEventType(); if (eventType != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { Log.w(TAG, AccessibilityEvent.eventTypeToString(eventType)); } else Log.v(TAG, AccessibilityEvent.eventTypeToString(eventType)); switch (eventType) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: onNotification(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: autoLoginWX(); onContentChanged(event); break; case AccessibilityEvent.TYPE_VIEW_CLICKED: onClick(event); break; } } catch (Exception e) { e.printStackTrace(); } }
Example 10
Source File: UIActionProvider.java From PrivacyStreams with Apache License 2.0 | 5 votes |
public void handleAccessibilityEvent(AccessibilityEvent event, AccessibilityNodeInfo rootNode){ int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED || eventType == AccessibilityEvent.TYPE_VIEW_LONG_CLICKED || eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED || eventType == AccessibilityEvent.TYPE_VIEW_SELECTED) { AccEvent accEvent = new AccEvent(event, rootNode); accEvent.setFieldValue(AccEvent.SOURCE_NODE, event.getSource()); this.output(accEvent); } }
Example 11
Source File: ViewClickedEventListener.java From Tracker with MIT License | 5 votes |
@Override public void sendAccessibilityEvent(View host, int eventType) { super.sendAccessibilityEvent(host, eventType); if (AccessibilityEvent.TYPE_VIEW_CLICKED == eventType && host != null) { Tracker.getInstance().addClickEvent(host, (Fragment) host.getTag(FRAGMENT_TAG_KEY)); } }
Example 12
Source File: AutofillManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public int getRelevantEventTypes(int relevantEventTypes) { return relevantEventTypes | AccessibilityEvent.TYPE_VIEW_FOCUSED | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED | AccessibilityEvent.TYPE_VIEW_CLICKED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED; }
Example 13
Source File: EditProtocol.java From ans-android-sdk with GNU General Public License v3.0 | 4 votes |
public BaseViewVisitor readEventBinding(JSONObject source, BaseViewVisitor.OnEventListener listener) throws BadInstructionsException { try { final String eventID = source.getString("event_id"); final String eventType = source.getString("event_type"); String matchType = null; if (source.has("match_text")) { matchType = source.getString("match_text"); if (InternalAgent.isEmpty(matchType)) { matchType = null; } } final JSONArray pathDesc = source.getJSONArray("path"); final List<Pathfinder.PathElement> path = readPath(pathDesc, mResourceIds); if (path.size() == 0) { throw new InapplicableInstructionsException("event '" + eventID + "' will not " + "be bound to any element in the UI."); } if ("click".equals(eventType)) { return new BaseViewVisitor.AddAccessibilityEventVisitor( path, AccessibilityEvent.TYPE_VIEW_CLICKED, eventID, matchType, listener ); } else if ("selected".equals(eventType)) { return new BaseViewVisitor.AddAccessibilityEventVisitor( path, AccessibilityEvent.TYPE_VIEW_SELECTED, eventID, matchType, listener ); } else if ("text_changed".equals(eventType)) { return new BaseViewVisitor.AddTextChangeListener(path, eventID, matchType, listener); } else if ("detected".equals(eventType)) { return new BaseViewVisitor.ViewDetectorVisitor(path, eventID, matchType, listener); } else { throw new BadInstructionsException("can't track event type \"" + eventType + "\""); } } catch (final JSONException e) { throw new BadInstructionsException("Can't interpret instructions due to " + "JSONException", e); } }
Example 14
Source File: AccessibilityEventUtils.java From talkback with Apache License 2.0 | 4 votes |
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 15
Source File: TimeCatMonitorService.java From timecat with Apache License 2.0 | 4 votes |
@Override public void onCreate() { super.onCreate(); back = getVirtualNavigationKey(this, "accessibility_back", "com.android.systemui", ""); home = getVirtualNavigationKey(this, "accessibility_home", "com.android.systemui", ""); recent = getVirtualNavigationKey(this, "accessibility_recent", "com.android.systemui", ""); readSettingFromSp(); ArcTipViewController.getInstance().addActionListener(actionListener); mRunningTaskUtil = new RunningTaskUtil(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.BROADCAST_TIMECAT_MONITOR_SERVICE_MODIFIED); intentFilter.addAction(Constants.REFRESH_WHITE_LIST_BROADCAST); intentFilter.addAction(Constants.FLOAT_REFRESH_WHITE_LIST_BROADCAST); intentFilter.addAction(Constants.UNIVERSAL_COPY_BROADCAST); intentFilter.addAction(Constants.UNIVERSAL_COPY_BROADCAST_DELAY); intentFilter.addAction(Constants.SCREEN_CAPTURE_OVER_BROADCAST); intentFilter.addAction(Constants.EFFECT_AFTER_REBOOT_BROADCAST); intentFilter.addAction(Constants.MONITOR_CLICK_BROADCAST); registerReceiver(timeCatBroadcastReceiver, intentFilter); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mScreenReceiver, filter); handler = new Handler(); handler.post(new Runnable() { @Override public void run() { try { startService(new Intent(TimeCatMonitorService.this, ListenClipboardService.class)); if (showFloatView) { String packageName; if (!TextUtils.isEmpty(mCurrentPackage)) { packageName = mCurrentPackage; } else { ComponentName task = mRunningTaskUtil.getTopActivtyFromLolipopOnwards(); packageName = task.getPackageName(); } if (floatWhiteList != null && floatWhiteList.contains(packageName)) { ArcTipViewController.getInstance().remove(); } else { if (ArcTipViewController.getInstance().isRemoved()) { ArcTipViewController.getInstance().showHideFloatImageView(); } else { ArcTipViewController.getInstance().show(); } } } keepAccessibilityOpen(); } catch (Throwable e) { e.printStackTrace(); } handler.postDelayed(this, 3000); } }); mAccessibilityServiceInfo = new AccessibilityServiceInfo(); mAccessibilityServiceInfo.feedbackType = FEEDBACK_GENERIC; mAccessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED | AccessibilityEvent.TYPE_VIEW_LONG_CLICKED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; int flag = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { flag = flag | AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { flag = flag | AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS; } mAccessibilityServiceInfo.flags = flag; mAccessibilityServiceInfo.notificationTimeout = 100; setServiceInfo(mAccessibilityServiceInfo); readWhiteList(); readFloatWhiteList(); keepAccessibilityOpen(); }
Example 16
Source File: AccessibilityUtils.java From DevUtils with Apache License 2.0 | 4 votes |
/** * 打印 AccessibilityEvent 信息日志 * @param event {@link AccessibilityEvent} * @param tag 日志 TAG */ public static void printAccessibilityEvent(final AccessibilityEvent event, final String tag) { if (event == null || !LogPrintUtils.isPrintLog()) return; StringBuilder builder = new StringBuilder(); builder.append("========================="); builder.append(NEW_LINE_STR); int eventType = event.getEventType(); // 事件类型 builder.append("packageName: " + event.getPackageName() + ""); // 响应事件的应用包名 builder.append(NEW_LINE_STR); builder.append("source: " + event.getSource() + ""); // 事件源信息 builder.append(NEW_LINE_STR); builder.append("source class: " + event.getClassName() + ""); // 事件源的类名, 如 android.widget.TextView builder.append(NEW_LINE_STR); builder.append("event type(int): " + eventType + ""); builder.append(NEW_LINE_STR); switch (eventType) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件 builder.append("event type: TYPE_NOTIFICATION_STATE_CHANGED"); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // 窗体状态改变 builder.append("event type: TYPE_WINDOW_STATE_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: // View 获取到焦点 builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED"); break; case AccessibilityEvent.TYPE_GESTURE_DETECTION_START: builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED"); break; case AccessibilityEvent.TYPE_GESTURE_DETECTION_END: builder.append("event type: TYPE_GESTURE_DETECTION_END"); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: builder.append("event type: TYPE_WINDOW_CONTENT_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_CLICKED: builder.append("event type: TYPE_VIEW_CLICKED"); break; case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: builder.append("event type: TYPE_VIEW_TEXT_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: builder.append("event type: TYPE_VIEW_SCROLLED"); break; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: builder.append("event type: TYPE_VIEW_TEXT_SELECTION_CHANGED"); break; } builder.append(NEW_LINE_STR); for (CharSequence txt : event.getText()) { // 输出当前事件包含的文本信息 builder.append("text: " + txt); builder.append(NEW_LINE_STR); } builder.append("========================="); // 打印日志 LogPrintUtils.dTag(tag, builder.toString()); }
Example 17
Source File: WechatAccService.java From RedEnvelopeAssistant with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event == null) return; if(SettingHelper.getREAutoMode()){ handleNotificationChange(event); } AccessibilityNodeInfo nodeInfo = event.getSource(); if (nodeInfo == null) { return; } AccessibilityNodeInfo rowNode = nodeInfo;// we can also use getRootInActiveWindow() instead; if (rowNode == null) { log( "noteInfo is null"); return; } LogUtil.d("eventtype:" + event.getEventType()); // String currentActivityName = // ActivityHelper.getTopActivityName(RedEnvelopeApplication.getInstance()); if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED) { // if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { CharSequence currentClassName = event.getClassName(); LogUtil.d("currentClassName:" + currentClassName); if ("com.tencent.mm.ui.LauncherUI".equals(currentClassName) || "com.tencent.mm.ui.chatting.ChattingUI".equals(currentClassName)) { // 聊天以及主页 chat page and the main page LogUtil.d("Chat page"); if (SettingHelper.getREAutoMode()) { handleChatPage(rowNode); } } else if ("com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyReceiveUI".equals(currentClassName)) { //打开红包主页 red envelope open page LogUtil.d("LuckyMoneyReceiveUI page"); if (SettingHelper.getREAutoMode() || SettingHelper.getRESafeMode()){ handleLuckyMoneyReceivePage(rowNode); if(SettingHelper.isRESound()){ ((RedEnvelopeApplication) RedEnvelopeApplication .getInstance()).getSoundHelper() .playSoundRedEnvelopeComing(); } } } else if ("com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyDetailUI".equals(currentClassName)) { // 红包详情主页 red envelope detail page LogUtil.d("red envelope detail page"); if (SettingHelper.getREAutoMode()){ handleLuckyMoneyDetailPage(rowNode); } } else { log( currentClassName + " page"); } } }
Example 18
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 19
Source File: ResponseTools.java From SoloPi with Apache License 2.0 | 4 votes |
@Subscriber(@Param(value = Constant.EVENT_ACCESSIBILITY_EVENT, sticky = false)) public void receiveAccessibilityEvent(UniversalEventBean eventBean) { long sendTime = System.currentTimeMillis(); if (eventBean == null) { LogUtil.e(TAG, "收到空EventBean"); return; } else if (eventBean.getParam(Constant.KEY_ACCESSIBILITY_TYPE) == null) { LogUtil.e(TAG, "收到的EventBean不包含AccessibilityType信息,无法处理,%s", eventBean); return; } if (!StringUtil.equals((String) eventBean.getParam(Constant.KEY_ACCESSIBILITY_SOURCE), app)) { LogUtil.d(TAG, "收到其他来源:%s", eventBean.getParam(Constant.KEY_ACCESSIBILITY_SOURCE)); return; } LogUtil.d(TAG, "收到辅助功能事件, %s", eventBean); switch ((Integer) eventBean.getParam(Constant.KEY_ACCESSIBILITY_TYPE)) { case AccessibilityEvent.TYPE_VIEW_CLICKED: processClickEvent(eventBean.getTime()); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: processContentChange(eventBean.getTime()); break; default: return; } // 获取节点文案 AccessibilityNodeInfo node = eventBean.getParam(Constant.KEY_ACCESSIBILITY_NODE); String text = ""; if (node != null) { text = StringUtil.toString(node.getText()); } if (responseList != null && refreshList != null) { LogUtil.d(TAG, "响应: [%d::%d]", eventResponse.getResponsDate() - eventResponse.getClickDate(), eventResponse.getRefreshDate() - eventResponse.getClickDate()); // 响应时间,从点击到第一次窗口变化的时间间隔 responseList.add(new RecordPattern.RecordItem(sendTime, (float) (eventResponse.getResponsDate() - eventResponse.getClickDate()), text + eventResponse.getOperation())); // 刷新时间,从点击到最后一次窗口变化的时间间隔 refreshList.add(new RecordPattern.RecordItem(sendTime, (float) (eventResponse.getRefreshDate() - eventResponse.getClickDate()), text + eventResponse.getOperation())); } }