Reading Notes-Android Full Buried Solution

Reading Notes-Android Full Buried Solution

this is the book

After reading "Android Full Buried Point Solution", I can summarize it in one sentence:
how to use the capabilities provided by the Android system to realize full-scene buried points without intruding into the original business logic as much as possible. That is to realize the decoupling of burying point and business.


1. Summary of the first three chapters

Chapter 1:
Full Buried Points: It refers to the ability to automatically collect user behavior data in advance without the need for development engineers to write code or only write a small amount of code.
Event types of all buried points: include: $AppStart, $AppEnd, $AppViewScreen, $AppClick
View binding Listener method: 1.setOnClickListener. 2.android:onClick=. 3.@OnClick annotation 4.DataBinding binding listener


Chapter 2: $AppViewScreen
Application.ActivityLifecycleCallbacks (API 14+)
can centrally process (monitor) all lifecycle events of the Activity.
You can increase the buried point of page exposure in the onActivityResumed() method. It should be noted that if the current page pops up a pop-up box to apply for permissions, and then return to the current page, onResume will be performed again, and the ignore page can be added through the ignoreAutoTrackActivity method.


Chapter 3: $AppStart , $AppEnd
register application.registerActivityLifecycleCallbacks, trigger $AppStart in onActivityStarted, and trigger timer in onActivityPaused.

2. Summary of the last eight chapters

The last eight chapters talk about the burying scheme of click events , which is a very important burying part of the business.
Click event buried point


Solution 1:
Register Application.ActivityLifecycleCallbacks, get the VIEW (FrameLayout) corresponding to the entire content area of ​​R.id.content in onActivityResumed, traverse the RootView, get the mOnclickListener of the current View by reflection, set a custom proxy WrapperOnClickListener, and call the original Listener inside The logic, plus the buried logic.


Solution 2:
Window.Callback
registers the callback. In onActivityCreated, activity.getWindow() gets the Window, calls window.getCallback(), and delegates the dispatchTouchEvent in Window.Callback, finds the clicked View through the MotionEvent parameter, and inserts the buried point logic ; Then call the dispatchTouchEvent method of the original Window.Callback.


Scheme three-five


Solution 3:
Proxy View.AccessibilityDelegate
in onActivityResumed, get RootView through activity.getWindow().getDecorView, recursively traverse RootView, proxy View mAccessibilityDelegate, and judge whether the eventType is AccessibilityEvent.TYPE_VIEW_CLICKED.


Solution 4:
Transparent layer
Customize the transparent View, add it to the top layer of each Activity (add the transparent layer in the onActivityCreated callback), and click on the transparent View.
Rewrite the View's onTouchEvent, according to the click coordinates (x, y) of the MotionEvent, find the actually clicked View in the RootView of the current Activity, proxy the View's mOnClickListener, and insert the buried point.


Solution 5:
AspectJ
is aspect-oriented, and inserts embedded code after the execution of the target method through point-cut matching.
AspectJ is the realization of the idea of ​​AOP.


Scheme 6-8


Solution 6: Before
ASM
packs and generates the .dex file, use the Transform API to manipulate the .class file, traverse the method of the .class file, modify the listener, and replace the original file.
Use the ASM framework API to load and parse .class files, find .class files and related methods that meet specific conditions, and modify the methods to insert buried points.


Solution 7: The principle of
Javassist
is similar to that of ASM, and the framework for operating .class files is replaced by Javassist.


Solution 8: The general processing flow of the
AST
editor for the code is:
JavaTXT -> lexical analysis -> generate AST -> semantic analysis -> compile bytecode
custom annotation processor process method, AST frame API traversal, find the target method , insert the buried point logic.

Guess you like

Origin blog.csdn.net/adayabetter/article/details/122147834