package com.example.plugintest;

import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;

public class PluginTestApplication extends  Application {

	private String packageName;

	@Override
	public void onCreate() {
		super.onCreate();

		Context ctx = getApplicationContext();
		Log.d("xx", "" + ctx);

		if (isApplicationProcess()) {
			Log.d("api欺骗成功，让插件以为自己在主进程运行");
		}

	}

	private boolean isApplicationProcess() {
		ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
		for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) {
			if (appProcess.pid == android.os.Process.myPid()) {
				if (appProcess.processName.equals(packageName)) {
					return true;
				}
			}
		}
		return false;
	}

	@Override
	protected void attachBaseContext(Context base) {
		super.attachBaseContext(base);
		packageName = getPackageName();
	}
}

@@ -127,16 +127,40 @@
 ntext;%0A%0A
+import java.util.List;%0A%0A
 public c
@@ -501,18 +501,17 @@
 Manager 
-mA
+a
 ctivityM
@@ -587,13 +587,13 @@
 ;%0A%09%09
-for (
+List%3C
 Acti
@@ -629,23 +629,66 @@
 Info
- appProcess : m
+%3E list = activityManager.getRunningAppProcesses();%0A%09%09for (
 Acti
@@ -691,35 +691,32 @@
 ActivityManager.
-get
 RunningAppProces
@@ -716,20 +716,38 @@
 pProcess
-es()
+Info appProcess : list
 ) %7B%0A%09%09%09i

update demo