From c3f72bcf3d970a8b5c306195ed5510523f2ed63c Mon Sep 17 00:00:00 2001 From: Andrea Ambu Date: Thu, 29 Apr 2021 17:05:49 +0100 Subject: [PATCH] hotword: Fix inconsistent @NonNull and API comment - setMediaSyncEvent does not need to accept any @Nullable param. - getMediaSyncEvent return @Nullable. This CL manually define the getter to allow for the @Nullable/@NotNull and doc asymmetry. Bug: 186469575 Fix: 186469575 Test: CtsVoiceInteractionTestCases Change-Id: Icc0b6282e6ee13c8fcaa7dea763a39c430e66644 --- .../service/voice/HotwordDetectedResult.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/core/java/android/service/voice/HotwordDetectedResult.java b/core/java/android/service/voice/HotwordDetectedResult.java index e50de1c30ba02..ee82c374691b9 100644 --- a/core/java/android/service/voice/HotwordDetectedResult.java +++ b/core/java/android/service/voice/HotwordDetectedResult.java @@ -57,8 +57,6 @@ public final class HotwordDetectedResult implements Parcelable { * A {@code MediaSyncEvent} that allows the {@link HotwordDetector} to recapture the audio * that contains the hotword trigger. This must be obtained using * {@link android.media.AudioRecord#shareAudioHistory(String, long)}. - *

- * This can be {@code null} if reprocessing the hotword trigger isn't required. */ @Nullable private MediaSyncEvent mMediaSyncEvent = null; @@ -150,6 +148,18 @@ public final class HotwordDetectedResult implements Parcelable { return 50; } + /** + * A {@code MediaSyncEvent} that allows the {@link HotwordDetector} to recapture the audio + * that contains the hotword trigger. This must be obtained using + * {@link android.media.AudioRecord#shareAudioHistory(String, long)}. + *

+ * This can be {@code null} if reprocessing the hotword trigger isn't required. + */ + // Suppress codegen to make javadoc consistent. Getter returns @Nullable, setter accepts + // @NonNull only, and by default codegen would use the same javadoc on both. + public @Nullable MediaSyncEvent getMediaSyncEvent() { + return mMediaSyncEvent; + } // Code below generated by codegen v1.0.23. @@ -197,18 +207,6 @@ public final class HotwordDetectedResult implements Parcelable { return mConfidenceLevel; } - /** - * A {@code MediaSyncEvent} that allows the {@link HotwordDetector} to recapture the audio - * that contains the hotword trigger. This must be obtained using - * {@link android.media.AudioRecord#shareAudioHistory(String, long)}. - *

- * This can be {@code null} if reprocessing the hotword trigger isn't required. - */ - @DataClass.Generated.Member - public @Nullable MediaSyncEvent getMediaSyncEvent() { - return mMediaSyncEvent; - } - /** * Byte offset in the audio stream when the trigger event happened. */ @@ -425,8 +423,6 @@ public final class HotwordDetectedResult implements Parcelable { * A {@code MediaSyncEvent} that allows the {@link HotwordDetector} to recapture the audio * that contains the hotword trigger. This must be obtained using * {@link android.media.AudioRecord#shareAudioHistory(String, long)}. - *

- * This can be {@code null} if reprocessing the hotword trigger isn't required. */ @DataClass.Generated.Member public @NonNull Builder setMediaSyncEvent(@NonNull MediaSyncEvent value) { @@ -555,10 +551,10 @@ public final class HotwordDetectedResult implements Parcelable { } @DataClass.Generated( - time = 1619059352684L, + time = 1620133603958L, codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/service/voice/HotwordDetectedResult.java", - inputSignatures = "public static final int BYTE_OFFSET_UNSET\nprivate final @android.service.voice.HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel\nprivate @android.annotation.Nullable android.media.MediaSyncEvent mMediaSyncEvent\nprivate final int mByteOffset\nprivate final int mScore\nprivate final int mPersonalizedScore\nprivate final int mHotwordPhraseId\nprivate final @android.annotation.NonNull android.os.PersistableBundle mExtras\nprivate static int defaultConfidenceLevel()\nprivate static int defaultByteOffset()\nprivate static int defaultScore()\nprivate static int defaultPersonalizedScore()\npublic static int getMaxScore()\nprivate static int defaultHotwordPhraseId()\npublic static int getMaxHotwordPhraseId()\nprivate static android.os.PersistableBundle defaultExtras()\npublic static int getMaxBundleSize()\nclass HotwordDetectedResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)") + inputSignatures = "public static final int BYTE_OFFSET_UNSET\nprivate final @android.service.voice.HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel\nprivate @android.annotation.Nullable android.media.MediaSyncEvent mMediaSyncEvent\nprivate final int mByteOffset\nprivate final int mScore\nprivate final int mPersonalizedScore\nprivate final int mHotwordPhraseId\nprivate final @android.annotation.NonNull android.os.PersistableBundle mExtras\nprivate static int defaultConfidenceLevel()\nprivate static int defaultByteOffset()\nprivate static int defaultScore()\nprivate static int defaultPersonalizedScore()\npublic static int getMaxScore()\nprivate static int defaultHotwordPhraseId()\npublic static int getMaxHotwordPhraseId()\nprivate static android.os.PersistableBundle defaultExtras()\npublic static int getMaxBundleSize()\npublic @android.annotation.Nullable android.media.MediaSyncEvent getMediaSyncEvent()\nclass HotwordDetectedResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)") @Deprecated private void __metadata() {}