use of com.jaredrummler.android.processes.models.AndroidAppProcess in project AnExplorer by 1hakr.
the class AppsProvider method getRunningAppProcessInfo.
/**
* Returns a list of application processes that are running on the device.
*
* @return a list of RunningAppProcessInfo records, or null if there are no
* running processes (it will not return an empty list). This list ordering is not
* specified.
*/
public static List<RunningAppProcessInfo> getRunningAppProcessInfo(Context ctx) {
ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcessInfos = new ArrayList<>();
String prevProcess = "";
if (Utils.hasNougat()) {
List<RunningServiceInfo> runningServices = am.getRunningServices(1000);
for (RunningServiceInfo process : runningServices) {
RunningAppProcessInfo info = new RunningAppProcessInfo(process.process, process.pid, null);
info.uid = process.uid;
info.importance = process.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
if (!prevProcess.equals(process.process)) {
prevProcess = process.process;
appProcessInfos.add(info);
}
}
return appProcessInfos;
} else if (Utils.hasLollipopMR1()) {
List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
for (AndroidAppProcess process : runningAppProcesses) {
RunningAppProcessInfo info = new RunningAppProcessInfo(process.name, process.pid, null);
info.uid = process.uid;
info.importance = process.foreground ? RunningAppProcessInfo.IMPORTANCE_FOREGROUND : RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
// TODO: Get more information about the process. pkgList, importance, lru, etc.
appProcessInfos.add(info);
}
return appProcessInfos;
}
return am.getRunningAppProcesses();
}
use of com.jaredrummler.android.processes.models.AndroidAppProcess in project AnExplorer by 1hakr.
the class AppsProvider method queryChildDocuments.
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder) throws FileNotFoundException {
final MatrixCursor result = new DocumentCursor(resolveDocumentProjection(projection), docId);
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
if (docId.startsWith(ROOT_ID_USER_APP)) {
List<PackageInfo> allAppList = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
for (PackageInfo packageInfo : allAppList) {
includeAppFromPackage(result, docId, packageInfo, false, null);
}
} else if (docId.startsWith(ROOT_ID_SYSTEM_APP)) {
List<PackageInfo> allAppList = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
for (PackageInfo packageInfo : allAppList) {
includeAppFromPackage(result, docId, packageInfo, true, null);
}
} else if (docId.startsWith(ROOT_ID_PROCESS)) {
if (Utils.hasNougat()) {
List<RunningServiceInfo> runningServices = activityManager.getRunningServices(1000);
for (RunningServiceInfo process : runningServices) {
includeAppFromService(result, docId, process, null);
}
} else if (Utils.hasLollipopMR1()) {
List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
for (AndroidAppProcess process : runningAppProcesses) {
includeAppFromProcess(result, docId, process, null);
}
} else {
List<RunningAppProcessInfo> runningProcessesList = activityManager.getRunningAppProcesses();
for (RunningAppProcessInfo processInfo : runningProcessesList) {
includeAppFromProcess(result, docId, processInfo, null);
}
}
}
} finally {
Binder.restoreCallingIdentity(token);
}
return result;
}
Aggregations