Project Condom is a thin library to wrap the naked Context
in your Android project before passing it to the 3rd-party SDK. It is designed to prevent the 3rd-party SDK from common unwanted behaviors which may harm the user experience of your app.
- Massive launch of processes in other apps (common in 3rd-party push SDKs), causing slow app starting and notable lagging on low to middle-end devices. This behavior has “chain reaction” effects among apps with similar SDKs, greatly aggravating the overall device performance.
Condom item
The “condom” is an ultra-light and thin Android tool library, which can be placed on the exposed Context of the Android application project and passed into a third-party SDK (usually its initialization method) to prevent common user experience damage behavior in the third-party SDK:
- A large number of processes of other applications are started in the background (common in SDK pushed by three parties), resulting in very slow application startup and serious lag in a period of time after startup (especially obvious on low-end models). This is because similar behaviors of third-party SDKS often exist in other applications launched in these SDK initialization stages, resulting in a “chain reaction” of process startup, consuming a large amount of CPU, file IO and memory resources in a short period of time, making the resources available to the current application greatly occupied (or even exhausted).
Common tripartite SDKS require the application to call its initialization method at startup, usually with the Context parameter, for example:
XxxClient.registerXxx(context, ...) ;
Just change it to:
XxxClient.registerXxx(CondomContext.wrap(context, "XxxSDK"), ...) ;
The tag parameter (“XxxSDK” in the above example) is the identifier specified by the developer as required to distinguish multiple CondomContext instances and will appear in the log with the tag suffix. If there is only one CondomContext instance, or no distinction is required, passing NULL will do.
With this simple one-line change, the third-party SDK can no longer use the Context with the condom to wake up other apps that are not currently running. (Apps with existing processes running can still be called associatively because there is no huge resource overhead associated with the creation of a large number of processes interlocking, so it is allowed. This is also the limiting principle that Android O is beginning to implement.)