Java Code Examples for android.content.Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
The following examples show how to use
android.content.Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecentTasks.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @return whether the given visible task is within the policy range. */ private boolean isInVisibleRange(TaskRecord task, int numVisibleTasks) { // Keep the last most task even if it is excluded from recents final boolean isExcludeFromRecents = (task.getBaseIntent().getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; if (isExcludeFromRecents) { if (DEBUG_RECENTS_TRIM_TASKS) Slog.d(TAG, "\texcludeFromRecents=true"); return numVisibleTasks == 1; } if (mMinNumVisibleTasks >= 0 && numVisibleTasks <= mMinNumVisibleTasks) { // Always keep up to the min number of recent tasks, after that fall through to the // checks below return true; } if (mMaxNumVisibleTasks >= 0) { // Always keep up to the max number of recent tasks, but return false afterwards return numVisibleTasks <= mMaxNumVisibleTasks; } if (mActiveTasksSessionDurationMs > 0) { // Keep the task if the inactive time is within the session window, this check must come // after the checks for the min/max visible task range if (task.getInactiveDuration() <= mActiveTasksSessionDurationMs) { return true; } } return false; }
Example 2
Source File: TaskRecord.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void setRootProcess(ProcessRecord proc) { clearRootProcess(); if (intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0) { mRootProcess = proc; proc.recentTasks.add(this); } }
Example 3
Source File: OPFIabActivity.java From OPFIab with Apache License 2.0 | 5 votes |
/** * Start new instance of this activity. * * @param context Can't be null. Context object witch will be used to start new instance of * {@link OPFIabActivity}. If passed object is not <code>instanceof</code> * {@link Activity}, new activity will be started with * {@link Intent#FLAG_ACTIVITY_NEW_TASK} flag. */ public static void start(@NonNull final Context context) { final Intent intent = new Intent(context, OPFIabActivity.class); final int flags = Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_ANIMATION; if (context instanceof Activity) { intent.setFlags(flags); } else { intent.setFlags(flags | Intent.FLAG_ACTIVITY_NEW_TASK); } OPFLog.d("Starting OPFIabActivity with " + context + " as context"); context.startActivity(intent); }
Example 4
Source File: RecentTasks.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * @return the list of recent tasks for presentation. */ ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, boolean getTasksAllowed, boolean getDetailedTasks, int userId, int callingUid) { final boolean withExcluded = (flags & RECENT_WITH_EXCLUDED) != 0; if (!mService.isUserRunning(userId, FLAG_AND_UNLOCKED)) { Slog.i(TAG, "user " + userId + " is still locked. Cannot load recents"); return ParceledListSlice.emptyList(); } loadUserRecentsLocked(userId); final Set<Integer> includedUsers = mUserController.getProfileIds(userId); includedUsers.add(Integer.valueOf(userId)); final ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<>(); final int size = mTasks.size(); int numVisibleTasks = 0; for (int i = 0; i < size; i++) { final TaskRecord tr = mTasks.get(i); if (isVisibleRecentTask(tr)) { numVisibleTasks++; if (isInVisibleRange(tr, numVisibleTasks)) { // Fall through } else { // Not in visible range continue; } } else { // Not visible continue; } // Skip remaining tasks once we reach the requested size if (res.size() >= maxNum) { continue; } // Only add calling user or related users recent tasks if (!includedUsers.contains(Integer.valueOf(tr.userId))) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, not user: " + tr); continue; } if (tr.realActivitySuspended) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, activity suspended: " + tr); continue; } // Return the entry if desired by the caller. We always return // the first entry, because callers always expect this to be the // foreground app. We may filter others if the caller has // not supplied RECENT_WITH_EXCLUDED and there is some reason // we should exclude the entry. if (i == 0 || withExcluded || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) { if (!getTasksAllowed) { // If the caller doesn't have the GET_TASKS permission, then only // allow them to see a small subset of tasks -- their own and home. if (!tr.isActivityTypeHome() && tr.effectiveUid != callingUid) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, not allowed: " + tr); continue; } } if (tr.autoRemoveRecents && tr.getTopActivity() == null) { // Don't include auto remove tasks that are finished or finishing. if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, auto-remove without activity: " + tr); continue; } if ((flags & RECENT_IGNORE_UNAVAILABLE) != 0 && !tr.isAvailable) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, unavail real act: " + tr); continue; } if (!tr.mUserSetupComplete) { // Don't include task launched while user is not done setting-up. if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, user setup not complete: " + tr); continue; } final ActivityManager.RecentTaskInfo rti = createRecentTaskInfo(tr); if (!getDetailedTasks) { rti.baseIntent.replaceExtras((Bundle)null); } res.add(rti); } } return new ParceledListSlice<>(res); }
Example 5
Source File: RecentTasks.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * @return whether the given active task should be presented to the user through SystemUI. */ private boolean isVisibleRecentTask(TaskRecord task) { if (DEBUG_RECENTS_TRIM_TASKS) Slog.d(TAG, "isVisibleRecentTask: task=" + task + " minVis=" + mMinNumVisibleTasks + " maxVis=" + mMaxNumVisibleTasks + " sessionDuration=" + mActiveTasksSessionDurationMs + " inactiveDuration=" + task.getInactiveDuration() + " activityType=" + task.getActivityType() + " windowingMode=" + task.getWindowingMode() + " intentFlags=" + task.getBaseIntent().getFlags()); switch (task.getActivityType()) { case ACTIVITY_TYPE_HOME: case ACTIVITY_TYPE_RECENTS: // Ignore certain activity types completely return false; case ACTIVITY_TYPE_ASSISTANT: // Ignore assistant that chose to be excluded from Recents, even if it's a top // task. if ((task.getBaseIntent().getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) { return false; } } // Ignore certain windowing modes switch (task.getWindowingMode()) { case WINDOWING_MODE_PINNED: return false; case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: if (DEBUG_RECENTS_TRIM_TASKS) Slog.d(TAG, "\ttop=" + task.getStack().topTask()); final ActivityStack stack = task.getStack(); if (stack != null && stack.topTask() == task) { // Only the non-top task of the primary split screen mode is visible return false; } } // If we're in lock task mode, ignore the root task if (task == mService.getLockTaskController().getRootTask()) { return false; } return true; }