Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
auto import from //branches/cupcake_rel/...@141571
Browse files Browse the repository at this point in the history
  • Loading branch information
The Android Open Source Project committed Mar 20, 2009
1 parent 632bb93 commit 87ad356
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/com/android/voicedialer/VoiceDialerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public class VoiceDialerActivity extends Activity {
private Handler mHandler;
private Thread mRecognizerThread = null;
private AudioManager mAudioManager;
private int mSavedVolume;
private ToneGenerator mToneGenerator;
private BluetoothHeadset mBluetoothHeadset;

Expand All @@ -89,11 +88,12 @@ protected void onCreate(Bundle icicle) {
if (Config.LOGD) Log.d(TAG, "onCreate");

mHandler = new Handler();

// get AudioManager, save current music volume, set music volume to zero
mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
mSavedVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);

// tell music player to shut up so we can hear
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
sendBroadcast(i);

// set up ToneGenerator
// currently disabled because it crashes audio input
Expand Down Expand Up @@ -227,7 +227,7 @@ private int playSound(int toneType) {
}

// use the Vibrator to prompt the user
if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
if ((mAudioManager != null) && (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER))) {
final int VIBRATOR_TIME = 150;
final int VIBRATOR_GUARD_TIME = 150;
Vibrator vibrator = new Vibrator();
Expand All @@ -252,12 +252,6 @@ protected void onPause() {
mBluetoothHeadset = null;
}

// restore volume, if changed
if (mSavedVolume > 0) {
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mSavedVolume, 0);
mSavedVolume = 0;
}

// no more tester
mVoiceDialerTester = null;

Expand Down

0 comments on commit 87ad356

Please sign in to comment.