summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2012-10-23 18:56:33 -0700
committer Dianne Hackborn <hackbod@google.com> 2012-10-23 18:56:33 -0700
commit9622ca4f8870f4e66ecb3ad771410620c950bb5c (patch)
tree87efb2e6f3088f15eea08350b4cc00d07ca78640
parent74261d847f64ccfeba0a7f08f6c59473a3b6647d (diff)
Fix issue #7401818: Wrong transition animation when clearing task
When we are clearing activities off the top of a task, propagate any activity options down from the top-most one to whatever top activity we are keeping. This ensures that if we set the activity options on the top activity of the task previously to give it the correct animation, we still keep that animation for the activity that really ends up being the top. Change-Id: I6919b644a530ac283fe4d320496edc2bf72aa04e
-rw-r--r--services/java/com/android/server/am/ActivityRecord.java15
-rwxr-xr-xservices/java/com/android/server/am/ActivityStack.java34
2 files changed, 48 insertions, 1 deletions
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index b9f5b5b2a780..749dc6651d38 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -602,6 +602,15 @@ final class ActivityRecord {
}
}
+ void updateOptionsLocked(ActivityOptions options) {
+ if (options != null) {
+ if (pendingOptions != null) {
+ pendingOptions.abort();
+ }
+ pendingOptions = options;
+ }
+ }
+
void applyOptionsLocked() {
if (pendingOptions != null) {
final int animationType = pendingOptions.getAnimationType();
@@ -653,6 +662,12 @@ final class ActivityRecord {
}
}
+ ActivityOptions takeOptionsLocked() {
+ ActivityOptions opts = pendingOptions;
+ pendingOptions = null;
+ return opts;
+ }
+
void removeUriPermissionsLocked() {
if (uriPermissions != null) {
uriPermissions.removeUriPermissionsLocked();
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 4bcb339b1479..4546dc3a8290 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1963,6 +1963,8 @@ final class ActivityStack {
int taskTopI = -1;
int replyChainEnd = -1;
int lastReparentPos = -1;
+ ActivityOptions topOptions = null;
+ boolean canMoveOptions = true;
for (int i=mHistory.size()-1; i>=-1; i--) {
ActivityRecord below = i >= 0 ? mHistory.get(i) : null;
@@ -2048,6 +2050,7 @@ final class ActivityStack {
}
int dstPos = 0;
ThumbnailHolder curThumbHolder = target.thumbHolder;
+ boolean gotOptions = !canMoveOptions;
for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) {
p = mHistory.get(srcPos);
if (p.finishing) {
@@ -2057,6 +2060,13 @@ final class ActivityStack {
+ " out to target's task " + target.task);
p.setTask(target.task, curThumbHolder, false);
curThumbHolder = p.thumbHolder;
+ canMoveOptions = false;
+ if (!gotOptions && topOptions == null) {
+ topOptions = p.takeOptionsLocked();
+ if (topOptions != null) {
+ gotOptions = true;
+ }
+ }
if (DEBUG_ADD_REMOVE) {
RuntimeException here = new RuntimeException("here");
here.fillInStackTrace();
@@ -2101,11 +2111,19 @@ final class ActivityStack {
replyChainEnd = targetI;
}
ActivityRecord p = null;
+ boolean gotOptions = !canMoveOptions;
for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) {
p = mHistory.get(srcPos);
if (p.finishing) {
continue;
}
+ canMoveOptions = false;
+ if (!gotOptions && topOptions == null) {
+ topOptions = p.takeOptionsLocked();
+ if (topOptions != null) {
+ gotOptions = true;
+ }
+ }
if (finishActivityLocked(p, srcPos,
Activity.RESULT_CANCELED, null, "reset", false)) {
replyChainEnd--;
@@ -2245,7 +2263,17 @@ final class ActivityStack {
target = below;
targetI = i;
}
-
+
+ if (topOptions != null) {
+ // If we got some ActivityOptions from an activity on top that
+ // was removed from the task, propagate them to the new real top.
+ if (taskTop != null) {
+ taskTop.updateOptionsLocked(topOptions);
+ } else {
+ topOptions.abort();
+ }
+ }
+
return taskTop;
}
@@ -2296,6 +2324,10 @@ final class ActivityStack {
if (r.finishing) {
continue;
}
+ ActivityOptions opts = r.takeOptionsLocked();
+ if (opts != null) {
+ ret.updateOptionsLocked(opts);
+ }
if (finishActivityLocked(r, i, Activity.RESULT_CANCELED,
null, "clear", false)) {
i--;