Skip to content

Commit 9622ca4

Browse files
author
Dianne Hackborn
committed
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
1 parent 74261d8 commit 9622ca4

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

services/java/com/android/server/am/ActivityRecord.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,15 @@ void updateOptionsLocked(Bundle options) {
602602
}
603603
}
604604

605+
void updateOptionsLocked(ActivityOptions options) {
606+
if (options != null) {
607+
if (pendingOptions != null) {
608+
pendingOptions.abort();
609+
}
610+
pendingOptions = options;
611+
}
612+
}
613+
605614
void applyOptionsLocked() {
606615
if (pendingOptions != null) {
607616
final int animationType = pendingOptions.getAnimationType();
@@ -653,6 +662,12 @@ void clearOptionsLocked() {
653662
}
654663
}
655664

665+
ActivityOptions takeOptionsLocked() {
666+
ActivityOptions opts = pendingOptions;
667+
pendingOptions = null;
668+
return opts;
669+
}
670+
656671
void removeUriPermissionsLocked() {
657672
if (uriPermissions != null) {
658673
uriPermissions.removeUriPermissionsLocked();

services/java/com/android/server/am/ActivityStack.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,8 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
19631963
int taskTopI = -1;
19641964
int replyChainEnd = -1;
19651965
int lastReparentPos = -1;
1966+
ActivityOptions topOptions = null;
1967+
boolean canMoveOptions = true;
19661968
for (int i=mHistory.size()-1; i>=-1; i--) {
19671969
ActivityRecord below = i >= 0 ? mHistory.get(i) : null;
19681970

@@ -2048,6 +2050,7 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
20482050
}
20492051
int dstPos = 0;
20502052
ThumbnailHolder curThumbHolder = target.thumbHolder;
2053+
boolean gotOptions = !canMoveOptions;
20512054
for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) {
20522055
p = mHistory.get(srcPos);
20532056
if (p.finishing) {
@@ -2057,6 +2060,13 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
20572060
+ " out to target's task " + target.task);
20582061
p.setTask(target.task, curThumbHolder, false);
20592062
curThumbHolder = p.thumbHolder;
2063+
canMoveOptions = false;
2064+
if (!gotOptions && topOptions == null) {
2065+
topOptions = p.takeOptionsLocked();
2066+
if (topOptions != null) {
2067+
gotOptions = true;
2068+
}
2069+
}
20602070
if (DEBUG_ADD_REMOVE) {
20612071
RuntimeException here = new RuntimeException("here");
20622072
here.fillInStackTrace();
@@ -2101,11 +2111,19 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
21012111
replyChainEnd = targetI;
21022112
}
21032113
ActivityRecord p = null;
2114+
boolean gotOptions = !canMoveOptions;
21042115
for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) {
21052116
p = mHistory.get(srcPos);
21062117
if (p.finishing) {
21072118
continue;
21082119
}
2120+
canMoveOptions = false;
2121+
if (!gotOptions && topOptions == null) {
2122+
topOptions = p.takeOptionsLocked();
2123+
if (topOptions != null) {
2124+
gotOptions = true;
2125+
}
2126+
}
21092127
if (finishActivityLocked(p, srcPos,
21102128
Activity.RESULT_CANCELED, null, "reset", false)) {
21112129
replyChainEnd--;
@@ -2245,7 +2263,17 @@ private final ActivityRecord resetTaskIfNeededLocked(ActivityRecord taskTop,
22452263
target = below;
22462264
targetI = i;
22472265
}
2248-
2266+
2267+
if (topOptions != null) {
2268+
// If we got some ActivityOptions from an activity on top that
2269+
// was removed from the task, propagate them to the new real top.
2270+
if (taskTop != null) {
2271+
taskTop.updateOptionsLocked(topOptions);
2272+
} else {
2273+
topOptions.abort();
2274+
}
2275+
}
2276+
22492277
return taskTop;
22502278
}
22512279

@@ -2296,6 +2324,10 @@ private final ActivityRecord performClearTaskLocked(int taskId,
22962324
if (r.finishing) {
22972325
continue;
22982326
}
2327+
ActivityOptions opts = r.takeOptionsLocked();
2328+
if (opts != null) {
2329+
ret.updateOptionsLocked(opts);
2330+
}
22992331
if (finishActivityLocked(r, i, Activity.RESULT_CANCELED,
23002332
null, "clear", false)) {
23012333
i--;

0 commit comments

Comments
 (0)