Avoid detached surface from returning to hierarchy
Transition#buildFinishTransaction contains the operation that
reparent the animation target to original parent. If the target
is removed before the transition finishes, when the finish
transaction applies, the removed surface may attach to hierarchy
again (becomes a handleNotAlive layer).
By deferring the WindowToken removal until after the transition is
finished, the removal transaction always applies after the finish
transaction. Then the the removed window won't attach to its original
parent again.
Note that the WindowState can still be removed directly, so it
(empty children) won't affect animation by showing something.
Bug: 366098095
Flag: EXEMPT bugfix
Test: atest WindowTokenTests#testTokenRemovalProcess
Test: Run the script (The output should be empty):
for i in {1..500}
do
adb shell wm size 200x200
adb shell input keyevent 24
adb shell wm size 1080x2400
adb shell input keyevent 25
done
adb shell dumpsys SurfaceFlinger | grep type=2020
Change-Id: Ie9c5857b2c387c4380bbb7718cb366bfe9cd4b7e
6 files changed