From the analysis of Tmall, Meituan and Qunar, how should front-end developers control the dynamic development of Mobile APP (I)






















The “two-second rule”
 

 















Robust adds a static member of type ChangeQuickRedirect for each class, and uses ChangeQuickRedirect logic in front of each method. If ChangeQuickRedirect is not null, It is possible to execute to accessDispatch to replace the old logic for fix purposes.

After the client gets patch.dex containing PatchesInfoPl. Java and Statepatch. Java, it loads the patch.dex with DexClassLoader and gets the patchesInfoPl. Java class by reflection. Once you get it, create an object for the class.

Then, through the getPatchedClassesInfo function of this object, we know that the class to be patched is com.meituan.sample.d (the confused name of com.meituan.sample.State). Then reflect the com.meituan.sample.d class in the current operating environment and assign the changeQuickRedirect field value to the object derived from the statepatch. Java class new in patch.dex. This is the main process of patch. Perhaps due to the early launch of the relationship, meituan this set of hot repair plan now seems to be in the rules, the current market of the mainstream Android hot repair framework are basically using similar scheme.

Hot fixes, like plugins, have a security risk of running external code, which requires validation. In addition, although hot fixes can achieve the purpose of fixing client bugs without issuing a version, we still need to pay attention to not abusing hot fixes. Due to its convenience, hot fixes will often deviate from the original intention of bugs on the repair line and become a tool for business change.

Hang Seng technology eye original article, unauthorized reprint prohibited. For details, see (click) reprint instructions.