summaryrefslogtreecommitdiff
path: root/core/java/android/view/VolumePanel.java
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2012-05-22 13:57:58 -0700
committerChristopher Tate <ctate@google.com>2012-05-24 17:30:39 -0700
commitc4b78d206ffcdccac01e3436a4a3462bef9672ed (patch)
tree33207411e0514c9fcf7f387d1ecb8d2c0167fedd /core/java/android/view/VolumePanel.java
parentb088ed7e23d4ac76b698a243ae7d1b85f1b7e775 (diff)
Support volume-changed sounds on master-volume-only configs
Some products manipulate only the master volume, and the existing code does not play volume-change tones when the master volume is adjusted. This CL includes some config-driven behavior that will play those tones (via the system stream) if desired. Bug 6498986 Change-Id: I2415773325d0a0039efc67897bc371b1f2e18063
Diffstat (limited to 'core/java/android/view/VolumePanel.java')
-rw-r--r--core/java/android/view/VolumePanel.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index b6e37a6d9eda..6a5677e90594 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -103,6 +103,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
private boolean mShowCombinedVolumes;
private boolean mVoiceCapable;
+ // True if we want to play tones on the system stream when the master stream is specified.
+ private final boolean mPlayMasterStreamTones;
+
/** Dialog containing all the sliders */
private final Dialog mDialog;
/** Dialog's content view */
@@ -275,6 +278,13 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
mMoreButton.setOnClickListener(this);
}
+ boolean masterVolumeOnly = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_useMasterVolume);
+ boolean masterVolumeKeySounds = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_useVolumeKeySounds);
+
+ mPlayMasterStreamTones = masterVolumeOnly && masterVolumeKeySounds;
+
listenToRingerMode();
}
@@ -657,7 +667,16 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
* Lock on this VolumePanel instance as long as you use the returned ToneGenerator.
*/
private ToneGenerator getOrCreateToneGenerator(int streamType) {
- if (streamType == STREAM_MASTER) return null;
+ if (streamType == STREAM_MASTER) {
+ // For devices that use the master volume setting only but still want to
+ // play a volume-changed tone, direct the master volume pseudostream to
+ // the system stream's tone generator.
+ if (mPlayMasterStreamTones) {
+ streamType = AudioManager.STREAM_SYSTEM;
+ } else {
+ return null;
+ }
+ }
synchronized (this) {
if (mToneGenerators[streamType] == null) {
try {