summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Candice <chihtinglo@google.com> 2025-01-13 10:57:49 +0000
committer Candice <chihtinglo@google.com> 2025-01-16 06:46:26 +0000
commite90ae66df0b65a07beefbeb00c036e457418f364 (patch)
tree20a8bf89ba600f2ef943ff7e8ee85fbe2475dfe1
parent909144396e8f9a3369b8987a3d0285ccbb2c6c50 (diff)
Check the magnification state before performing onAnimationEnd
onAnimationEnd will be called when we call cancel() on the animator. Therefore, we need to confirm the the expected state in onAnimationEnd for the following actions. Bug: 389083496 Test: atest FullscreenMagnificationControllerTest Flag: EXEMPT bugfix Change-Id: I8379aadc140c00657e0b8ac8177da6961f6f2b09
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/FullscreenMagnificationController.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/FullscreenMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/FullscreenMagnificationController.java
index caf043a1b1be..b2f3df60c82b 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/FullscreenMagnificationController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/FullscreenMagnificationController.java
@@ -200,7 +200,15 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(@NonNull Animator animation) {
- mHandler.post(() -> setState(ENABLED));
+ // This could be called when the animation ends or is canceled. Therefore, we need
+ // to check the state of fullscreen magnification for the following actions. We only
+ // update the state to ENABLED when the previous state is ENABLING which implies
+ // fullscreen magnification is experiencing an ongoing create border process.
+ mHandler.post(() -> {
+ if (getState() == ENABLING) {
+ setState(ENABLED);
+ }
+ });
}});
return valueAnimator;
}
@@ -221,7 +229,14 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(@NonNull Animator animation) {
- mHandler.post(() -> cleanUpBorder());
+ // This could be called when the animation ends or is canceled. Therefore, we need
+ // to check the state of fullscreen magnification for the following actions. Border
+ // cleanup should only happens after a removal process.
+ mHandler.post(() -> {
+ if (getState() == DISABLING) {
+ cleanUpBorder();
+ }
+ });
}});
return valueAnimator;
}
@@ -250,6 +265,8 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
// If there is an ongoing disable process or it is already disabled, return
return;
}
+ // The state should be updated as early as possible so others could check
+ // the ongoing process.
setState(DISABLING);
mShowHideBorderAnimator = createHideTargetAnimator(mFullscreenBorder);
mShowHideBorderAnimator.start();
@@ -297,10 +314,13 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
// If there is an ongoing enable process or it is already enabled, return
return;
}
+ // The state should be updated as early as possible so others could check
+ // the ongoing process.
+ setState(ENABLING);
+
if (mShowHideBorderAnimator != null) {
mShowHideBorderAnimator.cancel();
}
- setState(ENABLING);
onConfigurationChanged(mContext.getResources().getConfiguration());
mContext.registerComponentCallbacks(this);