Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53d9264d authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #2555171: Switching to app immediately after unmounting...

...SD card causes reboot.

Add option to not include temporarily unavailable recent tasks,
for the recent tasks UI to not display them.

Change-Id: I1495ca217b4292fd56f537459b44c0624262c292
parent ba6339fe
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -144,6 +144,13 @@ public class ActivityManager {
     */
    public static final int RECENT_WITH_EXCLUDED = 0x0001;
    
    /**
     * @hide
     * TODO: Make this public.  Provides a list that does not contain any
     * recent tasks that currently are not available to the user.
     */
    public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002;
    
    /**
     * Return a list of the tasks that the user has recently launched, with
     * the most recent being first and older ones after in order.
+21 −0
Original line number Diff line number Diff line
@@ -6867,6 +6867,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
            enforceCallingPermission(android.Manifest.permission.GET_TASKS,
                    "getRecentTasks()");
            IPackageManager pm = ActivityThread.getPackageManager();
            
            final int N = mRecentTasks.size();
            ArrayList<ActivityManager.RecentTaskInfo> res
                    = new ArrayList<ActivityManager.RecentTaskInfo>(
@@ -6883,6 +6885,25 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
                    rti.baseIntent = new Intent(
                            tr.intent != null ? tr.intent : tr.affinityIntent);
                    rti.origActivity = tr.origActivity;
                    
                    if ((flags&ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
                        // Check whether this activity is currently available.
                        try {
                            if (rti.origActivity != null) {
                                if (pm.getActivityInfo(rti.origActivity, 0) == null) {
                                    continue;
                                }
                            } else if (rti.baseIntent != null) {
                                if (pm.queryIntentActivities(rti.baseIntent,
                                        null, 0) == null) {
                                    continue;
                                }
                            }
                        } catch (RemoteException e) {
                            // Will never happen.
                        }
                    }
                    
                    res.add(rti);
                    maxNum--;
                }