Java Code Examples for android.accessibilityservice.AccessibilityService

The following are top voted examples for showing how to use android.accessibilityservice.AccessibilityService. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: https-github.com-hyb1996-NoRootScriptDroid   File: NotificationListener.java   View source code 6 votes vote down vote up
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
    if (event.getParcelableData() instanceof Notification) {
        Notification notification = (Notification) event.getParcelableData();
        Log.d(TAG, "onNotification: " + notification + "; " + event);
        onNotification(event, notification);
    } else {
        List<CharSequence> list = event.getText();
        Log.d(TAG, "onNotification: " + list + "; " + event);
        if (event.getPackageName().equals(mContext.getPackageName())) {
            return false;
        }
        if (list != null) {
            onNotification(event, new NotificationInfo(event.getPackageName(), list));
        }
    }
    return false;
}
 
Example 2
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityServiceUtils.java   View source code 6 votes vote down vote up
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    ComponentName expectedComponentName = new ComponentName(context, accessibilityService);

    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null)
        return false;

    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);

    while (colonSplitter.hasNext()) {
        String componentNameString = colonSplitter.next();
        ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);

        if (enabledService != null && enabledService.equals(expectedComponentName))
            return true;
    }

    return false;
}
 
Example 3
Project: Android_AutoSignInTool   File: autoSignInSMZDM.java   View source code 6 votes vote down vote up
public void doSMZDM(AccessibilityService service) {
    autoLock.lock();
    try {
        delay(8000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(4000);
        Utils.reLaunch(service, SMZDM);
        delay(4000);
        iteratorSMZDM(service.getRootInActiveWindow());
        autoCondition.await(10, TimeUnit.SECONDS); // 10s

        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(2000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(2000);
    } catch (Exception e) {
        e.printStackTrace();
    }
    autoLock.unlock();
    MainPage.condition.signal();
}
 
Example 4
Project: Android_AutoSignInTool   File: autoSignInTXDM.java   View source code 6 votes vote down vote up
public void doTXDM(AccessibilityService service) {
    autoLock.lock();
    try {
        delay(6000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(4000);
        Utils.reLaunch(service, TXDM);
        delay(4000);
        iteratorTXDM(service.getRootInActiveWindow(), service);
        delay(1000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(2000);
    } catch (Exception e) {
        e.printStackTrace();
    }
    autoLock.unlock();
    MainPage.condition.signal();
}
 
Example 5
Project: Android_AutoSignInTool   File: autoSignInTXDM.java   View source code 6 votes vote down vote up
private void iterator(AccessibilityNodeInfo info, AccessibilityService service) {
    if (info.getText() != null) {
        if (info.getText().equals("签到") && info.isClickable()) {
            info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            delay(3000);
            iterator(service.getRootInActiveWindow(), service);
            found = true;
            return;
        }
    } else {
        for (int i = 0; i < info.getChildCount(); i++) {
            if(info.getChild(i)!=null){
                if (found) {
                    found = false;
                    break;
                }
                iterator(info.getChild(i), service);
            }
        }
    }
    return ;
}
 
Example 6
Project: Android_AutoSignInTool   File: autoSignInTXDM.java   View source code 6 votes vote down vote up
private void iteratorTXDM(AccessibilityNodeInfo info, AccessibilityService service) {
    List<AccessibilityNodeInfo> node  = info.findAccessibilityNodeInfosByViewId("com.qq.ac.android:id/tab_layout_center");
    if (node != null) {
        AccessibilityNodeInfo find = node.get(0);
        if ("android.widget.RelativeLayout".equals(find.getClassName())
                && find.isClickable()) {
            find.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            delay(3000);
            iterator(service.getRootInActiveWindow(), service);
            found = true;
            return;
        }

    } else {
        for (int i = 0; i < info.getChildCount(); i++) {
            if(info.getChild(i)!=null){
                if (found) {
                    found = false;
                    break;
                }
                iteratorTXDM(info.getChild(i), service);
            }
        }
    }
    return ;
}
 
Example 7
Project: mtoolbox   File: HongBaoService.java   View source code 6 votes vote down vote up
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;
	}
}
 
Example 8
Project: pc-android-controller-android   File: AccessUtil.java   View source code 6 votes vote down vote up
/**
 * 返回事件
 */
public static void performBack(final AccessibilityService service, AccessibilityNodeInfo nodeInfo) {
    CharSequence packageName = nodeInfo.getPackageName();
    if (!(packageName+"").equals(WECHAT_PACKAGE_NAME)) {
        L.d("不是微信,不能后退 " + packageName);
        return;
    }
    if (service == null) {
        L.e("performBackWithDelay service is null");
        return;
    }
    if (service.getRootInActiveWindow() == null) {
        L.e("performBackWithDelay rootNode is null");
        return;
    }
    L.d("performBack Reboot ");
    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
}
 
Example 9
Project: pc-android-controller-android   File: AccessUtil.java   View source code 6 votes vote down vote up
public static void inputText(Context context, AccessibilityService service, AccessibilityNodeInfo nodeInfo,
                                 final String hello) {
        //找到当前获取焦点的view
//        AccessibilityNodeInfo target = nodeInfo.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
        AccessUtil.findNodeInfosByName(nodeInfo, "android.widget.EditText");
        AccessibilityNodeInfo target = editText;
        if (target == null) {
            L.d("inputHello: null");

            return;
        } else {
            L.d("inputHello: not null " + target.getText());
        }
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("message", hello);
        clipboard.setPrimaryClip(clip);
        L.d("设置粘贴板");
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
//            target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
//        }
        target.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
        L.d("获取焦点");
        target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
        L.d("粘贴内容");
//        openNext2("发送", nodeInfo, service);//点击发送
    }
 
Example 10
Project: pc-android-controller-android   File: AccessUtil.java   View source code 6 votes vote down vote up
public static boolean inputText2(Context context, AccessibilityService service, AccessibilityNodeInfo nodeInfo,
                                 final String hello) {
        //找到当前获取焦点的view
//        AccessibilityNodeInfo target = nodeInfo.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
        AccessUtil.findNodeInfosByName(nodeInfo, "android.widget.EditText");
        AccessibilityNodeInfo target = editText;
        if (target == null) {
            L.d("inputHello: null");

            return false;
        } else {
            L.d("inputHello: not null " + target.getText());
        }
        ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("message", hello);
        clipboard.setPrimaryClip(clip);
        L.d("设置粘贴板");
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
//            target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
//        }
        target.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
        L.d("获取焦点");
        target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
        L.d("粘贴内容");
        return true;
    }
 
Example 11
Project: pc-android-controller-android   File: WeChatNearly.java   View source code 6 votes vote down vote up
private void openNext2(String str, AccessibilityNodeInfo nodeInfo, final AccessibilityService service) {
    if (nodeInfo == null) {
        L.d("rootWindow为空");
        return;
    } else {
        L.d("openNext2 " + nodeInfo.getText());
    }
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(str);
    if (list.isEmpty()) {
        return;
    } else {
        CharSequence text = list.get(list.size() - 1).getText();
        if (TextUtils.isEmpty(text)) {
            return;
        } else {
            L.d("openNext2 " + text);
        }
    }

    i++;
    if (isGo) {
        isGo = false;
    }
}
 
Example 12
Project: Auto.js   File: AccessibilityServiceUtils.java   View source code 6 votes vote down vote up
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    ComponentName expectedComponentName = new ComponentName(context, accessibilityService);

    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null)
        return false;

    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);

    while (colonSplitter.hasNext()) {
        String componentNameString = colonSplitter.next();
        ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);

        if (enabledService != null && enabledService.equals(expectedComponentName))
            return true;
    }

    return false;
}
 
Example 13
Project: ReplyMessage   File: PerformClickUtils.java   View source code 6 votes vote down vote up
/**
 * 在当前页面查找文字内容并点击
 *
 * @param text
 */
public static void findTextAndClick(AccessibilityService accessibilityService, String text) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null && (text.equals(nodeInfo.getText()) || text.equals(nodeInfo.getContentDescription()))) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}
 
Example 14
Project: ReplyMessage   File: PerformClickUtils.java   View source code 6 votes vote down vote up
/**
 * 检查viewId进行点击
 *
 * @param accessibilityService
 * @param id
 */
public static void findViewIdAndClick(AccessibilityService accessibilityService, String id) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}
 
Example 15
Project: ReplyMessage   File: PerformClickUtils.java   View source code 6 votes vote down vote up
/**
 * 在当前页面查找对话框文字内容并点击
 *
 * @param text1 默认点击text1
 * @param text2
 */
public static void findDialogAndClick(AccessibilityService accessibilityService, String text1, String text2) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> dialogWait = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text1);
    List<AccessibilityNodeInfo> dialogConfirm = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text2);
    if (!dialogWait.isEmpty() && !dialogConfirm.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : dialogWait) {
            if (nodeInfo != null && text1.equals(nodeInfo.getText())) {
                performClick(nodeInfo);
                break;
            }
        }
    }

}
 
Example 16
Project: TPlayer   File: AceHelper.java   View source code 6 votes vote down vote up
/**
 * 检测当前辅助服务是否开启
 */
public static boolean checkAccessibilityEnabled(Context context,Class<? extends AccessibilityService> clazz) {
    int accessibilityEnabled = 0;
    final String service = context.getPackageName() + "/" + clazz.getCanonicalName();
    try {
        accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (Settings.SettingNotFoundException ignored) {
        // ignored
    }
    TextUtils.SimpleStringSplitter stringColonSplitter = new TextUtils.SimpleStringSplitter(':');
    if (accessibilityEnabled == 1) {
        String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (settingValue != null) {
            stringColonSplitter.setString(settingValue);
            while (stringColonSplitter.hasNext()) {
                String accessibilityService = stringColonSplitter.next();
                if (accessibilityService.equalsIgnoreCase(service)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 17
Project: weixin_auto   File: AutoUtil.java   View source code 6 votes vote down vote up
public static AccessibilityNodeInfo fineNodeByIdAndTextCheck(AccessibilityNodeInfo node,String id,String text,
                                         AccessibilityService context,Map<String,String> record, String recordAction){
    AccessibilityNodeInfo result = null;
    int count=0;
    while (count<6){
        node = context.getRootInActiveWindow();
        if(text==null){
            result = findNodeInfosById(node,id);
        }else if(id==null){
            result = findNodeInfosByText(node,text);
        }else{
            result = fineNodeByIdAndText(node,id,text);
        }
        if(result!=null)
            break;
        count = count +1;
        sleep(500*count);
    }
    if(result==null)
        recordAndLog(record,recordAction);
    return result;
}
 
Example 18
Project: brailleback   File: SearchNavigationMode.java   View source code 6 votes vote down vote up
public SearchNavigationMode(
        DisplayManager displayManager,
        AccessibilityService accessibilityService,
        FeedbackManager feedbackManager,
        TranslatorManager translatorManager,
        SelfBrailleManager selfBrailleManager,
        NodeBrailler nodeBrailler,
        SearchStateListener searchStateListener,
        CustomLabelManager labelManager) {
    mDisplayManager = displayManager;
    mAccessibilityService = accessibilityService;
    mFeedbackManager = feedbackManager;
    mTranslatorManager = translatorManager;
    mSelfBrailleManager = selfBrailleManager;
    mNodeBrailler = nodeBrailler;
    mSearchStateListener = searchStateListener;
    mLabelManager = labelManager;
    mSearchOverlay = new SearchOverlay(mAccessibilityService, mQueryText);
}
 
Example 19
Project: brailleback   File: SearchNavigationMode.java   View source code 6 votes vote down vote up
SearchNavigationMode(
        DisplayManager displayManager,
        AccessibilityService accessibilityService,
        FeedbackManager feedbackManager,
        TranslatorManager translatorManager,
        SelfBrailleManager selfBrailleManager,
        NodeBrailler nodeBrailler,
        SearchStateListener searchStateListener,
        SearchOverlay searchOverlay) {
    mDisplayManager = displayManager;
    mAccessibilityService = accessibilityService;
    mFeedbackManager = feedbackManager;
    mTranslatorManager = translatorManager;
    mSelfBrailleManager = selfBrailleManager;
    mNodeBrailler = nodeBrailler;
    mSearchStateListener = searchStateListener;
    mSearchOverlay = searchOverlay;
    mLabelManager = null;
}
 
Example 20
Project: talkback   File: GestureControllerAppTest.java   View source code 6 votes vote down vote up
@Test
public void testLegacyPrefs() {
    prefs.edit().putString(
            mockTalkBackService.getString(R.string.pref_two_part_vertical_gestures_key),
            mockTalkBackService.getString(R.string.value_two_part_vertical_gestures_jump))
            .apply();
    gestureController.onGesture(AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN);
    verify(mockCursorController).jumpToTop(InputModeManager.INPUT_MODE_TOUCH);
    gestureController.onGesture(AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP);
    verify(mockCursorController).jumpToBottom(InputModeManager.INPUT_MODE_TOUCH);
    prefs.edit().putString(
            mockTalkBackService.getString(R.string.pref_two_part_vertical_gestures_key),
            mockTalkBackService.getString(R.string.value_two_part_vertical_gestures_cycle))
            .apply();
    gestureController.onGesture(AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN);
    verify(mockCursorController).previousGranularity();
    gestureController.onGesture(AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP);
    verify(mockCursorController).nextGranularity();
}
 
Example 21
Project: WeChatMoney   File: StateMessageComing.java   View source code 6 votes vote down vote up
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
    System.out.println("StateMessageComing");
    List<CharSequence> texts = event.getText();
    for (CharSequence text : texts) {
        String content = text.toString();
        if (content.contains("[微信红包]")) {
            keepScreen(context);
            // 监听到微信红包的notification,打开通知
            if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) {
                Notification notification = (Notification) event.getParcelableData();
                PendingIntent pendingIntent = notification.contentIntent;
                try {
                    pendingIntent.send();
                } catch (PendingIntent.CanceledException e) {
                    e.printStackTrace();
                }
            }

        }
    }
    // 到这里,已进入到微信列表界面
    money.setState(money.moneyOrigin);
}
 
Example 22
Project: WeChatMoney   File: StateMoneyReceived.java   View source code 6 votes vote down vote up
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
    System.out.println("StateMoneyReceived");
    money.sleep();
    AccessibilityNodeInfo info = context.getRootInActiveWindow();
    if (info == null) {
        System.out.println("StateMoneyReceived is null");
        back(context, money);
        return;
    }
    List<AccessibilityNodeInfo> node3 = info.findAccessibilityNodeInfosByText("红包详情");
    List<AccessibilityNodeInfo> node4 = info.findAccessibilityNodeInfosByText("手慢了");
    if (!node3.isEmpty() || !node4.isEmpty()) {
        System.out.println("StateMoneyReceived has 红包详情");
        back(context, money);
    }
    money.setState(money.messageComing);
}
 
Example 23
Project: Float-Bar   File: Prefs.java   View source code 6 votes vote down vote up
/**
 * 执行操作的方法,根据传来的不同值执行不同的操作
 * 
 * @param service
 * @param event
 */
private void doOperation(AccessibilityService service, String event) {
	if (event.equals("openBar")) {
		Util.openStatusBar(mContext);
	} else if (event.equals("closeBar")) {
		Util.closeStatusBar(mContext);
	} else if (event.equals("openDraw")) {
		mContext.startService(new Intent(mContext, DrawService.class));
	} else if (event.equals("recents")) {
		Util.recentApps(service);
	} else if (event.equals("back")) {
		Util.virtualBack(service);
	} else if (event.equals("home")) {
		Util.virtualHome(mContext);
	} else if (event.equals("camera")) {
		Util.openCamera(mContext);
	}
}
 
Example 24
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityInfoProvider.java   View source code 5 votes vote down vote up
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        setLatestComponent(event.getPackageName(), event.getClassName());
    }
    return false;
}
 
Example 25
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityActionRecorder.java   View source code 5 votes vote down vote up
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
    if (getState() == STATE_RECORDING) {
        mConverter.record(service, event);
        checkTimeOut();
    }
    return false;
}
 
Example 26
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityActionConverter.java   View source code 5 votes vote down vote up
public void record(AccessibilityService service, AccessibilityEvent event) {
    EventToScriptConverter converter = CONVERTER_MAP.get(event.getEventType());
    if (converter != null) {
        if (mFirstAction && mShouldIgnoreFirstAction) {
            mFirstAction = false;
            return;
        }
        converter.onAccessibilityEvent(service, event, mScript);
        mScript.append("\n");
        EventBus.getDefault().post(new AccessibilityActionRecorder.AccessibilityActionRecordEvent(event));
    }
}
 
Example 27
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityActionConverter.java   View source code 5 votes vote down vote up
@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);
}
 
Example 28
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityActionConverter.java   View source code 5 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event, StringBuilder sb) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null)
        return;
    UiObject uiObject = UiObject.createRoot(service.getRootInActiveWindow());
    List<UiObject> editableList = FilterAction.EditableFilter.findEditable(uiObject);
    int i = findInEditableList(editableList, source);
    sb.append("while(!input(").append(i).append(", \"").append(source.getText()).append("\"));");
    source.recycle();
}
 
Example 29
Project: https-github.com-hyb1996-NoRootScriptDroid   File: SimpleActionAutomator.java   View source code 5 votes vote down vote up
private boolean performGlobalAction(final int action) {
    ensureAccessibilityServiceEnabled();
    AccessibilityService service = mAccessibilityBridge.getService();
    if (service == null)
        return false;
    return service.performGlobalAction(action);
}
 
Example 30
Project: Android_AutoSignInTool   File: autoSignInJDF.java   View source code 5 votes vote down vote up
public void doJDF(AccessibilityService service) {
    autoLock.lock();
    boolean ret;
    try {
        delay(10000);
        if (checkGestureLock(service.getRootInActiveWindow())) {
            ret = autoCondition.await(20, TimeUnit.SECONDS); // 20s
            if (!ret) {
                autoLock.unlock();
                MainPage.condition.signal();
                return;
            }
        }
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(1000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(1000);
        iteratorJDF(service.getRootInActiveWindow());  // 主页签到
        delay(6000);
        iteratorJDF(service.getRootInActiveWindow());  // 右上角签到
        ret = autoCondition.await(20, TimeUnit.SECONDS); // 10s
        //iteratorJDF(service.getRootInActiveWindow());  // 右上角钢蹦明细
        //ret = autoCondition.await(30, TimeUnit.SECONDS); // 30s
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(1000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(1000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(1000);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        delay(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    autoLock.unlock();
    MainPage.condition.signal();
}
 
Example 31
Project: Android_AutoSignInTool   File: Utils.java   View source code 5 votes vote down vote up
public static void reLaunch(AccessibilityService service, String text) {
    //prt(Utils.getTopApp(service.getApplicationContext()));
    if (!Utils.getTopApp(service.getApplicationContext()).equals(text)) {
        PackageManager packageManager = service.getApplicationContext().getPackageManager();
        Intent mBootUpIntent = packageManager.getLaunchIntentForPackage(text);
        mBootUpIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        mBootUpIntent.setAction(Intent.ACTION_MAIN);
        //mBootUpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        service.startActivity(mBootUpIntent);
    }
}
 
Example 32
Project: stynico   File: AppCompatDlalog.java   View source code 5 votes vote down vote up
@SuppressLint("NewApi")
   private boolean fill()
   {
       AccessibilityNodeInfo rootNode = getRootInActiveWindow();
       if (rootNode != null)
{
    SharedPreferences sharedPreferences = getSharedPreferences("hook_Cosplay", AccessibilityService.MODE_PRIVATE); 
    String htmly = sharedPreferences.getString("io_kii", "");
           return findEditText(rootNode, htmly);
       }
       return false;
   }
 
Example 33
Project: stynico   File: dex_smali.java   View source code 5 votes vote down vote up
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;
}
   }
 
Example 34
Project: miser-utils   File: ComeOnMoneyService.java   View source code 5 votes vote down vote up
private void returnHome() {
    Log.d(TAG, "返回home 上锁 isAutoOpen:" + isAutoOpen + ",  isWaked:" + isWaked);
    if (isAutoOpen) {
        isAutoOpen = false;
        performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
    }

    if (isWaked) {
        isWaked = false;
        wakeAndUnlock(false);
    }
}
 
Example 35
Project: CurrentActivity   File: AccessibilityServiceUtils.java   View source code 5 votes vote down vote up
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null) return false;
    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);
    while (colonSplitter.hasNext()) {
        ComponentName enabledService = ComponentName.unflattenFromString(colonSplitter.next());
        if (enabledService != null && enabledService.equals(new ComponentName(context, accessibilityService)))
            return true;
    }
    return false;
}
 
Example 36
Project: easyfilemanager   File: AppDetailsAutomatorManager.java   View source code 5 votes vote down vote up
private void handleAppDetail(AccessibilityNodeInfo source) {
	AccessibilityNodeInfo forceStopNodeInfo = null;
	forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_RES_NAME);
	if (forceStopNodeInfo == null) {
		if (Utils.hasLollipop()) {
			forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_RIGHT_BOTTON);
		} else {
			forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_LEFT_BOTTON);
		}
	}
	if (forceStopNodeInfo == null) {
		forceStopNodeInfo = AppDetailsAutomatorUtil.findAccessibilityNodeInfo(source, mForceStop);
	}
	if (forceStopNodeInfo == null) {
		forceStopNodeInfo = AppDetailsAutomatorUtil.findAccessibilityNodeInfo(source, mFinishApplication);
	}
	boolean performClick = false;
	if (forceStopNodeInfo != null) {
		AppDetailsAutomatorUtil.checkVisibleToUserTimeOut(forceStopNodeInfo);
		if (AppDetailsAutomatorUtil.isVisibleToUser(forceStopNodeInfo)) {
			AppDetailsAutomatorUtil.performClickAction(forceStopNodeInfo);
			performClick = true;
		}
		forceStopNodeInfo.recycle();
	}
	
	if (!performClick) {
		if (mPackageNames.isEmpty()) {
			source.performAction(AccessibilityService.GLOBAL_ACTION_BACK);
		}
		mHandler.sendEmptyMessage(MSG_PERFORM_STOP);
	}
}
 
Example 37
Project: pc-android-controller-android   File: AccessUtil.java   View source code 5 votes vote down vote up
/**
 * 返回事件
 */
public static void performHome(final AccessibilityService service) {
    if (service == null) {
        L.e("performBackWithDelay service is null");
        return;
    }
    if (service.getRootInActiveWindow() == null) {
        L.e("performBackWithDelay rootNode is null");
        return;
    }
    L.d("performHome");
    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
}
 
Example 38
Project: Auto.js   File: AccessibilityServiceTool.java   View source code 5 votes vote down vote up
public static boolean enableAccessibilityServiceByRoot(Context context, Class<? extends AccessibilityService> accessibilityService) {
    String serviceName = context.getPackageName() + "/" + accessibilityService.getName();
    try {
        return TextUtils.isEmpty(ProcessShell.execCommand(String.format(Locale.getDefault(), cmd, serviceName), true).error);
    } catch (Exception ignored) {
        return false;
    }
}
 
Example 39
Project: Auto.js   File: AccessibilityServiceTool.java   View source code 5 votes vote down vote up
public static boolean enableAccessibilityServiceByRootAndWaitFor(Context context, long timeOut) {
    if (enableAccessibilityServiceByRoot(context, com.stardust.view.accessibility.AccessibilityService.class)) {
        com.stardust.view.accessibility.AccessibilityService.waitForEnabled(timeOut);
        return true;
    }
    return false;
}
 
Example 40
Project: Auto.js   File: AccessibilityInfoProvider.java   View source code 5 votes vote down vote up
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        setLatestComponent(event.getPackageName(), event.getClassName());
    }
    return false;
}