diff --git a/api/current.txt b/api/current.txt index 9a47a66fd73eb..abf1224473a76 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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 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 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); diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt index 3e9077b36d38a..4484c8f15986c 100644 --- a/config/hiddenapi-light-greylist.txt +++ b/config/hiddenapi-light-greylist.txt @@ -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;->()V Landroid/app/TimePickerDialog;->mTimePicker:Landroid/widget/TimePicker; Landroid/app/trust/ITrustManager$Stub$Proxy;->(Landroid/os/IBinder;)V diff --git a/config/hiddenapi-vendor-list.txt b/config/hiddenapi-vendor-list.txt index 43b1a0e1c38c4..a07843be06d0d 100644 --- a/config/hiddenapi-vendor-list.txt +++ b/config/hiddenapi-vendor-list.txt @@ -1,7 +1,6 @@ Landroid/accounts/AccountManager;->(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 diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 90fa8ca82dbcc..5e428db6bf141 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -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. + * + * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, currently always 0. */ + @Deprecated 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 - */ - final public Configuration configuration = new Configuration(); - 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 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() { } + private RunningTaskInfo(Parcel source) { + readFromParcel(source); + } + + @Override public int describeContents() { return 0; } - 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); - } - 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; - } - description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); - numActivities = source.readInt(); - numRunning = source.readInt(); - supportsSplitScreenMultiWindow = source.readInt() != 0; - resizeMode = source.readInt(); - configuration.readFromParcel(source); + super.readFromParcel(source); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(id); + super.writeToParcel(dest, flags); } public static final Creator CREATOR = new Creator() { @@ -1719,10 +1527,6 @@ public class ActivityManager { return new RunningTaskInfo[size]; } }; - - private RunningTaskInfo(Parcel source) { - readFromParcel(source); - } } /** diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java new file mode 100644 index 0000000000000..970a0881a407c --- /dev/null +++ b/core/java/android/app/TaskInfo.java @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.app; + +import android.content.ComponentName; +import android.content.Intent; +import android.content.res.Configuration; +import android.os.Parcel; +import android.os.RemoteException; +import android.util.Log; + +/** + * Stores information about a particular Task. + */ +public class TaskInfo { + private static final String TAG = "TaskInfo"; + + /** + * The id of the user the task was running as. + * @hide + */ + public int userId; + + /** + * The id of the ActivityStack that currently contains this task. + * @hide + */ + public int stackId; + + /** + * The identifier for this task. + */ + public int taskId; + + /** + * Whether or not this task has any running activities. + */ + public boolean isRunning; + + /** + * The base intent of the task (generally the intent that launched the task). This intent can + * be used to relaunch the task (if it is no longer running) or brought to the front if it is. + */ + public Intent baseIntent; + + /** + * The component of the first activity in the task, can be considered the "application" of this + * task. + */ + public ComponentName baseActivity; + + /** + * The component of the top activity in the task, currently showing to the user. + */ + public ComponentName topActivity; + + /** + * The component of the target activity if this task was started from an activity alias. + * Otherwise, this is null. + */ + public ComponentName origActivity; + + /** + * The component of the activity that started this task (may be the component of the activity + * alias). + * @hide + */ + public ComponentName realActivity; + + /** + * The number of activities in this task (including running). + */ + public int numActivities; + + /** + * The last time this task was active since boot (including time spent in sleep). + * @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 ActivityManager.TaskDescription taskDescription; + + /** + * True if the task can go in the split-screen primary stack. + * @hide + */ + public boolean supportsSplitScreenMultiWindow; + + /** + * The resize mode of the task. See {@link ActivityInfo#resizeMode}. + * @hide + */ + public int resizeMode; + + /** + * The current configuration of the task. + * @hide + */ + public final Configuration configuration = new Configuration(); + + TaskInfo() { + // Do nothing + } + + private TaskInfo(Parcel source) { + readFromParcel(source); + } + + /** + * @param reducedResolution + * @return + * @hide + */ + public ActivityManager.TaskSnapshot getTaskSnapshot(boolean reducedResolution) { + try { + return ActivityManager.getService().getTaskSnapshot(taskId, reducedResolution); + } catch (RemoteException e) { + Log.e(TAG, "Failed to get task snapshot, taskId=" + taskId, e); + return null; + } + } + + /** + * Reads the TaskInfo from a parcel. + */ + void readFromParcel(Parcel source) { + userId = source.readInt(); + stackId = source.readInt(); + taskId = source.readInt(); + isRunning = source.readBoolean(); + baseIntent = source.readInt() != 0 + ? Intent.CREATOR.createFromParcel(source) + : null; + baseActivity = ComponentName.readFromParcel(source); + topActivity = ComponentName.readFromParcel(source); + origActivity = ComponentName.readFromParcel(source); + realActivity = ComponentName.readFromParcel(source); + + numActivities = source.readInt(); + lastActiveTime = source.readLong(); + + taskDescription = source.readInt() != 0 + ? ActivityManager.TaskDescription.CREATOR.createFromParcel(source) + : null; + supportsSplitScreenMultiWindow = source.readBoolean(); + resizeMode = source.readInt(); + configuration.readFromParcel(source); + } + + /** + * Writes the TaskInfo to a parcel. + */ + void writeToParcel(Parcel dest, int flags) { + dest.writeInt(userId); + dest.writeInt(stackId); + dest.writeInt(taskId); + dest.writeBoolean(isRunning); + + if (baseIntent != null) { + dest.writeInt(1); + baseIntent.writeToParcel(dest, 0); + } else { + dest.writeInt(0); + } + ComponentName.writeToParcel(baseActivity, dest); + ComponentName.writeToParcel(topActivity, dest); + ComponentName.writeToParcel(origActivity, dest); + ComponentName.writeToParcel(realActivity, dest); + + dest.writeInt(numActivities); + dest.writeLong(lastActiveTime); + + if (taskDescription != null) { + dest.writeInt(1); + taskDescription.writeToParcel(dest, flags); + } else { + dest.writeInt(0); + } + dest.writeBoolean(supportsSplitScreenMultiWindow); + dest.writeInt(resizeMode); + configuration.writeToParcel(dest, flags); + } + + @Override + public String toString() { + return "TaskInfo{userId=" + userId + " stackId=" + stackId + " taskId=" + taskId + + " isRunning=" + isRunning + + " baseIntent=" + baseIntent + " baseActivity=" + baseActivity + + " topActivity=" + topActivity + " origActivity=" + origActivity + + " realActivity=" + realActivity + + " numActivities=" + numActivities + + " lastActiveTime=" + lastActiveTime + + " supportsSplitScreenMultiWindow=" + supportsSplitScreenMultiWindow + + " resizeMode=" + resizeMode; + } +} diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java index 1967c76b23e34..fb22ad08e5cd5 100644 --- a/services/core/java/com/android/server/am/RecentTasks.java +++ b/services/core/java/com/android/server/am/RecentTasks.java @@ -702,8 +702,7 @@ class RecentTasks { if (intent == null || !callingPackage.equals(intent.getComponent().getPackageName())) { continue; } - ActivityManager.RecentTaskInfo taskInfo = createRecentTaskInfo(tr); - AppTaskImpl taskImpl = new AppTaskImpl(mService, taskInfo.persistentId, callingUid); + AppTaskImpl taskImpl = new AppTaskImpl(mService, tr.taskId, callingUid); list.add(taskImpl.asBinder()); } return list; @@ -1543,33 +1542,11 @@ class RecentTasks { * Creates a new RecentTaskInfo from a TaskRecord. */ ActivityManager.RecentTaskInfo createRecentTaskInfo(TaskRecord tr) { - // Compose the recent task info ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); - rti.id = tr.getTopActivity() == null ? INVALID_TASK_ID : tr.taskId; - rti.persistentId = tr.taskId; - rti.baseIntent = new Intent(tr.getBaseIntent()); - rti.origActivity = tr.origActivity; - rti.realActivity = tr.realActivity; - rti.description = tr.lastDescription; - rti.stackId = tr.getStackId(); - rti.userId = tr.userId; - rti.taskDescription = new ActivityManager.TaskDescription(tr.lastTaskDescription); - rti.lastActiveTime = tr.lastActiveTime; - rti.affiliatedTaskId = tr.mAffiliatedTaskId; - rti.affiliatedTaskColor = tr.mAffiliatedTaskColor; - rti.numActivities = 0; - if (!tr.matchParentBounds()) { - rti.bounds = new Rect(tr.getOverrideBounds()); - } - rti.supportsSplitScreenMultiWindow = tr.supportsSplitScreenWindowingMode(); - rti.resizeMode = tr.mResizeMode; - rti.configuration.setTo(tr.getConfiguration()); - - tr.getNumRunningActivities(mTmpReport); - rti.numActivities = mTmpReport.numActivities; - rti.baseActivity = (mTmpReport.base != null) ? mTmpReport.base.intent.getComponent() : null; - rti.topActivity = (mTmpReport.top != null) ? mTmpReport.top.intent.getComponent() : null; - + tr.fillTaskInfo(rti, mTmpReport); + // Fill in some deprecated values + rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID; + rti.persistentId = rti.taskId; return rti; } diff --git a/services/core/java/com/android/server/am/RunningTasks.java b/services/core/java/com/android/server/am/RunningTasks.java index c860df89f29fe..8c92496a18b68 100644 --- a/services/core/java/com/android/server/am/RunningTasks.java +++ b/services/core/java/com/android/server/am/RunningTasks.java @@ -85,20 +85,10 @@ class RunningTasks { * Constructs a {@link RunningTaskInfo} from a given {@param task}. */ private RunningTaskInfo createRunningTaskInfo(TaskRecord task) { - task.getNumRunningActivities(mTmpReport); - - final RunningTaskInfo ci = new RunningTaskInfo(); - ci.id = task.taskId; - ci.stackId = task.getStackId(); - ci.baseActivity = mTmpReport.base.intent.getComponent(); - ci.topActivity = mTmpReport.top.intent.getComponent(); - ci.lastActiveTime = task.lastActiveTime; - ci.description = task.lastDescription; - ci.numActivities = mTmpReport.numActivities; - ci.numRunning = mTmpReport.numRunning; - ci.supportsSplitScreenMultiWindow = task.supportsSplitScreenWindowingMode(); - ci.resizeMode = task.mResizeMode; - ci.configuration.setTo(task.getConfiguration()); - return ci; + final RunningTaskInfo rti = new RunningTaskInfo(); + task.fillTaskInfo(rti, mTmpReport); + // Fill in some deprecated values + rti.id = rti.taskId; + return rti; } } diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 11684afca5c46..2d0c2a86b7b7f 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -88,6 +88,7 @@ import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.AppGlobals; import android.app.IActivityManager; +import android.app.TaskInfo; import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -1939,6 +1940,35 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi } } + /** + * Fills in a {@link TaskInfo} with information from this task. + * @param info the {@link TaskInfo} to fill in + * @param reuseActivitiesReport a temporary activities report that we can reuse to fetch the + * running activities + */ + void fillTaskInfo(TaskInfo info, TaskActivitiesReport reuseActivitiesReport) { + getNumRunningActivities(reuseActivitiesReport); + info.userId = userId; + info.stackId = getStackId(); + info.taskId = taskId; + info.isRunning = getTopActivity() != null; + info.baseIntent = getBaseIntent(); + info.baseActivity = reuseActivitiesReport.base != null + ? reuseActivitiesReport.base.intent.getComponent() + : null; + info.topActivity = reuseActivitiesReport.top != null + ? reuseActivitiesReport.top.intent.getComponent() + : null; + info.origActivity = origActivity; + info.realActivity = realActivity; + info.numActivities = reuseActivitiesReport.numActivities; + info.lastActiveTime = lastActiveTime; + info.taskDescription = new ActivityManager.TaskDescription(lastTaskDescription); + info.supportsSplitScreenMultiWindow = supportsSplitScreenWindowingMode(); + info.resizeMode = mResizeMode; + info.configuration.setTo(getConfiguration()); + } + void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("userId="); pw.print(userId); pw.print(" effectiveUid="); UserHandle.formatUid(pw, effectiveUid);