Tag: accessibilityservice

如何在没有root的情况下(如Automate和Tasker)可靠地模拟Android上的触摸事件?

如何在我作为后台服务运行的应用程序之外可靠地模拟Android上的触摸事件(无需root)? 虽然之前已经提出过这个问题,但大多数答案都使用了ADB 。 (例如如何模拟Android设备上的触摸事件? ) https://github.com/chetbox/android-mouse-cursor使用辅助function提供了一个很好的解决方案,但不是很可靠,因为并非所有视图都对它做出响应,并且游戏在大多数时间都没有响应。 private void click() { AccessibilityNodeInfo nodeInfo = getRootInActiveWindow(); if (nodeInfo == null) return; AccessibilityNodeInfo nearestNodeToMouse = findSmallestNodeAtPoint(nodeInfo, cursorLayout.x, cursorLayout.y + 50); if (nearestNodeToMouse != null) { logNodeHierachy(nearestNodeToMouse, 0); nearestNodeToMouse.performAction(AccessibilityNodeInfo.ACTION_CLICK); } nodeInfo.recycle(); } 这是https://github.com/chetbox/android-mouse-cursor使用的当前代码。 Android版本是8.0,现货Android 是否有更好,更可靠的方法来模拟Java中的这些触摸事件? 提前致谢!

AccessibilityService在重新启动时停止接收事件

我有一个使用辅助function服务来收听通知的应用。 它可以在用户重新启动后正常工作。 如果重新启动,则必须从辅助function服务菜单中禁用/重新启用该服务。 为什么应用程序在重启后无法获取事件? @Override protected void onServiceConnected() { pMan = new PreferencesManager(this); bulbManager = new BulbManager(((Context) this), pMan.getBridge()); AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; info.feedbackType = AccessibilityEvent.TYPES_ALL_MASK; setServiceInfo(info); Log.d(“OMG, STARTED FINALLY!”, “RIGHT NOW!”); } 和xml 和清单

以编程方式使用辅助function服务读取通知栏标题,消息

使用辅助function服务我能够阅读通知栏标题和消息,我面临的问题是当第一次通知出现时我正在完美地阅读所有这些但是在第一次通知后,我只获得标题和文本“你有2条消息”等等,而不是整个消息。 等待你的专家意见。 代码: @Override protected void onServiceConnected() { Log.d(“AccessibilityServiceNotification”, “ServiceConnected”); try { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK; info.notificationTimeout = 100; setServiceInfo(info); } catch(Exception e) { Log.d(“ERROR onServiceConnected”, e.toString()); } } @Override public void onAccessibilityEvent(AccessibilityEvent event) { try { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); Parcelable data = event.getParcelableData(); if(data !=null) […]