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

Commit 05ddab93 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge "Nullability fixes for HotwordDetectionService APIs." into sc-dev am: f60fbc10

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14490409

Change-Id: I6296dd28eb2389f93a9b913f80abc12da8e97e8f
parents 091071da f60fbc10
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -10468,7 +10468,7 @@ package android.service.voice {
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public int setParameter(int, int);
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public int setParameter(int, int);
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition(int);
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition(int);
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition();
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition();
    method @Nullable public boolean startRecognition(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle);
    method public boolean startRecognition(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle);
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
    method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
    method public final void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory);
    method public final void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory);
    field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
    field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
@@ -10493,7 +10493,7 @@ package android.service.voice {
    method public abstract void onAvailabilityChanged(int);
    method public abstract void onAvailabilityChanged(int);
    method public void onHotwordDetectionServiceInitialized(int);
    method public void onHotwordDetectionServiceInitialized(int);
    method public void onHotwordDetectionServiceRestarted();
    method public void onHotwordDetectionServiceRestarted();
    method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
    method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
  }
  }
  public static class AlwaysOnHotwordDetector.EventPayload {
  public static class AlwaysOnHotwordDetector.EventPayload {
@@ -10554,8 +10554,8 @@ package android.service.voice {
  }
  }
  public static final class HotwordDetectionService.Callback {
  public static final class HotwordDetectionService.Callback {
    method public void onDetected(@Nullable android.service.voice.HotwordDetectedResult);
    method public void onDetected(@NonNull android.service.voice.HotwordDetectedResult);
    method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
    method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
  }
  }
  public interface HotwordDetector {
  public interface HotwordDetector {
@@ -10576,7 +10576,7 @@ package android.service.voice {
    method public void onHotwordDetectionServiceRestarted();
    method public void onHotwordDetectionServiceRestarted();
    method public void onRecognitionPaused();
    method public void onRecognitionPaused();
    method public void onRecognitionResumed();
    method public void onRecognitionResumed();
    method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
    method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
  }
  }
  public final class HotwordRejectedResult implements android.os.Parcelable {
  public final class HotwordRejectedResult implements android.os.Parcelable {
+1 −3
Original line number Original line Diff line number Diff line
@@ -55,10 +55,8 @@ abstract class AbstractHotwordDetector implements HotwordDetector {
    /**
    /**
     * Detect hotword from an externally supplied stream of data.
     * Detect hotword from an externally supplied stream of data.
     *
     *
     * @return a writeable file descriptor that clients can start writing data in the given format.
     * @return true if the request to start recognition succeeded
     * In order to stop detection, clients can close the given stream.
     */
     */
    @Nullable
    @Override
    @Override
    public boolean startRecognition(
    public boolean startRecognition(
            @NonNull ParcelFileDescriptor audioStream,
            @NonNull ParcelFileDescriptor audioStream,
+2 −2
Original line number Original line Diff line number Diff line
@@ -524,7 +524,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
         * @param result Info about the second stage detection result, provided by the
         * @param result Info about the second stage detection result, provided by the
         *         {@link HotwordDetectionService}.
         *         {@link HotwordDetectionService}.
         */
         */
        public void onRejected(@Nullable HotwordRejectedResult result) {
        public void onRejected(@NonNull HotwordRejectedResult result) {
        }
        }


        /**
        /**
@@ -1164,7 +1164,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
        }
        }


        @Override
        @Override
        public void onRejected(HotwordRejectedResult result) {
        public void onRejected(@NonNull HotwordRejectedResult result) {
            if (DBG) {
            if (DBG) {
                Slog.d(TAG, "onRejected(" + result + ")");
                Slog.d(TAG, "onRejected(" + result + ")");
            } else {
            } else {
+11 −4
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.service.voice;
package android.service.voice;


import static java.util.Objects.requireNonNull;

import android.annotation.DurationMillisLong;
import android.annotation.DurationMillisLong;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -414,11 +416,15 @@ public abstract class HotwordDetectionService extends Service {
        }
        }


        /**
        /**
         * Called when the detected result is valid.
         * Informs the {@link HotwordDetector} that the keyphrase was detected.
         *
         * @param result Info about the detection result. This is provided to the
         *         {@link HotwordDetector}.
         */
         */
        public void onDetected(@Nullable HotwordDetectedResult hotwordDetectedResult) {
        public void onDetected(@NonNull HotwordDetectedResult result) {
            requireNonNull(result);
            try {
            try {
                mRemoteCallback.onDetected(hotwordDetectedResult);
                mRemoteCallback.onDetected(result);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
                throw e.rethrowFromSystemServer();
            }
            }
@@ -433,7 +439,8 @@ public abstract class HotwordDetectionService extends Service {
         * @param result Info about the second stage detection result. This is provided to
         * @param result Info about the second stage detection result. This is provided to
         *         the {@link HotwordDetector}.
         *         the {@link HotwordDetector}.
         */
         */
        public void onRejected(@Nullable HotwordRejectedResult result) {
        public void onRejected(@NonNull HotwordRejectedResult result) {
            requireNonNull(result);
            try {
            try {
                mRemoteCallback.onRejected(result);
                mRemoteCallback.onRejected(result);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -160,7 +160,7 @@ public interface HotwordDetector {
         * @param result Info about the second stage detection result, provided by the
         * @param result Info about the second stage detection result, provided by the
         *         {@link HotwordDetectionService}.
         *         {@link HotwordDetectionService}.
         */
         */
        void onRejected(@Nullable HotwordRejectedResult result);
        void onRejected(@NonNull HotwordRejectedResult result);


        /**
        /**
         * Called when the {@link HotwordDetectionService} is created by the system and given a
         * Called when the {@link HotwordDetectionService} is created by the system and given a
Loading