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

Commit a9812d3c authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Remove unused legacy/hidden RecentTaskInfo fields" into main

parents d713ab6a c59dfa99
Loading
Loading
Loading
Loading
+0 −87
Original line number Diff line number Diff line
@@ -2678,62 +2678,6 @@ public class ActivityManager {
     * started or visited.
     */
    public static class RecentTaskInfo extends TaskInfo implements Parcelable {
        /**
         * @hide
         */
        public static class PersistedTaskSnapshotData {
            /**
             * The bounds of the task when the last snapshot was taken, may be null if the task is
             * not yet attached to the hierarchy.
             * @see {@link android.window.TaskSnapshot#mTaskSize}.
             * @hide
             */
            public @Nullable Point taskSize;

            /**
             * The content insets of the task when the task snapshot was taken.
             * @see {@link android.window.TaskSnapshot#mContentInsets}.
             * @hide
             */
            public @Nullable Rect contentInsets;

            /**
             * The size of the last snapshot taken, may be null if there is no associated snapshot.
             * @see {@link android.window.TaskSnapshot#mSnapshot}.
             * @hide
             */
            public @Nullable Point bufferSize;

            /**
             * Sets the data from the other data.
             * @hide
             */
            public void set(PersistedTaskSnapshotData other) {
                taskSize = other.taskSize;
                contentInsets = other.contentInsets;
                bufferSize = other.bufferSize;
            }

            /**
             * Sets the data from the provided {@param snapshot}.
             * @hide
             */
            public void set(TaskSnapshot snapshot) {
                if (snapshot == null) {
                    taskSize = null;
                    contentInsets = null;
                    bufferSize = null;
                    return;
                }
                final HardwareBuffer buffer = snapshot.getHardwareBuffer();
                taskSize = new Point(snapshot.getTaskSize());
                contentInsets = new Rect(snapshot.getContentInsets());
                bufferSize = buffer != null
                        ? new Point(buffer.getWidth(), buffer.getHeight())
                        : null;
            }
        }

        /**
         * If this task is currently running, this is the identifier for it.
         * If it is not running, this will be -1.
@@ -2770,24 +2714,6 @@ public class ActivityManager {
        @Deprecated
        public int affiliatedTaskId;

        /**
         * Information of organized child tasks.
         *
         * @deprecated No longer used
         * @hide
         */
        @Deprecated
        public ArrayList<RecentTaskInfo> childrenTaskInfos = new ArrayList<>();

        /**
         * Information about the last snapshot taken for this task.
         *
         * @deprecated No longer used
         * @hide
         */
        @Deprecated
        public PersistedTaskSnapshotData lastSnapshotData = new PersistedTaskSnapshotData();

        public RecentTaskInfo() {
        }

@@ -2803,10 +2729,6 @@ public class ActivityManager {
        public void readFromParcel(Parcel source) {
            id = source.readInt();
            persistentId = source.readInt();
            childrenTaskInfos = source.readArrayList(RecentTaskInfo.class.getClassLoader(), android.app.ActivityManager.RecentTaskInfo.class);
            lastSnapshotData.taskSize = source.readTypedObject(Point.CREATOR);
            lastSnapshotData.contentInsets = source.readTypedObject(Rect.CREATOR);
            lastSnapshotData.bufferSize = source.readTypedObject(Point.CREATOR);
            super.readTaskFromParcel(source);
        }

@@ -2814,10 +2736,6 @@ public class ActivityManager {
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeInt(persistentId);
            dest.writeList(childrenTaskInfos);
            dest.writeTypedObject(lastSnapshotData.taskSize, flags);
            dest.writeTypedObject(lastSnapshotData.contentInsets, flags);
            dest.writeTypedObject(lastSnapshotData.bufferSize, flags);
            super.writeTaskToParcel(dest, flags);
        }

@@ -2884,11 +2802,6 @@ public class ActivityManager {
                pw.println(" }");
            }
            pw.print("   ");
            pw.print(" lastSnapshotData {");
            pw.print(" taskSize=" + lastSnapshotData.taskSize);
            pw.print(" contentInsets=" + lastSnapshotData.contentInsets);
            pw.print(" bufferSize=" + lastSnapshotData.bufferSize);
            pw.println(" }");
        }
    }

+0 −13
Original line number Diff line number Diff line
@@ -2025,22 +2025,9 @@ class RecentTasks {
        // Fill in some deprecated values.
        rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
        rti.persistentId = rti.taskId;
        rti.lastSnapshotData.set(tr.mLastTaskSnapshotData);
        if (!getTasksAllowed) {
            Task.trimIneffectiveInfo(tr, rti);
        }

        // Fill in organized child task info for the task created by organizer.
        if (tr.mCreatedByOrganizer) {
            for (int i = tr.getChildCount() - 1; i >= 0; i--) {
                final Task childTask = tr.getChildAt(i).asTask();
                if (childTask != null && childTask.isOrganized()) {
                    final ActivityManager.RecentTaskInfo cti = new ActivityManager.RecentTaskInfo();
                    childTask.fillTaskInfo(cti, true /* stripExtras */, tda);
                    rti.childrenTaskInfos.add(cti);
                }
            }
        }
        return rti;
    }

+8 −51
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo.PersistedTaskSnapshotData;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
@@ -256,9 +255,6 @@ class Task extends TaskFragment {
    private static final String ATTR_MIN_HEIGHT = "min_height";
    private static final String ATTR_PERSIST_TASK_VERSION = "persist_task_version";
    private static final String ATTR_WINDOW_LAYOUT_AFFINITY = "window_layout_affinity";
    private static final String ATTR_LAST_SNAPSHOT_TASK_SIZE = "last_snapshot_task_size";
    private static final String ATTR_LAST_SNAPSHOT_CONTENT_INSETS = "last_snapshot_content_insets";
    private static final String ATTR_LAST_SNAPSHOT_BUFFER_SIZE = "last_snapshot_buffer_size";

    // How long to wait for all background Activities to redraw following a call to
    // convertToTranslucent().
@@ -472,10 +468,6 @@ class Task extends TaskFragment {
    // NOTE: This value needs to be persisted with each task
    private TaskDescription mTaskDescription;

    // Information about the last snapshot that should be persisted with the task to allow SystemUI
    // to layout without loading all the task snapshots
    final PersistedTaskSnapshotData mLastTaskSnapshotData;

    /** @see #setCanAffectSystemUiFlags */
    private boolean mCanAffectSystemUiFlags = true;

@@ -635,14 +627,13 @@ class Task extends TaskFragment {
            ComponentName _realActivity, ComponentName _origActivity, boolean _rootWasReset,
            boolean _autoRemoveRecents, int _userId, int _effectiveUid,
            String _lastDescription, long lastTimeMoved, boolean neverRelinquishIdentity,
            TaskDescription _lastTaskDescription, PersistedTaskSnapshotData _lastSnapshotData,
            int taskAffiliation, int prevTaskId, int nextTaskId, int callingUid,
            String callingPackage, @Nullable String callingFeatureId, int resizeMode,
            boolean supportsPictureInPicture, boolean _realActivitySuspended,
            boolean userSetupComplete, int minWidth, int minHeight, ActivityInfo info,
            IVoiceInteractionSession _voiceSession, IVoiceInteractor _voiceInteractor,
            boolean _createdByOrganizer, IBinder _launchCookie, boolean _deferTaskAppear,
            boolean _removeWithTaskOrganizer) {
            TaskDescription _lastTaskDescription, int taskAffiliation, int prevTaskId,
            int nextTaskId, int callingUid, String callingPackage,
            @Nullable String callingFeatureId, int resizeMode, boolean supportsPictureInPicture,
            boolean _realActivitySuspended, boolean userSetupComplete, int minWidth, int minHeight,
            ActivityInfo info, IVoiceInteractionSession _voiceSession,
            IVoiceInteractor _voiceInteractor, boolean _createdByOrganizer, IBinder _launchCookie,
            boolean _deferTaskAppear, boolean _removeWithTaskOrganizer) {
        super(atmService, null /* fragmentToken */, _createdByOrganizer, false /* isEmbedded */);

        mTaskId = _taskId;
@@ -652,9 +643,6 @@ class Task extends TaskFragment {
        mTaskDescription = _lastTaskDescription != null
                ? _lastTaskDescription
                : new TaskDescription();
        mLastTaskSnapshotData = _lastSnapshotData != null
                ? _lastSnapshotData
                : new PersistedTaskSnapshotData();
        affinityIntent = _affinityIntent;
        affinity = _affinity;
        rootAffinity = _rootAffinity;
@@ -3111,7 +3099,6 @@ class Task extends TaskFragment {
    }

    void onSnapshotChanged(TaskSnapshot snapshot) {
        mLastTaskSnapshotData.set(snapshot);
        mAtmService.getTaskChangeNotificationController().notifyTaskSnapshotChanged(
                mTaskId, snapshot);
    }
@@ -3990,19 +3977,6 @@ class Task extends TaskFragment {
        out.attributeInt(null, ATTR_MIN_HEIGHT, mMinHeight);
        out.attributeInt(null, ATTR_PERSIST_TASK_VERSION, PERSIST_TASK_VERSION);

        if (mLastTaskSnapshotData.taskSize != null) {
            out.attribute(null, ATTR_LAST_SNAPSHOT_TASK_SIZE,
                    mLastTaskSnapshotData.taskSize.flattenToString());
        }
        if (mLastTaskSnapshotData.contentInsets != null) {
            out.attribute(null, ATTR_LAST_SNAPSHOT_CONTENT_INSETS,
                    mLastTaskSnapshotData.contentInsets.flattenToString());
        }
        if (mLastTaskSnapshotData.bufferSize != null) {
            out.attribute(null, ATTR_LAST_SNAPSHOT_BUFFER_SIZE,
                    mLastTaskSnapshotData.bufferSize.flattenToString());
        }

        if (affinityIntent != null) {
            out.startTag(null, TAG_AFFINITYINTENT);
            affinityIntent.saveToXml(out);
@@ -4069,7 +4043,6 @@ class Task extends TaskFragment {
        int taskId = INVALID_TASK_ID;
        final int outerDepth = in.getDepth();
        TaskDescription taskDescription = new TaskDescription();
        PersistedTaskSnapshotData lastSnapshotData = new PersistedTaskSnapshotData();
        int taskAffiliation = INVALID_TASK_ID;
        int prevTaskId = INVALID_TASK_ID;
        int nextTaskId = INVALID_TASK_ID;
@@ -4176,15 +4149,6 @@ class Task extends TaskFragment {
                case ATTR_PERSIST_TASK_VERSION:
                    persistTaskVersion = Integer.parseInt(attrValue);
                    break;
                case ATTR_LAST_SNAPSHOT_TASK_SIZE:
                    lastSnapshotData.taskSize = Point.unflattenFromString(attrValue);
                    break;
                case ATTR_LAST_SNAPSHOT_CONTENT_INSETS:
                    lastSnapshotData.contentInsets = Rect.unflattenFromString(attrValue);
                    break;
                case ATTR_LAST_SNAPSHOT_BUFFER_SIZE:
                    lastSnapshotData.bufferSize = Point.unflattenFromString(attrValue);
                    break;
                default:
                    if (!attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
                        Slog.w(TAG, "Task: Unknown attribute=" + attrName);
@@ -4278,7 +4242,6 @@ class Task extends TaskFragment {
                .setLastTimeMoved(lastTimeOnTop)
                .setNeverRelinquishIdentity(neverRelinquishIdentity)
                .setLastTaskDescription(taskDescription)
                .setLastSnapshotData(lastSnapshotData)
                .setTaskAffiliation(taskAffiliation)
                .setPrevAffiliateTaskId(prevTaskId)
                .setNextAffiliateTaskId(nextTaskId)
@@ -6444,7 +6407,6 @@ class Task extends TaskFragment {
        private long mLastTimeMoved;
        private boolean mNeverRelinquishIdentity;
        private TaskDescription mLastTaskDescription;
        private PersistedTaskSnapshotData mLastSnapshotData;
        private int mTaskAffiliation;
        private int mPrevAffiliateTaskId = INVALID_TASK_ID;
        private int mNextAffiliateTaskId = INVALID_TASK_ID;
@@ -6672,11 +6634,6 @@ class Task extends TaskFragment {
            return this;
        }

        private Builder setLastSnapshotData(PersistedTaskSnapshotData lastSnapshotData) {
            mLastSnapshotData = lastSnapshotData;
            return this;
        }

        private Builder setOrigActivity(ComponentName origActivity) {
            mOrigActivity = origActivity;
            return this;
@@ -6825,7 +6782,7 @@ class Task extends TaskFragment {
            return new Task(mAtmService, mTaskId, mIntent, mAffinityIntent, mAffinity,
                    mRootAffinity, mRealActivity, mOrigActivity, mRootWasReset, mAutoRemoveRecents,
                    mUserId, mEffectiveUid, mLastDescription, mLastTimeMoved,
                    mNeverRelinquishIdentity, mLastTaskDescription, mLastSnapshotData,
                    mNeverRelinquishIdentity, mLastTaskDescription,
                    mTaskAffiliation, mPrevAffiliateTaskId, mNextAffiliateTaskId, mCallingUid,
                    mCallingPackage, mCallingFeatureId, mResizeMode, mSupportsPictureInPicture,
                    mRealActivitySuspended, mUserSetupComplete, mMinWidth, mMinHeight,
+0 −58
Original line number Diff line number Diff line
@@ -495,24 +495,6 @@ public class RecentTasksTest extends WindowTestsBase {
                true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());
    }

    @Test
    public void testAppendOrganizedChildTaskInfo() {
        final Task root = createTaskBuilder(".CreatedByOrganizerRoot").build();
        root.mCreatedByOrganizer = true;
        // Add organized and non-organized child.
        final Task child1 = createTaskBuilder(".Task1").setParentTask(root).build();
        final Task child2 = createTaskBuilder(".Task2").setParentTask(root).build();
        doReturn(true).when(child1).isOrganized();
        doReturn(false).when(child2).isOrganized();
        mRecentTasks.add(root);

        // Make sure only organized child will be appended.
        final List<RecentTaskInfo> infos = getRecentTasks(0 /* flags */);
        final List<RecentTaskInfo> childrenTaskInfos = infos.get(0).childrenTaskInfos;
        assertEquals(childrenTaskInfos.size(), 1);
        assertEquals(childrenTaskInfos.get(0).taskId, child1.mTaskId);
    }

    @Test
    public void testAddTasksHomeClearUntrackedTasks_expectFinish() {
        // There may be multiple tasks with the same base intent by flags (FLAG_ACTIVITY_NEW_TASK |
@@ -1419,46 +1401,6 @@ public class RecentTasksTest extends WindowTestsBase {
        }
    }

    @Test
    public void testLastSnapshotData_snapshotSaved() {
        final TaskSnapshot snapshot = createSnapshot(new Point(100, 100), new Point(80, 80));
        final Task task1 = createTaskBuilder(".Task").build();
        task1.onSnapshotChanged(snapshot);

        mRecentTasks.add(task1);
        final List<RecentTaskInfo> infos = getRecentTasks(0 /* flags */);
        final RecentTaskInfo.PersistedTaskSnapshotData lastSnapshotData =
                infos.get(0).lastSnapshotData;
        assertTrue(lastSnapshotData.taskSize.equals(100, 100));
        assertTrue(lastSnapshotData.bufferSize.equals(80, 80));
    }

    @Test
    public void testLastSnapshotData_noBuffer() {
        final Task task1 = createTaskBuilder(".Task").build();
        final TaskSnapshot snapshot = createSnapshot(new Point(100, 100), null);
        task1.onSnapshotChanged(snapshot);

        mRecentTasks.add(task1);
        final List<RecentTaskInfo> infos = getRecentTasks(0 /* flags */);
        final RecentTaskInfo.PersistedTaskSnapshotData lastSnapshotData =
                infos.get(0).lastSnapshotData;
        assertTrue(lastSnapshotData.taskSize.equals(100, 100));
        assertNull(lastSnapshotData.bufferSize);
    }

    @Test
    public void testLastSnapshotData_notSet() {
        final Task task1 = createTaskBuilder(".Task").build();

        mRecentTasks.add(task1);
        final List<RecentTaskInfo> infos = getRecentTasks(0 /* flags */);
        final RecentTaskInfo.PersistedTaskSnapshotData lastSnapshotData =
                infos.get(0).lastSnapshotData;
        assertNull(lastSnapshotData.taskSize);
        assertNull(lastSnapshotData.bufferSize);
    }

    @Test
    public void testCreateRecentTaskInfo_detachedTask() {
        final Task task = createTaskBuilder(".Task").build();