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) { if (task == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId); throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
} }
return mService.getRecentTasks().createRecentTaskInfo(task); return mService.getRecentTasks().createRecentTaskInfo(task,
false /* stripExtras */);
} finally { } finally {
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
} }

View File

@@ -961,7 +961,7 @@ class RecentTasks {
continue; continue;
} }
res.add(createRecentTaskInfo(task)); res.add(createRecentTaskInfo(task, true /* stripExtras */));
} }
return res; return res;
} }
@@ -1832,9 +1832,9 @@ class RecentTasks {
/** /**
* Creates a new RecentTaskInfo from a Task. * 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(); ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
tr.fillTaskInfo(rti); tr.fillTaskInfo(rti, stripExtras);
// Fill in some deprecated values // Fill in some deprecated values
rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID; rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
rti.persistentId = rti.taskId; 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 * 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. * task info will not include any extras or clip data.
*/ */
void fillTaskInfo(TaskInfo info) { 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); getNumRunningActivities(mReuseActivitiesReport);
info.userId = mUserId; info.userId = mUserId;
info.stackId = getRootTaskId(); 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. // Make a copy of base intent because this is like a snapshot info.
// Besides, {@link RecentTasks#getRecentTasksImpl} may modify it. // Besides, {@link RecentTasks#getRecentTasksImpl} may modify it.
final int baseIntentFlags = baseIntent == null ? 0 : baseIntent.getFlags(); 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.baseIntent.setFlags(baseIntentFlags);
info.baseActivity = mReuseActivitiesReport.base != null info.baseActivity = mReuseActivitiesReport.base != null
? mReuseActivitiesReport.base.intent.getComponent() ? mReuseActivitiesReport.base.intent.getComponent()