use of android.media.ToneGenerator in project android_frameworks_base by crdroidandroid.
the class TonesAutoTest method tonesDtmfTest.
// Test all DTMF tones one by one
public static boolean tonesDtmfTest() throws Exception {
Log.v(TAG, "DTMF tones test");
ToneGenerator toneGen;
int type;
boolean result = true;
toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
for (type = ToneGenerator.TONE_DTMF_0; type <= ToneGenerator.TONE_DTMF_D; type++) {
if (toneGen.startTone(type)) {
Thread.sleep(200);
toneGen.stopTone();
Thread.sleep(100);
} else {
result = false;
break;
}
}
toneGen.release();
return result;
}
use of android.media.ToneGenerator in project android_frameworks_base by crdroidandroid.
the class VolumeDialogController method onPlaySoundW.
protected void onPlaySoundW(int streamType, int flags) {
// If preference is no sound - just exit here
if (CMSettings.System.getInt(mContext.getContentResolver(), CMSettings.System.VOLUME_ADJUST_SOUNDS_ENABLED, 1) == 0) {
return;
}
if (mWorker.hasMessages(W.STOP_SOUNDS)) {
mWorker.removeMessages(W.STOP_SOUNDS);
// Force stop right now
onStopSoundsW();
}
ToneGenerator toneGen = getOrCreateToneGeneratorW(streamType);
if (toneGen != null) {
toneGen.startTone(ToneGenerator.TONE_PROP_BEEP);
mWorker.sendMessageDelayed(mWorker.obtainMessage(W.STOP_SOUNDS), BEEP_DURATION);
}
mWorker.removeMessages(W.FREE_RESOURCES);
mWorker.sendMessageDelayed(mWorker.obtainMessage(W.FREE_RESOURCES), FREE_DELAY);
}
Aggregations