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

Commit 0ef63954 authored by Atneya Nair's avatar Atneya Nair Committed by Automerger Merge Worker
Browse files

Merge "Throw if AOHD is inited without a underlying DSP" into udc-dev am: 23c3902e am: ffb9a6d3

parents 0f097385 ffb9a6d3
Loading
Loading
Loading
Loading
+28 −12
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.ActivityThread;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
@@ -257,6 +259,16 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
    })
    public @interface ModelParams {}

    /**
     * Gates returning {@code IllegalStateException} in {@link #initialize(
     * PersistableBundle, SharedMemory, SoundTrigger.ModuleProperties)} when no DSP module
     * is available. If the change is not enabled, the existing behavior of not throwing an
     * exception and delivering {@link STATE_HARDWARE_UNAVAILABLE} is retained.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    static final long THROW_ON_INITIALIZE_IF_NO_DSP = 269165460L;

    /**
     * Controls the sensitivity threshold adjustment factor for a given model.
     * Negative value corresponds to less sensitive model (high threshold) and
@@ -870,8 +882,10 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
                                .equals(SoundTrigger.FAKE_HAL_ARCH))
                        .findFirst()
                        .orElse(null);
                // (@atneya) intentionally let a null moduleProperties through until
                // all CTS tests are fixed
                if (CompatChanges.isChangeEnabled(THROW_ON_INITIALIZE_IF_NO_DSP) &&
                        moduleProperties == null) {
                    throw new IllegalStateException("No DSP module available to attach to");
                }
            }
            mSoundTriggerSession =
                    mModelManagementService.createSoundTriggerSessionAsOriginator(
@@ -1753,6 +1767,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
                }
            }

            if (!CompatChanges.isChangeEnabled(THROW_ON_INITIALIZE_IF_NO_DSP)) {
                ModuleProperties dspModuleProperties;
                try {
                    dspModuleProperties =
@@ -1765,6 +1780,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
                if (dspModuleProperties == null) {
                    return STATE_HARDWARE_UNAVAILABLE;
                }
            }

            return STATE_NOT_READY;
        }
+18 −0
Original line number Diff line number Diff line
@@ -463,6 +463,10 @@ public class VoiceInteractionService extends Service {
     * @param callback The callback to notify of detection events.
     * @return An always-on hotword detector for the given keyphrase and locale.
     *
     * @throws SecurityException if the caller does not hold required permissions
     * @throws IllegalStateException if there is no DSP hardware support when a caller has a
     * target SDK of API level 34 or above.
     *
     * @deprecated Use {@link #createAlwaysOnHotwordDetector(String, Locale, Executor,
     *             AlwaysOnHotwordDetector.Callback)} instead.
     * @hide
@@ -500,6 +504,10 @@ public class VoiceInteractionService extends Service {
     * @param callback The callback to notify of detection events.
     * @return An always-on hotword detector for the given keyphrase and locale.
     *
     * @throws SecurityException if the caller does not hold required permissions
     * @throws IllegalStateException if there is no DSP hardware support when a caller has a
     * target SDK of API level 34 or above.
     *
     * @hide
     */
    @SystemApi
@@ -581,6 +589,11 @@ public class VoiceInteractionService extends Service {
     * @param callback The callback to notify of detection events.
     * @return An always-on hotword detector for the given keyphrase and locale.
     *
     * @throws SecurityException if the caller does not hold required permissions
     * @throws IllegalStateException if the hotword detection service is not set, isolated process
     * is not set, or there is no DSP hardware support when a caller has a target SDK of API
     * level 34 or above.
     *
     * @deprecated Use {@link #createAlwaysOnHotwordDetector(String, Locale, PersistableBundle,
     *             SharedMemory, Executor, AlwaysOnHotwordDetector.Callback)} instead.
     * @hide
@@ -631,6 +644,11 @@ public class VoiceInteractionService extends Service {
     * @param callback The callback to notify of detection events.
     * @return An always-on hotword detector for the given keyphrase and locale.
     *
     * @throws SecurityException if the caller does not hold required permissions
     * @throws IllegalStateException if the hotword detection service is not set, isolated process
     * is not set, or there is no DSP hardware support when a caller has a target SDK of API level
     * 34 or above.
     *
     * @hide
     */
    @SystemApi