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

Commit 3cb55598 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #5139085: Some Recents items can't be killed"

parents 9fefa3c7 eeb1dca3
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -96,11 +96,13 @@ public class RecentsPanelView extends RelativeLayout
    /* package */ final class ActivityDescription {
        final ActivityManager.RecentTaskInfo recentTaskInfo;
        final ResolveInfo resolveInfo;
        int taskId; // application task id for curating apps
        Intent intent; // launch intent for application
        final int taskId; // application task id for curating apps
        final int persistentTaskId; // persistent id
        final Intent intent; // launch intent for application
        final String packageName; // used to override animations (see onClick())
        final int position; // position in list

        Matrix matrix; // arbitrary rotation matrix to correct orientation
        String packageName; // used to override animations (see onClick())
        int position; // position in list

        private Bitmap mThumbnail; // generated by Activity.onCreateThumbnail()
        private Drawable mIcon; // application package icon
@@ -108,11 +110,12 @@ public class RecentsPanelView extends RelativeLayout

        public ActivityDescription(ActivityManager.RecentTaskInfo _recentInfo,
                ResolveInfo _resolveInfo, Intent _intent,
                int _id, int _pos, String _packageName) {
                int _pos, String _packageName) {
            recentTaskInfo = _recentInfo;
            resolveInfo = _resolveInfo;
            intent = _intent;
            taskId = _id;
            taskId = _recentInfo.id;
            persistentTaskId = _recentInfo.persistentId;
            position = _pos;
            packageName = _packageName;
        }
@@ -496,17 +499,17 @@ public class RecentsPanelView extends RelativeLayout
                final String title = info.loadLabel(pm).toString();
                // Drawable icon = info.loadIcon(pm);
                Drawable icon = getFullResIcon(resolveInfo, pm);
                int id = recentInfo.id;
                if (title != null && title.length() > 0 && icon != null) {
                    if (DEBUG) Log.v(TAG, "creating activity desc for id=" + id + ", label=" + title);
                    if (DEBUG) Log.v(TAG, "creating activity desc for id="
                            + recentInfo.id + ", label=" + title);
                    ActivityManager.TaskThumbnails thumbs = am.getTaskThumbnails(
                            recentInfo.persistentId);
                    ActivityDescription item = new ActivityDescription(recentInfo,
                            resolveInfo, intent, id, index, info.packageName);
                            resolveInfo, intent, index, info.packageName);
                    activityDescriptions.add(item);
                    ++index;
                } else {
                    if (DEBUG) Log.v(TAG, "SKIPPING item " + id);
                    if (DEBUG) Log.v(TAG, "SKIPPING item " + recentInfo.id);
                }
            }
        }
@@ -727,7 +730,7 @@ public class RecentsPanelView extends RelativeLayout
        // the task.
        final ActivityManager am = (ActivityManager)
                mContext.getSystemService(Context.ACTIVITY_SERVICE);
        am.removeTask(ad.taskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
        am.removeTask(ad.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
    }

    private void startApplicationDetailsActivity(String packageName) {
+23 −0
Original line number Diff line number Diff line
@@ -5159,6 +5159,29 @@ public final class ActivityManagerService extends ActivityManagerNative
                    cleanUpRemovedTaskLocked(r,
                            (flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0);
                    return true;
                } else {
                    TaskRecord tr = null;
                    int i=0;
                    while (i < mRecentTasks.size()) {
                        TaskRecord t = mRecentTasks.get(i);
                        if (t.taskId == taskId) {
                            tr = t;
                            break;
                        }
                        i++;
                    }
                    if (tr != null) {
                        if (tr.numActivities <= 0) {
                            // Caller is just removing a recent task that is
                            // not actively running.  That is easy!
                            mRecentTasks.remove(i);
                        } else {
                            Slog.w(TAG, "removeTask: task " + taskId
                                    + " does not have activities to remove, "
                                    + " but numActivities=" + tr.numActivities
                                    + ": " + tr);
                        }
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(ident);