summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2016-10-07 11:09:21 -0700
committerDoris Liu <tianliu@google.com>2016-10-08 21:00:14 +0000
commit679fe6ab6f4b9252ef414a0c0c5ad9633f3d0294 (patch)
tree822ed6b3bd23063dfcf65b197e8e6a8e2d617034 /libs
parentad81502f20d1dedbd3aab2835b7e416d32cde261 (diff)
downloadandroid-frameworks-base-679fe6ab6f4b9252ef414a0c0c5ad9633f3d0294.tar.gz
android-frameworks-base-679fe6ab6f4b9252ef414a0c0c5ad9633f3d0294.tar.xz
Support calling start() in onAnimationFinished(...) in AVD
This CL fixed an issue where calling start() from onAnimationFinished() caused AnimationListenerBridge::onAnimationFinished(...) to be unsafely re-entered and the new start listener was (incorrectly) reset to null. BUG: 31971397 Test: test apk in the bug linked above Change-Id: Ica809ef2dab884950b93b54f2d0cb4b81e9830f1
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/PropertyValuesAnimatorSet.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libs/hwui/PropertyValuesAnimatorSet.cpp b/libs/hwui/PropertyValuesAnimatorSet.cpp
index 38fb70a..e3258e3 100644
--- a/libs/hwui/PropertyValuesAnimatorSet.cpp
+++ b/libs/hwui/PropertyValuesAnimatorSet.cpp
@@ -46,8 +46,17 @@ PropertyValuesAnimatorSet::PropertyValuesAnimatorSet()
void PropertyValuesAnimatorSet::onFinished(BaseRenderNodeAnimator* animator) {
if (mOneShotListener.get()) {
- mOneShotListener->onAnimationFinished(animator);
+ sp<AnimationListener> listener = std::move(mOneShotListener);
+ // Set the listener to nullptr before the onAnimationFinished callback, rather than after,
+ // for two reasons:
+ // 1) We need to prevent changes to mOneShotListener during the onAnimationFinished
+ // callback (specifically in AnimationListenerBridge::onAnimationFinished(...) from
+ // triggering dtor of the bridge and potentially unsafely re-entering
+ // AnimationListenerBridge::onAnimationFinished(...).
+ // 2) It's possible that there are changes to the listener during the callback, therefore
+ // we need to reset the listener before the callback rather than afterwards.
mOneShotListener = nullptr;
+ listener->onAnimationFinished(animator);
}
}