Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe342dcb authored by guotao.deng's avatar guotao.deng Committed by Gerrit Code Review
Browse files

VolumePanel: volume bar disorderly jump when drag it.

under stream type is STREAM_BLUETOOTH_SCO or STREAM_VOICE_CALL,
if we drag the volume bar, it will disorderly jump.

for example, connect bt headset and make a call, change volume and
drag volume bar during call, this isue will appear.

Change-Id: Ie61d6010c3eb249448878533250c7fad0e24f089
parent 85591945
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <SeekBar
        <view
            class="com.android.systemui.volume.VolumePanel$VolumeSeekBar"
            android:id="@+id/seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
+40 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
@@ -1716,6 +1717,11 @@ public class VolumePanel extends Handler implements DemoMode {
            final Object tag = seekBar.getTag();
            if (fromUser && tag instanceof StreamControl) {
                StreamControl sc = (StreamControl) tag;
                // Revert volume changes done in onShowVolumeChanged()
                if (sc.streamType == AudioManager.STREAM_BLUETOOTH_SCO
                        || sc.streamType == AudioManager.STREAM_VOICE_CALL) {
                    progress = Math.max(0, progress - 1);
                }
                setStreamVolume(sc, progress,
                        AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
            }
@@ -1750,6 +1756,40 @@ public class VolumePanel extends Handler implements DemoMode {
        }
    };

    public static class VolumeSeekBar extends SeekBar {
        public VolumeSeekBar(Context context) {
            super(context);
        }

        public VolumeSeekBar(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public VolumeSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }

        public VolumeSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
        }

        @Override
        protected int updateTouchProgress(int lastProgress, int newProgress) {
            final Object tag = getTag();
            if (tag instanceof StreamControl) {
                StreamControl sc = (StreamControl) tag;
                // In-call voice streams shouldn't be draggable down to 0, see onShowVolumeChanged
                if (sc.streamType == AudioManager.STREAM_BLUETOOTH_SCO
                        || sc.streamType == AudioManager.STREAM_VOICE_CALL) {
                    if (newProgress == 0) {
                        return 1;
                    }
                }
            }
            return super.updateTouchProgress(lastProgress, newProgress);
        }
    }

    public interface Callback {
        void onZenSettings();
        void onInteraction();