Skip to content

Commit

Permalink
Bugfix:Optimizing performance
Browse files Browse the repository at this point in the history
  • Loading branch information
cmzy committed Jan 5, 2016
1 parent e7f4905 commit d09fec0
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ public class PluginProcessManager {
private static Map<String, Object> sPluginLoadedApkCache = new WeakHashMap<String, Object>(1);

public static String getCurrentProcessName(Context context) {
if (context == null)
return sCurrentProcessName;

synchronized (sGetCurrentProcessNameLock) {
if (sCurrentProcessName == null) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> infos = activityManager.getRunningAppProcesses();
if (infos == null)
return null;

for (RunningAppProcessInfo info : infos) {
if (info.pid == android.os.Process.myPid()) {
sCurrentProcessName = info.processName;
Expand Down Expand Up @@ -143,10 +149,12 @@ private static void initProcessList(Context context) {
}

public static final boolean isPluginProcess(Context context) {
initProcessList(context);
String currentProcessName = getCurrentProcessName(context);
return !TextUtils.equals(currentProcessName, context.getPackageName()) &&
!sProcessList.contains(currentProcessName);
if (TextUtils.equals(currentProcessName, context.getPackageName()))
return false;

initProcessList(context);
return !sProcessList.contains(currentProcessName);
}

public static ClassLoader getPluginClassLoader(String pkg) throws IllegalAccessException, NoSuchMethodException, ClassNotFoundException, InvocationTargetException {
Expand Down

0 comments on commit d09fec0

Please sign in to comment.