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

Commit 7dbef2da authored by Arunesh Mishra's avatar Arunesh Mishra Committed by Android (Google) Code Review
Browse files

Merge "Fix AlwaysOnHotwordDetector recognition event bug." into nyc-dev

parents dc5e3a30 f47f173b
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -26,10 +26,20 @@ oneway interface IRecognitionStatusCallback {
     * Called when the keyphrase is spoken.
     * Called when the keyphrase is spoken.
     *
     *
     * @param recognitionEvent Object containing data relating to the
     * @param recognitionEvent Object containing data relating to the
     *                         recognition event such as trigger audio data, if it was requested
     *                         keyphrase recognition event such as keyphrase
     *                         and is available.
     *                         extras.
     */
     */
    void onDetected(in SoundTrigger.RecognitionEvent recognitionEvent);
    void onKeyphraseDetected(in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent);

   /**
     * Called when a generic sound trigger event is witnessed.
     *
     * @param recognitionEvent Object containing data relating to the
     *                         recognition event such as trigger audio data (if
     *                         requested).
     */

    void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent);


    /**
    /**
     * Called when the detection fails due to an error.
     * Called when the detection fails due to an error.
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ parcelable SoundTrigger.ConfidenceLevel;
parcelable SoundTrigger.Keyphrase;
parcelable SoundTrigger.Keyphrase;
parcelable SoundTrigger.RecognitionEvent;
parcelable SoundTrigger.RecognitionEvent;
parcelable SoundTrigger.KeyphraseRecognitionEvent;
parcelable SoundTrigger.KeyphraseRecognitionEvent;
parcelable SoundTrigger.GenericSoundRecognitionEvent;
parcelable SoundTrigger.GenericRecognitionEvent;
parcelable SoundTrigger.KeyphraseRecognitionExtra;
parcelable SoundTrigger.KeyphraseRecognitionExtra;
parcelable SoundTrigger.KeyphraseSoundModel;
parcelable SoundTrigger.KeyphraseSoundModel;
parcelable SoundTrigger.GenericSoundModel;
parcelable SoundTrigger.GenericSoundModel;
+37 −3
Original line number Original line Diff line number Diff line
@@ -595,7 +595,7 @@ public class SoundTrigger {
            }
            }
        };
        };


        private static RecognitionEvent fromParcel(Parcel in) {
        protected static RecognitionEvent fromParcel(Parcel in) {
            int status = in.readInt();
            int status = in.readInt();
            int soundModelHandle = in.readInt();
            int soundModelHandle = in.readInt();
            boolean captureAvailable = in.readByte() == 1;
            boolean captureAvailable = in.readByte() == 1;
@@ -980,7 +980,7 @@ public class SoundTrigger {
        public static final Parcelable.Creator<KeyphraseRecognitionEvent> CREATOR
        public static final Parcelable.Creator<KeyphraseRecognitionEvent> CREATOR
                = new Parcelable.Creator<KeyphraseRecognitionEvent>() {
                = new Parcelable.Creator<KeyphraseRecognitionEvent>() {
            public KeyphraseRecognitionEvent createFromParcel(Parcel in) {
            public KeyphraseRecognitionEvent createFromParcel(Parcel in) {
                return KeyphraseRecognitionEvent.fromParcel(in);
                return KeyphraseRecognitionEvent.fromParcelForKeyphrase(in);
            }
            }


            public KeyphraseRecognitionEvent[] newArray(int size) {
            public KeyphraseRecognitionEvent[] newArray(int size) {
@@ -988,7 +988,7 @@ public class SoundTrigger {
            }
            }
        };
        };


        private static KeyphraseRecognitionEvent fromParcel(Parcel in) {
        private static KeyphraseRecognitionEvent fromParcelForKeyphrase(Parcel in) {
            int status = in.readInt();
            int status = in.readInt();
            int soundModelHandle = in.readInt();
            int soundModelHandle = in.readInt();
            boolean captureAvailable = in.readByte() == 1;
            boolean captureAvailable = in.readByte() == 1;
@@ -1094,6 +1094,40 @@ public class SoundTrigger {
                    captureDelayMs, capturePreambleMs, triggerInData, captureFormat,
                    captureDelayMs, capturePreambleMs, triggerInData, captureFormat,
                    data);
                    data);
        }
        }

        public static final Parcelable.Creator<GenericRecognitionEvent> CREATOR
                = new Parcelable.Creator<GenericRecognitionEvent>() {
            public GenericRecognitionEvent createFromParcel(Parcel in) {
                return GenericRecognitionEvent.fromParcelForGeneric(in);
            }

            public GenericRecognitionEvent[] newArray(int size) {
                return new GenericRecognitionEvent[size];
            }
        };

        private static GenericRecognitionEvent fromParcelForGeneric(Parcel in) {
            RecognitionEvent event = RecognitionEvent.fromParcel(in);
            return new GenericRecognitionEvent(event.status, event.soundModelHandle,
                    event.captureAvailable, event.captureSession, event.captureDelayMs,
                    event.capturePreambleMs, event.triggerInData, event.captureFormat, event.data);
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass()) return false;
            RecognitionEvent other = (RecognitionEvent) obj;
            return super.equals(obj);
        }

        @Override
        public String toString() {
            return "GenericRecognitionEvent ::" + super.toString();
        }
    }
    }


    /**
    /**
+5 −5
Original line number Original line Diff line number Diff line
@@ -617,11 +617,7 @@ public class AlwaysOnHotwordDetector {
        }
        }


        @Override
        @Override
        public void onDetected(RecognitionEvent event) {
        public void onKeyphraseDetected(KeyphraseRecognitionEvent event) {
            if (! (event instanceof KeyphraseRecognitionEvent)) {
                Slog.e(TAG, "onDetected() called for a soundtrigger event.");
                return;
            }
            if (DBG) {
            if (DBG) {
                Slog.d(TAG, "onDetected(" + event + ")");
                Slog.d(TAG, "onDetected(" + event + ")");
            } else {
            } else {
@@ -632,6 +628,10 @@ public class AlwaysOnHotwordDetector {
                            event.captureFormat, event.captureSession, event.data))
                            event.captureFormat, event.captureSession, event.data))
                    .sendToTarget();
                    .sendToTarget();
        }
        }
        @Override
        public void onGenericSoundTriggerDetected(SoundTrigger.GenericRecognitionEvent event) {
            Slog.w(TAG, "Generic sound trigger event detected at AOHD: " + event);
        }


        @Override
        @Override
        public void onError(int status) {
        public void onError(int status) {
+7 −2
Original line number Original line Diff line number Diff line
@@ -289,8 +289,8 @@ public final class SoundTriggerDetector {
         * @hide
         * @hide
         */
         */
        @Override
        @Override
        public void onDetected(SoundTrigger.RecognitionEvent event) {
        public void onGenericSoundTriggerDetected(SoundTrigger.GenericRecognitionEvent event) {
            Slog.d(TAG, "onDetected()" + event);
            Slog.d(TAG, "onGenericSoundTriggerDetected()" + event);
            Message.obtain(mHandler,
            Message.obtain(mHandler,
                    MSG_SOUND_TRIGGER_DETECTED,
                    MSG_SOUND_TRIGGER_DETECTED,
                    new EventPayload(event.triggerInData, event.captureAvailable,
                    new EventPayload(event.triggerInData, event.captureAvailable,
@@ -298,6 +298,11 @@ public final class SoundTriggerDetector {
                    .sendToTarget();
                    .sendToTarget();
        }
        }


        @Override
        public void onKeyphraseDetected(SoundTrigger.KeyphraseRecognitionEvent event) {
            Slog.e(TAG, "Ignoring onKeyphraseDetected() called for " + event);
        }

        /**
        /**
         * @hide
         * @hide
         */
         */
Loading