I. Technical background
Assistive features are designed to help disabled users use Android devices and apps, run in the background, listen for user interface state transitions such as page switches, focus changes, notifications, Toast, etc., and receive callbacks from the system when AccessibilityEvents are triggered. Later, it was used by developers to develop plug-ins, such as wechat hongbao assistant, and some plug-ins that need to listen to third-party applications.
Principle and realization
The principle of
To summarize, Google has embedded interfaces in View, ViewGroup, TextView and other controls for text change, slide, UI change, when these changes in the control system API, API system and then assemble the data of these objects, in order to ensure data security, The system recreates objects (AccessibilityEvent, AccessibilityNodeInfo) to store the data indirectly, and then returns the data to the corresponding Service across processes.
The specific implementation
The first step: AccessibilityService Creates a service and inherits AccessibilityService. It implements the parent class onInterrupt(), onAccessibilityEvent(), and state change callbackStep 2: Configure AccessibilityService
Step 3: Let the user open accessibility permissions
Take you to analyze how to monitor wechat red envelopes
Three aspects:
How do I listen for message notifications
Determine if there is a red envelope in the notification bar
How to click chat list red packets
Sharing tools required
Uiautomatorviewer. bat helps us get the controls on the screen and operate with scripts C:\Users\Administrator\AppData\Local\Android\Sdk\tools\bin\ uiautomatorViewer. bat
2. The adb adb shell dumpsys window | findstr searches mCurrent will help the current WeChat class name of the page
The following method can find an ID node
And then you can sneak things in1. Find the node containing wechat red envelope and use UIAutomatorViewer to find ID 2. Automatically click this node to enter the chat page
How to find chat page red packets
Get chat page red envelope ID
Next, enter the word disassembly page, according to the above analysis logic can be completed, no more talk, we achieve their own