diff options
| author | 2023-02-16 22:00:03 +0000 | |
|---|---|---|
| committer | 2023-02-21 18:54:11 +0000 | |
| commit | 6fd682046109a73527668510e875f81398d6f97f (patch) | |
| tree | a87bde36652245d12968f109f3cfa52ffc4c70e3 | |
| parent | 203679cd8263b20cc08c141240953741e6cc1b43 (diff) | |
add DetectedPhrase API
HotwordDetectedResult.getHotwordPhraseId is migrated to
DetectedPhrase.
New API getPhrase added to HotwordDetectedPhrase.
Bug: 265083046
Test: atest CtsVoiceInteractionHostTestCases
Test: atest CtsVoiceInteractionTestCases
Change-Id: I89ce0c01615bf85d520f14d632c07b5a8fc9a137
| -rw-r--r-- | core/api/system-current.txt | 23 | ||||
| -rw-r--r-- | core/java/android/service/voice/DetectedPhrase.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/service/voice/DetectedPhrase.java | 286 | ||||
| -rw-r--r-- | core/java/android/service/voice/HotwordDetectedResult.java | 129 |
4 files changed, 398 insertions, 59 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index e6d636155dcd..c14de7029a16 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -13040,6 +13040,21 @@ package android.service.voice { method public int getStart(); } + public final class DetectedPhrase implements android.os.Parcelable { + method public int describeContents(); + method public int getId(); + method @Nullable public String getPhrase(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.DetectedPhrase> CREATOR; + } + + public static final class DetectedPhrase.Builder { + ctor public DetectedPhrase.Builder(); + method @NonNull public android.service.voice.DetectedPhrase build(); + method @NonNull public android.service.voice.DetectedPhrase.Builder setId(int); + method @NonNull public android.service.voice.DetectedPhrase.Builder setPhrase(@NonNull String); + } + public abstract class DetectorFailure implements android.os.Parcelable { method public int describeContents(); method @NonNull public String getErrorMessage(); @@ -13080,12 +13095,13 @@ package android.service.voice { method public int getAudioChannel(); method @NonNull public java.util.List<android.service.voice.HotwordAudioStream> getAudioStreams(); method public int getConfidenceLevel(); + method @NonNull public android.service.voice.DetectedPhrase getDetectedPhrase(); method @NonNull public android.os.PersistableBundle getExtras(); method public int getHotwordDurationMillis(); method public int getHotwordOffsetMillis(); - method public int getHotwordPhraseId(); + method @Deprecated public int getHotwordPhraseId(); method public static int getMaxBundleSize(); - method public static int getMaxHotwordPhraseId(); + method @Deprecated public static int getMaxHotwordPhraseId(); method public static int getMaxScore(); method @Nullable public android.media.MediaSyncEvent getMediaSyncEvent(); method public int getPersonalizedScore(); @@ -13114,11 +13130,12 @@ package android.service.voice { method @NonNull public android.service.voice.HotwordDetectedResult.Builder setAudioChannel(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setAudioStreams(@NonNull java.util.List<android.service.voice.HotwordAudioStream>); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setConfidenceLevel(int); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setDetectedPhrase(@NonNull android.service.voice.DetectedPhrase); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setExtras(@NonNull android.os.PersistableBundle); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setHotwordDetectionPersonalized(boolean); 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 @Deprecated @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 setPersonalizedScore(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setScore(int); diff --git a/core/java/android/service/voice/DetectedPhrase.aidl b/core/java/android/service/voice/DetectedPhrase.aidl new file mode 100644 index 000000000000..23a405d51ed9 --- /dev/null +++ b/core/java/android/service/voice/DetectedPhrase.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.service.voice; + +parcelable DetectedPhrase; diff --git a/core/java/android/service/voice/DetectedPhrase.java b/core/java/android/service/voice/DetectedPhrase.java new file mode 100644 index 000000000000..bd906125f59d --- /dev/null +++ b/core/java/android/service/voice/DetectedPhrase.java @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.service.voice; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.SystemApi; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; +import com.android.internal.util.Preconditions; + +/** + * Details about the phrase used to generate a {@link HotwordDetectedResult} + * + * @hide + */ +@DataClass( + genConstructor = false, + genBuilder = true, + genEqualsHashCode = true, + genHiddenConstDefs = true, + genParcelable = true, + genToString = true +) +@SystemApi +public final class DetectedPhrase implements Parcelable { + + /** + * An ID representing the keyphrase that triggered the successful detection. + */ + private int mId = 0; + + static int defaultHotwordPhraseId() { + return 0; + } + + /** + * A string representing exactly what was heard and interpreted by the service leading to + * a successful detection. + * + * <p>Can be null if not set in {@link DetectedPhrase.Builder} + */ + @Nullable + private String mPhrase = null; + + /** + * Provides an instance of {@link DetectedPhrase.Builder} with state corresponding to + * this instance. + * @hide + */ + public DetectedPhrase.Builder buildUpon() { + return new DetectedPhrase.Builder() + .setId(mId) + .setPhrase(mPhrase); + } + + private void onConstructed() { + Preconditions.checkArgumentNonnegative(mId, "hotwordPhraseId"); + } + + + + // Code below generated by codegen v1.0.23. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/voice/DetectedPhrase.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + @DataClass.Generated.Member + /* package-private */ DetectedPhrase( + int id, + @Nullable String phrase) { + this.mId = id; + this.mPhrase = phrase; + + onConstructed(); + } + + /** + * An ID representing the keyphrase that triggered the successful detection. + */ + @DataClass.Generated.Member + public int getId() { + return mId; + } + + /** + * A string representing exactly what was heard and interpreted by the service leading to + * a successful detection. + * + * <p>Can be null if not set in {@link DetectedPhrase.Builder} + */ + @DataClass.Generated.Member + public @Nullable String getPhrase() { + return mPhrase; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "DetectedPhrase { " + + "id = " + mId + ", " + + "phrase = " + mPhrase + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(DetectedPhrase other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + DetectedPhrase that = (DetectedPhrase) o; + //noinspection PointlessBooleanExpression + return true + && mId == that.mId + && java.util.Objects.equals(mPhrase, that.mPhrase); + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + mId; + _hash = 31 * _hash + java.util.Objects.hashCode(mPhrase); + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + byte flg = 0; + if (mPhrase != null) flg |= 0x2; + dest.writeByte(flg); + dest.writeInt(mId); + if (mPhrase != null) dest.writeString(mPhrase); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ DetectedPhrase(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + byte flg = in.readByte(); + int id = in.readInt(); + String phrase = (flg & 0x2) == 0 ? null : in.readString(); + + this.mId = id; + this.mPhrase = phrase; + + onConstructed(); + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<DetectedPhrase> CREATOR + = new Parcelable.Creator<DetectedPhrase>() { + @Override + public DetectedPhrase[] newArray(int size) { + return new DetectedPhrase[size]; + } + + @Override + public DetectedPhrase createFromParcel(@NonNull android.os.Parcel in) { + return new DetectedPhrase(in); + } + }; + + /** + * A builder for {@link DetectedPhrase} + */ + @SuppressWarnings("WeakerAccess") + @DataClass.Generated.Member + public static final class Builder { + + private int mId; + private @Nullable String mPhrase; + + private long mBuilderFieldsSet = 0L; + + public Builder() { + } + + /** + * An ID representing the keyphrase that triggered the successful detection. + */ + @DataClass.Generated.Member + public @NonNull Builder setId(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x1; + mId = value; + return this; + } + + /** + * A string representing exactly what was heard and interpreted by the service leading to + * a successful detection. + * + * <p>Can be null if not set in {@link DetectedPhrase.Builder} + */ + @DataClass.Generated.Member + public @NonNull Builder setPhrase(@NonNull String value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x2; + mPhrase = value; + return this; + } + + /** Builds the instance. This builder should not be touched after calling this! */ + public @NonNull DetectedPhrase build() { + checkNotUsed(); + mBuilderFieldsSet |= 0x4; // Mark builder used + + if ((mBuilderFieldsSet & 0x1) == 0) { + mId = 0; + } + if ((mBuilderFieldsSet & 0x2) == 0) { + mPhrase = null; + } + DetectedPhrase o = new DetectedPhrase( + mId, + mPhrase); + return o; + } + + private void checkNotUsed() { + if ((mBuilderFieldsSet & 0x4) != 0) { + throw new IllegalStateException( + "This Builder should not be reused. Use a new Builder instance instead"); + } + } + } + + @DataClass.Generated( + time = 1676870329959L, + codegenVersion = "1.0.23", + sourceFile = "frameworks/base/core/java/android/service/voice/DetectedPhrase.java", + inputSignatures = "private int mId\nprivate @android.annotation.Nullable java.lang.String mPhrase\nstatic int defaultHotwordPhraseId()\npublic android.service.voice.DetectedPhrase.Builder buildUpon()\nprivate void onConstructed()\nclass DetectedPhrase 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() {} + + + //@formatter:on + // End of generated code + +} diff --git a/core/java/android/service/voice/HotwordDetectedResult.java b/core/java/android/service/voice/HotwordDetectedResult.java index dee560b322bb..dd3f99cc27ef 100644 --- a/core/java/android/service/voice/HotwordDetectedResult.java +++ b/core/java/android/service/voice/HotwordDetectedResult.java @@ -203,17 +203,23 @@ public final class HotwordDetectedResult implements Parcelable { * An ID representing the keyphrase that triggered the successful detection. * * <p>Only values between 0 and {@link #getMaxHotwordPhraseId()} (inclusive) are accepted. + * + * @deprecated Use {@link #getDetectedPhrase()} and + * {@link DetectedPhrase#getId()}. */ - private final int mHotwordPhraseId; - private static int defaultHotwordPhraseId() { - return 0; + @Deprecated + public int getHotwordPhraseId() { + return mDetectedPhrase.getId(); } /** * Returns the maximum value of {@link #getHotwordPhraseId()}. + * + * @deprecated There is no maximum phrase ID enforced */ + @Deprecated public static int getMaxHotwordPhraseId() { - return 63; + return Integer.MAX_VALUE; } /** @@ -285,6 +291,10 @@ public final class HotwordDetectedResult implements Parcelable { return mMediaSyncEvent; } + @NonNull + private DetectedPhrase mDetectedPhrase = + new DetectedPhrase.Builder().build(); + /** * Returns how many bytes should be written into the Parcel * @@ -302,6 +312,9 @@ public final class HotwordDetectedResult implements Parcelable { /** * Returns how many bits have been written into the HotwordDetectedResult. * + * <p>{@link #getAudioStreams()} and {@link #getDetectedPhrase()} + * are not counted here. + * * @hide */ public static int getUsageSize(@NonNull HotwordDetectedResult hotwordDetectedResult) { @@ -329,9 +342,6 @@ public final class HotwordDetectedResult implements Parcelable { if (hotwordDetectedResult.getPersonalizedScore() != defaultPersonalizedScore()) { totalBits += bitCount(HotwordDetectedResult.getMaxScore()); } - if (hotwordDetectedResult.getHotwordPhraseId() != defaultHotwordPhraseId()) { - totalBits += bitCount(HotwordDetectedResult.getMaxHotwordPhraseId()); - } PersistableBundle persistableBundle = hotwordDetectedResult.getExtras(); if (!persistableBundle.isEmpty()) { totalBits += getParcelableSize(persistableBundle) * Byte.SIZE; @@ -339,7 +349,7 @@ public final class HotwordDetectedResult implements Parcelable { return totalBits; } - private static int bitCount(long value) { + static int bitCount(long value) { int bits = 0; while (value > 0) { bits++; @@ -352,8 +362,6 @@ public final class HotwordDetectedResult implements Parcelable { Preconditions.checkArgumentInRange(mScore, 0, getMaxScore(), "score"); Preconditions.checkArgumentInRange(mPersonalizedScore, 0, getMaxScore(), "personalizedScore"); - Preconditions.checkArgumentInRange(mHotwordPhraseId, 0, getMaxHotwordPhraseId(), - "hotwordPhraseId"); Preconditions.checkArgumentInRange((long) mHotwordDurationMillis, 0, AudioRecord.getMaxSharedAudioHistoryMillis(), "hotwordDurationMillis"); if (mHotwordOffsetMillis != HOTWORD_OFFSET_UNSET) { @@ -448,10 +456,25 @@ public final class HotwordDetectedResult implements Parcelable { Objects.requireNonNull(value, "value should not be null"); final Builder builder = (Builder) this; // If the code gen flag in build() is changed, we must update the flag e.g. 0x200 here. - builder.mBuilderFieldsSet |= 0x200; + builder.mBuilderFieldsSet |= 0x100; builder.mAudioStreams = List.copyOf(value); return builder; } + + /** + * An ID representing the keyphrase that triggered the successful detection. + * + * <p>Only values between 0 and {@link #getMaxHotwordPhraseId()} (inclusive) are accepted. + * + * @deprecated Use {@link HotwordDetectedResult.Builder#setDetectedPhrase(DetectedPhrase)} + * and {@link DetectedPhrase.Builder#setId(int)} + */ + @Deprecated + public @NonNull Builder setHotwordPhraseId(int value) { + final Builder builder = (Builder) this; + builder.setDetectedPhrase(new DetectedPhrase.Builder().setId(value).build()); + return builder; + } } /** @@ -468,9 +491,9 @@ public final class HotwordDetectedResult implements Parcelable { .setHotwordDetectionPersonalized(mHotwordDetectionPersonalized) .setScore(mScore) .setPersonalizedScore(mPersonalizedScore) - .setHotwordPhraseId(mHotwordPhraseId) .setAudioStreams(mAudioStreams) - .setExtras(mExtras); + .setExtras(mExtras) + .setDetectedPhrase(mDetectedPhrase); } @@ -579,9 +602,9 @@ public final class HotwordDetectedResult implements Parcelable { boolean hotwordDetectionPersonalized, int score, int personalizedScore, - int hotwordPhraseId, @NonNull List<HotwordAudioStream> audioStreams, - @NonNull PersistableBundle extras) { + @NonNull PersistableBundle extras, + @NonNull DetectedPhrase detectedPhrase) { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( HotwordConfidenceLevelValue.class, null, mConfidenceLevel); @@ -592,13 +615,15 @@ public final class HotwordDetectedResult implements Parcelable { this.mHotwordDetectionPersonalized = hotwordDetectionPersonalized; this.mScore = score; this.mPersonalizedScore = personalizedScore; - this.mHotwordPhraseId = hotwordPhraseId; this.mAudioStreams = audioStreams; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mAudioStreams); this.mExtras = extras; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mExtras); + this.mDetectedPhrase = detectedPhrase; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mDetectedPhrase); onConstructed(); } @@ -673,16 +698,6 @@ public final class HotwordDetectedResult implements Parcelable { } /** - * An ID representing the keyphrase that triggered the successful detection. - * - * <p>Only values between 0 and {@link #getMaxHotwordPhraseId()} (inclusive) are accepted. - */ - @DataClass.Generated.Member - public int getHotwordPhraseId() { - return mHotwordPhraseId; - } - - /** * App-specific extras to support trigger. * * <p>The size of this bundle will be limited to {@link #getMaxBundleSize}. Results will larger @@ -712,6 +727,11 @@ public final class HotwordDetectedResult implements Parcelable { return mExtras; } + @DataClass.Generated.Member + public @NonNull DetectedPhrase getDetectedPhrase() { + return mDetectedPhrase; + } + @Override @DataClass.Generated.Member public String toString() { @@ -727,9 +747,9 @@ public final class HotwordDetectedResult implements Parcelable { "hotwordDetectionPersonalized = " + mHotwordDetectionPersonalized + ", " + "score = " + mScore + ", " + "personalizedScore = " + mPersonalizedScore + ", " + - "hotwordPhraseId = " + mHotwordPhraseId + ", " + "audioStreams = " + mAudioStreams + ", " + - "extras = " + mExtras + + "extras = " + mExtras + ", " + + "detectedPhrase = " + mDetectedPhrase + " }"; } @@ -754,9 +774,9 @@ public final class HotwordDetectedResult implements Parcelable { && mHotwordDetectionPersonalized == that.mHotwordDetectionPersonalized && mScore == that.mScore && mPersonalizedScore == that.mPersonalizedScore - && mHotwordPhraseId == that.mHotwordPhraseId && Objects.equals(mAudioStreams, that.mAudioStreams) - && Objects.equals(mExtras, that.mExtras); + && Objects.equals(mExtras, that.mExtras) + && Objects.equals(mDetectedPhrase, that.mDetectedPhrase); } @Override @@ -774,9 +794,9 @@ public final class HotwordDetectedResult implements Parcelable { _hash = 31 * _hash + Boolean.hashCode(mHotwordDetectionPersonalized); _hash = 31 * _hash + mScore; _hash = 31 * _hash + mPersonalizedScore; - _hash = 31 * _hash + mHotwordPhraseId; _hash = 31 * _hash + Objects.hashCode(mAudioStreams); _hash = 31 * _hash + Objects.hashCode(mExtras); + _hash = 31 * _hash + Objects.hashCode(mDetectedPhrase); return _hash; } @@ -797,9 +817,9 @@ public final class HotwordDetectedResult implements Parcelable { dest.writeInt(mAudioChannel); dest.writeInt(mScore); dest.writeInt(mPersonalizedScore); - dest.writeInt(mHotwordPhraseId); dest.writeParcelableList(mAudioStreams, flags); dest.writeTypedObject(mExtras, flags); + dest.writeTypedObject(mDetectedPhrase, flags); } @Override @@ -822,10 +842,10 @@ public final class HotwordDetectedResult implements Parcelable { int audioChannel = in.readInt(); int score = in.readInt(); int personalizedScore = in.readInt(); - int hotwordPhraseId = in.readInt(); List<HotwordAudioStream> audioStreams = new ArrayList<>(); in.readParcelableList(audioStreams, HotwordAudioStream.class.getClassLoader()); PersistableBundle extras = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR); + DetectedPhrase detectedPhrase = (DetectedPhrase) in.readTypedObject(DetectedPhrase.CREATOR); this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( @@ -837,13 +857,15 @@ public final class HotwordDetectedResult implements Parcelable { this.mHotwordDetectionPersonalized = hotwordDetectionPersonalized; this.mScore = score; this.mPersonalizedScore = personalizedScore; - this.mHotwordPhraseId = hotwordPhraseId; this.mAudioStreams = audioStreams; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mAudioStreams); this.mExtras = extras; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mExtras); + this.mDetectedPhrase = detectedPhrase; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mDetectedPhrase); onConstructed(); } @@ -877,9 +899,9 @@ public final class HotwordDetectedResult implements Parcelable { private boolean mHotwordDetectionPersonalized; private int mScore; private int mPersonalizedScore; - private int mHotwordPhraseId; private @NonNull List<HotwordAudioStream> mAudioStreams; private @NonNull PersistableBundle mExtras; + private @NonNull DetectedPhrase mDetectedPhrase; private long mBuilderFieldsSet = 0L; @@ -990,19 +1012,6 @@ public final class HotwordDetectedResult implements Parcelable { } /** - * An ID representing the keyphrase that triggered the successful detection. - * - * <p>Only values between 0 and {@link #getMaxHotwordPhraseId()} (inclusive) are accepted. - */ - @DataClass.Generated.Member - public @NonNull Builder setHotwordPhraseId(int value) { - checkNotUsed(); - mBuilderFieldsSet |= 0x100; - mHotwordPhraseId = value; - return this; - } - - /** * App-specific extras to support trigger. * * <p>The size of this bundle will be limited to {@link #getMaxBundleSize}. Results will larger @@ -1030,11 +1039,19 @@ public final class HotwordDetectedResult implements Parcelable { @DataClass.Generated.Member public @NonNull Builder setExtras(@NonNull PersistableBundle value) { checkNotUsed(); - mBuilderFieldsSet |= 0x400; + mBuilderFieldsSet |= 0x200; mExtras = value; return this; } + @DataClass.Generated.Member + public @NonNull Builder setDetectedPhrase(@NonNull DetectedPhrase value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x400; + mDetectedPhrase = value; + return this; + } + /** Builds the instance. This builder should not be touched after calling this! */ public @NonNull HotwordDetectedResult build() { checkNotUsed(); @@ -1065,13 +1082,13 @@ public final class HotwordDetectedResult implements Parcelable { mPersonalizedScore = defaultPersonalizedScore(); } if ((mBuilderFieldsSet & 0x100) == 0) { - mHotwordPhraseId = defaultHotwordPhraseId(); + mAudioStreams = defaultAudioStreams(); } if ((mBuilderFieldsSet & 0x200) == 0) { - mAudioStreams = defaultAudioStreams(); + mExtras = defaultExtras(); } if ((mBuilderFieldsSet & 0x400) == 0) { - mExtras = defaultExtras(); + mDetectedPhrase = new DetectedPhrase.Builder().build(); } HotwordDetectedResult o = new HotwordDetectedResult( mConfidenceLevel, @@ -1082,9 +1099,9 @@ public final class HotwordDetectedResult implements Parcelable { mHotwordDetectionPersonalized, mScore, mPersonalizedScore, - mHotwordPhraseId, mAudioStreams, - mExtras); + mExtras, + mDetectedPhrase); return o; } @@ -1097,10 +1114,10 @@ public final class HotwordDetectedResult implements Parcelable { } @DataClass.Generated( - time = 1668385264834L, + time = 1676870324215L, codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/service/voice/HotwordDetectedResult.java", - 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 static final int LIMIT_HOTWORD_OFFSET_MAX_VALUE\nprivate static final int LIMIT_AUDIO_CHANNEL_MAX_VALUE\nprivate static final java.lang.String EXTRA_PROXIMITY\npublic static final int PROXIMITY_UNKNOWN\npublic static final int PROXIMITY_NEAR\npublic static final int PROXIMITY_FAR\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 mHotwordDetectionPersonalized\nprivate final int mScore\nprivate final int mPersonalizedScore\nprivate final int mHotwordPhraseId\nprivate final @android.annotation.NonNull java.util.List<android.service.voice.HotwordAudioStream> mAudioStreams\nprivate final @android.annotation.NonNull android.os.PersistableBundle mExtras\nprivate static int sMaxBundleSize\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 java.util.List<android.service.voice.HotwordAudioStream> defaultAudioStreams()\nprivate static android.os.PersistableBundle defaultExtras()\npublic static int getMaxBundleSize()\npublic @android.annotation.Nullable android.media.MediaSyncEvent getMediaSyncEvent()\npublic static int getParcelableSize(android.os.Parcelable)\npublic static int getUsageSize(android.service.voice.HotwordDetectedResult)\nprivate static int bitCount(long)\nprivate void onConstructed()\npublic @android.annotation.NonNull java.util.List<android.service.voice.HotwordAudioStream> getAudioStreams()\npublic void setProximity(double)\npublic @android.service.voice.HotwordDetectedResult.ProximityValue int getProximity()\nprivate @android.service.voice.HotwordDetectedResult.ProximityValue int convertToProximityLevel(double)\npublic android.service.voice.HotwordDetectedResult.Builder buildUpon()\nclass HotwordDetectedResult extends java.lang.Object implements [android.os.Parcelable]\npublic @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setAudioStreams(java.util.List<android.service.voice.HotwordAudioStream>)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)\npublic @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setAudioStreams(java.util.List<android.service.voice.HotwordAudioStream>)\nclass BaseBuilder extends java.lang.Object implements []") + 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 static final int LIMIT_HOTWORD_OFFSET_MAX_VALUE\nprivate static final int LIMIT_AUDIO_CHANNEL_MAX_VALUE\nprivate static final java.lang.String EXTRA_PROXIMITY\npublic static final int PROXIMITY_UNKNOWN\npublic static final int PROXIMITY_NEAR\npublic static final int PROXIMITY_FAR\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 mHotwordDetectionPersonalized\nprivate final int mScore\nprivate final int mPersonalizedScore\nprivate final @android.annotation.NonNull java.util.List<android.service.voice.HotwordAudioStream> mAudioStreams\nprivate final @android.annotation.NonNull android.os.PersistableBundle mExtras\nprivate static int sMaxBundleSize\nprivate @android.annotation.NonNull android.service.voice.DetectedPhrase mDetectedPhrase\nprivate static int defaultConfidenceLevel()\nprivate static int defaultScore()\nprivate static int defaultPersonalizedScore()\npublic static int getMaxScore()\npublic @java.lang.Deprecated int getHotwordPhraseId()\npublic static @java.lang.Deprecated int getMaxHotwordPhraseId()\nprivate static java.util.List<android.service.voice.HotwordAudioStream> defaultAudioStreams()\nprivate static android.os.PersistableBundle defaultExtras()\npublic static int getMaxBundleSize()\npublic @android.annotation.Nullable android.media.MediaSyncEvent getMediaSyncEvent()\npublic static int getParcelableSize(android.os.Parcelable)\npublic static int getUsageSize(android.service.voice.HotwordDetectedResult)\nstatic int bitCount(long)\nprivate void onConstructed()\npublic @android.annotation.NonNull java.util.List<android.service.voice.HotwordAudioStream> getAudioStreams()\npublic void setProximity(double)\npublic @android.service.voice.HotwordDetectedResult.ProximityValue int getProximity()\nprivate @android.service.voice.HotwordDetectedResult.ProximityValue int convertToProximityLevel(double)\npublic android.service.voice.HotwordDetectedResult.Builder buildUpon()\nclass HotwordDetectedResult extends java.lang.Object implements [android.os.Parcelable]\npublic @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setAudioStreams(java.util.List<android.service.voice.HotwordAudioStream>)\npublic @java.lang.Deprecated @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setHotwordPhraseId(int)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)\npublic @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setAudioStreams(java.util.List<android.service.voice.HotwordAudioStream>)\npublic @java.lang.Deprecated @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setHotwordPhraseId(int)\nclass BaseBuilder extends java.lang.Object implements []") @Deprecated private void __metadata() {} |