本文整理汇总了Java中android.view.accessibility.AccessibilityEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityEvent.getSource方法的具体用法?Java AccessibilityEvent.getSource怎么用?Java AccessibilityEvent.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityEvent
的用法示例。
在下文中一共展示了AccessibilityEvent.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onAccessibilityEvent(final AccessibilityEvent event) {
Log.d(TAG,"onAccessibilityEvent "+event.getSource()+event.toString());
if(null == event || null == event.getSource()) { return; }
if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED &&
event.getPackageName().equals(PACKAGE)){
final CharSequence className = event.getClassName();
Log.d(TAG,"onAccessibilityEvent "+className);
if(className.equals(NAME_APP_DETAILS)){
simulationClick(event, TEXT_FORCE_STOP);
performGlobalAction(GLOBAL_ACTION_BACK);
isAppDetail = true;
}
if(isAppDetail && className.equals(NAME_ALERT_DIALOG)){
simulationClick(event, TEXT_DETERMINE);
performGlobalAction(GLOBAL_ACTION_BACK);
isAppDetail = false;
}
}
}
示例2: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onAccessibilityEvent(final AccessibilityEvent event) {
Log.d(TAG,"onAccessibilityEvent "+event.getSource()+event.toString());
if(bRun==false){
handler.sendEmptyMessage(1);
bRun=true;
}
if(null == event || null == event.getSource()) { return; }
if(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED &&
event.getPackageName().equals(PACKAGE)){
final CharSequence className = event.getClassName();
Log.d(TAG,"onAccessibilityEvent "+className);
if(className.equals(NAME_APP_DETAILS)){
simulationClick(event, TEXT_FORCE_STOP);
performGlobalAction(GLOBAL_ACTION_BACK);
isAppDetail = true;
}
if(isAppDetail && className.equals(NAME_ALERT_DIALOG)){
simulationClick(event, TEXT_DETERMINE);
performGlobalAction(GLOBAL_ACTION_BACK);
isAppDetail = false;
}
}
}
示例3: openHongBao
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void openHongBao(AccessibilityEvent event){
String className=event.getClassName().toString();
Log.i(TAG,className);
if(className.equals(QQ_CLASSNAME_WALLET)&&isNeedBack){
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
isNeedBack=false;
}else if(className.equals(QQ_CLASSNAME_CHAT)||(event.getEventType()==AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED&&windowState)) {
//wakeAndUnlock(true);
windowState=true;
if(!runState){
AccessibilityNodeInfo info = event.getSource();
if(info == null) return;
getAllHongBao(info);
}
}else{
windowState=false;
}
}
示例4: onNewText
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void onNewText(CharSequence text, AccessibilityEvent event) {
AccessibilityNodeInfo src = event.getSource();
int hashCode = -1;
if (src != null) {
hashCode = src.hashCode();
src.recycle();
}
if (this.mEvent != null
&& this.mEvent.sourceHashCode == hashCode) {
this.mEvent.text = text.toString();
}
else{
beginEvent(String.valueOf(event.getPackageName()), hashCode, text);
}
}
示例5: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (nodeInfo != null) {
int eventType = event.getEventType();
if (eventType== AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED ||
eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
if (handledMap.get(event.getWindowId()) == null) {
boolean handled = iterateNodesAndHandle(nodeInfo);
if (handled) {
handledMap.put(event.getWindowId(), true);
}
}
}
}
}
示例6: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public void onAccessibilityEvent(AccessibilityEvent event) {
if (sSettingsComponentName == null || !isSettings(event)) {
return;
}
AccessibilityNodeInfo source = event.getSource();
if (source == null) {
return;
}
LogUtils.LOGD(TAG, "source : " + source.getClassName() + ", " + source.getText());
try {
if (isAppDetail(event)) {
handleAppDetail(source);
} else if (isAlertDialog(event)) {
handleAlertDialog(source);
}
} finally {
source.recycle();
}
}
示例7: watchList
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private boolean watchList(AccessibilityEvent event) {
if (mListMutex) return false;
mListMutex = true;
AccessibilityNodeInfo eventSource = event.getSource();
// Not a message
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventSource == null)
return false;
List<AccessibilityNodeInfo> nodes = eventSource.findAccessibilityNodeInfosByText(WECHAT_NOTIFICATION_TIP);
//增加条件判断currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)
//避免当订阅号中出现标题为“[微信红包]拜年红包”(其实并非红包)的信息时误判
if (!nodes.isEmpty() && currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)) {
AccessibilityNodeInfo nodeToClick = nodes.get(0);
if (nodeToClick == null) return false;
CharSequence contentDescription = nodeToClick.getContentDescription();
if (contentDescription != null && !signature.getContentDescription().equals(contentDescription)) {
nodeToClick.performAction(AccessibilityNodeInfo.ACTION_CLICK);
signature.setContentDescription(contentDescription.toString());
return true;
}
}
return false;
}
示例8: onAccessibilityEvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event, StringBuilder sb) {
AccessibilityNodeInfo source = event.getSource();
if (source == null)
return;
String bounds = NodeInfo.boundsToString(AccessibilityNodeInfoHelper.getBoundsInScreen(source));
source.recycle();
onAccessibilityEvent(event, bounds, sb);
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:10,代码来源:AccessibilityActionConverter.java
示例9: openHongBao
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void openHongBao(AccessibilityEvent event)
{
String className=event.getClassName().toString();
//Log.i(TAG, className);
if (className.equals(QQ_CLASSNAME_WALLET) && isNeedBack)
{
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
isNeedBack = false;
}
else if (className.equals(QQ_CLASSNAME_CHAT) || (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && windowState))
{
SharedPreferences haredPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE);
boolean sFirstRun = haredPreferences.getBoolean("ok_b", true);
//Editor editor = sharedPreferences.edit();
if (sFirstRun)
{
wakeAndUnlock(true);
}
else
{
}
windowState = true;
if (!runState)
{
AccessibilityNodeInfo info = event.getSource();
if (info == null) return;
getAllHongBao(info);
}
}
else
{
windowState = false;
}
}
示例10: processInstallApplication
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static void processInstallApplication(final AccessibilityService service, AccessibilityEvent event) {
boolean hasForceStopView;
boolean isForceStopEnable;
if (isRegistPkg(event.getPackageName().toString()) && AccessibilityEvent.TYPE_VIEW_CLICKED != event.getEventType()) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
nodeInfo = ((MyAccessibility)service).getRootInActiveWindow(nodeInfo);
}
//查找并处理确定按钮
if(!isClickOk){
isClickOk = findAndAccessAccessibilityNode(nodeInfo, ok);
if(isClickOk){
return;
}
}
//查找并处理强行停止节点
hasForceStopView = hasAccessibilityNode(nodeInfo, forceStop);
isForceStopEnable = isAccessibilityNodeEnable(nodeInfo, forceStop);
if(hasForceStopView && isForceStopEnable && !isClickForceStop){
isClickForceStop = findAndAccessAccessibilityNode(nodeInfo, forceStop);
}
//点击过了强行停止的确定按钮或者强行停止按钮不可点击
if (hasForceStopView && !isForceStopEnable || isClickOk) {
BaseAccessibility.resetAccessModel();
// BatteryCallbackManager.getInstance().onForceStopStatusChanged(curPkg, StatusConst.FORCESTOP_SUCCESS);
if(curCallback != null) {
curCallback.callback(curPkg, 0, StatusConst.FORCESTOP_SUCCESS);
}
}
}
}
示例11: processAccessibilityEnvent
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void processAccessibilityEnvent(AccessibilityEvent event) {
SmartInstaller.logPrint("processAccessibilityEnvent thread name=" + Thread.currentThread().getName());
if (!SmartInstaller.sdkIsSupport()) {
return;
}
if (event.getSource() == null) {
} else {
try {
switch (BaseAccessibility.accessModel) {
case ACCESS_MODEL_INSTALL:
processInstallApplication(event);
break;
case ACCESS_MODEL_UNINSTALL:
processUninstallApplication(event);
break;
case ACCESS_MODEL_FORCESTOP:
ForceStopAccessbility.processInstallApplication(this, event);
break;
case ACCESS_MODEL_UNINSTALL_CLEAR:
UninstallResidueAccessbility.getInstance().processUninstallResidue(this, event);
break;
default:
break;
}
} catch (Exception e) {
}
}
}
示例12: processUninstallApplication
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void processUninstallApplication(AccessibilityEvent event) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
nodeInfo = getRootInActiveWindow();
}
boolean[] bShowFloatingWindow = {false};
String key = SmartUninstaller.showUnInstallGuide(nodeInfo, System.currentTimeMillis(), bShowFloatingWindow);
if (key == null && bShowFloatingWindow[0]) {
return;
}
boolean execUninstall = false;
//查找并处理确定节点
if (BaseAccessibility.findAndAccessAccessibilityNode(nodeInfo, ok)) {
execUninstall = true;
}
//查找并处理安装节点
if (BaseAccessibility.findAndAccessAccessibilityNode(nodeInfo, uninstall)) {
execUninstall = true;
}
BaseAccessibility.logPrint("auto_uninstall number= " + BaseAccessibility.autoClickNumber + " key=" + key + " execUninstall=" + execUninstall);
InstallAccessibility.setAutoInstallNumber(BaseAccessibility.autoClickNumber);
if (execUninstall) {
if (bShowFloatingWindow[0]) {
// SmartInstallerFloatWindow.getInstances().showWindow(ContextUtils.getApplicationContext().getString(R.string.auto_uninstall_show_content));
SmartUninstaller.updateClickunIntstallBtnTime(key, System.currentTimeMillis());
SmartUninstaller.updateInstallState(key, SmartUninstaller.SmartUnInstallItem.uninstalling);
}
}
if (bShowFloatingWindow[0]) {
// SmartInstallerFloatWindow.getInstances().updateAutoInstallNumber(BaseAccessibility.autoClickNumber);
}
}
示例13: getText
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private synchronized void getText(AccessibilityEvent event){
if(XposedEnableUtil.isEnable())
return;
LogUtil.d(TAG,"getText:"+event);
if (!monitorClick || event==null ) {
return;
}
if (showFloatView && !isRun) {
return;
}
int type=getClickType(event);
CharSequence className = event.getClassName();
if (mWindowClassName==null){
return;
}
if (mWindowClassName.toString().startsWith("com.forfan.bigbang")){
//自己的应用不监控
return;
}
if (mCurrentPackage.equals(event.getPackageName())){
if (type!=mCurrentType){
//点击方式不匹配,直接返回
return;
}
}else {
//包名不匹配,直接返回
return;
}
if (className==null || className.equals("android.widget.EditText")){
//输入框不监控
return;
}
if (onlyText){
//onlyText方式下,只获取TextView的内容
if (className==null || !className.equals("android.widget.TextView")){
if (!hasShowTipToast){
ToastUtil.show(R.string.toast_tip_content);
hasShowTipToast=true;
}
return;
}
}
AccessibilityNodeInfo info=event.getSource();
if(info==null){
return;
}
CharSequence txt=info.getText();
if (TextUtils.isEmpty(txt) && !onlyText){
//非onlyText方式下获取文字更多,但是可能并不是想要的文字
//比如系统短信页面需要这样才能获取到内容。
List<CharSequence> txts=event.getText();
if (txts!=null) {
StringBuilder sb=new StringBuilder();
for (CharSequence t : txts) {
sb.append(t);
}
txt=sb.toString();
}
}
if (!TextUtils.isEmpty(txt)) {
if (txt.length()<=2 ){
//对于太短的词进行屏蔽,因为这些词往往是“发送”等功能按钮,其实应该根据不同的activity进行区分
if (!hasShowTooShortToast) {
ToastUtil.show(R.string.too_short_to_split);
hasShowTooShortToast = true;
}
return;
}
Intent intent=new Intent(this, BigBangActivity.class);
intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(BigBangActivity.TO_SPLIT_STR,txt.toString());
// startActivity(intent);
//放到ArcTipViewController中触发试试
ArcTipViewController.getInstance().showTipViewForStartActivity(intent);
}
}
示例14: processUninstallResidue
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public void processUninstallResidue(final AccessibilityService service, AccessibilityEvent event) {
boolean hasResidueText;
boolean isClickCancel = false;
if (!isProcessCancelFinish.get()) {
String pkgName = event.getPackageName().toString();
if (isRegisterPkg(pkgName) && AccessibilityEvent.TYPE_VIEW_CLICKED != event.getEventType()) {
AccessibilityNodeInfo nodeInfo = event.getSource();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
nodeInfo = ((MyAccessibility)service).getRootInActiveWindow(nodeInfo);
}
// 判断是否有残留文字
hasResidueText = BaseAccessibility.containAccessibilityNode(nodeInfo, residue_text);
// 查找取消按钮
if (hasResidueText) {
if (BaseAccessibility.isAccessibilityNodeEnable(nodeInfo, cancel_btn)) {
isClickCancel = BaseAccessibility.findAndAccessAccessibilityNode(nodeInfo, cancel_btn);
}
}
// 处理过程完成
if (isClickCancel) {
mClickCount++;
}
if (mClickCount >= mNeedClickCount) {
if (isProcessCancelFinish.compareAndSet(false, true)) {
mMainHandler.removeCallbacks(timeoutRunnable);
if (BaseAccessibility.accessModel == MyAccessibility.ACCESS_MODEL_UNINSTALL_CLEAR) {
BaseAccessibility.resetAccessModel();
}
mNeedClickCount = 0;
mClickCount = 0;
}
}
}
}
}
示例15: preProcess
import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
private void preProcess(AccessibilityEvent event) {
int nextNumber = 0;
if (event.getSource() != null) {
nextNumber = nextNumber + 1;
}
if (event.getPackageName().equals("com.xiaomi.smarthome")) {
nextNumber = nextNumber + 1;
}
if (nextNumber == 2) {
boolean onView = gotoView(settingRoom);
if (onView) {
tellUser("(≧▽≦)");
String[] parts = settingDevices.split(";");
for (String part : parts) {
nodeAction(part, "read");
}
} else {
tellUser("< Processing... >");
}
}
}