Fix issue 1992233: DTMF tones on Sholes is really long.
Do not use a delayed message to define the DTMF tone duration. Use the duration parameter in ToneGenerator.startTone() instead. This garanties that the actual tone duration is independent from the filling level of the audio buffers when the tone starts.
diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java
index 3e43eaf..aa7cc70 100644
--- a/src/com/android/contacts/TwelveKeyDialer.java
+++ b/src/com/android/contacts/TwelveKeyDialer.java
@@ -76,9 +76,6 @@
private static final String TAG = "TwelveKeyDialer";
- // Handler message codes
- private static final int STOP_TONE = 1;
-
/** The length of DTMF tones in milliseconds */
private static final int TONE_LENGTH_MS = 150;
@@ -459,7 +456,6 @@
synchronized(mToneGeneratorLock) {
if (mToneGenerator != null) {
- mToneStopper.removeMessages(STOP_TONE);
mToneGenerator.release();
mToneGenerator = null;
}
@@ -722,22 +718,6 @@
finish();
}
- Handler mToneStopper = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case STOP_TONE:
- synchronized(mToneGeneratorLock) {
- if (mToneGenerator == null) {
- Log.w(TAG, "mToneStopper: mToneGenerator == null");
- } else {
- mToneGenerator.stopTone();
- }
- }
- break;
- }
- }
- };
/**
* Plays the specified tone for TONE_LENGTH_MS milliseconds.
@@ -772,12 +752,8 @@
return;
}
- // Remove pending STOP_TONE messages
- mToneStopper.removeMessages(STOP_TONE);
-
// Start the new tone (will stop any playing tone)
- mToneGenerator.startTone(tone);
- mToneStopper.sendEmptyMessageDelayed(STOP_TONE, TONE_LENGTH_MS);
+ mToneGenerator.startTone(tone, TONE_LENGTH_MS);
}
}