From 966917e51304a04f963b29203335ab683cf74f18 Mon Sep 17 00:00:00 2001 From: Sergey Volnov Date: Fri, 21 May 2021 00:14:29 +0100 Subject: [PATCH] Adjust HotwordDetectedResult with up-to-date information. Asked for API exception in b/168305377#comment49. Bug: 168305377 CTS-Coverage-Bug: 183425641 Test: atest CtsVoiceInteractionTestCases Change-Id: I50c39c430950f21950210feffc287203b49780c6 --- core/api/system-current.txt | 28 +- .../service/voice/HotwordDetectedResult.java | 288 +++++++++++++++--- .../service/voice/HotwordDetector.java | 23 -- .../service/voice/HotwordRejectedResult.java | 74 ++++- 4 files changed, 323 insertions(+), 90 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 143d674bc029c..d56d95502c83d 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10517,9 +10517,11 @@ package android.service.voice { public final class HotwordDetectedResult implements android.os.Parcelable { method public int describeContents(); - method public int getByteOffset(); + method public int getAudioChannel(); method public int getConfidenceLevel(); method @NonNull public android.os.PersistableBundle getExtras(); + method public int getHotwordDurationMillis(); + method public int getHotwordOffsetMillis(); method public int getHotwordPhraseId(); method public static int getMaxBundleSize(); method public static int getMaxHotwordPhraseId(); @@ -10527,19 +10529,31 @@ package android.service.voice { method @Nullable public android.media.MediaSyncEvent getMediaSyncEvent(); method public int getPersonalizedScore(); method public int getScore(); + method public boolean isPersonalizedHotwordDetection(); method public void writeToParcel(@NonNull android.os.Parcel, int); - field public static final int BYTE_OFFSET_UNSET = -1; // 0xffffffff + field public static final int AUDIO_CHANNEL_UNSET = -1; // 0xffffffff + field public static final int CONFIDENCE_LEVEL_HIGH = 5; // 0x5 + field public static final int CONFIDENCE_LEVEL_LOW = 1; // 0x1 + field public static final int CONFIDENCE_LEVEL_LOW_MEDIUM = 2; // 0x2 + field public static final int CONFIDENCE_LEVEL_MEDIUM = 3; // 0x3 + field public static final int CONFIDENCE_LEVEL_MEDIUM_HIGH = 4; // 0x4 + field public static final int CONFIDENCE_LEVEL_NONE = 0; // 0x0 + field public static final int CONFIDENCE_LEVEL_VERY_HIGH = 6; // 0x6 field @NonNull public static final android.os.Parcelable.Creator CREATOR; + field public static final int HOTWORD_OFFSET_UNSET = -1; // 0xffffffff } public static final class HotwordDetectedResult.Builder { ctor public HotwordDetectedResult.Builder(); method @NonNull public android.service.voice.HotwordDetectedResult build(); - method @NonNull public android.service.voice.HotwordDetectedResult.Builder setByteOffset(int); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setAudioChannel(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setConfidenceLevel(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setExtras(@NonNull android.os.PersistableBundle); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setHotwordDurationMillis(int); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setHotwordOffsetMillis(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setHotwordPhraseId(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setMediaSyncEvent(@NonNull android.media.MediaSyncEvent); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setPersonalizedHotwordDetection(boolean); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setPersonalizedScore(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setScore(int); } @@ -10569,10 +10583,6 @@ package android.service.voice { method public boolean startRecognition(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle); method public boolean stopRecognition(); method public void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory); - field public static final int CONFIDENCE_LEVEL_HIGH = 3; // 0x3 - field public static final int CONFIDENCE_LEVEL_LOW = 1; // 0x1 - field public static final int CONFIDENCE_LEVEL_MEDIUM = 2; // 0x2 - field public static final int CONFIDENCE_LEVEL_NONE = 0; // 0x0 } public static interface HotwordDetector.Callback { @@ -10589,6 +10599,10 @@ package android.service.voice { method public int describeContents(); method public int getConfidenceLevel(); method public void writeToParcel(@NonNull android.os.Parcel, int); + field public static final int CONFIDENCE_LEVEL_HIGH = 3; // 0x3 + field public static final int CONFIDENCE_LEVEL_LOW = 1; // 0x1 + field public static final int CONFIDENCE_LEVEL_MEDIUM = 2; // 0x2 + field public static final int CONFIDENCE_LEVEL_NONE = 0; // 0x0 field @NonNull public static final android.os.Parcelable.Creator CREATOR; } diff --git a/core/java/android/service/voice/HotwordDetectedResult.java b/core/java/android/service/voice/HotwordDetectedResult.java index ee82c374691b9..95e43f3cbb598 100644 --- a/core/java/android/service/voice/HotwordDetectedResult.java +++ b/core/java/android/service/voice/HotwordDetectedResult.java @@ -16,8 +16,7 @@ package android.service.voice; -import static android.service.voice.HotwordDetector.CONFIDENCE_LEVEL_NONE; - +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -43,11 +42,48 @@ import com.android.internal.util.DataClass; @SystemApi public final class HotwordDetectedResult implements Parcelable { - /** Represents unset value for byte offset. */ - public static final int BYTE_OFFSET_UNSET = -1; + /** No confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_NONE = 0; + + /** Low confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_LOW = 1; + + /** Low-to-medium confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_LOW_MEDIUM = 2; + + /** Medium confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_MEDIUM = 3; + + /** Medium-to-high confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_MEDIUM_HIGH = 4; + + /** High confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_HIGH = 5; + + /** Very high confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_VERY_HIGH = 6; + + /** @hide */ + @IntDef(prefix = {"CONFIDENCE_LEVEL_"}, value = { + CONFIDENCE_LEVEL_NONE, + CONFIDENCE_LEVEL_LOW, + CONFIDENCE_LEVEL_LOW_MEDIUM, + CONFIDENCE_LEVEL_MEDIUM, + CONFIDENCE_LEVEL_MEDIUM_HIGH, + CONFIDENCE_LEVEL_HIGH, + CONFIDENCE_LEVEL_VERY_HIGH + }) + @interface HotwordConfidenceLevelValue { + } + + /** Represents unset value for the hotword offset. */ + public static final int HOTWORD_OFFSET_UNSET = -1; + + /** Represents unset value for the triggered audio channel. */ + public static final int AUDIO_CHANNEL_UNSET = -1; /** Confidence level in the trigger outcome. */ - @HotwordDetector.HotwordConfidenceLevelValue + @HotwordConfidenceLevelValue private final int mConfidenceLevel; private static int defaultConfidenceLevel() { return CONFIDENCE_LEVEL_NONE; @@ -62,12 +98,27 @@ public final class HotwordDetectedResult implements Parcelable { private MediaSyncEvent mMediaSyncEvent = null; /** - * Byte offset in the audio stream when the trigger event happened. + * Offset in milliseconds the audio stream when the trigger event happened (end of hotword + * phrase). */ - private final int mByteOffset; - private static int defaultByteOffset() { - return BYTE_OFFSET_UNSET; - } + private int mHotwordOffsetMillis = HOTWORD_OFFSET_UNSET; + + /** + * Duration in milliseconds of the hotword trigger phrase. + * + *

Only values between 0 and {@link android.media.AudioRecord#getMaxSharedAudioHistoryMillis} + * (inclusive) are accepted. + */ + private int mHotwordDurationMillis = 0; + + /** Audio channel containing the highest-confidence hotword signal. **/ + private int mAudioChannel = AUDIO_CHANNEL_UNSET; + + /** + * Returns whether the trigger has happened due to model having been personalized to fit user's + * voice. + */ + private boolean mPersonalizedHotwordDetection = false; /** * Score for the hotword trigger. @@ -162,6 +213,7 @@ public final class HotwordDetectedResult implements Parcelable { } + // Code below generated by codegen v1.0.23. // // DO NOT MODIFY! @@ -175,20 +227,62 @@ public final class HotwordDetectedResult implements Parcelable { //@formatter:off + /** @hide */ + @IntDef(prefix = "CONFIDENCE_LEVEL_", value = { + CONFIDENCE_LEVEL_NONE, + CONFIDENCE_LEVEL_LOW, + CONFIDENCE_LEVEL_LOW_MEDIUM, + CONFIDENCE_LEVEL_MEDIUM, + CONFIDENCE_LEVEL_MEDIUM_HIGH, + CONFIDENCE_LEVEL_HIGH, + CONFIDENCE_LEVEL_VERY_HIGH + }) + @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) + @DataClass.Generated.Member + public @interface ConfidenceLevel {} + + /** @hide */ + @DataClass.Generated.Member + public static String confidenceLevelToString(@ConfidenceLevel int value) { + switch (value) { + case CONFIDENCE_LEVEL_NONE: + return "CONFIDENCE_LEVEL_NONE"; + case CONFIDENCE_LEVEL_LOW: + return "CONFIDENCE_LEVEL_LOW"; + case CONFIDENCE_LEVEL_LOW_MEDIUM: + return "CONFIDENCE_LEVEL_LOW_MEDIUM"; + case CONFIDENCE_LEVEL_MEDIUM: + return "CONFIDENCE_LEVEL_MEDIUM"; + case CONFIDENCE_LEVEL_MEDIUM_HIGH: + return "CONFIDENCE_LEVEL_MEDIUM_HIGH"; + case CONFIDENCE_LEVEL_HIGH: + return "CONFIDENCE_LEVEL_HIGH"; + case CONFIDENCE_LEVEL_VERY_HIGH: + return "CONFIDENCE_LEVEL_VERY_HIGH"; + default: return Integer.toHexString(value); + } + } + @DataClass.Generated.Member /* package-private */ HotwordDetectedResult( - @HotwordDetector.HotwordConfidenceLevelValue int confidenceLevel, + @HotwordConfidenceLevelValue int confidenceLevel, @Nullable MediaSyncEvent mediaSyncEvent, - int byteOffset, + int hotwordOffsetMillis, + int hotwordDurationMillis, + int audioChannel, + boolean personalizedHotwordDetection, int score, int personalizedScore, int hotwordPhraseId, @NonNull PersistableBundle extras) { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( - HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); + HotwordConfidenceLevelValue.class, null, mConfidenceLevel); this.mMediaSyncEvent = mediaSyncEvent; - this.mByteOffset = byteOffset; + this.mHotwordOffsetMillis = hotwordOffsetMillis; + this.mHotwordDurationMillis = hotwordDurationMillis; + this.mAudioChannel = audioChannel; + this.mPersonalizedHotwordDetection = personalizedHotwordDetection; this.mScore = score; this.mPersonalizedScore = personalizedScore; this.mHotwordPhraseId = hotwordPhraseId; @@ -203,16 +297,45 @@ public final class HotwordDetectedResult implements Parcelable { * Confidence level in the trigger outcome. */ @DataClass.Generated.Member - public @HotwordDetector.HotwordConfidenceLevelValue int getConfidenceLevel() { + public @HotwordConfidenceLevelValue int getConfidenceLevel() { return mConfidenceLevel; } /** - * Byte offset in the audio stream when the trigger event happened. + * Offset in milliseconds the audio stream when the trigger event happened (end of hotword + * phrase). */ @DataClass.Generated.Member - public int getByteOffset() { - return mByteOffset; + public int getHotwordOffsetMillis() { + return mHotwordOffsetMillis; + } + + /** + * Duration in milliseconds of the hotword trigger phrase. + * + *

Only values between 0 and {@link android.media.AudioRecord#getMaxSharedAudioHistoryMillis} + * (inclusive) are accepted. + */ + @DataClass.Generated.Member + public int getHotwordDurationMillis() { + return mHotwordDurationMillis; + } + + /** + * Audio channel containing the highest-confidence hotword signal. * + */ + @DataClass.Generated.Member + public int getAudioChannel() { + return mAudioChannel; + } + + /** + * Returns whether the trigger has happened due to model having been personalized to fit user's + * voice. + */ + @DataClass.Generated.Member + public boolean isPersonalizedHotwordDetection() { + return mPersonalizedHotwordDetection; } /** @@ -274,7 +397,10 @@ public final class HotwordDetectedResult implements Parcelable { return "HotwordDetectedResult { " + "confidenceLevel = " + mConfidenceLevel + ", " + "mediaSyncEvent = " + mMediaSyncEvent + ", " + - "byteOffset = " + mByteOffset + ", " + + "hotwordOffsetMillis = " + mHotwordOffsetMillis + ", " + + "hotwordDurationMillis = " + mHotwordDurationMillis + ", " + + "audioChannel = " + mAudioChannel + ", " + + "personalizedHotwordDetection = " + mPersonalizedHotwordDetection + ", " + "score = " + mScore + ", " + "personalizedScore = " + mPersonalizedScore + ", " + "hotwordPhraseId = " + mHotwordPhraseId + ", " + @@ -297,7 +423,10 @@ public final class HotwordDetectedResult implements Parcelable { return true && mConfidenceLevel == that.mConfidenceLevel && java.util.Objects.equals(mMediaSyncEvent, that.mMediaSyncEvent) - && mByteOffset == that.mByteOffset + && mHotwordOffsetMillis == that.mHotwordOffsetMillis + && mHotwordDurationMillis == that.mHotwordDurationMillis + && mAudioChannel == that.mAudioChannel + && mPersonalizedHotwordDetection == that.mPersonalizedHotwordDetection && mScore == that.mScore && mPersonalizedScore == that.mPersonalizedScore && mHotwordPhraseId == that.mHotwordPhraseId @@ -313,7 +442,10 @@ public final class HotwordDetectedResult implements Parcelable { int _hash = 1; _hash = 31 * _hash + mConfidenceLevel; _hash = 31 * _hash + java.util.Objects.hashCode(mMediaSyncEvent); - _hash = 31 * _hash + mByteOffset; + _hash = 31 * _hash + mHotwordOffsetMillis; + _hash = 31 * _hash + mHotwordDurationMillis; + _hash = 31 * _hash + mAudioChannel; + _hash = 31 * _hash + Boolean.hashCode(mPersonalizedHotwordDetection); _hash = 31 * _hash + mScore; _hash = 31 * _hash + mPersonalizedScore; _hash = 31 * _hash + mHotwordPhraseId; @@ -327,12 +459,15 @@ public final class HotwordDetectedResult implements Parcelable { // You can override field parcelling by defining methods like: // void parcelFieldName(Parcel dest, int flags) { ... } - byte flg = 0; + int flg = 0; + if (mPersonalizedHotwordDetection) flg |= 0x20; if (mMediaSyncEvent != null) flg |= 0x2; - dest.writeByte(flg); + dest.writeInt(flg); dest.writeInt(mConfidenceLevel); if (mMediaSyncEvent != null) dest.writeTypedObject(mMediaSyncEvent, flags); - dest.writeInt(mByteOffset); + dest.writeInt(mHotwordOffsetMillis); + dest.writeInt(mHotwordDurationMillis); + dest.writeInt(mAudioChannel); dest.writeInt(mScore); dest.writeInt(mPersonalizedScore); dest.writeInt(mHotwordPhraseId); @@ -350,10 +485,13 @@ public final class HotwordDetectedResult implements Parcelable { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } - byte flg = in.readByte(); + int flg = in.readInt(); + boolean personalizedHotwordDetection = (flg & 0x20) != 0; int confidenceLevel = in.readInt(); MediaSyncEvent mediaSyncEvent = (flg & 0x2) == 0 ? null : (MediaSyncEvent) in.readTypedObject(MediaSyncEvent.CREATOR); - int byteOffset = in.readInt(); + int hotwordOffsetMillis = in.readInt(); + int hotwordDurationMillis = in.readInt(); + int audioChannel = in.readInt(); int score = in.readInt(); int personalizedScore = in.readInt(); int hotwordPhraseId = in.readInt(); @@ -361,9 +499,12 @@ public final class HotwordDetectedResult implements Parcelable { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( - HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); + HotwordConfidenceLevelValue.class, null, mConfidenceLevel); this.mMediaSyncEvent = mediaSyncEvent; - this.mByteOffset = byteOffset; + this.mHotwordOffsetMillis = hotwordOffsetMillis; + this.mHotwordDurationMillis = hotwordDurationMillis; + this.mAudioChannel = audioChannel; + this.mPersonalizedHotwordDetection = personalizedHotwordDetection; this.mScore = score; this.mPersonalizedScore = personalizedScore; this.mHotwordPhraseId = hotwordPhraseId; @@ -395,9 +536,12 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public static final class Builder { - private @HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel; + private @HotwordConfidenceLevelValue int mConfidenceLevel; private @Nullable MediaSyncEvent mMediaSyncEvent; - private int mByteOffset; + private int mHotwordOffsetMillis; + private int mHotwordDurationMillis; + private int mAudioChannel; + private boolean mPersonalizedHotwordDetection; private int mScore; private int mPersonalizedScore; private int mHotwordPhraseId; @@ -412,7 +556,7 @@ public final class HotwordDetectedResult implements Parcelable { * Confidence level in the trigger outcome. */ @DataClass.Generated.Member - public @NonNull Builder setConfidenceLevel(@HotwordDetector.HotwordConfidenceLevelValue int value) { + public @NonNull Builder setConfidenceLevel(@HotwordConfidenceLevelValue int value) { checkNotUsed(); mBuilderFieldsSet |= 0x1; mConfidenceLevel = value; @@ -433,13 +577,51 @@ public final class HotwordDetectedResult implements Parcelable { } /** - * Byte offset in the audio stream when the trigger event happened. + * Offset in milliseconds the audio stream when the trigger event happened (end of hotword + * phrase). */ @DataClass.Generated.Member - public @NonNull Builder setByteOffset(int value) { + public @NonNull Builder setHotwordOffsetMillis(int value) { checkNotUsed(); mBuilderFieldsSet |= 0x4; - mByteOffset = value; + mHotwordOffsetMillis = value; + return this; + } + + /** + * Duration in milliseconds of the hotword trigger phrase. + * + *

Only values between 0 and {@link android.media.AudioRecord#getMaxSharedAudioHistoryMillis} + * (inclusive) are accepted. + */ + @DataClass.Generated.Member + public @NonNull Builder setHotwordDurationMillis(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x8; + mHotwordDurationMillis = value; + return this; + } + + /** + * Audio channel containing the highest-confidence hotword signal. * + */ + @DataClass.Generated.Member + public @NonNull Builder setAudioChannel(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x10; + mAudioChannel = value; + return this; + } + + /** + * Returns whether the trigger has happened due to model having been personalized to fit user's + * voice. + */ + @DataClass.Generated.Member + public @NonNull Builder setPersonalizedHotwordDetection(boolean value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x20; + mPersonalizedHotwordDetection = value; return this; } @@ -451,7 +633,7 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public @NonNull Builder setScore(int value) { checkNotUsed(); - mBuilderFieldsSet |= 0x8; + mBuilderFieldsSet |= 0x40; mScore = value; return this; } @@ -464,7 +646,7 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public @NonNull Builder setPersonalizedScore(int value) { checkNotUsed(); - mBuilderFieldsSet |= 0x10; + mBuilderFieldsSet |= 0x80; mPersonalizedScore = value; return this; } @@ -477,7 +659,7 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public @NonNull Builder setHotwordPhraseId(int value) { checkNotUsed(); - mBuilderFieldsSet |= 0x20; + mBuilderFieldsSet |= 0x100; mHotwordPhraseId = value; return this; } @@ -500,7 +682,7 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public @NonNull Builder setExtras(@NonNull PersistableBundle value) { checkNotUsed(); - mBuilderFieldsSet |= 0x40; + mBuilderFieldsSet |= 0x200; mExtras = value; return this; } @@ -508,7 +690,7 @@ public final class HotwordDetectedResult implements Parcelable { /** Builds the instance. This builder should not be touched after calling this! */ public @NonNull HotwordDetectedResult build() { checkNotUsed(); - mBuilderFieldsSet |= 0x80; // Mark builder used + mBuilderFieldsSet |= 0x400; // Mark builder used if ((mBuilderFieldsSet & 0x1) == 0) { mConfidenceLevel = defaultConfidenceLevel(); @@ -517,24 +699,36 @@ public final class HotwordDetectedResult implements Parcelable { mMediaSyncEvent = null; } if ((mBuilderFieldsSet & 0x4) == 0) { - mByteOffset = defaultByteOffset(); + mHotwordOffsetMillis = HOTWORD_OFFSET_UNSET; } if ((mBuilderFieldsSet & 0x8) == 0) { - mScore = defaultScore(); + mHotwordDurationMillis = 0; } if ((mBuilderFieldsSet & 0x10) == 0) { - mPersonalizedScore = defaultPersonalizedScore(); + mAudioChannel = AUDIO_CHANNEL_UNSET; } if ((mBuilderFieldsSet & 0x20) == 0) { - mHotwordPhraseId = defaultHotwordPhraseId(); + mPersonalizedHotwordDetection = false; } if ((mBuilderFieldsSet & 0x40) == 0) { + mScore = defaultScore(); + } + if ((mBuilderFieldsSet & 0x80) == 0) { + mPersonalizedScore = defaultPersonalizedScore(); + } + if ((mBuilderFieldsSet & 0x100) == 0) { + mHotwordPhraseId = defaultHotwordPhraseId(); + } + if ((mBuilderFieldsSet & 0x200) == 0) { mExtras = defaultExtras(); } HotwordDetectedResult o = new HotwordDetectedResult( mConfidenceLevel, mMediaSyncEvent, - mByteOffset, + mHotwordOffsetMillis, + mHotwordDurationMillis, + mAudioChannel, + mPersonalizedHotwordDetection, mScore, mPersonalizedScore, mHotwordPhraseId, @@ -543,7 +737,7 @@ public final class HotwordDetectedResult implements Parcelable { } private void checkNotUsed() { - if ((mBuilderFieldsSet & 0x80) != 0) { + if ((mBuilderFieldsSet & 0x400) != 0) { throw new IllegalStateException( "This Builder should not be reused. Use a new Builder instance instead"); } @@ -551,10 +745,10 @@ public final class HotwordDetectedResult implements Parcelable { } @DataClass.Generated( - time = 1620133603958L, + time = 1621631039729L, 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()\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)") + inputSignatures = "public static final int CONFIDENCE_LEVEL_NONE\npublic static final int CONFIDENCE_LEVEL_LOW\npublic static final int CONFIDENCE_LEVEL_LOW_MEDIUM\npublic static final int CONFIDENCE_LEVEL_MEDIUM\npublic static final int CONFIDENCE_LEVEL_MEDIUM_HIGH\npublic static final int CONFIDENCE_LEVEL_HIGH\npublic static final int CONFIDENCE_LEVEL_VERY_HIGH\npublic static final int HOTWORD_OFFSET_UNSET\npublic static final int AUDIO_CHANNEL_UNSET\nprivate final @android.service.voice.HotwordDetectedResult.HotwordConfidenceLevelValue int mConfidenceLevel\nprivate @android.annotation.Nullable android.media.MediaSyncEvent mMediaSyncEvent\nprivate int mHotwordOffsetMillis\nprivate int mHotwordDurationMillis\nprivate int mAudioChannel\nprivate boolean mPersonalizedHotwordDetection\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 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() {} diff --git a/core/java/android/service/voice/HotwordDetector.java b/core/java/android/service/voice/HotwordDetector.java index b2f810aac09e8..e2478195bdde6 100644 --- a/core/java/android/service/voice/HotwordDetector.java +++ b/core/java/android/service/voice/HotwordDetector.java @@ -19,7 +19,6 @@ package android.service.voice; import static android.Manifest.permission.CAPTURE_AUDIO_HOTWORD; import static android.Manifest.permission.RECORD_AUDIO; -import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; @@ -37,28 +36,6 @@ import android.os.SharedMemory; @SystemApi public interface HotwordDetector { - /** No confidence in hotword detector result. */ - int CONFIDENCE_LEVEL_NONE = 0; - - /** Small confidence in hotword detector result. */ - int CONFIDENCE_LEVEL_LOW = 1; - - /** Medium confidence in hotword detector result. */ - int CONFIDENCE_LEVEL_MEDIUM = 2; - - /** High confidence in hotword detector result. */ - int CONFIDENCE_LEVEL_HIGH = 3; - - /** @hide */ - @IntDef(prefix = {"CONFIDENCE_LEVEL_"}, value = { - CONFIDENCE_LEVEL_NONE, - CONFIDENCE_LEVEL_LOW, - CONFIDENCE_LEVEL_MEDIUM, - CONFIDENCE_LEVEL_HIGH - }) - @interface HotwordConfidenceLevelValue { - } - /** * Starts hotword recognition. *

diff --git a/core/java/android/service/voice/HotwordRejectedResult.java b/core/java/android/service/voice/HotwordRejectedResult.java index 5d85662e38056..78664f6040938 100644 --- a/core/java/android/service/voice/HotwordRejectedResult.java +++ b/core/java/android/service/voice/HotwordRejectedResult.java @@ -16,8 +16,7 @@ package android.service.voice; -import static android.service.voice.HotwordDetector.CONFIDENCE_LEVEL_NONE; - +import android.annotation.IntDef; import android.annotation.SystemApi; import android.os.Parcelable; @@ -39,8 +38,30 @@ import com.android.internal.util.DataClass; @SystemApi public final class HotwordRejectedResult implements Parcelable { + /** No confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_NONE = 0; + + /** Small confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_LOW = 1; + + /** Medium confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_MEDIUM = 2; + + /** High confidence in hotword detector result. */ + public static final int CONFIDENCE_LEVEL_HIGH = 3; + + /** @hide */ + @IntDef(prefix = {"CONFIDENCE_LEVEL_"}, value = { + CONFIDENCE_LEVEL_NONE, + CONFIDENCE_LEVEL_LOW, + CONFIDENCE_LEVEL_MEDIUM, + CONFIDENCE_LEVEL_HIGH + }) + @interface HotwordConfidenceLevelValue { + } + /** Confidence level in the trigger outcome. */ - @HotwordDetector.HotwordConfidenceLevelValue + @HotwordConfidenceLevelValue private final int mConfidenceLevel; private static int defaultConfidenceLevel() { return CONFIDENCE_LEVEL_NONE; @@ -48,7 +69,7 @@ public final class HotwordRejectedResult implements Parcelable { - // Code below generated by codegen v1.0.22. + // Code below generated by codegen v1.0.23. // // DO NOT MODIFY! // CHECKSTYLE:OFF Generated code @@ -61,12 +82,39 @@ public final class HotwordRejectedResult implements Parcelable { //@formatter:off + /** @hide */ + @IntDef(prefix = "CONFIDENCE_LEVEL_", value = { + CONFIDENCE_LEVEL_NONE, + CONFIDENCE_LEVEL_LOW, + CONFIDENCE_LEVEL_MEDIUM, + CONFIDENCE_LEVEL_HIGH + }) + @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) + @DataClass.Generated.Member + public @interface ConfidenceLevel {} + + /** @hide */ + @DataClass.Generated.Member + public static String confidenceLevelToString(@ConfidenceLevel int value) { + switch (value) { + case CONFIDENCE_LEVEL_NONE: + return "CONFIDENCE_LEVEL_NONE"; + case CONFIDENCE_LEVEL_LOW: + return "CONFIDENCE_LEVEL_LOW"; + case CONFIDENCE_LEVEL_MEDIUM: + return "CONFIDENCE_LEVEL_MEDIUM"; + case CONFIDENCE_LEVEL_HIGH: + return "CONFIDENCE_LEVEL_HIGH"; + default: return Integer.toHexString(value); + } + } + @DataClass.Generated.Member /* package-private */ HotwordRejectedResult( - @HotwordDetector.HotwordConfidenceLevelValue int confidenceLevel) { + @HotwordConfidenceLevelValue int confidenceLevel) { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( - HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); + HotwordConfidenceLevelValue.class, null, mConfidenceLevel); // onConstructed(); // You can define this method to get a callback } @@ -75,7 +123,7 @@ public final class HotwordRejectedResult implements Parcelable { * Confidence level in the trigger outcome. */ @DataClass.Generated.Member - public @HotwordDetector.HotwordConfidenceLevelValue int getConfidenceLevel() { + public @HotwordConfidenceLevelValue int getConfidenceLevel() { return mConfidenceLevel; } @@ -141,7 +189,7 @@ public final class HotwordRejectedResult implements Parcelable { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( - HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); + HotwordConfidenceLevelValue.class, null, mConfidenceLevel); // onConstructed(); // You can define this method to get a callback } @@ -168,7 +216,7 @@ public final class HotwordRejectedResult implements Parcelable { @DataClass.Generated.Member public static final class Builder { - private @HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel; + private @HotwordConfidenceLevelValue int mConfidenceLevel; private long mBuilderFieldsSet = 0L; @@ -179,7 +227,7 @@ public final class HotwordRejectedResult implements Parcelable { * Confidence level in the trigger outcome. */ @DataClass.Generated.Member - public @android.annotation.NonNull Builder setConfidenceLevel(@HotwordDetector.HotwordConfidenceLevelValue int value) { + public @android.annotation.NonNull Builder setConfidenceLevel(@HotwordConfidenceLevelValue int value) { checkNotUsed(); mBuilderFieldsSet |= 0x1; mConfidenceLevel = value; @@ -208,10 +256,10 @@ public final class HotwordRejectedResult implements Parcelable { } @DataClass.Generated( - time = 1616108967315L, - codegenVersion = "1.0.22", + time = 1621551683210L, + codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/service/voice/HotwordRejectedResult.java", - inputSignatures = "private final @android.service.voice.HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel\nprivate static int defaultConfidenceLevel()\nclass HotwordRejectedResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genHiddenBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)") + inputSignatures = "public static final int CONFIDENCE_LEVEL_NONE\npublic static final int CONFIDENCE_LEVEL_LOW\npublic static final int CONFIDENCE_LEVEL_MEDIUM\npublic static final int CONFIDENCE_LEVEL_HIGH\nprivate final @android.service.voice.HotwordRejectedResult.HotwordConfidenceLevelValue int mConfidenceLevel\nprivate static int defaultConfidenceLevel()\nclass HotwordRejectedResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genHiddenBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)") @Deprecated private void __metadata() {}