Add option to not play sample in SeekBarVolumizer.

Bug: 78806021
Change-Id: Ib4d760aa092c606bdc1340c18dead88d4b7ddaee
diff --git a/core/java/android/preference/SeekBarVolumizer.java b/core/java/android/preference/SeekBarVolumizer.java
index 2a094bb..c68b4fc 100644
--- a/core/java/android/preference/SeekBarVolumizer.java
+++ b/core/java/android/preference/SeekBarVolumizer.java
@@ -81,6 +81,7 @@
     private int mVolumeBeforeMute = -1;
     private int mRingerMode;
     private int mZenMode;
+    private boolean mPlaySample;
 
     private static final int MSG_SET_STREAM_VOLUME = 0;
     private static final int MSG_START_SAMPLE = 1;
@@ -94,6 +95,15 @@
     private boolean mAllowRinger;
 
     public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) {
+        this(context, streamType, defaultUri, callback, true);
+    }
+
+    public SeekBarVolumizer(
+            Context context,
+            int streamType,
+            Uri defaultUri,
+            Callback callback,
+            boolean playSample) {
         mContext = context;
         mAudioManager = context.getSystemService(AudioManager.class);
         mNotificationManager = context.getSystemService(NotificationManager.class);
@@ -116,6 +126,7 @@
         mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
         mLastAudibleStreamVolume = mAudioManager.getLastAudibleStreamVolume(mStreamType);
         mMuted = mAudioManager.isStreamMute(mStreamType);
+        mPlaySample = playSample;
         if (mCallback != null) {
             mCallback.onMuted(mMuted, isZenMuted());
         }
@@ -190,13 +201,19 @@
                         AudioManager.FLAG_SHOW_UI_WARNINGS);
                 break;
             case MSG_START_SAMPLE:
-                onStartSample();
+                if (mPlaySample) {
+                    onStartSample();
+                }
                 break;
             case MSG_STOP_SAMPLE:
-                onStopSample();
+                if (mPlaySample) {
+                    onStopSample();
+                }
                 break;
             case MSG_INIT_SAMPLE:
-                onInitSample();
+                if (mPlaySample) {
+                    onInitSample();
+                }
                 break;
             default:
                 Log.e(TAG, "invalid SeekBarVolumizer message: "+msg.what);