android.accessibilityservice.AccessibilityService Java Examples
The following examples show how to use
android.accessibilityservice.AccessibilityService.
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: DirectionNavigationActor.java From talkback with Apache License 2.0 | 6 votes |
public DirectionNavigationActor( InputModeManager inputModeManager, GlobalVariables globalVariables, Analytics analytics, Compositor compositor, AccessibilityService service, ProcessorPhoneticLetters processorPhoneticLetters, AccessibilityFocusMonitor accessibilityFocusMonitor, ScreenStateMonitor screenStateMonitor) { this.context = service; this.inputModeManager = inputModeManager; this.analytics = analytics; this.accessibilityFocusMonitor = accessibilityFocusMonitor; this.cursorGranularityManager = new CursorGranularityManager( globalVariables, compositor, service, processorPhoneticLetters); focusProcessorForLogicalNavigation = new FocusProcessorForLogicalNavigation( service, accessibilityFocusMonitor, screenStateMonitor); }
Example #2
Source File: CursorGranularityManager.java From talkback with Apache License 2.0 | 6 votes |
/** * Populates a list with the set of {@link CursorGranularity}s supported by the specified root * node and its navigable children. * * @param service The a11y service. * @param root The root node from which to extract granularities. * @return A list of supported granularities. */ public static List<CursorGranularity> getSupportedGranularities( AccessibilityService service, AccessibilityNodeInfoCompat root, EventId eventId) { final List<CursorGranularity> supported = new ArrayList<>(); Set<AccessibilityNodeInfoCompat> visitedNodes = new HashSet<>(); final int supportedMask = extractNavigableNodes(root, null, visitedNodes, eventId, service); AccessibilityNodeInfoUtils.recycleNodes(visitedNodes); final boolean hasWebContent = WebInterfaceUtils.hasNavigableWebContent(root); String[] supportedHtmlElements = WebInterfaceUtils.getSupportedHtmlElements(root); CursorGranularity.extractFromMask( supportedMask, hasWebContent, supportedHtmlElements, supported); return supported; }
Example #3
Source File: AccessUtil.java From pc-android-controller-android with Apache License 2.0 | 6 votes |
/** * 返回事件 */ 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 #4
Source File: dex_smali.java From styT with Apache License 2.0 | 6 votes |
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)) { windowState = true; if (!runState) { AccessibilityNodeInfo info = event.getSource(); if (info == null) return; getAllHongBao(info); } } else { windowState = false; } }
Example #5
Source File: SearchNavigationMode.java From brailleback with Apache License 2.0 | 6 votes |
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 #6
Source File: Prefs.java From Float-Bar with Eclipse Public License 1.0 | 6 votes |
/** * 执行操作的方法,根据传来的不同值执行不同的操作 * * @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 #7
Source File: ScreenFeedbackManager.java From talkback with Apache License 2.0 | 6 votes |
public ScreenFeedbackManager( AccessibilityService service, @Nullable AccessibilityHintsManager hintsManager, SpeechController speechController, FeedbackController feedbackController, boolean screenOrientationLandscape) { interpreter = new WindowEventInterpreter(service); interpreter.addListener(this); allContext = getAllContext(service, createPreferences()); feedbackComposer = createComposer(); this.service = service; isArc = FeatureSupport.isArc(); accessibilityHintsManager = hintsManager; this.speechController = speechController; this.feedbackController = feedbackController; isScreenOrientationLandscape = screenOrientationLandscape; }
Example #8
Source File: AccessUtil.java From pc-android-controller-android with Apache License 2.0 | 6 votes |
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 #9
Source File: AccessibilityUtils.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 查找符合条件的节点 * @param service {@link AccessibilityService} * @param text 文本内容 ( 搜索包含该文本内容的节点 ) * @param className 节点所属的类 ( 类名 ) * @return 包含该文本内容, 且属于指定类的节点集合 */ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) public static List<AccessibilityNodeInfo> findAccessibilityNodeInfosByText(final AccessibilityService service, final String text, final String className) { if (service == null || text == null || className == null) return null; List<AccessibilityNodeInfo> lists = new ArrayList<>(); // 获取根节点 AccessibilityNodeInfo nodeInfo = service.getRootInActiveWindow(); // 取得当前激活窗体的根节点 if (nodeInfo == null) return lists; // 通过文字找到当前的节点 List<AccessibilityNodeInfo> nodes = nodeInfo.findAccessibilityNodeInfosByText(text); for (int i = 0; i < nodes.size(); i++) { AccessibilityNodeInfo node = nodes.get(i); // 判断是否符合的类型 if (node.getClassName().equals(className) && node.isEnabled()) { // 保存符合条件 lists.add(node); } } return lists; }
Example #10
Source File: Prefs.java From Float-Bar with Eclipse Public License 1.0 | 6 votes |
/** * 执行操作的方法,根据传来的不同值执行不同的操作 * * @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 #11
Source File: AccessibilityUtils.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 查找符合条件的节点 * @param service {@link AccessibilityService} * @param focus 焦点类型 * @param className 节点所属的类 ( 类名 ) * @return 拥有特定焦点类型的节点 */ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) public static AccessibilityNodeInfo findFocus(final AccessibilityService service, final int focus, final String className) { if (service == null || className == null) return null; // 获取根节点 AccessibilityNodeInfo nodeInfo = service.getRootInActiveWindow(); // 取得当前激活窗体的根节点 if (nodeInfo == null) return null; // 通过指定的焦点类型找到当前的节点 AccessibilityNodeInfo node = nodeInfo.findFocus(focus); // 防止为 null if (node != null) { // 判断是否符合的类型 if (node.getClassName().equals(className) && node.isEnabled()) { return node; } } return null; }
Example #12
Source File: AccessUtil.java From pc-android-controller-android with Apache License 2.0 | 6 votes |
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 #13
Source File: LockAccessibilityService.java From Lock with Apache License 2.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (ACTION_LOCK.equals(intent.getAction())) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { performGlobalAction(AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN); } } return Service.START_STICKY; }
Example #14
Source File: AccessibilityServiceCompatUtils.java From talkback with Apache License 2.0 | 5 votes |
public static AccessibilityNodeInfoCompat getInputFocusedNode(AccessibilityService service) { // TODO: Shall we use active window or accessibility focused window? AccessibilityNodeInfoCompat activeRoot = getRootInActiveWindow(service); if (activeRoot != null) { try { return activeRoot.findFocus(AccessibilityNodeInfoCompat.FOCUS_INPUT); } finally { activeRoot.recycle(); } } return null; }
Example #15
Source File: FocusFinder.java From brailleback with Apache License 2.0 | 5 votes |
public static AccessibilityNodeInfoCompat getFocusedNode( AccessibilityService service, boolean fallbackOnRoot) { AccessibilityNodeInfo root = service.getRootInActiveWindow(); AccessibilityNodeInfo focused = null; try { AccessibilityNodeInfo ret = null; if (root != null) { focused = root.findFocus( AccessibilityNodeInfo.FOCUS_ACCESSIBILITY); if (focused != null && focused.isVisibleToUser()) { ret = focused; focused = null; } else if (fallbackOnRoot) { ret = root; root = null; } } else { LogUtils.log(service, Log.ERROR, "No current window root"); } if (ret != null) { return new AccessibilityNodeInfoCompat(ret); } } finally { if (root != null) { root.recycle(); } if (focused != null) { focused.recycle(); } } return null; }
Example #16
Source File: Util.java From Float-Bar with Eclipse Public License 1.0 | 5 votes |
/** * 模拟最近任务 * * @param service */ public static void recentApps(AccessibilityService service) { if (VERSION.SDK_INT < 16) { Toast.makeText(service, "Android 4.1及以上系统才支持此功能,请升级后重试", 1).show(); } else { service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); } }
Example #17
Source File: MainTreeBuilder.java From talkback with Apache License 2.0 | 5 votes |
@VisibleForTesting public MainTreeBuilder( AccessibilityService service, LinearScanTreeBuilder linearScanTreeBuilder, RowColumnTreeBuilder rowColumnTreeBuilder, TalkBackOrderNDegreeTreeBuilder talkBackOrderNDegreeTreeBuilder) { super(service); this.linearScanTreeBuilder = linearScanTreeBuilder; this.rowColumnTreeBuilder = rowColumnTreeBuilder; orderNTreeBuilder = talkBackOrderNDegreeTreeBuilder; }
Example #18
Source File: IMENavigationMode.java From brailleback with Apache License 2.0 | 5 votes |
/** Public constructor for general use. */ public IMENavigationMode(NavigationMode next, AccessibilityService service, DisplayManager displayManager, FeedbackManager feedbackManager, SelfBrailleManager selfBrailleManager, TranslatorManager translatorManager) { mNext = next; mAccessibilityService = service; mDisplayManager = displayManager; mFeedbackManager = feedbackManager; mSelfBrailleManager = selfBrailleManager; mTranslatorManager = translatorManager; mIME = null; }
Example #19
Source File: UTest.java From Taskbar with Apache License 2.0 | 5 votes |
private void testSendAccessibilityAction(boolean serviceEnabled, boolean hasPermission, boolean hasRun) { PowerMockito.spy(U.class); when(U.isAccessibilityServiceEnabled(context)).thenReturn(serviceEnabled); when(U.hasWriteSecureSettingsPermission(context)).thenReturn(hasPermission); RunnableHooker onComplete = new RunnableHooker(); U.sendAccessibilityAction( context, AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN, onComplete ); // Run all delayed message. ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); assertEquals(hasRun, onComplete.hasRun()); }
Example #20
Source File: AccessUtil.java From pc-android-controller-android with Apache License 2.0 | 5 votes |
/** * 返回事件 */ 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 #21
Source File: FocusActor.java From talkback with Apache License 2.0 | 5 votes |
public FocusActor( AccessibilityService service, ScreenStateMonitor screenStateMonitor, AccessibilityFocusActionHistory accessibilityFocusActionHistory, AccessibilityFocusMonitor accessibilityFocusMonitor) { this.history = accessibilityFocusActionHistory; this.accessibilityFocusMonitor = accessibilityFocusMonitor; focusManagerInternal = new FocusManagerInternal(service, screenStateMonitor, history, accessibilityFocusMonitor); }
Example #22
Source File: SideBarContent.java From AndroidSideBar with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_brightness: removeOrSendMsg(true,true); brightnessPermissionCheck(); break; case R.id.tv_back: removeOrSendMsg(true,true); clearSeekBar(); mSideBarService.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK); break; case R.id.tv_home: removeOrSendMsg(true,false); goNormal(); mSideBarService.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME); break; case R.id.tv_annotation: removeOrSendMsg(true,false); goNormal(); annotationGo(); break; case R.id.tv_volume: removeOrSendMsg(true,true); brightnessOrVolume(1); break; case R.id.tv_backstage: removeOrSendMsg(true,false); goNormal(); mSideBarService.performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); break; } }
Example #23
Source File: BrailleMenuNavigationMode.java From brailleback with Apache License 2.0 | 5 votes |
public BrailleMenuNavigationMode( DisplayManager displayManager, AccessibilityService accessibilityService, FeedbackManager feedbackManager, CustomLabelManager labelManager, BrailleMenuListener brailleMenuListener) { mDisplayManager = displayManager; mAccessibilityService = accessibilityService; mFeedbackManager = feedbackManager; mLabelManager = labelManager; mBrailleMenuListener = brailleMenuListener; mCurrentIndex = 0; }
Example #24
Source File: dex_smali.java From stynico with MIT License | 5 votes |
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 #25
Source File: ShowActionsMenuNode.java From talkback with Apache License 2.0 | 5 votes |
/** * Returns a new ShowActionsMenuNode if the provided {@link SwitchAccessNodeCompat} has actions we * support and is visible to the user. * * @param service AccessibilityService used to determine whether autoselect is enabled * @param nodeCompat The {@link SwitchAccessNodeCompat} based on which this node will be created * @return A ShowActionsMenuMode if the provided {@link SwitchAccessNodeCompat} has supported * actions. Returns {@code null} otherwise} */ @Nullable public static ShowActionsMenuNode createNodeIfHasActions( AccessibilityService service, SwitchAccessNodeCompat nodeCompat) { List<SwitchAccessNodeCompat> nodeCompats = getNodesIfHasActions(nodeCompat); // Create a node if valid actions exist. if (nodeCompats != null) { return new ShowActionsMenuNode( nodeCompats, service, new SwitchAccessActionTimeline(nodeCompat)); } else { return null; } }
Example #26
Source File: ActionTimeline.java From talkback with Apache License 2.0 | 5 votes |
/** * Executes an undo operation by performing the next action. May modify the state of the screen. * * @return {@code true} if the execution of the undo operation was successful */ public synchronized boolean performUndo(AccessibilityService service) { updateTimeStamp(); if (!canPerformUndo()) { return false; } // Get the previous action final TimelineAction prevActionObj = getLastActionExecuted(); if (!(prevActionObj instanceof Undoable)) { return false; } final Undoable prevAction = (Undoable) prevActionObj; // Get the inverse action and perform it final TimelineAction inverseAction = prevAction.generateInverseAction(); if (inverseAction == null) { return false; } final ActionResult result = inverseAction.execute(service); // Change the action's stack assignment if we were successfully able to perform the action if (result.isSuccessful()) { undoActionPerformed(); return true; } else { return false; } }
Example #27
Source File: Util.java From Float-Bar with Eclipse Public License 1.0 | 5 votes |
/** * 模拟最近任务 * * @param service */ public static void recentApps(AccessibilityService service) { if (VERSION.SDK_INT < 16) { Toast.makeText(service, "Android 4.1及以上系统才支持此功能,请升级后重试", 1).show(); } else { service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); } }
Example #28
Source File: AccessibilityUtils.java From SmsCode with GNU General Public License v3.0 | 5 votes |
/** * 获取无障碍服务的ID * * @param serviceClz accessibility service class * @return accessibility service id */ public static String getServiceId(Class<? extends AccessibilityService> serviceClz) { // eg. // service Class: com.github.tianma8023.smscode.service.accessibility.SmsCodeAutoInputService // package name: com.github.tianma8023.smscode // accessibility service id : com.github.tianma8023.smscode/.service.accessibility.SmsCodeAutoInputService String packageName = BuildConfig.APPLICATION_ID; String serviceClzName = serviceClz.getName(); int index = serviceClzName.indexOf(packageName); if (index != -1) { return packageName + "/" + serviceClzName.substring(index + packageName.length()); } return serviceClzName; }
Example #29
Source File: MainTreeBuilder.java From talkback with Apache License 2.0 | 5 votes |
/** @param service A valid {@link AccessibilityService} for interacting with the framework */ public MainTreeBuilder(AccessibilityService service) { super(service); linearScanTreeBuilder = new LinearScanTreeBuilder(service); rowColumnTreeBuilder = new RowColumnTreeBuilder(service); orderNTreeBuilder = new TalkBackOrderNDegreeTreeBuilder(service); }
Example #30
Source File: FocusProcessorForLogicalNavigation.java From talkback with Apache License 2.0 | 5 votes |
public FocusProcessorForLogicalNavigation( AccessibilityService service, AccessibilityFocusMonitor accessibilityFocusMonitor, ScreenStateMonitor screenStateMonitor) { this.service = service; this.accessibilityFocusMonitor = accessibilityFocusMonitor; this.screenStateMonitor = screenStateMonitor; isWindowNavigationSupported = !FeatureSupport.isTv(service); }