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

Commit 9c05fff0 authored by Sandeep Siddhartha's avatar Sandeep Siddhartha Committed by Android (Google) Code Review
Browse files

Merge "Stop recognition when shutting down VIS" into lmp-dev

parents 2c848009 5e33fb05
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class VoiceInteractionService extends Service {
    /**
     * Called during service de-initialization to tell you when the system is shutting the
     * service down.
     * At this point this service may no longer be the active {@link VoiceInteractionService}.
     */
    public void onShutdown() {
    }
+24 −0
Original line number Diff line number Diff line
@@ -240,6 +240,30 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
        }
    }

    synchronized void stopAllRecognitions() {
        if (moduleProperties == null || mModule == null) {
            return;
        }

        if (mCurrentSoundModelHandle == INVALID_SOUND_MODEL_HANDLE) {
            return;
        }

        int status = mModule.stopRecognition(mCurrentSoundModelHandle);
        if (status != SoundTrigger.STATUS_OK) {
            Slog.w(TAG, "stopRecognition call failed with " + status);
        }
        status = mModule.unloadSoundModel(mCurrentSoundModelHandle);
        if (status != SoundTrigger.STATUS_OK) {
            Slog.w(TAG, "unloadSoundModel call failed with " + status);
        }

        mCurrentSoundModelHandle = INVALID_SOUND_MODEL_HANDLE;
        mCurrentSoundModelUuid = null;

        mActiveListeners.clear();
    }

    //---- SoundTrigger.StatusListener methods
    @Override
    public void onRecognition(RecognitionEvent event) {
+1 −3
Original line number Diff line number Diff line
@@ -49,9 +49,6 @@ import com.android.server.UiThread;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
import java.util.UUID;


/**
 * SystemService that publishes an IVoiceInteractionManagerService.
@@ -151,6 +148,7 @@ public class VoiceInteractionManagerService extends SystemService {
                }
                if (force || mImpl == null || mImpl.mUser != mCurUser
                        || !mImpl.mComponent.equals(serviceComponent)) {
                    mSoundTriggerHelper.stopAllRecognitions();
                    if (mImpl != null) {
                        mImpl.shutdownLocked();
                    }