Allow app tasks api to fetch its own task base-intent extras

- We strip it for other callers where we know we don't need the info
  but apps might need this for some reason

Bug: 159649017
Test: atest AppTaskTests#testBaseIntentHasExtras
Change-Id: I3365989cad92e557f1143f52ffd77e85f8618c0d
This commit is contained in:
Winson Chung
2020-06-23 10:41:44 -07:00
parent 449851f8e2
commit 02757715fb
3 changed files with 16 additions and 5 deletions

View File

@@ -83,7 +83,8 @@ class AppTaskImpl extends IAppTask.Stub {
if (task == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
}
return mService.getRecentTasks().createRecentTaskInfo(task);
return mService.getRecentTasks().createRecentTaskInfo(task,
false /* stripExtras */);
} finally {
Binder.restoreCallingIdentity(origId);
}

View File

@@ -961,7 +961,7 @@ class RecentTasks {
continue;
}
res.add(createRecentTaskInfo(task));
res.add(createRecentTaskInfo(task, true /* stripExtras */));
}
return res;
}
@@ -1832,9 +1832,9 @@ class RecentTasks {
/**
* Creates a new RecentTaskInfo from a Task.
*/
ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr) {
ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras) {
ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
tr.fillTaskInfo(rti);
tr.fillTaskInfo(rti, stripExtras);
// Fill in some deprecated values
rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
rti.persistentId = rti.taskId;

View File

@@ -3551,11 +3551,19 @@ class Task extends WindowContainer<WindowContainer> {
}
}
/**
* Fills in a {@link TaskInfo} with information from this task. Note that the base intent in the
* task info will not include any extras or clip data.
*/
void fillTaskInfo(TaskInfo info) {
fillTaskInfo(info, true /* stripExtras */);
}
/**
* Fills in a {@link TaskInfo} with information from this task.
*/
void fillTaskInfo(TaskInfo info, boolean stripExtras) {
getNumRunningActivities(mReuseActivitiesReport);
info.userId = mUserId;
info.stackId = getRootTaskId();
@@ -3566,7 +3574,9 @@ class Task extends WindowContainer<WindowContainer> {
// Make a copy of base intent because this is like a snapshot info.
// Besides, {@link RecentTasks#getRecentTasksImpl} may modify it.
final int baseIntentFlags = baseIntent == null ? 0 : baseIntent.getFlags();
info.baseIntent = baseIntent == null ? new Intent() : baseIntent.cloneFilter();
info.baseIntent = baseIntent == null
? new Intent()
: stripExtras ? baseIntent.cloneFilter() : new Intent(baseIntent);
info.baseIntent.setFlags(baseIntentFlags);
info.baseActivity = mReuseActivitiesReport.base != null
? mReuseActivitiesReport.base.intent.getComponent()