diff options
-rw-r--r-- | core/jni/android_media_AudioSystem.cpp | 11 | ||||
-rw-r--r-- | media/java/android/media/AudioManager.java | 10 | ||||
-rw-r--r-- | media/java/android/media/AudioSystem.java | 7 | ||||
-rwxr-xr-x | services/java/com/android/server/NotificationManagerService.java | 5 |
4 files changed, 30 insertions, 3 deletions
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 56db116..631cdae 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -75,6 +75,14 @@ android_media_AudioSystem_isStreamActive(JNIEnv *env, jobject thiz, jint stream, return state; } +static jboolean +android_media_AudioSystem_isSourceActive(JNIEnv *env, jobject thiz, jint source) +{ + bool state = false; + AudioSystem::isSourceActive((audio_source_t) source, &state); + return state; +} + static int android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyValuePairs) { @@ -261,7 +269,8 @@ static JNINativeMethod gMethods[] = { {"getParameters", "(Ljava/lang/String;)Ljava/lang/String;", (void *)android_media_AudioSystem_getParameters}, {"muteMicrophone", "(Z)I", (void *)android_media_AudioSystem_muteMicrophone}, {"isMicrophoneMuted", "()Z", (void *)android_media_AudioSystem_isMicrophoneMuted}, - {"isStreamActive", "(II)Z", (void *)android_media_AudioSystem_isStreamActive}, + {"isStreamActive", "(II)Z", (void *)android_media_AudioSystem_isStreamActive}, + {"isSourceActive", "(I)Z", (void *)android_media_AudioSystem_isSourceActive}, {"setDeviceConnectionState", "(IILjava/lang/String;)I", (void *)android_media_AudioSystem_setDeviceConnectionState}, {"getDeviceConnectionState", "(ILjava/lang/String;)I", (void *)android_media_AudioSystem_getDeviceConnectionState}, {"setPhoneState", "(I)I", (void *)android_media_AudioSystem_setPhoneState}, 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 * diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 85b488c..2e7a54b 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -1066,8 +1066,9 @@ public class NotificationManagerService extends INotificationManager.Stub } mSoundNotification = r; // do not play notifications if stream volume is 0 - // (typically because ringer mode is silent). - if (audioManager.getStreamVolume(audioStreamType) != 0) { + // (typically because ringer mode is silent) or if speech recognition is active. + if ((audioManager.getStreamVolume(audioStreamType) != 0) + && !audioManager.isSpeechRecognitionActive()) { final long identity = Binder.clearCallingIdentity(); try { final IRingtonePlayer player = mAudioService.getRingtonePlayer(); |