use of android.app.ActivityManager.RunningTaskInfo in project android_frameworks_base by ResurrectionRemix.
the class TaskManager method loadRunningTasks.
private void loadRunningTasks() {
// get running task
List<RunningTaskInfo> runningTaskList = mActivityManager.getRunningTasks(100);
List<ResolveInfo> mHomeResolveList = mPackageManager.queryIntentActivities(mHomeIntent, PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_RESOLVED_FILTER);
showTaskList.clear();
for (RunningTaskInfo runningTaskInfo : runningTaskList) {
boolean needshow = true;
DetailProcess detailProcess = new DetailProcess(mContext, runningTaskInfo);
final String packageName = detailProcess.getPackageName();
if (appNeedHide(packageName)) {
needshow = false;
}
if (needshow && mHomeResolveList != null) {
final int count = mHomeResolveList.size();
for (int i = 0; i < count; i++) {
if (mHomeResolveList.get(i).activityInfo.packageName.equals(packageName)) {
detailProcess.setHome(true);
break;
}
}
}
if (needshow && !detailProcess.filter()) {
showTaskList.add(detailProcess);
}
}
}
use of android.app.ActivityManager.RunningTaskInfo in project UltimateAndroid by cymcsg.
the class PackageUtils method isTopActivity.
/**
* whether the app whost package's name is packageName is on the top of the stack
* <ul>
* <strong>Attentions:</strong>
* <li>You should add <strong>android.permission.GET_TASKS</strong> in manifest</li>
* </ul>
*
* @param context
* @param packageName
* @return if params error or task stack is null, return null, otherwise retun whether the app is on the top of
* stack
*/
public static Boolean isTopActivity(Context context, String packageName) {
if (context == null || BasicUtils.judgeNotNull(packageName)) {
return null;
}
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasksInfo = activityManager.getRunningTasks(1);
if (BasicUtils.judgeNotNull(tasksInfo)) {
return null;
}
try {
return packageName.equals(tasksInfo.get(0).topActivity.getPackageName());
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
use of android.app.ActivityManager.RunningTaskInfo in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method getTasks.
@Override
public List<RunningTaskInfo> getTasks(int maxNum, int flags) {
final int callingUid = Binder.getCallingUid();
ArrayList<RunningTaskInfo> list = new ArrayList<RunningTaskInfo>();
synchronized (this) {
if (DEBUG_ALL)
Slog.v(TAG, "getTasks: max=" + maxNum + ", flags=" + flags);
final boolean allowed = isGetTasksAllowed("getTasks", Binder.getCallingPid(), callingUid);
// TODO: Improve with MRU list from all ActivityStacks.
mStackSupervisor.getTasksLocked(maxNum, list, callingUid, allowed);
}
return list;
}
use of android.app.ActivityManager.RunningTaskInfo in project android_frameworks_base by DirtyUnicorns.
the class ActivityStack method getTasksLocked.
void getTasksLocked(List<RunningTaskInfo> list, int callingUid, boolean allowed) {
boolean focusedStack = mStackSupervisor.getFocusedStack() == this;
boolean topTask = true;
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
if (task.getTopActivity() == null) {
continue;
}
ActivityRecord r = null;
ActivityRecord top = null;
ActivityRecord tmp;
int numActivities = 0;
int numRunning = 0;
final ArrayList<ActivityRecord> activities = task.mActivities;
if (!allowed && !task.isHomeTask() && task.effectiveUid != callingUid) {
continue;
}
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
tmp = activities.get(activityNdx);
if (tmp.finishing) {
continue;
}
r = tmp;
// Initialize state for next task if needed.
if (top == null || (top.state == ActivityState.INITIALIZING)) {
top = r;
numActivities = numRunning = 0;
}
// Add 'r' into the current task.
numActivities++;
if (r.app != null && r.app.thread != null) {
numRunning++;
}
if (DEBUG_ALL)
Slog.v(TAG, r.intent.getComponent().flattenToShortString() + ": task=" + r.task);
}
RunningTaskInfo ci = new RunningTaskInfo();
ci.id = task.taskId;
ci.stackId = mStackId;
ci.baseActivity = r.intent.getComponent();
ci.topActivity = top.intent.getComponent();
ci.lastActiveTime = task.lastActiveTime;
if (focusedStack && topTask) {
// Give the latest time to ensure foreground task can be sorted
// at the first, because lastActiveTime of creating task is 0.
// Only do this if the clock didn't run backwards, though.
ci.lastActiveTime = Math.max(ci.lastActiveTime, System.currentTimeMillis());
topTask = false;
}
if (top.task != null) {
ci.description = top.task.lastDescription;
}
ci.numActivities = numActivities;
ci.numRunning = numRunning;
ci.isDockable = task.canGoInDockedStack();
ci.resizeMode = task.mResizeMode;
list.add(ci);
}
}
use of android.app.ActivityManager.RunningTaskInfo in project UltimateAndroid by cymcsg.
the class PackageUtils method isTopActivity.
/**
* whether the app whost package's name is packageName is on the top of the stack
* <ul>
* Attentions:
* <li>You should add android.permission.GET_TASKS in manifest</li>
* </ul>
*
* @param context
* @param packageName
* @return if params error or task stack is null, return null, otherwise retun whether the app is on the top of
* stack
*/
public static Boolean isTopActivity(Context context, String packageName) {
if (context == null || !BasicUtils.judgeNotNull(packageName)) {
return null;
}
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasksInfo = activityManager.getRunningTasks(1);
if (!BasicUtils.judgeNotNull(tasksInfo)) {
return null;
}
try {
return packageName.equals(tasksInfo.get(0).topActivity.getPackageName());
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
Aggregations