// Path: FrogCare/src/com/bingoogol/frogcare/domain/ProcessInfo.java
// public class ProcessInfo {
// 	private Drawable icon;
//     private String appName;
//     private String packname;
//     private long memsize;
//     private boolean checked;
//     public Drawable getIcon() {
// 		return icon;
// 	}
// 	public void setIcon(Drawable icon) {
// 		this.icon = icon;
// 	}
// 	public String getAppName() {
// 		return appName;
// 	}
// 	public void setAppName(String appName) {
// 		this.appName = appName;
// 	}
// 	public String getPackname() {
// 		return packname;
// 	}
// 	public void setPackname(String packname) {
// 		this.packname = packname;
// 	}
// 	public long getMemsize() {
// 		return memsize;
// 	}
// 	public void setMemsize(long memsize) {
// 		this.memsize = memsize;
// 	}
// 	public boolean isChecked() {
// 		return checked;
// 	}
// 	public void setChecked(boolean checked) {
// 		this.checked = checked;
// 	}
// 	public boolean isUserProcess() {
// 		return userProcess;
// 	}
// 	public void setUserProcess(boolean userProcess) {
// 		this.userProcess = userProcess;
// 	}
// 	private boolean userProcess;
// }


import java.util.ArrayList;
import java.util.List;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import com.bingoogol.frogcare.domain.ProcessInfo;
package com.bingoogol.frogcare.engine;




public class ProcessInfoProvider {
	/**
	 * 获取正在运行的进程信息
	 * 
	 * @param context
	 * @return
	 */
	public static List<ProcessInfo> getProcessInfos(Context context) {
		List<ProcessInfo> processInfos = new ArrayList<ProcessInfo>();
		PackageManager pm = context.getPackageManager();
		ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();
		for (RunningAppProcessInfo info : infos) {
			ProcessInfo processInfo = new ProcessInfo();
			String packname = info.processName;
			processInfo.setPackname(packname);
			try {
				ApplicationInfo applicationInfo = pm.getApplicationInfo(packname, 0);
				if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
					processInfo.setUserProcess(false);
				} else {
					processInfo.setUserProcess(true);
				}
				processInfo.setAppName(applicationInfo.loadLabel(pm).toString());
				processInfo.setIcon(applicationInfo.loadIcon(pm));
			} catch (PackageManager.NameNotFoundException e) {
				// 当前应用程序不是标准的apk
				processInfo.setAppName(packname);
// Path: FrogCare/src/com/bingoogol/frogcare/domain/ProcessInfo.java
// public class ProcessInfo {
// 	private Drawable icon;
//     private String appName;
//     private String packname;
//     private long memsize;
//     private boolean checked;
//     public Drawable getIcon() {
// 		return icon;
// 	}
// 	public void setIcon(Drawable icon) {
// 		this.icon = icon;
// 	}
// 	public String getAppName() {
// 		return appName;
// 	}
// 	public void setAppName(String appName) {
// 		this.appName = appName;
// 	}
// 	public String getPackname() {
// 		return packname;
// 	}
// 	public void setPackname(String packname) {
// 		this.packname = packname;
// 	}
// 	public long getMemsize() {
// 		return memsize;
// 	}
// 	public void setMemsize(long memsize) {
// 		this.memsize = memsize;
// 	}
// 	public boolean isChecked() {
// 		return checked;
// 	}
// 	public void setChecked(boolean checked) {
// 		this.checked = checked;
// 	}
// 	public boolean isUserProcess() {
// 		return userProcess;
// 	}
// 	public void setUserProcess(boolean userProcess) {
// 		this.userProcess = userProcess;
// 	}
// 	private boolean userProcess;
// }


// Path: FrogCare/src/com/bingoogol/frogcare/engine/ProcessInfoProvider.java
import java.util.ArrayList;
import java.util.List;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import com.bingoogol.frogcare.domain.ProcessInfo;

package com.bingoogol.frogcare.engine;




public class ProcessInfoProvider {
	/**
	 * 获取正在运行的进程信息
	 * 
	 * @param context
	 * @return
	 */
	public static List<ProcessInfo> getProcessInfos(Context context) {
		List<ProcessInfo> processInfos = new ArrayList<ProcessInfo>();
		PackageManager pm = context.getPackageManager();
		ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();
		for (RunningAppProcessInfo info : infos) {
			ProcessInfo processInfo = new ProcessInfo();
			String packname = info.processName;
			processInfo.setPackname(packname);
			try {
				ApplicationInfo applicationInfo = pm.getApplicationInfo(packname, 0);
				if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
					processInfo.setUserProcess(false);
				} else {
					processInfo.setUserProcess(true);
				}
				processInfo.setAppName(applicationInfo.loadLabel(pm).toString());
				processInfo.setIcon(applicationInfo.loadIcon(pm));
			} catch (PackageManager.NameNotFoundException e) {
				// 当前应用程序不是标准的apk
				processInfo.setAppName(packname);
				processInfo.setIcon(context.getResources().getDrawable(android.R.drawable.star_on));