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

Commit 47a6757c authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge "Allow HotwordDetectionService to return HotwordRejectedResult." into sc-dev am: 8f02ccf5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13955919

Change-Id: Ibe6c653cc4e103942b870cb2b3bea7dd61eee99c
parents 4ecb670b 8f02ccf5
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -10342,7 +10342,6 @@ package android.service.voice {
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
    field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
    field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
    field public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION = 2; // 0x2
    field public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION = 2; // 0x2
    field public static final int HOTWORD_DETECTION_FALSE_ALERT = 0; // 0x0
    field public static final int MODEL_PARAM_THRESHOLD_FACTOR = 0; // 0x0
    field public static final int MODEL_PARAM_THRESHOLD_FACTOR = 0; // 0x0
    field public static final int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS = 2; // 0x2
    field public static final int RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS = 2; // 0x2
    field public static final int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO = 1; // 0x1
    field public static final int RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO = 1; // 0x1
@@ -10365,7 +10364,7 @@ package android.service.voice {
    method public abstract void onError();
    method public abstract void onError();
    method public abstract void onRecognitionPaused();
    method public abstract void onRecognitionPaused();
    method public abstract void onRecognitionResumed();
    method public abstract void onRecognitionResumed();
    method public void onRejected(int);
    method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
  }
  }
  public static class AlwaysOnHotwordDetector.EventPayload {
  public static class AlwaysOnHotwordDetector.EventPayload {
@@ -10414,7 +10413,7 @@ package android.service.voice {
  public static final class HotwordDetectionService.DspHotwordDetectionCallback {
  public static final class HotwordDetectionService.DspHotwordDetectionCallback {
    method public void onDetected();
    method public void onDetected();
    method public void onRejected();
    method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
  }
  }
  public interface HotwordDetector {
  public interface HotwordDetector {
+10 −19
Original line number Original line Diff line number Diff line
@@ -238,18 +238,6 @@ public class AlwaysOnHotwordDetector {
    })
    })
    public @interface ModelParams {}
    public @interface ModelParams {}


    /**
     * Indicates that the given audio data is a false alert for {@link VoiceInteractionService}.
     */
    public static final int HOTWORD_DETECTION_FALSE_ALERT = 0;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, prefix = { "HOTWORD_DETECTION_" }, value = {
            HOTWORD_DETECTION_FALSE_ALERT,
    })
    public @interface HotwordDetectionResult {}

    /**
    /**
     * Controls the sensitivity threshold adjustment factor for a given model.
     * Controls the sensitivity threshold adjustment factor for a given model.
     * Negative value corresponds to less sensitive model (high threshold) and
     * Negative value corresponds to less sensitive model (high threshold) and
@@ -478,11 +466,14 @@ public class AlwaysOnHotwordDetector {
        public abstract void onRecognitionResumed();
        public abstract void onRecognitionResumed();


        /**
        /**
         * Called when the validated result is invalid.
         * Called when the {@link HotwordDetectionService second stage detection} did not detect the
         * keyphrase.
         *
         *
         * @param reason The reason why the validated result is invalid.
         * @param result Info about the second stage detection result, provided by the
         *         {@link HotwordDetectionService}.
         */
         */
        public void onRejected(@HotwordDetectionResult int reason) {}
        public void onRejected(@Nullable HotwordRejectedResult result) {
        }
    }
    }


    /**
    /**
@@ -1069,13 +1060,13 @@ public class AlwaysOnHotwordDetector {
        }
        }


        @Override
        @Override
        public void onRejected(int reason) {
        public void onRejected(HotwordRejectedResult result) {
            if (DBG) {
            if (DBG) {
                Slog.d(TAG, "onRejected(" + reason + ")");
                Slog.d(TAG, "onRejected(" + result + ")");
            } else {
            } else {
                Slog.i(TAG, "onRejected");
                Slog.i(TAG, "onRejected");
            }
            }
            Message.obtain(mHandler, MSG_HOTWORD_REJECTED, reason).sendToTarget();
            Message.obtain(mHandler, MSG_HOTWORD_REJECTED, result).sendToTarget();
        }
        }


        @Override
        @Override
@@ -1124,7 +1115,7 @@ public class AlwaysOnHotwordDetector {
                    mExternalCallback.onRecognitionResumed();
                    mExternalCallback.onRecognitionResumed();
                    break;
                    break;
                case MSG_HOTWORD_REJECTED:
                case MSG_HOTWORD_REJECTED:
                    mExternalCallback.onRejected(msg.arg1);
                    mExternalCallback.onRejected((HotwordRejectedResult) msg.obj);
                    break;
                    break;
                default:
                default:
                    super.handleMessage(msg);
                    super.handleMessage(msg);
+6 −3
Original line number Original line Diff line number Diff line
@@ -182,11 +182,14 @@ public abstract class HotwordDetectionService extends Service {
        }
        }


        /**
        /**
         * Called when the detected result is invalid.
         * Informs the {@link AlwaysOnHotwordDetector} that the keyphrase was not detected.
         *
         * @param result Info about the second stage detection result. This is provided to
         *         the {@link AlwaysOnHotwordDetector}.
         */
         */
        public void onRejected() {
        public void onRejected(@Nullable HotwordRejectedResult result) {
            try {
            try {
                mRemoteCallback.onRejected();
                mRemoteCallback.onRejected(result);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
                throw e.rethrowFromSystemServer();
            }
            }
+4 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.service.voice;
package android.service.voice;


import android.service.voice.HotwordRejectedResult;

/**
/**
 * Callback for returning the detected result from the HotwordDetectionService.
 * Callback for returning the detected result from the HotwordDetectionService.
 *
 *
@@ -28,7 +30,7 @@ oneway interface IDspHotwordDetectionCallback {
    void onDetected();
    void onDetected();


    /**
    /**
     * Called when the detected result is invalid.
     * Sends {@code result} to the HotwordDetector.
     */
     */
    void onRejected();
    void onRejected(in HotwordRejectedResult result);
}
}
+6 −3
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.app;
package com.android.internal.app;


import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger;
import android.service.voice.HotwordRejectedResult;


/**
/**
 * @hide
 * @hide
@@ -41,11 +42,13 @@ oneway interface IHotwordRecognitionStatusCallback {
    void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent);
    void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent);


    /**
    /**
     * Called when the validated result is invalid.
     * Called when the {@link HotwordDetectionService second stage detection} did not detect the
     * keyphrase.
     *
     *
     * @param reason The reason why the validated result is invalid.
     * @param result Info about the second stage detection result, provided by the
     *         {@link HotwordDetectionService}.
     */
     */
    void onRejected(int reason);
    void onRejected(in HotwordRejectedResult result);


    /**
    /**
     * Called when the detection fails due to an error.
     * Called when the detection fails due to an error.
Loading