@Override public void onAccessibilityEvent(AccessibilityEvent event) { int eventType = event.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: for (String id : installBtnId) { AccessibilityNodeInfo node = AccessibilityNodeUtil.findNodeById(event.getSource(), id); if (node != null) { AccessibilityNodeUtil.click(node); Toast.makeText(this, "安装成功", Toast.LENGTH_SHORT).show(); break; } } break; default: break; } }
/** * Update whether or not the current native tab and/or web contents are * currently visible (from an accessibility perspective), or whether * they're obscured by another view. */ public void updateAccessibilityVisibility() { View view = getView(); if (view != null) { int importantForAccessibility = isObscuredByAnotherViewForAccessibility() ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS : View.IMPORTANT_FOR_ACCESSIBILITY_YES; if (view.getImportantForAccessibility() != importantForAccessibility) { view.setImportantForAccessibility(importantForAccessibility); view.sendAccessibilityEvent( AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); } } ContentViewCore cvc = getContentViewCore(); if (cvc != null) { boolean isWebContentObscured = isObscuredByAnotherViewForAccessibility() || isShowingSadTab(); cvc.setObscuredByAnotherView(isWebContentObscured); } }
private void setCurrentActivityName(AccessibilityEvent event) { if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { return; } try { ComponentName componentName = new ComponentName( event.getPackageName().toString(), event.getClassName().toString() ); getPackageManager().getActivityInfo(componentName, 0); currentActivityName = componentName.flattenToShortString(); } catch (PackageManager.NameNotFoundException e) { currentActivityName = WECHAT_LUCKMONEY_GENERAL_ACTIVITY; } }
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { // Dispatch scroll events from this ViewPager. if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) { return super.dispatchPopulateAccessibilityEvent(event); } // Dispatch all other accessibility events from the current page. final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == VISIBLE) { final YViewPagerNew.ItemInfo ii = infoForChild(child); if (ii != null && ii.position == mCurItem && child.dispatchPopulateAccessibilityEvent(event)) { return true; } } } return false; }
/** * 内容改变 * * @param event */ private void contentChange(AccessibilityEvent event) { AccessibilityNodeInfo root = getRootInActiveWindow(); if (root == null) { return; } if (WechatVersionUtils.canFindViewById(context) && WechatVersionUtils.canRobWechatVersion(context)) { List<AccessibilityNodeInfo> exitNodeInfos = root.findAccessibilityNodeInfosByViewId(WechatVersionUtils.getWechatExitId(context)); if (exitNodeInfos != null && exitNodeInfos.size() > 0) { // 是聊天界面 if (isWechatAlway) { } } else { isWechatAlway = false; } } }
public void autoChat(AccessibilityEvent event, AccessibilityNodeInfo node,WeixinAutoService context,Map<String,String> record){ int eventType = event.getEventType(); //1、消息列表获取信息头像 List<AccessibilityNodeInfo> msgNumImages= node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/i4"); if(msgNumImages!=null&&msgNumImages.size()>0){ AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(context.getRootInActiveWindow(),"com.tencent.mm:id/afv","杰"),record,"杰",1000); sendMsg(context.getRootInActiveWindow(),context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(context.getRootInActiveWindow(),"com.tencent.mm:id/afv","LSan"),record,"LSan",1000); sendMsg(context.getRootInActiveWindow(),context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","华"),record,"华",1000); sendMsg(node,context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","Aoo"),record,"Aoo",1000); sendMsg(node,context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","曼婷"),record,"Aoo",1000); sendMsg(node,context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","苏苏"),record,"Aoo",1000); sendMsg(node,context,record); AutoUtil.performClick(AutoUtil.fineNodeByIdAndText(node,"com.tencent.mm:id/afv","zh琪"),record,"Aoo",1000); sendMsg(node,context,record); } }
void dispatchOnDrawerOpened(View drawerView) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); if (!lp.knownOpen) { lp.knownOpen = true; if (mListener != null) { mListener.onDrawerOpened(drawerView); } updateChildrenImportantForAccessibility(drawerView, true); // Only send WINDOW_STATE_CHANGE if the host has window focus. if (hasWindowFocus()) { sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } drawerView.requestFocus(); } }
@TargetApi(16) @Override public boolean performAccessibilityAction(int action, Bundle args) { if (super.performAccessibilityAction(action, args)) { return true; } if (duration <= 0) { return false; } if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) { if (scrubIncrementally(-getPositionIncrement())) { stopScrubbing(false); } } else if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) { if (scrubIncrementally(getPositionIncrement())) { stopScrubbing(false); } } else { return false; } sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); return true; }
@Override public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { super.onInitializeAccessibilityEvent(host, event); event.setClassName(DirectionalViewpager.class.getName()); AccessibilityRecordCompat recordCompat = null; if (isHorizontal()) { recordCompat = AccessibilityEventCompat.asRecord(event); } else { recordCompat = AccessibilityRecordCompat.obtain(); } recordCompat.setScrollable(canScroll()); if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED && mAdapter != null) { recordCompat.setItemCount(mAdapter.getCount()); recordCompat.setFromIndex(mCurItem); recordCompat.setToIndex(mCurItem); } }
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { event.setClassName(getClass().getName()); event.setPackageName(getPackageName()); LayoutParams params = getWindow().getAttributes(); boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT); event.setFullScreen(isFullScreen); CharSequence title = getTitle(); if (!TextUtils.isEmpty(title)) { event.getText().add(title); } return true; }
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { // Dispatch scroll events from this ViewPager. if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) { return super.dispatchPopulateAccessibilityEvent(event); } // Dispatch all other accessibility events from the current page. final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == VISIBLE) { final ItemInfo ii = infoForChild(child); if (ii != null && ii.position == mCurItem && child.dispatchPopulateAccessibilityEvent(event)) { return true; } } } return false; }
private void sendScrollAccessibilityEvent() { AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); if (am.isEnabled()) { if (mCurrentPage != getNextPage()) { AccessibilityEvent ev = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED); ev.setScrollable(true); ev.setScrollX(getScrollX()); ev.setScrollY(getScrollY()); ev.setMaxScrollX(mMaxScrollX); ev.setMaxScrollY(0); sendAccessibilityEventUnchecked(ev); } } }
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { final boolean result = super.dispatchPopulateAccessibilityEvent(event); final List<CharSequence> text = event.getText(); text.clear(); // Populate event with a fake title based on the current state. if (mState == State.APPS) { text.add(getString(R.string.all_apps_button_label)); } else if (mState == State.WIDGETS) { text.add(getString(R.string.widget_button_text)); } else if (mWorkspace != null) { text.add(mWorkspace.getCurrentPageDescription()); } else { text.add(getString(R.string.all_apps_home_button_label)); } return result; }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (getChildCount() > 0) { final AccessibilityRecordCompat record = AccessibilityEventCompat .asRecord(event); final View start = findFirstVisibleItemClosestToStart(false, true); final View end = findFirstVisibleItemClosestToEnd(false, true); if (start == null || end == null) { return; } final int startPos = getPosition(start); final int endPos = getPosition(end); if (startPos < endPos) { record.setFromIndex(startPos); record.setToIndex(endPos); } else { record.setFromIndex(endPos); record.setToIndex(startPos); } } }
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { boolean populated = false; if (event.getEventType() == 8) { event.setEventType(4); } View selectedView = getSelectedView(); if (selectedView != null) { populated = selectedView.dispatchPopulateAccessibilityEvent(event); } if (!populated) { if (selectedView != null) { event.setEnabled(selectedView.isEnabled()); } event.setItemCount(getCount()); event.setCurrentItemIndex(getSelectedItemPosition()); } return populated; }
@Override public void onAccessibilityEvent(AccessibilityEvent event) { SharedPreferences settings = getSharedPreferences(data, 0); settingRoom = settings.getString(settingRoomField, ""); settingDevices = settings.getString(settingDevicesField, ""); if (settingRoom.equals("") || settingDevices.equals("")) { tellUser("配置檔不完整"); return; } int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { preProcess(event); Log.i(TAG, "onAccessibilityEvent"); } }
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (getChildCount() > 0) { AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); View start = findFirstVisibleItemClosestToStart(false, true); View end = findFirstVisibleItemClosestToEnd(false, true); if (start != null && end != null) { int startPos = getPosition(start); int endPos = getPosition(end); if (startPos < endPos) { record.setFromIndex(startPos); record.setToIndex(endPos); return; } record.setFromIndex(endPos); record.setToIndex(startPos); } } }
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { // Dispatch scroll events from this ViewPager. if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) { return super.dispatchPopulateAccessibilityEvent(event); } // Dispatch all other accessibility events from the current page. final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == VISIBLE) { final YViewPagerOrigin.ItemInfo ii = infoForChild(child); if (ii != null && ii.position == mCurItem && child.dispatchPopulateAccessibilityEvent(event)) { return true; } } } return false; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void openHongBao(AccessibilityEvent event) { CharSequence className = event.getClassName(); checkScreen(getApplicationContext()); if ("com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyReceiveUI".equals(className)) { // 点中了红包,下一步就是去拆红包 checkKey1(); } else if ("com.tencent.mm.ui.LauncherUI".equals(className) || "com.tencent.mobileqq.activity.ChatActivity".equals(className)) { // 在聊天界面,去点中红包 checkKey2(); } else { // 在聊天界面,去点中红包 checkKey2(); } }
/** */ @Override @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(GridViewWidget.class.getName()); }
public void autoFetchFrData(AccessibilityEvent event, AccessibilityNodeInfo node,WeixinAutoService context,Map<String,String> record){ if(node==null){ LogUtil.d("autoFetchFrData","node 为空;"); node = context.getRootInActiveWindow(); return; } Set<String> set = new HashSet<String>(); //if(node.getChildCount()>0){ List<AccessibilityNodeInfo> items = new ArrayList<AccessibilityNodeInfo>(); List<AccessibilityNodeInfo> items0 = node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/b66"); List<AccessibilityNodeInfo> items1 = node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/mo"); if(items0==null&&items1==null){ LogUtil.d("autoFetchFrData","列表数据为空");return;} items.addAll(items0); items.addAll(items1); if(items!=null&&items.size()>0){ for(AccessibilityNodeInfo item:items){ String text = item.getText().toString(); set.add(text); if(isExist(strs,text)){ System.out.println("重复---->"+text); }else{ LogUtil.d("autoFetchFrData",text); } } } // } int waitTimes = 4000+(int) (Math.random()*1200); AutoUtil.sleep(waitTimes); AccessibilityNodeInfo nodeInfo2 = AutoUtil.findNodeInfosById(node,"com.tencent.mm:id/csl");//listView if(nodeInfo2!=null){ nodeInfo2.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); } }
@TargetApi(14) public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { if (!super.onRequestSendAccessibilityEvent(child, event)) { return false; } AccessibilityEvent record = AccessibilityEvent.obtain(); onInitializeAccessibilityEvent(record); child.dispatchPopulateAccessibilityEvent(record); event.appendRecord(record); return true; }
@Override public void sendAccessibilityEventUnchecked(AccessibilityEvent event) { if (shouldDeferAccessibilityEvent(event)) { return; } super.sendAccessibilityEventUnchecked(event); }
@Override public void onAccessibilityEvent(AccessibilityEvent event) { //虚拟手机按键处理,优先级高于是否点击分词的判断 if ((event.getEventType() == TYPE_VIEW_LONG_CLICKED) && ("com.android.systemui".equals(event.getPackageName()))) { if (TextUtils.isEmpty(event.getContentDescription())){ return; } //长按虚拟机触发的,需要转到按键处理去 if (!TextUtils.isEmpty(back) && event.getContentDescription().equals(back)){ KeyPressedTipViewController.getInstance().onKeyLongPress(KeyEvent.KEYCODE_BACK); }else if (!TextUtils.isEmpty(home) && event.getContentDescription().equals(home)){ KeyPressedTipViewController.getInstance().onKeyLongPress(KeyEvent.KEYCODE_HOME); }else if (!TextUtils.isEmpty(recent) && event.getContentDescription().equals(recent)){ KeyPressedTipViewController.getInstance().onKeyLongPress(KeyEvent.KEYCODE_APP_SWITCH); } } if (!isRun){ return; } LogUtil.d(TAG,"onAccessibilityEvent:"+event); int type=event.getEventType(); switch (type){ case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: mWindowClassName = event.getClassName(); mCurrentPackage = event.getPackageName()==null?"":event.getPackageName().toString(); Integer selectType=selections.get(mCurrentPackage); mCurrentType = selectType==null?TYPE_VIEW_NONE:(selectType+1); if ("com.tencent.mm.plugin.sns.ui.SnsTimeLineUI".equals(mWindowClassName)){ setCapabilities(true); }else { setCapabilities(false); } break; case TYPE_VIEW_CLICKED: case TYPE_VIEW_LONG_CLICKED: getText(event); break; } }
@Override public boolean dispatchPopulateAccessibilityEvent( AccessibilityEvent event ) { View selectedView = getSelectedView(); if ( selectedView != null && selectedView.getVisibility() == VISIBLE && selectedView.dispatchPopulateAccessibilityEvent( event ) ) { return true; } return false; }
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (getChildCount() > 0) { AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); record.setFromIndex(findFirstVisibleItemPosition()); record.setToIndex(findLastVisibleItemPosition()); } }
@Override public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { super.onInitializeAccessibilityEvent(host, event); event.setClassName(ViewPager.class.getName()); final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain(); recordCompat.setScrollable(canScroll()); if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED && mAdapter != null) { recordCompat.setItemCount(mAdapter.getCount()); recordCompat.setFromIndex(mCurItem); recordCompat.setToIndex(mCurItem); } }
public boolean requestSendAccessibilityEvent(ViewParent parent, View child, AccessibilityEvent event) { if (child == null) { return false; } ((AccessibilityManager) child.getContext().getSystemService("accessibility")).sendAccessibilityEvent(event); return true; }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(isScrollableForAccessibility()); View selectedView = getSelectedView(); if (selectedView != null) { event.setEnabled(selectedView.isEnabled()); } event.setCurrentItemIndex(getSelectedItemPosition()); event.setFromIndex(getFirstVisiblePosition()); event.setToIndex(getLastVisiblePosition()); event.setItemCount(getCount()); }
private void onViewFocused(AccessibilityEvent event, AccessibilityNodeInfo rootNode) { if(mEvent != null && event != null) { // Store Text Input. AccEvent accEvent = new AccEvent(event, rootNode); accEvent.setFieldValue(AccEvent.TEXT, mEvent.text); this.output(accEvent); } this.mEvent = null; }
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { super.onInitializeAccessibilityEvent(host, event); event.setClassName(ViewPager.class.getName()); AccessibilityRecordCompat recordCompat = AccessibilityEventCompat.asRecord(event); recordCompat.setScrollable(canScroll()); if (event.getEventType() == 4096 && ViewPager.this.mAdapter != null) { recordCompat.setItemCount(ViewPager.this.mAdapter.getCount()); recordCompat.setFromIndex(ViewPager.this.mCurItem); recordCompat.setToIndex(ViewPager.this.mCurItem); } }
private void dispatchContentChangedIfNecessary() { int flags = this.mEatenAccessibilityChangeFlags; this.mEatenAccessibilityChangeFlags = 0; if (flags != 0 && isAccessibilityEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(); event.setEventType(2048); AccessibilityEventCompat.setContentChangeTypes(event, flags); sendAccessibilityEventUnchecked(event); } }
@Override public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { int eventType = accessibilityEvent.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: if (mForceStopManager.isForceStopRequested()) { mForceStopManager.onAccessibilityEvent(accessibilityEvent); } break; } }
private void sendAccessibilityEventForVirtualText(int eventType) { if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(eventType); mInputText.onInitializeAccessibilityEvent(event); mInputText.onPopulateAccessibilityEvent(event); event.setSource(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT); requestSendAccessibilityEvent(NumberPicker.this, event); } }
private void onTimeChanged() { mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); if (mOnTimeChangedListener != null) { mOnTimeChangedListener.onTimeChanged(mDelegator, getHour(), getMinute()); } if (mAutoFillChangeListener != null) { mAutoFillChangeListener.onTimeChanged(mDelegator, getHour(), getMinute()); } }
public boolean onRequestSendAccessibilityEvent(View paramView, AccessibilityEvent paramAccessibilityEvent) { if (super.onRequestSendAccessibilityEvent(paramView, paramAccessibilityEvent)) { AccessibilityEvent localAccessibilityEvent = AccessibilityEvent.obtain(); onInitializeAccessibilityEvent(localAccessibilityEvent); paramView.dispatchPopulateAccessibilityEvent(localAccessibilityEvent); paramAccessibilityEvent.appendRecord(localAccessibilityEvent); return true; } return false; }
AccEvent(AccessibilityEvent accessibilityEvent, AccessibilityNodeInfo rootNode) { this.setFieldValue(EVENT, accessibilityEvent); this.setFieldValue(EVENT_TIME, accessibilityEvent.getEventTime()); this.setFieldValue(ROOT_NODE, rootNode); this.setFieldValue(EVENT_TYPE, accessibilityEvent.getEventType()); CharSequence charSequence = accessibilityEvent.getPackageName(); String packageName = charSequence == null ? "" : charSequence.toString(); this.setFieldValue(PACKAGE_NAME, packageName); }
/** */ @Override @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(FrameLayoutWidget.class.getName()); }
private AccessibilityEvent createEvent(int virtualViewId, int eventType) { switch (virtualViewId) { case -1: return createEventForHost(eventType); default: return createEventForChild(virtualViewId, eventType); } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (getChildCount() > 0) { final AccessibilityRecordCompat record = AccessibilityEventCompat .asRecord(event); record.setFromIndex(findFirstVisibleItemPosition()); record.setToIndex(findLastVisibleItemPosition()); } }