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

Commit 76660ef7 authored by Sergey Volnov's avatar Sergey Volnov Committed by Android (Google) Code Review
Browse files

Merge "Hotword: Add onStopDetection() for software detectors." into sc-dev

parents 12d855bb 31f241cc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10565,6 +10565,7 @@ package android.service.voice {
    method public void onDetect(@NonNull android.service.voice.AlwaysOnHotwordDetector.EventPayload, long, @NonNull android.service.voice.HotwordDetectionService.Callback);
    method public void onDetect(@NonNull android.service.voice.HotwordDetectionService.Callback);
    method public void onDetect(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle, @NonNull android.service.voice.HotwordDetectionService.Callback);
    method public void onStopDetection();
    method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer);
    field public static final int INITIALIZATION_STATUS_SUCCESS = 0; // 0x0
    field public static final int INITIALIZATION_STATUS_UNKNOWN = 100; // 0x64
+14 −0
Original line number Diff line number Diff line
@@ -192,6 +192,11 @@ public abstract class HotwordDetectionService extends Service {
            mContentCaptureManager = new ContentCaptureManager(
                    HotwordDetectionService.this, manager, options);
        }

        @Override
        public void stopDetection() {
            HotwordDetectionService.this.onStopDetection();
        }
    };

    @Override
@@ -348,6 +353,15 @@ public abstract class HotwordDetectionService extends Service {
        onUpdateState(options, sharedMemory, UPDATE_TIMEOUT_MILLIS, intConsumer);
    }

    /**
     * Called when the {@link VoiceInteractionService}
     * {@link HotwordDetector#stopRecognition() requests} that hotword recognition be stopped.
     * <p>
     * Any open {@link android.media.AudioRecord} should be closed here.
     */
    public void onStopDetection() {
    }

    /**
     * Callback for returning the detection result.
     *
+2 −0
Original line number Diff line number Diff line
@@ -53,4 +53,6 @@ oneway interface IHotwordDetectionService {
    void updateContentCaptureManager(
        in IContentCaptureManager contentCaptureManager,
        in ContentCaptureOptions options);

    void stopDetection();
}
+2 −0
Original line number Diff line number Diff line
@@ -287,6 +287,8 @@ final class HotwordDetectionConnection {
            Slog.d(TAG, "stopListening");
        }

        mRemoteHotwordDetectionService.run(service -> service.stopDetection());

        synchronized (mLock) {
            if (mCurrentAudioSink != null) {
                Slog.i(TAG, "Closing audio stream to hotword detector: stopping requested");