summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTetsutoki Shiozawa <tetsutoki.x.shiozawa@sonymobile.com>2020-01-27 15:37:10 +0900
committerLuca Stefani <luca.stefani.ge1@gmail.com>2020-05-30 11:55:56 +0200
commit7439406bbfef0327ec4f7df2411b69564ddb7074 (patch)
tree0d1d43a1cb39ba38e08ac014c4dcbe0bf32d6fb2
parent4dcd7d21bd1cc81f7f9db7e196d4de2300bb88bf (diff)
downloadframeworks_base-7439406bbfef0327ec4f7df2411b69564ddb7074.tar.gz
frameworks_base-7439406bbfef0327ec4f7df2411b69564ddb7074.tar.bz2
frameworks_base-7439406bbfef0327ec4f7df2411b69564ddb7074.zip
Fix: Media volume bar indicates a wrong value
Symptom: Media volume bar shows non-zero value even during the mute state. Root cause: A request for updating progress of ProgressBar has 2 kind of updating ways, animated and non-animated. If a non-animated request is invoked before completing an animated request, the visual progress can be overwritten by the old animated request. As a result, the visual progress value becomes different from the actual value. Solution: A running animation on the primary progress should be canceled before handling a new non-animated request. Bug: 148759348 Test: atest CtsWidgetTestCases:ProgressBarTest Change-Id: I569dbea4c6346ecfff8141d8378b4952fb1fa530 Merged-In: I569dbea4c6346ecfff8141d8378b4952fb1fa530
-rw-r--r--core/java/android/widget/ProgressBar.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 2e957434569..aa38316d6d0 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -16,6 +16,8 @@
package android.widget;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.InterpolatorRes;
import android.annotation.NonNull;
@@ -246,6 +248,8 @@ public class ProgressBar extends View {
private AccessibilityEventSender mAccessibilityEventSender;
+ private ObjectAnimator mLastProgressAnimator;
+
/**
* Create a new progress bar with range 0...100 and initial progress of 0.
* @param context the application environment
@@ -1544,8 +1548,19 @@ public class ProgressBar extends View {
animator.setAutoCancel(true);
animator.setDuration(PROGRESS_ANIM_DURATION);
animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mLastProgressAnimator = null;
+ }
+ });
animator.start();
+ mLastProgressAnimator = animator;
} else {
+ if (isPrimary && mLastProgressAnimator != null) {
+ mLastProgressAnimator.cancel();
+ mLastProgressAnimator = null;
+ }
setVisualProgress(id, scale);
}