1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
/*
* 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 static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import android.window.WindowContainerToken;
/**
* 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
*/
@UnsupportedAppUsage
public int userId;
/**
* The id of the ActivityStack that currently contains this task.
* @hide
*/
@UnsupportedAppUsage
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.
*/
@NonNull
public Intent baseIntent;
/**
* The component of the first activity in the task, can be considered the "application" of this
* task.
*/
@Nullable
public ComponentName baseActivity;
/**
* The component of the top activity in the task, currently showing to the user.
*/
@Nullable
public ComponentName topActivity;
/**
* The component of the target activity if this task was started from an activity alias.
* Otherwise, this is null.
*/
@Nullable
public ComponentName origActivity;
/**
* The component of the activity that started this task (may be the component of the activity
* alias).
* @hide
*/
@Nullable
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
*/
@UnsupportedAppUsage
public long lastActiveTime;
/**
* The id of the display this task is associated with.
* @hide
*/
public int displayId;
/**
* The recent activity values for the highest activity in the stack to have set the values.
* {@link Activity#setTaskDescription(android.app.ActivityManager.TaskDescription)}.
*/
@Nullable
public ActivityManager.TaskDescription taskDescription;
/**
* True if the task can go in the split-screen primary stack.
* @hide
*/
@UnsupportedAppUsage
public boolean supportsSplitScreenMultiWindow;
/**
* The resize mode of the task. See {@link ActivityInfo#resizeMode}.
* @hide
*/
@UnsupportedAppUsage
public int resizeMode;
/**
* The current configuration of the task.
* @hide
*/
@NonNull
@UnsupportedAppUsage
public final Configuration configuration = new Configuration();
/**
* Used as an opaque identifier for this task.
* @hide
*/
@NonNull
public WindowContainerToken token;
/**
* The PictureInPictureParams for the Task, if set.
* @hide
*/
@Nullable
public PictureInPictureParams pictureInPictureParams;
/**
* The activity type of the top activity in this task.
* @hide
*/
public @WindowConfiguration.ActivityType int topActivityType;
/**
* The {@link ActivityInfo} of the top activity in this task.
* @hide
*/
@Nullable
public ActivityInfo topActivityInfo;
TaskInfo() {
// Do nothing
}
private TaskInfo(Parcel source) {
readFromParcel(source);
}
/**
* @param isLowResolution
* @return
* @hide
*/
public ActivityManager.TaskSnapshot getTaskSnapshot(boolean isLowResolution) {
try {
return ActivityManager.getService().getTaskSnapshot(taskId, isLowResolution);
} catch (RemoteException e) {
Log.e(TAG, "Failed to get task snapshot, taskId=" + taskId, e);
return null;
}
}
/** @hide */
public boolean isResizable() {
return resizeMode != RESIZE_MODE_UNRESIZEABLE;
}
/** @hide */
@NonNull
@TestApi
public WindowContainerToken getToken() {
return token;
}
/** @hide */
@NonNull
@TestApi
public Configuration getConfiguration() {
return configuration;
}
/**
* Reads the TaskInfo from a parcel.
*/
void readFromParcel(Parcel source) {
userId = source.readInt();
stackId = source.readInt();
taskId = source.readInt();
displayId = 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);
token = WindowContainerToken.CREATOR.createFromParcel(source);
topActivityType = source.readInt();
pictureInPictureParams = source.readInt() != 0
? PictureInPictureParams.CREATOR.createFromParcel(source)
: null;
topActivityInfo = source.readInt() != 0
? ActivityInfo.CREATOR.createFromParcel(source)
: null;
}
/**
* Writes the TaskInfo to a parcel.
*/
void writeToParcel(Parcel dest, int flags) {
dest.writeInt(userId);
dest.writeInt(stackId);
dest.writeInt(taskId);
dest.writeInt(displayId);
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);
token.writeToParcel(dest, flags);
dest.writeInt(topActivityType);
if (pictureInPictureParams == null) {
dest.writeInt(0);
} else {
dest.writeInt(1);
pictureInPictureParams.writeToParcel(dest, flags);
}
if (topActivityInfo == null) {
dest.writeInt(0);
} else {
dest.writeInt(1);
topActivityInfo.writeToParcel(dest, flags);
}
}
@Override
public String toString() {
return "TaskInfo{userId=" + userId + " stackId=" + stackId + " taskId=" + taskId
+ " displayId=" + displayId
+ " isRunning=" + isRunning
+ " baseIntent=" + baseIntent + " baseActivity=" + baseActivity
+ " topActivity=" + topActivity + " origActivity=" + origActivity
+ " realActivity=" + realActivity
+ " numActivities=" + numActivities
+ " lastActiveTime=" + lastActiveTime
+ " supportsSplitScreenMultiWindow=" + supportsSplitScreenMultiWindow
+ " resizeMode=" + resizeMode
+ " token=" + token
+ " topActivityType=" + topActivityType
+ " pictureInPictureParams=" + pictureInPictureParams
+ " topActivityInfo=" + topActivityInfo;
}
}
|