@@ -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