OSDN Git Service

Fix bug 2239212 "Dial pad has no sound"
authorJean-Michel Trivi <jmtrivi@google.com>
Tue, 10 Nov 2009 21:00:45 +0000 (13:00 -0800)
committerJean-Michel Trivi <jmtrivi@google.com>
Tue, 10 Nov 2009 21:00:45 +0000 (13:00 -0800)
The DTMF stream volume is tied to the in-call volume. In the dialer
outside of a call, the user has no way to change the touch tone
volume. If (s)he lowered the incall volume all the way down,
the user will usually complain that the dial pad has no sound,
and if they maxed it out, they'll complain it's too loud.
 This change causes the tones to use the media volume, outside of
a call only, and to change the media volume when the user presses
the hardware volume keys.
This gives us both the advantage of keeping the incall behavior consistent
with the existing behavior (AFAIK there are no complaints regarding
in call DTMF volume), but offers the user control over the volume
in the dialer before/after a call.

src/com/android/contacts/TwelveKeyDialer.java

index 1ec0360..2d8b4e6 100644 (file)
@@ -80,7 +80,10 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener,
     private static final int TONE_LENGTH_MS = 150;
 
     /** The DTMF tone volume relative to other sounds in the stream */
-    private static final int TONE_RELATIVE_VOLUME = 50;
+    private static final int TONE_RELATIVE_VOLUME = 80;
+
+    /** Stream type used to play the DTMF tones off call, and mapped to the volume control keys */
+    private static final int DIAL_TONE_STREAM_TYPE = AudioManager.STREAM_MUSIC;
 
     /** Play the vibrate pattern only once. */
     private static final int VIBRATE_NO_REPEAT = -1;
@@ -404,8 +407,11 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener,
         synchronized(mToneGeneratorLock) {
             if (mToneGenerator == null) {
                 try {
-                    mToneGenerator = new ToneGenerator(AudioManager.STREAM_DTMF,
-                            TONE_RELATIVE_VOLUME);
+                    // we want the user to be able to control the volume of the dial tones
+                    // outside of a call, so we use the stream type that is also mapped to the
+                    // volume control keys for this activity
+                    mToneGenerator = new ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME);
+                    setVolumeControlStream(DIAL_TONE_STREAM_TYPE);
                 } catch (RuntimeException e) {
                     Log.w(TAG, "Exception caught while creating local tone generator: " + e);
                     mToneGenerator = null;