From d677054ca63f55abaa1c478ea3c50f6be665a979 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Wed, 10 Oct 2012 12:03:41 -0700 Subject: Don't play notifications during speech recognition Add support for querying AudioManager to know whether speech recognition is currently underway. Don't play a notification if speech recognition is underway. Bug 7314859 Change-Id: I1bd013a3168cfe1a6b6dcfd28565e1c3c512eb6a --- media/java/android/media/AudioManager.java | 10 ++++++++++ media/java/android/media/AudioSystem.java | 7 +++++++ 2 files changed, 17 insertions(+) (limited to 'media/java') diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index ee17bd3..035b282 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -1526,6 +1526,16 @@ public class AudioManager { /** * @hide + * Checks whether speech recognition is active + * @return true if a recording with source {@link MediaRecorder.AudioSource#VOICE_RECOGNITION} + * is underway. + */ + public boolean isSpeechRecognitionActive() { + return AudioSystem.isSourceActive(MediaRecorder.AudioSource.VOICE_RECOGNITION); + } + + /** + * @hide * If the stream is active locally or remotely, adjust its volume according to the enforced * priority rules. * Note: only AudioManager.STREAM_MUSIC is supported at the moment diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 103e817..260ddc7 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -111,6 +111,13 @@ public class AudioSystem public static native boolean isStreamActive(int stream, int inPastMs); /* + * Checks whether the specified audio source is active. + * + * return true if any recorder using this source is currently recording + */ + public static native boolean isSourceActive(int source); + + /* * Sets a group generic audio configuration parameters. The use of these parameters * are platform dependent, see libaudio * -- cgit v1.1