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

Commit abfdcceb authored by Winson Chung's avatar Winson Chung
Browse files

Consolidate RecentTaskInfo and RunningTaskInfo into TaskInfo class

- Remove overlapping logic for building both recent/running task infos
- Deprecate unused members of recent/running task infos
- Skip creating unnecessary recent task info when creating AppTaskImpl

Bug: 111078814
Test: Build and open Overview (ensure it still works)
Test: atest CtsAppTestCases:ActivityManagerRecentTaskInfoTest
Test: atest CtsAppTestCases:ActivityManagerRunningTaskInfoTest
Change-Id: Iaf1731002196bb89319de141a05ab92a7dcb2928
parent 0c16e74b
Loading
Loading
Loading
Loading
+21 −19
Original line number Diff line number Diff line
@@ -3951,22 +3951,16 @@ package android.app {
    field public int uid;
  }
  public static class ActivityManager.RecentTaskInfo implements android.os.Parcelable {
  public static class ActivityManager.RecentTaskInfo extends android.app.TaskInfo implements android.os.Parcelable {
    ctor public ActivityManager.RecentTaskInfo();
    method public int describeContents();
    method public void readFromParcel(android.os.Parcel);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.ActivityManager.RecentTaskInfo> CREATOR;
    field public int affiliatedTaskId;
    field public android.content.ComponentName baseActivity;
    field public android.content.Intent baseIntent;
    field public java.lang.CharSequence description;
    field public int id;
    field public int numActivities;
    field public android.content.ComponentName origActivity;
    field public int persistentId;
    field public android.app.ActivityManager.TaskDescription taskDescription;
    field public android.content.ComponentName topActivity;
    field public deprecated int affiliatedTaskId;
    field public deprecated java.lang.CharSequence description;
    field public deprecated int id;
    field public deprecated int persistentId;
  }
  public static class ActivityManager.RunningAppProcessInfo implements android.os.Parcelable {
@@ -4030,19 +4024,16 @@ package android.app {
    field public int uid;
  }
  public static class ActivityManager.RunningTaskInfo implements android.os.Parcelable {
  public static class ActivityManager.RunningTaskInfo extends android.app.TaskInfo implements android.os.Parcelable {
    ctor public ActivityManager.RunningTaskInfo();
    method public int describeContents();
    method public void readFromParcel(android.os.Parcel);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.ActivityManager.RunningTaskInfo> CREATOR;
    field public android.content.ComponentName baseActivity;
    field public java.lang.CharSequence description;
    field public int id;
    field public int numActivities;
    field public int numRunning;
    field public android.graphics.Bitmap thumbnail;
    field public android.content.ComponentName topActivity;
    field public deprecated java.lang.CharSequence description;
    field public deprecated int id;
    field public deprecated int numRunning;
    field public deprecated android.graphics.Bitmap thumbnail;
  }
  public static class ActivityManager.TaskDescription implements android.os.Parcelable {
@@ -6091,6 +6082,17 @@ package android.app {
    method public void setDefaultTab(int);
  }
  public class TaskInfo {
    field public android.content.ComponentName baseActivity;
    field public android.content.Intent baseIntent;
    field public boolean isRunning;
    field public int numActivities;
    field public android.content.ComponentName origActivity;
    field public android.app.ActivityManager.TaskDescription taskDescription;
    field public int taskId;
    field public android.content.ComponentName topActivity;
  }
  public class TaskStackBuilder {
    method public android.app.TaskStackBuilder addNextIntent(android.content.Intent);
    method public android.app.TaskStackBuilder addNextIntentWithParentStack(android.content.Intent);
+5 −7
Original line number Diff line number Diff line
@@ -111,13 +111,6 @@ Landroid/app/ActivityManager$MemoryInfo;->foregroundAppThreshold:J
Landroid/app/ActivityManager$MemoryInfo;->hiddenAppThreshold:J
Landroid/app/ActivityManager$MemoryInfo;->secondaryServerThreshold:J
Landroid/app/ActivityManager$MemoryInfo;->visibleAppThreshold:J
Landroid/app/ActivityManager$RecentTaskInfo;->affiliatedTaskColor:I
Landroid/app/ActivityManager$RecentTaskInfo;->firstActiveTime:J
Landroid/app/ActivityManager$RecentTaskInfo;->lastActiveTime:J
Landroid/app/ActivityManager$RecentTaskInfo;->resizeMode:I
Landroid/app/ActivityManager$RecentTaskInfo;->stackId:I
Landroid/app/ActivityManager$RecentTaskInfo;->supportsSplitScreenMultiWindow:Z
Landroid/app/ActivityManager$RecentTaskInfo;->userId:I
Landroid/app/ActivityManager$RunningAppProcessInfo;->flags:I
Landroid/app/ActivityManager$RunningAppProcessInfo;->FLAG_HAS_ACTIVITIES:I
Landroid/app/ActivityManager$RunningAppProcessInfo;->FLAG_PERSISTENT:I
@@ -936,6 +929,11 @@ Landroid/app/StatusBarManager;->getService()Lcom/android/internal/statusbar/ISta
Landroid/app/StatusBarManager;->mContext:Landroid/content/Context;
Landroid/app/StatusBarManager;->mToken:Landroid/os/IBinder;
Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
Landroid/app/TaskInfo;->lastActiveTime:J
Landroid/app/TaskInfo;->resizeMode:I
Landroid/app/TaskInfo;->stackId:I
Landroid/app/TaskInfo;->supportsSplitScreenMultiWindow:Z
Landroid/app/TaskInfo;->userId:I
Landroid/app/TaskStackListener;-><init>()V
Landroid/app/TimePickerDialog;->mTimePicker:Landroid/widget/TimePicker;
Landroid/app/trust/ITrustManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
+1 −1
Original line number Diff line number Diff line
Landroid/accounts/AccountManager;-><init>(Landroid/content/Context;Landroid/accounts/IAccountManager;Landroid/os/Handler;)V
Landroid/app/Activity;->managedQuery(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
Landroid/app/Activity;->registerRemoteAnimations(Landroid/view/RemoteAnimationDefinition;)V
Landroid/app/ActivityManager$RecentTaskInfo;->configuration:Landroid/content/res/Configuration;
Landroid/app/ActivityManager$TaskDescription;->loadTaskDescriptionIcon(Ljava/lang/String;I)Landroid/graphics/Bitmap;
Landroid/app/ActivityManager$TaskSnapshot;->getSnapshot()Landroid/graphics/GraphicBuffer;
Landroid/app/ActivityManagerNative;->broadcastStickyIntent(Landroid/content/Intent;Ljava/lang/String;I)V
@@ -40,6 +39,7 @@ Landroid/app/KeyguardManager;->isDeviceLocked(I)Z
Landroid/app/NotificationManager;->cancelAsUser(Ljava/lang/String;ILandroid/os/UserHandle;)V
Landroid/app/StatusBarManager;->removeIcon(Ljava/lang/String;)V
Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;IILjava/lang/String;)V
Landroid/app/TaskInfo;->configuration:Landroid/content/res/Configuration;
Landroid/app/TaskStackListener;->onActivityDismissingDockedStack()V
Landroid/app/TaskStackListener;->onActivityForcedResizable(Ljava/lang/String;II)V
Landroid/app/TaskStackListener;->onActivityLaunchOnSecondaryDisplayFailed()V
+56 −252
Original line number Diff line number Diff line
@@ -1323,197 +1323,66 @@ public class ActivityManager {
     * Information you can retrieve about tasks that the user has most recently
     * started or visited.
     */
    public static class RecentTaskInfo implements Parcelable {
    public static class RecentTaskInfo extends TaskInfo implements Parcelable {
        /**
         * If this task is currently running, this is the identifier for it.
         * If it is not running, this will be -1.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, use
         * {@link RecentTaskInfo#taskId} to get the task id and {@link RecentTaskInfo#isRunning}
         * to determine if it is running.
         */
        @Deprecated
        public int id;

        /**
         * The true identifier of this task, valid even if it is not running.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, use
         * {@link RecentTaskInfo#taskId}.
         */
        @Deprecated
        public int persistentId;

        /**
         * The original Intent used to launch the task.  You can use this
         * Intent to re-launch the task (if it is no longer running) or bring
         * the current task to the front.
         */
        public Intent baseIntent;

        /**
         * If this task was started from an alias, this is the actual
         * activity component that was initially started; the component of
         * the baseIntent in this case is the name of the actual activity
         * implementation that the alias referred to.  Otherwise, this is null.
         */
        public ComponentName origActivity;

        /**
         * The actual activity component that started the task.
         * @hide
         */
        @Nullable
        public ComponentName realActivity;

        /**
         * Description of the task's last state.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always null.
         */
        @Deprecated
        public CharSequence description;

        /**
         * The id of the ActivityStack this Task was on most recently.
         * @hide
         */
        public int stackId;

        /**
         * The id of the user the task was running as.
         * @hide
         */
        public int userId;

        /**
         * The first time this task was active.
         * @hide
         */
        public long firstActiveTime;

        /**
         * The last time this task was active.
         * @hide
         */
        public long lastActiveTime;

        /**
         * The recent activity values for the highest activity in the stack to have set the values.
         * {@link Activity#setTaskDescription(android.app.ActivityManager.TaskDescription)}.
         */
        public TaskDescription taskDescription;

        /**
         * Task affiliation for grouping with other tasks.
         */
        public int affiliatedTaskId;

        /**
         * Task affiliation color of the source task with the affiliated task id.
         *
         * @hide
         */
        public int affiliatedTaskColor;

        /**
         * The component launched as the first activity in the task.
         * This can be considered the "application" of this task.
         */
        public ComponentName baseActivity;

        /**
         * The activity component at the top of the history stack of the task.
         * This is what the user is currently doing.
         */
        public ComponentName topActivity;

        /**
         * Number of activities in this task.
         */
        public int numActivities;

        /**
         * The bounds of the task.
         * @hide
         */
        public Rect bounds;

        /**
         * True if the task can go in the docked stack.
         * @hide
         */
        public boolean supportsSplitScreenMultiWindow;

        /**
         * The resize mode of the task. See {@link ActivityInfo#resizeMode}.
         * @hide
         */
        public int resizeMode;

        /**
         * The current configuration this task is in.
         * @hide
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always 0.
         */
        final public Configuration configuration = new Configuration();
        @Deprecated
        public int affiliatedTaskId;

        public RecentTaskInfo() {
        }

        private RecentTaskInfo(Parcel source) {
            readFromParcel(source);
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public void readFromParcel(Parcel source) {
            id = source.readInt();
            persistentId = source.readInt();
            super.readFromParcel(source);
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeInt(persistentId);
            if (baseIntent != null) {
                dest.writeInt(1);
                baseIntent.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            ComponentName.writeToParcel(origActivity, dest);
            ComponentName.writeToParcel(realActivity, dest);
            TextUtils.writeToParcel(description, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            if (taskDescription != null) {
                dest.writeInt(1);
                taskDescription.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            dest.writeInt(stackId);
            dest.writeInt(userId);
            dest.writeLong(lastActiveTime);
            dest.writeInt(affiliatedTaskId);
            dest.writeInt(affiliatedTaskColor);
            ComponentName.writeToParcel(baseActivity, dest);
            ComponentName.writeToParcel(topActivity, dest);
            dest.writeInt(numActivities);
            if (bounds != null) {
                dest.writeInt(1);
                bounds.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0);
            dest.writeInt(resizeMode);
            configuration.writeToParcel(dest, flags);
        }

        public void readFromParcel(Parcel source) {
            id = source.readInt();
            persistentId = source.readInt();
            baseIntent = source.readInt() > 0 ? Intent.CREATOR.createFromParcel(source) : null;
            origActivity = ComponentName.readFromParcel(source);
            realActivity = ComponentName.readFromParcel(source);
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            taskDescription = source.readInt() > 0 ?
                    TaskDescription.CREATOR.createFromParcel(source) : null;
            stackId = source.readInt();
            userId = source.readInt();
            lastActiveTime = source.readLong();
            affiliatedTaskId = source.readInt();
            affiliatedTaskColor = source.readInt();
            baseActivity = ComponentName.readFromParcel(source);
            topActivity = ComponentName.readFromParcel(source);
            numActivities = source.readInt();
            bounds = source.readInt() > 0 ?
                    Rect.CREATOR.createFromParcel(source) : null;
            supportsSplitScreenMultiWindow = source.readInt() == 1;
            resizeMode = source.readInt();
            configuration.readFromParcel(source);
            super.writeToParcel(dest, flags);
        }

        public static final Creator<RecentTaskInfo> CREATOR
@@ -1525,10 +1394,6 @@ public class ActivityManager {
                return new RecentTaskInfo[size];
            }
        };

        private RecentTaskInfo(Parcel source) {
            readFromParcel(source);
        }
    }

    /**
@@ -1596,119 +1461,62 @@ public class ActivityManager {
     * the system may have killed its process and is only holding on to its
     * last state in order to restart it when the user returns.
     */
    public static class RunningTaskInfo implements Parcelable {
    public static class RunningTaskInfo extends TaskInfo implements Parcelable {

        /**
         * A unique identifier for this task.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, use
         * {@link RunningTaskInfo#taskId}.
         */
        @Deprecated
        public int id;

        /**
         * The stack that currently contains this task.
         * @hide
         */
        public int stackId;

        /**
         * The component launched as the first activity in the task.  This can
         * be considered the "application" of this task.
         */
        public ComponentName baseActivity;

        /**
         * The activity component at the top of the history stack of the task.
         * This is what the user is currently doing.
         */
        public ComponentName topActivity;

        /**
         * Thumbnail representation of the task's current state.  Currently
         * always null.
         * Thumbnail representation of the task's current state.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always null.
         */
        @Deprecated
        public Bitmap thumbnail;

        /**
         * Description of the task's current state.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always null.
         */
        @Deprecated
        public CharSequence description;

        /**
         * Number of activities in this task.
         */
        public int numActivities;

        /**
         * Number of activities that are currently running (not stopped
         * and persisted) in this task.
         * Number of activities that are currently running (not stopped and persisted) in this task.
         *
         * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always 0.
         */
        @Deprecated
        public int numRunning;

        /**
         * Last time task was run. For sorting.
         * @hide
         */
        public long lastActiveTime;

        /**
         * True if the task can go in the docked stack.
         * @hide
         */
        public boolean supportsSplitScreenMultiWindow;

        /**
         * The resize mode of the task. See {@link ActivityInfo#resizeMode}.
         * @hide
         */
        public int resizeMode;

        /**
         * The full configuration the task is currently running in.
         * @hide
         */
        final public Configuration configuration = new Configuration();

        public RunningTaskInfo() {
        }

        public int describeContents() {
            return 0;
        private RunningTaskInfo(Parcel source) {
            readFromParcel(source);
        }

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeInt(stackId);
            ComponentName.writeToParcel(baseActivity, dest);
            ComponentName.writeToParcel(topActivity, dest);
            if (thumbnail != null) {
                dest.writeInt(1);
                thumbnail.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            TextUtils.writeToParcel(description, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            dest.writeInt(numActivities);
            dest.writeInt(numRunning);
            dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0);
            dest.writeInt(resizeMode);
            configuration.writeToParcel(dest, flags);
        @Override
        public int describeContents() {
            return 0;
        }

        public void readFromParcel(Parcel source) {
            id = source.readInt();
            stackId = source.readInt();
            baseActivity = ComponentName.readFromParcel(source);
            topActivity = ComponentName.readFromParcel(source);
            if (source.readInt() != 0) {
                thumbnail = Bitmap.CREATOR.createFromParcel(source);
            } else {
                thumbnail = null;
            super.readFromParcel(source);
        }
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            numActivities = source.readInt();
            numRunning = source.readInt();
            supportsSplitScreenMultiWindow = source.readInt() != 0;
            resizeMode = source.readInt();
            configuration.readFromParcel(source);

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            super.writeToParcel(dest, flags);
        }

        public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() {
@@ -1719,10 +1527,6 @@ public class ActivityManager {
                return new RunningTaskInfo[size];
            }
        };

        private RunningTaskInfo(Parcel source) {
            readFromParcel(source);
        }
    }

    /**
+214 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading