OSDN Git Service

Fix the "Alarm volume" icon is displayed incorrectly
authorShigeki Yokomichi <shigeki.x.yokomichi@sonymobile.com>
Thu, 25 Feb 2016 08:17:39 +0000 (17:17 +0900)
committerBasil Gello <vasek.gello@gmail.com>
Wed, 25 Jul 2018 10:51:01 +0000 (12:51 +0200)
Symptom:
1. Set Alarm volume to 0 on Sound & notification screen, then tap
Back key and reopen the screen.
2. Set Alarm volume up to 1 or larger, then alarm icon changes to
unmute.
3. Set Alarm volume down to 0, then the icon doesn't change to
mute. There expected the icon should change to mute one.

Detail and sample:
SeekBarVolumizer manages a variable mLastAudibleStreamVolume.
This variable decides whether it executes mute procedure or not.
When this variable is 0, it will not execute mute procedure.
Because the condition to execute mute proceduce is below.
-  lastAudibleVolume * (mute ? -1 : 1) < 0
What original code will not update this variable from constructor
is one of problems. So once the icon changes to unmute one,
the icon will never change to mute one.

Solution:
Changed the condition as it doesn't depend on value of
lastAudibleVolume.

Bug: 30265487

Change-Id: I42165f39d1f344169674c09a045b6fb2bb25db4d

core/java/android/preference/SeekBarVolumizer.java

index cc6b529..5929853 100644 (file)
@@ -362,8 +362,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
             if (msg.what == UPDATE_SLIDER) {
                 if (mSeekBar != null) {
                     mLastProgress = msg.arg1;
-                    mLastAudibleStreamVolume = Math.abs(msg.arg2);
-                    final boolean muted = msg.arg2 < 0;
+                    mLastAudibleStreamVolume = msg.arg2;
+                    final boolean muted = ((Boolean)msg.obj).booleanValue();
                     if (muted != mMuted) {
                         mMuted = muted;
                         if (mCallback != null) {
@@ -376,8 +376,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
         }
 
         public void postUpdateSlider(int volume, int lastAudibleVolume, boolean mute) {
-            final int arg2 = lastAudibleVolume * (mute ? -1 : 1);
-            obtainMessage(UPDATE_SLIDER, volume, arg2).sendToTarget();
+            obtainMessage(UPDATE_SLIDER, volume, lastAudibleVolume, new Boolean(mute)).sendToTarget();
         }
     }