Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afb19545 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android Git Automerger
Browse files

am 7e466e89: am bcfc1ca8: Merge "Don\'t play notifications during speech...

am 7e466e89: am bcfc1ca8: Merge "Don\'t play notifications during speech recognition" into jb-mr1-dev

* commit '7e466e89':
  Don't play notifications during speech recognition
parents 223e0a8a 7e466e89
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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)
{
@@ -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},
+10 −0
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -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
+3 −2
Original line number Diff line number Diff line
@@ -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();