Merge "Nullability fixes for HotwordDetectionService APIs." into sc-dev
This commit is contained in:
@@ -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 boolean startRecognition(int);
|
||||
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 public final void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory);
|
||||
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 void onHotwordDetectionServiceInitialized(int);
|
||||
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 {
|
||||
@@ -10554,8 +10554,8 @@ package android.service.voice {
|
||||
}
|
||||
|
||||
public static final class HotwordDetectionService.Callback {
|
||||
method public void onDetected(@Nullable android.service.voice.HotwordDetectedResult);
|
||||
method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
|
||||
method public void onDetected(@NonNull android.service.voice.HotwordDetectedResult);
|
||||
method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
|
||||
}
|
||||
|
||||
public interface HotwordDetector {
|
||||
@@ -10576,7 +10576,7 @@ package android.service.voice {
|
||||
method public void onHotwordDetectionServiceRestarted();
|
||||
method public void onRecognitionPaused();
|
||||
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 {
|
||||
|
||||
@@ -55,10 +55,8 @@ abstract class AbstractHotwordDetector implements HotwordDetector {
|
||||
/**
|
||||
* Detect hotword from an externally supplied stream of data.
|
||||
*
|
||||
* @return a writeable file descriptor that clients can start writing data in the given format.
|
||||
* In order to stop detection, clients can close the given stream.
|
||||
* @return true if the request to start recognition succeeded
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public boolean startRecognition(
|
||||
@NonNull ParcelFileDescriptor audioStream,
|
||||
|
||||
@@ -524,7 +524,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
|
||||
* @param result Info about the second stage detection result, provided by the
|
||||
* {@link HotwordDetectionService}.
|
||||
*/
|
||||
public void onRejected(@Nullable HotwordRejectedResult result) {
|
||||
public void onRejected(@NonNull HotwordRejectedResult result) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1164,7 +1164,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRejected(HotwordRejectedResult result) {
|
||||
public void onRejected(@NonNull HotwordRejectedResult result) {
|
||||
if (DBG) {
|
||||
Slog.d(TAG, "onRejected(" + result + ")");
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.service.voice;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import android.annotation.DurationMillisLong;
|
||||
import android.annotation.IntDef;
|
||||
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 {
|
||||
mRemoteCallback.onDetected(hotwordDetectedResult);
|
||||
mRemoteCallback.onDetected(result);
|
||||
} catch (RemoteException e) {
|
||||
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
|
||||
* the {@link HotwordDetector}.
|
||||
*/
|
||||
public void onRejected(@Nullable HotwordRejectedResult result) {
|
||||
public void onRejected(@NonNull HotwordRejectedResult result) {
|
||||
requireNonNull(result);
|
||||
try {
|
||||
mRemoteCallback.onRejected(result);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -160,7 +160,7 @@ public interface HotwordDetector {
|
||||
* @param result Info about the second stage detection result, provided by the
|
||||
* {@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
|
||||
|
||||
@@ -612,7 +612,7 @@ final class HotwordDetectionConnection {
|
||||
options,
|
||||
new IDspHotwordDetectionCallback.Stub() {
|
||||
@Override
|
||||
public void onRejected(@Nullable HotwordRejectedResult result)
|
||||
public void onRejected(HotwordRejectedResult result)
|
||||
throws RemoteException {
|
||||
bestEffortClose(serviceAudioSink);
|
||||
bestEffortClose(serviceAudioSource);
|
||||
@@ -622,7 +622,7 @@ final class HotwordDetectionConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetected(@Nullable HotwordDetectedResult triggerResult)
|
||||
public void onDetected(HotwordDetectedResult triggerResult)
|
||||
throws RemoteException {
|
||||
bestEffortClose(serviceAudioSink);
|
||||
bestEffortClose(serviceAudioSource);
|
||||
|
||||
Reference in New Issue
Block a user