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

Commit 7040c129 authored by Felix Oghina's avatar Felix Oghina Committed by Atneya Nair
Browse files

[hotword] detach session when detector is destroyed

Bug: 272147641
Bug: 274806716

Test: atest AlwaysOnHotwordDetectorTest

Change-Id: I2297806b6d6161aa1bd88eaf780ae2266f4f8f7a
parent 14de6500
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -1334,13 +1334,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
    @Override
    public void destroy() {
        synchronized (mLock) {
            if (mAvailability == STATE_KEYPHRASE_ENROLLED) {
                try {
                    stopRecognition();
                } catch (Exception e) {
                    Log.i(TAG, "failed to stopRecognition in destroy", e);
                }
            }
            detachSessionLocked();

            mAvailability = STATE_INVALID;
            mIsAvailabilityOverriddenByTestApi = false;
@@ -1349,6 +1343,17 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
        super.destroy();
    }

    private void detachSessionLocked() {
        try {
            if (DBG) Slog.d(TAG, "detachSessionLocked() " + mSoundTriggerSession);
            if (mSoundTriggerSession != null) {
                mSoundTriggerSession.detach();
            }
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
+5 −0
Original line number Diff line number Diff line
@@ -94,4 +94,9 @@ interface IVoiceInteractionSoundTriggerSession {
     */
    @nullable SoundTrigger.ModelParamRange queryParameter(int keyphraseId,
            in ModelParams modelParam);
    /**
     * Invalidates the sound trigger session and clears any associated resources. Subsequent calls
     * to this object will throw IllegalStateException.
     */
    void detach();
}
+6 −0
Original line number Diff line number Diff line
@@ -141,6 +141,12 @@ public interface SoundTriggerInternal {
        ModelParamRange queryParameter(int keyphraseId,
                @ModelParams int modelParam);

        /**
         * Invalidates the sound trigger session and clears any associated resources. Subsequent
         * calls to this object will throw IllegalStateException.
         */
        void detach();

        /**
         * Unloads (and stops if running) the given keyphraseId
         */
+5 −0
Original line number Diff line number Diff line
@@ -1662,6 +1662,11 @@ public class SoundTriggerService extends SystemService {
                return mSoundTriggerHelper.queryKeyphraseParameter(keyphraseId, modelParam);
            }

            @Override
            public void detach() {
                mSoundTriggerHelper.detach();
            }

            @Override
            public int unloadKeyphraseModel(int keyphraseId) {
                return mSoundTriggerHelper.unloadKeyphraseSoundModel(keyphraseId);
+5 −0
Original line number Diff line number Diff line
@@ -69,4 +69,9 @@ final class SoundTriggerSessionBinderProxy extends IVoiceInteractionSoundTrigger
    public SoundTrigger.ModelParamRange queryParameter(int i, int i1) throws RemoteException {
        return mDelegate.queryParameter(i, i1);
    }

    @Override
    public void detach() throws RemoteException {
        mDelegate.detach();
    }
}
Loading