From 2c1faed4123baca6d5c2d87a7609da0fb33cbbd9 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Tue, 23 Jul 2013 12:56:02 -0700 Subject: [PATCH] Set task and activity types when adding to task. Activities from the home package were causing tasks types to change from application to home. This was not the intention of setting the task type when adding an activity. This change sets the task type to the inherent type of the first activity added. All subsequent activities added to the task then inherent the task's type overriding the inherent type of the task. Fixes bug 9972495. Change-Id: Ib77675aea790ea64d4f166af62c7138e89356c13 --- .../java/com/android/server/am/ActivityRecord.java | 2 +- .../java/com/android/server/am/TaskRecord.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index b858755623eda..bf3713b3b538c 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -80,7 +80,7 @@ final class ActivityRecord { static final int APPLICATION_ACTIVITY_TYPE = 0; static final int HOME_ACTIVITY_TYPE = 1; static final int RECENTS_ACTIVITY_TYPE = 2; - final int mActivityType; + int mActivityType; final String baseDir; // where activity source (resources etc) located final String resDir; // where public activity source (public resources etc) located diff --git a/services/java/com/android/server/am/TaskRecord.java b/services/java/com/android/server/am/TaskRecord.java index ebcf22aded899..63793fa906fff 100644 --- a/services/java/com/android/server/am/TaskRecord.java +++ b/services/java/com/android/server/am/TaskRecord.java @@ -57,7 +57,8 @@ final class TaskRecord extends ThumbnailHolder { /** Current stack */ ActivityStack stack; - private boolean mApplicationTask = true; + /** Takes on same set of values as ActivityRecord.mActivityType */ + private int mTaskType; TaskRecord(int _taskId, ActivityInfo info, Intent _intent) { taskId = _taskId; @@ -163,9 +164,12 @@ final class TaskRecord extends ThumbnailHolder { // Was not previously in list. numFullscreen++; } - // Only set this to be an application task if it has not already been set as home task. - if (mApplicationTask) { - mApplicationTask = r.isApplicationActivity(); + // Only set this based on the first activity + if (mActivities.isEmpty()) { + mTaskType = r.mActivityType; + } else { + // Otherwise make all added activities match this one. + r.mActivityType = mTaskType; } mActivities.add(index, r); } @@ -319,7 +323,7 @@ final class TaskRecord extends ThumbnailHolder { } boolean isApplicationTask() { - return mApplicationTask; + return mTaskType == ActivityRecord.APPLICATION_ACTIVITY_TYPE; } public TaskAccessInfo getTaskAccessInfoLocked(boolean inclThumbs) {