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

Commit a9b13c75 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disallow combining trusted and non-trusted detectors"

parents cc283700 c7bfbbae
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -345,6 +345,12 @@ public class VoiceInteractionService extends Service {
     * Calling this a second time invalidates the previously created hotword detector
     * which can no longer be used to manage recognition.
     *
     * <p>Note: If there are any active detectors that are created by using
     * {@link #createAlwaysOnHotwordDetector(String, Locale, PersistableBundle, SharedMemory,
     * AlwaysOnHotwordDetector.Callback)} or {@link #createHotwordDetector(PersistableBundle,
     * SharedMemory, HotwordDetector.Callback)}, call this will throw an
     * {@link IllegalArgumentException}.
     *
     * @param keyphrase The keyphrase that's being used, for example "Hello Android".
     * @param locale The locale for which the enrollment needs to be performed.
     * @param callback The callback to notify of detection events.
@@ -377,6 +383,10 @@ public class VoiceInteractionService extends Service {
     * <p>Note: The system will trigger hotword detection service after calling this function when
     * all conditions meet the requirements.
     *
     * <p>Note: If there are any active detectors that are created by using
     * {@link #createAlwaysOnHotwordDetector(String, Locale, AlwaysOnHotwordDetector.Callback)},
     * call this will throw an {@link IllegalArgumentException}.
     *
     * @param keyphrase The keyphrase that's being used, for example "Hello Android".
     * @param locale The locale for which the enrollment needs to be performed.
     * @param options Application configuration data provided by the
@@ -420,6 +430,14 @@ public class VoiceInteractionService extends Service {
                safelyShutdownAllHotwordDetectors();
            }

            for (HotwordDetector detector : mActiveHotwordDetectors) {
                if (detector.isUsingHotwordDetectionService() != supportHotwordDetectionService) {
                    throw new IllegalArgumentException(
                            "It disallows to create trusted and non-trusted detectors "
                                    + "at the same time.");
                }
            }

            AlwaysOnHotwordDetector dspDetector = new AlwaysOnHotwordDetector(keyphrase, locale,
                    callback, mKeyphraseEnrollmentInfo, mSystemService,
                    getApplicationContext().getApplicationInfo().targetSdkVersion,
@@ -460,6 +478,10 @@ public class VoiceInteractionService extends Service {
     * devices where hardware filtering is available (such as through a DSP), it's highly
     * recommended to use {@link #createAlwaysOnHotwordDetector} instead.
     *
     * <p>Note: If there are any active detectors that are created by using
     * {@link #createAlwaysOnHotwordDetector(String, Locale, AlwaysOnHotwordDetector.Callback)},
     * call this will throw an {@link IllegalArgumentException}.
     *
     * @param options Application configuration data to be provided to the
     * {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or
     * other contents that can be used to communicate with other processes.
@@ -490,7 +512,11 @@ public class VoiceInteractionService extends Service {
                safelyShutdownAllHotwordDetectors();
            } else {
                for (HotwordDetector detector : mActiveHotwordDetectors) {
                    if (detector instanceof SoftwareHotwordDetector) {
                    if (!detector.isUsingHotwordDetectionService()) {
                        throw new IllegalArgumentException(
                                "It disallows to create trusted and non-trusted detectors "
                                        + "at the same time.");
                    } else if (detector instanceof SoftwareHotwordDetector) {
                        throw new IllegalArgumentException(
                                "There is already an active SoftwareHotwordDetector. "
                                        + "It must be destroyed to create a new one.");