Merge "Adjust HotwordDetectedResult with up-to-date information." into sc-dev

This commit is contained in:
Ahaan Ugale
2021-05-22 00:11:26 +00:00
committed by Android (Google) Code Review
4 changed files with 323 additions and 90 deletions

View File

@@ -10513,9 +10513,11 @@ package android.service.voice {
public final class HotwordDetectedResult implements android.os.Parcelable { public final class HotwordDetectedResult implements android.os.Parcelable {
method public int describeContents(); method public int describeContents();
method public int getByteOffset(); method public int getAudioChannel();
method public int getConfidenceLevel(); method public int getConfidenceLevel();
method @NonNull public android.os.PersistableBundle getExtras(); method @NonNull public android.os.PersistableBundle getExtras();
method public int getHotwordDurationMillis();
method public int getHotwordOffsetMillis();
method public int getHotwordPhraseId(); method public int getHotwordPhraseId();
method public static int getMaxBundleSize(); method public static int getMaxBundleSize();
method public static int getMaxHotwordPhraseId(); method public static int getMaxHotwordPhraseId();
@@ -10523,19 +10525,31 @@ package android.service.voice {
method @Nullable public android.media.MediaSyncEvent getMediaSyncEvent(); method @Nullable public android.media.MediaSyncEvent getMediaSyncEvent();
method public int getPersonalizedScore(); method public int getPersonalizedScore();
method public int getScore(); method public int getScore();
method public boolean isPersonalizedHotwordDetection();
method public void writeToParcel(@NonNull android.os.Parcel, int); 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<android.service.voice.HotwordDetectedResult> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.HotwordDetectedResult> CREATOR;
field public static final int HOTWORD_OFFSET_UNSET = -1; // 0xffffffff
} }
public static final class HotwordDetectedResult.Builder { public static final class HotwordDetectedResult.Builder {
ctor public HotwordDetectedResult.Builder(); ctor public HotwordDetectedResult.Builder();
method @NonNull public android.service.voice.HotwordDetectedResult build(); 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 setConfidenceLevel(int);
method @NonNull public android.service.voice.HotwordDetectedResult.Builder setExtras(@NonNull android.os.PersistableBundle); 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 setHotwordPhraseId(int);
method @NonNull public android.service.voice.HotwordDetectedResult.Builder setMediaSyncEvent(@NonNull android.media.MediaSyncEvent); 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 setPersonalizedScore(int);
method @NonNull public android.service.voice.HotwordDetectedResult.Builder setScore(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setScore(int);
} }
@@ -10565,10 +10579,6 @@ package android.service.voice {
method 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 public boolean stopRecognition(); method public boolean stopRecognition();
method public void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory); 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 { public static interface HotwordDetector.Callback {
@@ -10585,6 +10595,10 @@ package android.service.voice {
method public int describeContents(); method public int describeContents();
method public int getConfidenceLevel(); method public int getConfidenceLevel();
method public void writeToParcel(@NonNull android.os.Parcel, int); 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<android.service.voice.HotwordRejectedResult> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.HotwordRejectedResult> CREATOR;
} }

View File

@@ -16,8 +16,7 @@
package android.service.voice; package android.service.voice;
import static android.service.voice.HotwordDetector.CONFIDENCE_LEVEL_NONE; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi; import android.annotation.SystemApi;
@@ -43,11 +42,48 @@ import com.android.internal.util.DataClass;
@SystemApi @SystemApi
public final class HotwordDetectedResult implements Parcelable { public final class HotwordDetectedResult implements Parcelable {
/** Represents unset value for byte offset. */ /** No confidence in hotword detector result. */
public static final int BYTE_OFFSET_UNSET = -1; 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. */ /** Confidence level in the trigger outcome. */
@HotwordDetector.HotwordConfidenceLevelValue @HotwordConfidenceLevelValue
private final int mConfidenceLevel; private final int mConfidenceLevel;
private static int defaultConfidenceLevel() { private static int defaultConfidenceLevel() {
return CONFIDENCE_LEVEL_NONE; return CONFIDENCE_LEVEL_NONE;
@@ -62,12 +98,27 @@ public final class HotwordDetectedResult implements Parcelable {
private MediaSyncEvent mMediaSyncEvent = null; 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 int mHotwordOffsetMillis = HOTWORD_OFFSET_UNSET;
private static int defaultByteOffset() {
return BYTE_OFFSET_UNSET; /**
} * Duration in milliseconds of the hotword trigger phrase.
*
* <p>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. * Score for the hotword trigger.
@@ -162,6 +213,7 @@ public final class HotwordDetectedResult implements Parcelable {
} }
// Code below generated by codegen v1.0.23. // Code below generated by codegen v1.0.23.
// //
// DO NOT MODIFY! // DO NOT MODIFY!
@@ -175,20 +227,62 @@ public final class HotwordDetectedResult implements Parcelable {
//@formatter:off //@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 @DataClass.Generated.Member
/* package-private */ HotwordDetectedResult( /* package-private */ HotwordDetectedResult(
@HotwordDetector.HotwordConfidenceLevelValue int confidenceLevel, @HotwordConfidenceLevelValue int confidenceLevel,
@Nullable MediaSyncEvent mediaSyncEvent, @Nullable MediaSyncEvent mediaSyncEvent,
int byteOffset, int hotwordOffsetMillis,
int hotwordDurationMillis,
int audioChannel,
boolean personalizedHotwordDetection,
int score, int score,
int personalizedScore, int personalizedScore,
int hotwordPhraseId, int hotwordPhraseId,
@NonNull PersistableBundle extras) { @NonNull PersistableBundle extras) {
this.mConfidenceLevel = confidenceLevel; this.mConfidenceLevel = confidenceLevel;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); HotwordConfidenceLevelValue.class, null, mConfidenceLevel);
this.mMediaSyncEvent = mediaSyncEvent; this.mMediaSyncEvent = mediaSyncEvent;
this.mByteOffset = byteOffset; this.mHotwordOffsetMillis = hotwordOffsetMillis;
this.mHotwordDurationMillis = hotwordDurationMillis;
this.mAudioChannel = audioChannel;
this.mPersonalizedHotwordDetection = personalizedHotwordDetection;
this.mScore = score; this.mScore = score;
this.mPersonalizedScore = personalizedScore; this.mPersonalizedScore = personalizedScore;
this.mHotwordPhraseId = hotwordPhraseId; this.mHotwordPhraseId = hotwordPhraseId;
@@ -203,16 +297,45 @@ public final class HotwordDetectedResult implements Parcelable {
* Confidence level in the trigger outcome. * Confidence level in the trigger outcome.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public @HotwordDetector.HotwordConfidenceLevelValue int getConfidenceLevel() { public @HotwordConfidenceLevelValue int getConfidenceLevel() {
return mConfidenceLevel; 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 @DataClass.Generated.Member
public int getByteOffset() { public int getHotwordOffsetMillis() {
return mByteOffset; return mHotwordOffsetMillis;
}
/**
* Duration in milliseconds of the hotword trigger phrase.
*
* <p>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 { " + return "HotwordDetectedResult { " +
"confidenceLevel = " + mConfidenceLevel + ", " + "confidenceLevel = " + mConfidenceLevel + ", " +
"mediaSyncEvent = " + mMediaSyncEvent + ", " + "mediaSyncEvent = " + mMediaSyncEvent + ", " +
"byteOffset = " + mByteOffset + ", " + "hotwordOffsetMillis = " + mHotwordOffsetMillis + ", " +
"hotwordDurationMillis = " + mHotwordDurationMillis + ", " +
"audioChannel = " + mAudioChannel + ", " +
"personalizedHotwordDetection = " + mPersonalizedHotwordDetection + ", " +
"score = " + mScore + ", " + "score = " + mScore + ", " +
"personalizedScore = " + mPersonalizedScore + ", " + "personalizedScore = " + mPersonalizedScore + ", " +
"hotwordPhraseId = " + mHotwordPhraseId + ", " + "hotwordPhraseId = " + mHotwordPhraseId + ", " +
@@ -297,7 +423,10 @@ public final class HotwordDetectedResult implements Parcelable {
return true return true
&& mConfidenceLevel == that.mConfidenceLevel && mConfidenceLevel == that.mConfidenceLevel
&& java.util.Objects.equals(mMediaSyncEvent, that.mMediaSyncEvent) && 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 && mScore == that.mScore
&& mPersonalizedScore == that.mPersonalizedScore && mPersonalizedScore == that.mPersonalizedScore
&& mHotwordPhraseId == that.mHotwordPhraseId && mHotwordPhraseId == that.mHotwordPhraseId
@@ -313,7 +442,10 @@ public final class HotwordDetectedResult implements Parcelable {
int _hash = 1; int _hash = 1;
_hash = 31 * _hash + mConfidenceLevel; _hash = 31 * _hash + mConfidenceLevel;
_hash = 31 * _hash + java.util.Objects.hashCode(mMediaSyncEvent); _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 + mScore;
_hash = 31 * _hash + mPersonalizedScore; _hash = 31 * _hash + mPersonalizedScore;
_hash = 31 * _hash + mHotwordPhraseId; _hash = 31 * _hash + mHotwordPhraseId;
@@ -327,12 +459,15 @@ public final class HotwordDetectedResult implements Parcelable {
// You can override field parcelling by defining methods like: // You can override field parcelling by defining methods like:
// void parcelFieldName(Parcel dest, int flags) { ... } // void parcelFieldName(Parcel dest, int flags) { ... }
byte flg = 0; int flg = 0;
if (mPersonalizedHotwordDetection) flg |= 0x20;
if (mMediaSyncEvent != null) flg |= 0x2; if (mMediaSyncEvent != null) flg |= 0x2;
dest.writeByte(flg); dest.writeInt(flg);
dest.writeInt(mConfidenceLevel); dest.writeInt(mConfidenceLevel);
if (mMediaSyncEvent != null) dest.writeTypedObject(mMediaSyncEvent, flags); if (mMediaSyncEvent != null) dest.writeTypedObject(mMediaSyncEvent, flags);
dest.writeInt(mByteOffset); dest.writeInt(mHotwordOffsetMillis);
dest.writeInt(mHotwordDurationMillis);
dest.writeInt(mAudioChannel);
dest.writeInt(mScore); dest.writeInt(mScore);
dest.writeInt(mPersonalizedScore); dest.writeInt(mPersonalizedScore);
dest.writeInt(mHotwordPhraseId); dest.writeInt(mHotwordPhraseId);
@@ -350,10 +485,13 @@ public final class HotwordDetectedResult implements Parcelable {
// You can override field unparcelling by defining methods like: // You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... } // static FieldType unparcelFieldName(Parcel in) { ... }
byte flg = in.readByte(); int flg = in.readInt();
boolean personalizedHotwordDetection = (flg & 0x20) != 0;
int confidenceLevel = in.readInt(); int confidenceLevel = in.readInt();
MediaSyncEvent mediaSyncEvent = (flg & 0x2) == 0 ? null : (MediaSyncEvent) in.readTypedObject(MediaSyncEvent.CREATOR); 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 score = in.readInt();
int personalizedScore = in.readInt(); int personalizedScore = in.readInt();
int hotwordPhraseId = in.readInt(); int hotwordPhraseId = in.readInt();
@@ -361,9 +499,12 @@ public final class HotwordDetectedResult implements Parcelable {
this.mConfidenceLevel = confidenceLevel; this.mConfidenceLevel = confidenceLevel;
com.android.internal.util.AnnotationValidations.validate( com.android.internal.util.AnnotationValidations.validate(
HotwordDetector.HotwordConfidenceLevelValue.class, null, mConfidenceLevel); HotwordConfidenceLevelValue.class, null, mConfidenceLevel);
this.mMediaSyncEvent = mediaSyncEvent; this.mMediaSyncEvent = mediaSyncEvent;
this.mByteOffset = byteOffset; this.mHotwordOffsetMillis = hotwordOffsetMillis;
this.mHotwordDurationMillis = hotwordDurationMillis;
this.mAudioChannel = audioChannel;
this.mPersonalizedHotwordDetection = personalizedHotwordDetection;
this.mScore = score; this.mScore = score;
this.mPersonalizedScore = personalizedScore; this.mPersonalizedScore = personalizedScore;
this.mHotwordPhraseId = hotwordPhraseId; this.mHotwordPhraseId = hotwordPhraseId;
@@ -395,9 +536,12 @@ public final class HotwordDetectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public static final class Builder { public static final class Builder {
private @HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel; private @HotwordConfidenceLevelValue int mConfidenceLevel;
private @Nullable MediaSyncEvent mMediaSyncEvent; private @Nullable MediaSyncEvent mMediaSyncEvent;
private int mByteOffset; private int mHotwordOffsetMillis;
private int mHotwordDurationMillis;
private int mAudioChannel;
private boolean mPersonalizedHotwordDetection;
private int mScore; private int mScore;
private int mPersonalizedScore; private int mPersonalizedScore;
private int mHotwordPhraseId; private int mHotwordPhraseId;
@@ -412,7 +556,7 @@ public final class HotwordDetectedResult implements Parcelable {
* Confidence level in the trigger outcome. * Confidence level in the trigger outcome.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public @NonNull Builder setConfidenceLevel(@HotwordDetector.HotwordConfidenceLevelValue int value) { public @NonNull Builder setConfidenceLevel(@HotwordConfidenceLevelValue int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x1; mBuilderFieldsSet |= 0x1;
mConfidenceLevel = value; 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 @DataClass.Generated.Member
public @NonNull Builder setByteOffset(int value) { public @NonNull Builder setHotwordOffsetMillis(int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x4; mBuilderFieldsSet |= 0x4;
mByteOffset = value; mHotwordOffsetMillis = value;
return this;
}
/**
* Duration in milliseconds of the hotword trigger phrase.
*
* <p>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; return this;
} }
@@ -451,7 +633,7 @@ public final class HotwordDetectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public @NonNull Builder setScore(int value) { public @NonNull Builder setScore(int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x8; mBuilderFieldsSet |= 0x40;
mScore = value; mScore = value;
return this; return this;
} }
@@ -464,7 +646,7 @@ public final class HotwordDetectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public @NonNull Builder setPersonalizedScore(int value) { public @NonNull Builder setPersonalizedScore(int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x10; mBuilderFieldsSet |= 0x80;
mPersonalizedScore = value; mPersonalizedScore = value;
return this; return this;
} }
@@ -477,7 +659,7 @@ public final class HotwordDetectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public @NonNull Builder setHotwordPhraseId(int value) { public @NonNull Builder setHotwordPhraseId(int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x20; mBuilderFieldsSet |= 0x100;
mHotwordPhraseId = value; mHotwordPhraseId = value;
return this; return this;
} }
@@ -500,7 +682,7 @@ public final class HotwordDetectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public @NonNull Builder setExtras(@NonNull PersistableBundle value) { public @NonNull Builder setExtras(@NonNull PersistableBundle value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x40; mBuilderFieldsSet |= 0x200;
mExtras = value; mExtras = value;
return this; return this;
} }
@@ -508,7 +690,7 @@ public final class HotwordDetectedResult implements Parcelable {
/** Builds the instance. This builder should not be touched after calling this! */ /** Builds the instance. This builder should not be touched after calling this! */
public @NonNull HotwordDetectedResult build() { public @NonNull HotwordDetectedResult build() {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x80; // Mark builder used mBuilderFieldsSet |= 0x400; // Mark builder used
if ((mBuilderFieldsSet & 0x1) == 0) { if ((mBuilderFieldsSet & 0x1) == 0) {
mConfidenceLevel = defaultConfidenceLevel(); mConfidenceLevel = defaultConfidenceLevel();
@@ -517,24 +699,36 @@ public final class HotwordDetectedResult implements Parcelable {
mMediaSyncEvent = null; mMediaSyncEvent = null;
} }
if ((mBuilderFieldsSet & 0x4) == 0) { if ((mBuilderFieldsSet & 0x4) == 0) {
mByteOffset = defaultByteOffset(); mHotwordOffsetMillis = HOTWORD_OFFSET_UNSET;
} }
if ((mBuilderFieldsSet & 0x8) == 0) { if ((mBuilderFieldsSet & 0x8) == 0) {
mScore = defaultScore(); mHotwordDurationMillis = 0;
} }
if ((mBuilderFieldsSet & 0x10) == 0) { if ((mBuilderFieldsSet & 0x10) == 0) {
mPersonalizedScore = defaultPersonalizedScore(); mAudioChannel = AUDIO_CHANNEL_UNSET;
} }
if ((mBuilderFieldsSet & 0x20) == 0) { if ((mBuilderFieldsSet & 0x20) == 0) {
mHotwordPhraseId = defaultHotwordPhraseId(); mPersonalizedHotwordDetection = false;
} }
if ((mBuilderFieldsSet & 0x40) == 0) { if ((mBuilderFieldsSet & 0x40) == 0) {
mScore = defaultScore();
}
if ((mBuilderFieldsSet & 0x80) == 0) {
mPersonalizedScore = defaultPersonalizedScore();
}
if ((mBuilderFieldsSet & 0x100) == 0) {
mHotwordPhraseId = defaultHotwordPhraseId();
}
if ((mBuilderFieldsSet & 0x200) == 0) {
mExtras = defaultExtras(); mExtras = defaultExtras();
} }
HotwordDetectedResult o = new HotwordDetectedResult( HotwordDetectedResult o = new HotwordDetectedResult(
mConfidenceLevel, mConfidenceLevel,
mMediaSyncEvent, mMediaSyncEvent,
mByteOffset, mHotwordOffsetMillis,
mHotwordDurationMillis,
mAudioChannel,
mPersonalizedHotwordDetection,
mScore, mScore,
mPersonalizedScore, mPersonalizedScore,
mHotwordPhraseId, mHotwordPhraseId,
@@ -543,7 +737,7 @@ public final class HotwordDetectedResult implements Parcelable {
} }
private void checkNotUsed() { private void checkNotUsed() {
if ((mBuilderFieldsSet & 0x80) != 0) { if ((mBuilderFieldsSet & 0x400) != 0) {
throw new IllegalStateException( throw new IllegalStateException(
"This Builder should not be reused. Use a new Builder instance instead"); "This Builder should not be reused. Use a new Builder instance instead");
} }
@@ -551,10 +745,10 @@ public final class HotwordDetectedResult implements Parcelable {
} }
@DataClass.Generated( @DataClass.Generated(
time = 1620133603958L, time = 1621631039729L,
codegenVersion = "1.0.23", codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/service/voice/HotwordDetectedResult.java", 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 @Deprecated
private void __metadata() {} private void __metadata() {}

View File

@@ -19,7 +19,6 @@ package android.service.voice;
import static android.Manifest.permission.CAPTURE_AUDIO_HOTWORD; import static android.Manifest.permission.CAPTURE_AUDIO_HOTWORD;
import static android.Manifest.permission.RECORD_AUDIO; import static android.Manifest.permission.RECORD_AUDIO;
import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.RequiresPermission; import android.annotation.RequiresPermission;
@@ -37,28 +36,6 @@ import android.os.SharedMemory;
@SystemApi @SystemApi
public interface HotwordDetector { 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. * Starts hotword recognition.
* <p> * <p>

View File

@@ -16,8 +16,7 @@
package android.service.voice; package android.service.voice;
import static android.service.voice.HotwordDetector.CONFIDENCE_LEVEL_NONE; import android.annotation.IntDef;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.os.Parcelable; import android.os.Parcelable;
@@ -39,8 +38,30 @@ import com.android.internal.util.DataClass;
@SystemApi @SystemApi
public final class HotwordRejectedResult implements Parcelable { 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. */ /** Confidence level in the trigger outcome. */
@HotwordDetector.HotwordConfidenceLevelValue @HotwordConfidenceLevelValue
private final int mConfidenceLevel; private final int mConfidenceLevel;
private static int defaultConfidenceLevel() { private static int defaultConfidenceLevel() {
return CONFIDENCE_LEVEL_NONE; 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! // DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code // CHECKSTYLE:OFF Generated code
@@ -61,12 +82,39 @@ public final class HotwordRejectedResult implements Parcelable {
//@formatter:off //@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 @DataClass.Generated.Member
/* package-private */ HotwordRejectedResult( /* package-private */ HotwordRejectedResult(
@HotwordDetector.HotwordConfidenceLevelValue int confidenceLevel) { @HotwordConfidenceLevelValue int confidenceLevel) {
this.mConfidenceLevel = confidenceLevel; this.mConfidenceLevel = confidenceLevel;
com.android.internal.util.AnnotationValidations.validate( 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 // 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. * Confidence level in the trigger outcome.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public @HotwordDetector.HotwordConfidenceLevelValue int getConfidenceLevel() { public @HotwordConfidenceLevelValue int getConfidenceLevel() {
return mConfidenceLevel; return mConfidenceLevel;
} }
@@ -141,7 +189,7 @@ public final class HotwordRejectedResult implements Parcelable {
this.mConfidenceLevel = confidenceLevel; this.mConfidenceLevel = confidenceLevel;
com.android.internal.util.AnnotationValidations.validate( 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 // onConstructed(); // You can define this method to get a callback
} }
@@ -168,7 +216,7 @@ public final class HotwordRejectedResult implements Parcelable {
@DataClass.Generated.Member @DataClass.Generated.Member
public static final class Builder { public static final class Builder {
private @HotwordDetector.HotwordConfidenceLevelValue int mConfidenceLevel; private @HotwordConfidenceLevelValue int mConfidenceLevel;
private long mBuilderFieldsSet = 0L; private long mBuilderFieldsSet = 0L;
@@ -179,7 +227,7 @@ public final class HotwordRejectedResult implements Parcelable {
* Confidence level in the trigger outcome. * Confidence level in the trigger outcome.
*/ */
@DataClass.Generated.Member @DataClass.Generated.Member
public @android.annotation.NonNull Builder setConfidenceLevel(@HotwordDetector.HotwordConfidenceLevelValue int value) { public @android.annotation.NonNull Builder setConfidenceLevel(@HotwordConfidenceLevelValue int value) {
checkNotUsed(); checkNotUsed();
mBuilderFieldsSet |= 0x1; mBuilderFieldsSet |= 0x1;
mConfidenceLevel = value; mConfidenceLevel = value;
@@ -208,10 +256,10 @@ public final class HotwordRejectedResult implements Parcelable {
} }
@DataClass.Generated( @DataClass.Generated(
time = 1616108967315L, time = 1621551683210L,
codegenVersion = "1.0.22", codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/service/voice/HotwordRejectedResult.java", 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 @Deprecated
private void __metadata() {} private void __metadata() {}