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

Commit fe38986f authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi
Browse files

Add support for STHAL 2.4 at lower layers of middleware

This change adds support for talking to a STHAL V2.4 and adapting the
earlier versions to look like the latest.

Test: Manual verification of basic soundtrigger flows.
Bug: 178722883
Change-Id: Ied6e1735b0b264273e27aac21be361d5fd0b2aca
parent ee705fa2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ java_library_static {
        "android.hardware.configstore-V1.0-java",
        "android.hardware.contexthub-V1.0-java",
        "android.hardware.rebootescrow-V1-java",
        "android.hardware.soundtrigger-V2.3-java",
        "android.hardware.soundtrigger-V2.4-java",
        "android.hardware.power.stats-V1-java",
        "android.hidl.manager-V1.2-java",
        "capture_state_listener-aidl-java",
+54 −34
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.soundtrigger_middleware;

import android.hardware.soundtrigger.V2_3.ModelParameterRange;
import android.hidl.base.V1_0.IBase;
import android.os.IHwBinder;

@@ -51,30 +50,38 @@ import android.os.IHwBinder;
 * so that clients have access to the entire functionality without having to burden themselves with
 * compatibility, as much as possible.
 */
public interface ISoundTriggerHw2 {
interface ISoundTriggerHw2 {
    /**
     * @see android.hardware.soundtrigger.V2_3.ISoundTriggerHw#getPropertiesEx(
     * android.hardware.soundtrigger.V2_3.ISoundTriggerHw.getPropertiesExCallback)
     * @see android.hardware.soundtrigger.V2_3.ISoundTriggerHw#getProperties_2_3(
     *              android.hardware.soundtrigger.V2_3.ISoundTriggerHw.getProperties_2_3Callback)
     */
    android.hardware.soundtrigger.V2_3.Properties getProperties();

    /**
     * @see android.hardware.soundtrigger.V2_2.ISoundTriggerHw#loadSoundModel_2_1(android.hardware.soundtrigger.V2_1.ISoundTriggerHw.SoundModel,
     * android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback, int,
     * android.hardware.soundtrigger.V2_1.ISoundTriggerHw.loadSoundModel_2_1Callback)
     * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHw#registerGlobalCallback(
     *              android.hardware.soundtrigger.V2_4.ISoundTriggerHwGlobalCallback)
     */
    void registerCallback(GlobalCallback callback);

    /**
     * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHw#loadSoundModel_2_4(
     *              android.hardware.soundtrigger.V2_1.ISoundTriggerHw.SoundModel,
     *              android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback,
     *              android.hardware.soundtrigger.V2_4.ISoundTriggerHw.loadSoundModel_2_4Callback)
     */
    int loadSoundModel(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.SoundModel soundModel,
            SoundTriggerHw2Compat.Callback callback, int cookie);
            ModelCallback callback);

    /**
     * @see android.hardware.soundtrigger.V2_2.ISoundTriggerHw#loadPhraseSoundModel_2_1(android.hardware.soundtrigger.V2_1.ISoundTriggerHw.PhraseSoundModel,
     * android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback, int,
     * android.hardware.soundtrigger.V2_1.ISoundTriggerHw.loadPhraseSoundModel_2_1Callback)
     * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHw#loadPhraseSoundModel_2_4(
     *              android.hardware.soundtrigger.V2_1.ISoundTriggerHw.PhraseSoundModel,
     *              android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback,
     *              android.hardware.soundtrigger.V2_4.ISoundTriggerHw.loadPhraseSoundModel_2_4Callback)
     */
    int loadPhraseSoundModel(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.PhraseSoundModel soundModel,
            SoundTriggerHw2Compat.Callback callback, int cookie);
            ModelCallback callback);

    /**
     * @see android.hardware.soundtrigger.V2_2.ISoundTriggerHw#unloadSoundModel(int)
@@ -87,18 +94,12 @@ public interface ISoundTriggerHw2 {
    void stopRecognition(int modelHandle);

    /**
     * @see android.hardware.soundtrigger.V2_2.ISoundTriggerHw#stopAllRecognitions()
     */
    void stopAllRecognitions();

    /**
     * @see android.hardware.soundtrigger.V2_3.ISoundTriggerHw#startRecognition_2_3(int,
     * android.hardware.soundtrigger.V2_3.RecognitionConfig,
     * android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback, int)
     * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHw#startRecognition_2_4(
     *              int,
     *              android.hardware.soundtrigger.V2_3.RecognitionConfig)
     */
    void startRecognition(int modelHandle,
            android.hardware.soundtrigger.V2_3.RecognitionConfig config,
            SoundTriggerHw2Compat.Callback callback, int cookie);
            android.hardware.soundtrigger.V2_3.RecognitionConfig config);

    /**
     * @see android.hardware.soundtrigger.V2_2.ISoundTriggerHw#getModelState(int)
@@ -107,7 +108,7 @@ public interface ISoundTriggerHw2 {

    /**
     * @see android.hardware.soundtrigger.V2_3.ISoundTriggerHw#getParameter(int, int,
     * ISoundTriggerHw.getParameterCallback)
     * android.hardware.soundtrigger.V2_3.ISoundTriggerHw.getParameterCallback)
     */
    int getModelParameter(int modelHandle, int param);

@@ -119,9 +120,10 @@ public interface ISoundTriggerHw2 {
    /**
     * @return null if not supported.
     * @see android.hardware.soundtrigger.V2_3.ISoundTriggerHw#queryParameter(int, int,
     * ISoundTriggerHw.queryParameterCallback)
     * android.hardware.soundtrigger.V2_3.ISoundTriggerHw.queryParameterCallback)
     */
    ModelParameterRange queryParameter(int modelHandle, int param);
    android.hardware.soundtrigger.V2_3.ModelParameterRange queryParameter(int modelHandle,
            int param);

    /**
     * @see IHwBinder#linkToDeath(IHwBinder.DeathRecipient, long)
@@ -138,21 +140,39 @@ public interface ISoundTriggerHw2 {
     */
    String interfaceDescriptor() throws android.os.RemoteException;

    interface Callback {
    /**
         * @see android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback#recognitionCallback_2_1(android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent,
     * Callback interface for model-related events.
     */
    interface ModelCallback {
        /**
         * @see android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback#recognitionCallback_2_1(
         *              android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent,
         *              int)
         */
        void recognitionCallback(
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent event,
                int cookie);
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent event);

        /**
         * @see android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback#phraseRecognitionCallback_2_1(android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent,
         * @see android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback#phraseRecognitionCallback_2_1(
         *              android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent,
         *              int)
         */
        void phraseRecognitionCallback(
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent event,
                int cookie);
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent event);

        /**
         * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback#modelUnloaded(int)
         */
        void modelUnloaded(int modelHandle);
    }

    /**
     * Callback interface for global events.
     */
    interface GlobalCallback {
        /**
         * @see android.hardware.soundtrigger.V2_4.ISoundTriggerHwGlobalCallback#tryAgain()
         */
        void tryAgain();
    }
}
+136 −61
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.os.IHwBinder;
import android.os.RemoteException;

import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

@@ -42,16 +44,18 @@ import java.util.concurrent.atomic.AtomicReference;
 * </ul>
 */
final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
    private final @NonNull
    IHwBinder mBinder;
    private final @NonNull
    android.hardware.soundtrigger.V2_0.ISoundTriggerHw mUnderlying_2_0;
    private final @Nullable
    android.hardware.soundtrigger.V2_1.ISoundTriggerHw mUnderlying_2_1;
    private final @Nullable
    android.hardware.soundtrigger.V2_2.ISoundTriggerHw mUnderlying_2_2;
    private final @Nullable
    android.hardware.soundtrigger.V2_3.ISoundTriggerHw mUnderlying_2_3;
    private final @NonNull IHwBinder mBinder;
    private final @NonNull android.hardware.soundtrigger.V2_0.ISoundTriggerHw mUnderlying_2_0;
    private final @Nullable android.hardware.soundtrigger.V2_1.ISoundTriggerHw mUnderlying_2_1;
    private final @Nullable android.hardware.soundtrigger.V2_2.ISoundTriggerHw mUnderlying_2_2;
    private final @Nullable android.hardware.soundtrigger.V2_3.ISoundTriggerHw mUnderlying_2_3;
    private final @Nullable android.hardware.soundtrigger.V2_4.ISoundTriggerHw mUnderlying_2_4;

    // HAL <=2.1 requires us to pass a callback argument to startRecognition. We will store the one
    // passed on load and then pass it on start. We don't bother storing the callback on newer
    // versions.
    private final @NonNull ConcurrentMap<Integer, ModelCallback> mModelCallbacks =
            new ConcurrentHashMap<>();

    public SoundTriggerHw2Compat(
            @NonNull android.hardware.soundtrigger.V2_0.ISoundTriggerHw underlying) {
@@ -67,11 +71,21 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
        // version, so we go down the versions in descending order to find the latest one supported,
        // and then simply up-cast it to obtain all the versions that are earlier.

        // Attempt 2.4
        android.hardware.soundtrigger.V2_4.ISoundTriggerHw as2_4 =
                android.hardware.soundtrigger.V2_4.ISoundTriggerHw.asInterface(binder);
        if (as2_4 != null) {
            mUnderlying_2_0 =
                    mUnderlying_2_1 = mUnderlying_2_2 = mUnderlying_2_3 = mUnderlying_2_4 = as2_4;
            return;
        }

        // Attempt 2.3
        android.hardware.soundtrigger.V2_3.ISoundTriggerHw as2_3 =
                android.hardware.soundtrigger.V2_3.ISoundTriggerHw.asInterface(binder);
        if (as2_3 != null) {
            mUnderlying_2_0 = mUnderlying_2_1 = mUnderlying_2_2 = mUnderlying_2_3 = as2_3;
            mUnderlying_2_4 = null;
            return;
        }

@@ -80,7 +94,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
                android.hardware.soundtrigger.V2_2.ISoundTriggerHw.asInterface(binder);
        if (as2_2 != null) {
            mUnderlying_2_0 = mUnderlying_2_1 = mUnderlying_2_2 = as2_2;
            mUnderlying_2_3 = null;
            mUnderlying_2_3 = mUnderlying_2_4 = null;
            return;
        }

@@ -89,7 +103,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
                android.hardware.soundtrigger.V2_1.ISoundTriggerHw.asInterface(binder);
        if (as2_1 != null) {
            mUnderlying_2_0 = mUnderlying_2_1 = as2_1;
            mUnderlying_2_2 = mUnderlying_2_3 = null;
            mUnderlying_2_2 = mUnderlying_2_3 = mUnderlying_2_4 = null;
            return;
        }

@@ -98,7 +112,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
                android.hardware.soundtrigger.V2_0.ISoundTriggerHw.asInterface(binder);
        if (as2_0 != null) {
            mUnderlying_2_0 = as2_0;
            mUnderlying_2_1 = mUnderlying_2_2 = mUnderlying_2_3 = null;
            mUnderlying_2_1 = mUnderlying_2_2 = mUnderlying_2_3 = mUnderlying_2_4 = null;
            return;
        }

@@ -135,24 +149,51 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
        }
    }

    @Override
    public void registerCallback(GlobalCallback callback) {
        try {
            try {
                as2_4().registerGlobalCallback(new GlobalCallbackWrapper(callback));
            } catch (NotSupported e) {
                // In versions < 2.4 the events represented by this callback don't exist, we can
                // safely ignore this.
            }
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @Override
    public int loadSoundModel(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.SoundModel soundModel,
            Callback callback, int cookie) {
            ModelCallback callback) {
        try {
            AtomicInteger retval = new AtomicInteger(-1);
            AtomicInteger handle = new AtomicInteger(0);

            try {
                as2_1().loadSoundModel_2_1(soundModel, new SoundTriggerCallback(callback), cookie,
                as2_4().loadSoundModel_2_4(soundModel, new ModelCallbackWrapper(callback),
                        (r, h) -> {
                            retval.set(r);
                            handle.set(h);
                        });
                handleHalStatus(retval.get(), "loadSoundModel_2_4");
            } catch (NotSupported e) {
                // Fall-back to the 2.1 version:
                try {
                    as2_1().loadSoundModel_2_1(soundModel, new ModelCallbackWrapper(callback),
                            0,
                            (r, h) -> {
                                retval.set(r);
                                handle.set(h);
                            });
                    handleHalStatus(retval.get(), "loadSoundModel_2_1");
                    mModelCallbacks.put(handle.get(), callback);
                } catch (NotSupported ee) {
                    // Fall-back to the 2.0 version:
                return loadSoundModel_2_0(soundModel, callback, cookie);
                    return loadSoundModel_2_0(soundModel, callback);
                }
            }
            handleHalStatus(retval.get(), "loadSoundModel_2_1");
            return handle.get();
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
@@ -162,22 +203,33 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
    @Override
    public int loadPhraseSoundModel(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.PhraseSoundModel soundModel,
            Callback callback, int cookie) {
            ModelCallback callback) {
        try {
            AtomicInteger retval = new AtomicInteger(-1);
            AtomicInteger handle = new AtomicInteger(0);
            try {
                as2_1().loadPhraseSoundModel_2_1(soundModel, new SoundTriggerCallback(callback),
                        cookie,
                as2_4().loadPhraseSoundModel_2_4(soundModel, new ModelCallbackWrapper(callback),
                        (r, h) -> {
                            retval.set(r);
                            handle.set(h);
                        });
                handleHalStatus(retval.get(), "loadPhraseSoundModel_2_4");
            } catch (NotSupported e) {
                // Fall-back to the 2.1 version:
                try {
                    as2_1().loadPhraseSoundModel_2_1(soundModel, new ModelCallbackWrapper(callback),
                            0,
                            (r, h) -> {
                                retval.set(r);
                                handle.set(h);
                            });
                    handleHalStatus(retval.get(), "loadPhraseSoundModel_2_1");
                    mModelCallbacks.put(handle.get(), callback);
                } catch (NotSupported ee) {
                    // Fall-back to the 2.0 version:
                return loadPhraseSoundModel_2_0(soundModel, callback, cookie);
                    return loadPhraseSoundModel_2_0(soundModel, callback);
                }
            }
            handleHalStatus(retval.get(), "loadSoundModel_2_1");
            return handle.get();
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
@@ -187,6 +239,8 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
    @Override
    public void unloadSoundModel(int modelHandle) {
        try {
            // Safe if key doesn't exist.
            mModelCallbacks.remove(modelHandle);
            int retval = as2_0().unloadSoundModel(modelHandle);
            handleHalStatus(retval, "unloadSoundModel");
        } catch (RemoteException e) {
@@ -205,27 +259,22 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {

    }

    @Override
    public void stopAllRecognitions() {
        try {
            int retval = as2_0().stopAllRecognitions();
            handleHalStatus(retval, "stopAllRecognitions");
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @Override
    public void startRecognition(int modelHandle,
            android.hardware.soundtrigger.V2_3.RecognitionConfig config,
            Callback callback, int cookie) {
            android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
        try {
            try {
                int retval = as2_4().startRecognition_2_4(modelHandle, config);
                handleHalStatus(retval, "startRecognition_2_4");
            } catch (NotSupported e) {
                // Fall-back to the 2.3 version:
                try {
                    int retval = as2_3().startRecognition_2_3(modelHandle, config);
                    handleHalStatus(retval, "startRecognition_2_3");
            } catch (NotSupported e) {
                } catch (NotSupported ee) {
                    // Fall-back to the 2.0 version:
                startRecognition_2_1(modelHandle, config, callback, cookie);
                    startRecognition_2_1(modelHandle, config);
                }
            }
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
@@ -333,7 +382,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {

    private int loadSoundModel_2_0(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.SoundModel soundModel,
            Callback callback, int cookie)
            ModelCallback callback)
            throws RemoteException {
        // Convert the soundModel to V2.0.
        android.hardware.soundtrigger.V2_0.ISoundTriggerHw.SoundModel model_2_0 =
@@ -341,17 +390,18 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {

        AtomicInteger retval = new AtomicInteger(-1);
        AtomicInteger handle = new AtomicInteger(0);
        as2_0().loadSoundModel(model_2_0, new SoundTriggerCallback(callback), cookie, (r, h) -> {
        as2_0().loadSoundModel(model_2_0, new ModelCallbackWrapper(callback), 0, (r, h) -> {
            retval.set(r);
            handle.set(h);
        });
        handleHalStatus(retval.get(), "loadSoundModel");
        mModelCallbacks.put(handle.get(), callback);
        return handle.get();
    }

    private int loadPhraseSoundModel_2_0(
            android.hardware.soundtrigger.V2_1.ISoundTriggerHw.PhraseSoundModel soundModel,
            Callback callback, int cookie)
            ModelCallback callback)
            throws RemoteException {
        // Convert the soundModel to V2.0.
        android.hardware.soundtrigger.V2_0.ISoundTriggerHw.PhraseSoundModel model_2_0 =
@@ -359,28 +409,28 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {

        AtomicInteger retval = new AtomicInteger(-1);
        AtomicInteger handle = new AtomicInteger(0);
        as2_0().loadPhraseSoundModel(model_2_0, new SoundTriggerCallback(callback), cookie,
        as2_0().loadPhraseSoundModel(model_2_0, new ModelCallbackWrapper(callback), 0,
                (r, h) -> {
                    retval.set(r);
                    handle.set(h);
                });
        handleHalStatus(retval.get(), "loadSoundModel");
        mModelCallbacks.put(handle.get(), callback);
        return handle.get();
    }

    private void startRecognition_2_1(int modelHandle,
            android.hardware.soundtrigger.V2_3.RecognitionConfig config,
            Callback callback, int cookie) {
            android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
        try {
            try {
                android.hardware.soundtrigger.V2_1.ISoundTriggerHw.RecognitionConfig config_2_1 =
                        Hw2CompatUtil.convertRecognitionConfig_2_3_to_2_1(config);
                int retval = as2_1().startRecognition_2_1(modelHandle, config_2_1,
                        new SoundTriggerCallback(callback), cookie);
                        new ModelCallbackWrapper(mModelCallbacks.get(modelHandle)), 0);
                handleHalStatus(retval, "startRecognition_2_1");
            } catch (NotSupported e) {
                // Fall-back to the 2.0 version:
                startRecognition_2_0(modelHandle, config, callback, cookie);
                startRecognition_2_0(modelHandle, config);
            }
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
@@ -388,13 +438,12 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
    }

    private void startRecognition_2_0(int modelHandle,
            android.hardware.soundtrigger.V2_3.RecognitionConfig config,
            Callback callback, int cookie)
            android.hardware.soundtrigger.V2_3.RecognitionConfig config)
            throws RemoteException {
        android.hardware.soundtrigger.V2_0.ISoundTriggerHw.RecognitionConfig config_2_0 =
                Hw2CompatUtil.convertRecognitionConfig_2_3_to_2_0(config);
        int retval = as2_0().startRecognition(modelHandle, config_2_0,
                new SoundTriggerCallback(callback), cookie);
                new ModelCallbackWrapper(mModelCallbacks.get(modelHandle)), 0);
        handleHalStatus(retval, "startRecognition");
    }

@@ -427,6 +476,14 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
        return mUnderlying_2_3;
    }

    private @NonNull
    android.hardware.soundtrigger.V2_4.ISoundTriggerHw as2_4() throws NotSupported {
        if (mUnderlying_2_4 == null) {
            throw new NotSupported("Underlying driver version < 2.4");
        }
        return mUnderlying_2_4;
    }

    /**
     * A checked exception representing the requested interface version not being supported.
     * At the public interface layer, use {@link #throwAsRecoverableException()} to propagate it to
@@ -448,28 +505,46 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
        }
    }

    private static class SoundTriggerCallback extends
            android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.Stub {
        private final @NonNull
        Callback mDelegate;
    private static class GlobalCallbackWrapper extends
            android.hardware.soundtrigger.V2_4.ISoundTriggerHwGlobalCallback.Stub {
        private final @NonNull GlobalCallback mDelegate;

        private SoundTriggerCallback(
                @NonNull Callback delegate) {
        private GlobalCallbackWrapper(@NonNull GlobalCallback delegate) {
            mDelegate = delegate;
        }

        @Override
        public void tryAgain() {
            mDelegate.tryAgain();
        }
    }

    private static class ModelCallbackWrapper extends
            android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback.Stub {
        private final @NonNull ModelCallback mDelegate;

        private ModelCallbackWrapper(
                @NonNull ModelCallback delegate) {
            mDelegate = Objects.requireNonNull(delegate);
        }

        @Override
        public void modelUnloaded(int modelHandle) {
            mDelegate.modelUnloaded(modelHandle);
        }

        @Override
        public void recognitionCallback_2_1(
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent event,
                int cookie) {
            mDelegate.recognitionCallback(event, cookie);
            mDelegate.recognitionCallback(event);
        }

        @Override
        public void phraseRecognitionCallback_2_1(
                android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent event,
                int cookie) {
            mDelegate.phraseRecognitionCallback(event, cookie);
            mDelegate.phraseRecognitionCallback(event);
        }

        @Override
@@ -485,7 +560,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
                int cookie) {
            android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent event_2_1 =
                    Hw2CompatUtil.convertRecognitionEvent_2_0_to_2_1(event);
            mDelegate.recognitionCallback(event_2_1, cookie);
            mDelegate.recognitionCallback(event_2_1);
        }

        @Override
@@ -494,7 +569,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHw2 {
                int cookie) {
            android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent
                    event_2_1 = Hw2CompatUtil.convertPhraseRecognitionEvent_2_0_to_2_1(event);
            mDelegate.phraseRecognitionCallback(event_2_1, cookie);
            mDelegate.phraseRecognitionCallback(event_2_1);
        }

        @Override
+94 −56

File changed.

Preview size limit exceeded, changes collapsed.

+15 −19

File changed.

Preview size limit exceeded, changes collapsed.

Loading