@SuppressLint("PrivateApi") private static void installCondomProcessActivityManager(final CondomCore condom)
			throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
		final Class<?> ActivityManagerNative = Class.forName("android.app.ActivityManagerNative");
		Field ActivityManagerNative_gDefault = null;
		if (SDK_INT < O) try {
			ActivityManagerNative_gDefault = ActivityManagerNative.getDeclaredField("gDefault");
		} catch (final NoSuchFieldException ignored) {}		// ActivityManagerNative.gDefault is no longer available on Android O.
		if (ActivityManagerNative_gDefault == null) { //noinspection JavaReflectionMemberAccess
			ActivityManagerNative_gDefault = ActivityManager.class.getDeclaredField("IActivityManagerSingleton");
		}
		ActivityManagerNative_gDefault.setAccessible(true);
		final Class<?> Singleton = Class.forName("android.util.Singleton");
		@SuppressLint("DiscouragedPrivateApi") final Method Singleton_get = Singleton.getDeclaredMethod("get");
		Singleton_get.setAccessible(true);
		final Field Singleton_mInstance = Singleton.getDeclaredField("mInstance");
		Singleton_mInstance.setAccessible(true);
		final Class<?> IActivityManager = Class.forName("android.app.IActivityManager");

		final Object/* Singleton */singleton = ActivityManagerNative_gDefault.get(null);
		if (singleton == null) throw new IllegalStateException("ActivityManagerNative.gDefault is null");
		final Object/* IActivityManager */am = Singleton_get.invoke(singleton);
		if (am == null) throw new IllegalStateException("ActivityManagerNative.gDefault.get() returns null");

		final InvocationHandler handler;
		if (Proxy.isProxyClass(am.getClass()) && (handler = Proxy.getInvocationHandler(am)) instanceof CondomProcessActivityManager) {
			Log.w(TAG, "CondomActivityManager was already installed in this process.");
			((CondomProcessActivityManager) handler).mCondom = condom;
		} else {
			final Object condom_am = Proxy.newProxyInstance(condom.mBase.getClassLoader(), new Class[] { IActivityManager },
					new CondomProcessActivityManager(condom, am));
			Singleton_mInstance.set(singleton, condom_am);
		}
	}
Install the condom protection for current process. This method should generally never be called in the main process of app.

<p>It is suggested to use {@link android.content.ContentProvider ContentProvider} with "android:process", to install it in specified process.
library/src/main/java/com/oasisfeng/condom/CondomProcess.java