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

Commit f30fc111 authored by Sandeep Siddhartha's avatar Sandeep Siddhartha Committed by Android (Google) Code Review
Browse files

Merge "Handle microphone contention/Phone calls while recognition is active" into lmp-dev

parents 8abea424 cb4e81c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27535,6 +27535,8 @@ package android.service.voice {
    method public abstract void onAvailabilityChanged(int);
    method public abstract void onDetected(android.service.voice.AlwaysOnHotwordDetector.EventPayload);
    method public abstract void onError();
    method public abstract void onRecognitionPaused();
    method public abstract void onRecognitionResumed();
  }
  public static class AlwaysOnHotwordDetector.EventPayload {
+8 −0
Original line number Diff line number Diff line
@@ -34,4 +34,12 @@ oneway interface IRecognitionStatusCallback {
     * @param status The error code that was seen.
     */
    void onError(int status);
    /**
     * Called when the recognition is paused temporarily for some reason.
     */
    void onRecognitionPaused();
    /**
     * Called when the recognition is resumed after it was temporarily paused.
     */
    void onRecognitionResumed();
}
 No newline at end of file
+32 −0
Original line number Diff line number Diff line
@@ -161,6 +161,8 @@ public class AlwaysOnHotwordDetector {
    private static final int MSG_AVAILABILITY_CHANGED = 1;
    private static final int MSG_HOTWORD_DETECTED = 2;
    private static final int MSG_DETECTION_ERROR = 3;
    private static final int MSG_DETECTION_PAUSE = 4;
    private static final int MSG_DETECTION_RESUME = 5;

    private final String mText;
    private final String mLocale;
@@ -239,6 +241,18 @@ public class AlwaysOnHotwordDetector {
         * Called when the detection fails due to an error.
         */
        void onError();
        /**
         * Called when the recognition is paused temporarily for some reason.
         * This is an informational callback, and the clients shouldn't be doing anything here
         * except showing an indication on their UI if they have to.
         */
        void onRecognitionPaused();
        /**
         * Called when the recognition is resumed after it was temporarily paused.
         * This is an informational callback, and the clients shouldn't be doing anything here
         * except showing an indication on their UI if they have to.
         */
        void onRecognitionResumed();
    }

    /**
@@ -508,6 +522,18 @@ public class AlwaysOnHotwordDetector {
            Slog.i(TAG, "onError: " + status);
            mHandler.sendEmptyMessage(MSG_DETECTION_ERROR);
        }

        @Override
        public void onRecognitionPaused() {
            Slog.i(TAG, "onRecognitionPaused");
            mHandler.sendEmptyMessage(MSG_DETECTION_PAUSE);
        }

        @Override
        public void onRecognitionResumed() {
            Slog.i(TAG, "onRecognitionResumed");
            mHandler.sendEmptyMessage(MSG_DETECTION_RESUME);
        }
    }

    class MyHandler extends Handler {
@@ -530,6 +556,12 @@ public class AlwaysOnHotwordDetector {
                case MSG_DETECTION_ERROR:
                    mExternalCallback.onError();
                    break;
                case MSG_DETECTION_PAUSE:
                    mExternalCallback.onRecognitionPaused();
                    break;
                case MSG_DETECTION_RESUME:
                    mExternalCallback.onRecognitionResumed();
                    break;
                default:
                    super.handleMessage(msg);
            }
+351 −207

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.service.voice.IVoiceInteractionService;
import android.service.voice.IVoiceInteractionSession;
import android.telephony.TelephonyManager;
import android.util.Slog;

import com.android.internal.app.IVoiceInteractionManagerService;
@@ -67,7 +68,8 @@ public class VoiceInteractionManagerService extends SystemService {
        mContext = context;
        mResolver = context.getContentResolver();
        mDbHelper = new DatabaseHelper(context);
        mSoundTriggerHelper = new SoundTriggerHelper();
        mSoundTriggerHelper = new SoundTriggerHelper(
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));
    }

    @Override
Loading