Loading core/jni/android_media_AudioSystem.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -262,6 +270,7 @@ static JNINativeMethod gMethods[] = { {"muteMicrophone", "(Z)I", (void *)android_media_AudioSystem_muteMicrophone}, {"isMicrophoneMuted", "()Z", (void *)android_media_AudioSystem_isMicrophoneMuted}, {"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}, Loading media/java/android/media/AudioManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1524,6 +1524,16 @@ public class AudioManager { return AudioSystem.isStreamActive(STREAM_MUSIC, 0); } /** * @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 Loading media/java/android/media/AudioSystem.java +7 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,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 Loading services/java/com/android/server/NotificationManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -1069,8 +1069,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(); Loading Loading
core/jni/android_media_AudioSystem.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -262,6 +270,7 @@ static JNINativeMethod gMethods[] = { {"muteMicrophone", "(Z)I", (void *)android_media_AudioSystem_muteMicrophone}, {"isMicrophoneMuted", "()Z", (void *)android_media_AudioSystem_isMicrophoneMuted}, {"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}, Loading
media/java/android/media/AudioManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1524,6 +1524,16 @@ public class AudioManager { return AudioSystem.isStreamActive(STREAM_MUSIC, 0); } /** * @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 Loading
media/java/android/media/AudioSystem.java +7 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,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 Loading
services/java/com/android/server/NotificationManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -1069,8 +1069,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(); Loading