diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 26d654220df74..164acbddbb493 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -13116,12 +13116,14 @@ package android.service.voice { method public int describeContents(); method public int getAudioChannel(); method @NonNull public java.util.List getAudioStreams(); + method public int getBackgroundAudioPower(); 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 @Deprecated public int getHotwordPhraseId(); + method public static int getMaxBackgroundAudioPower(); method public static int getMaxBundleSize(); method @Deprecated public static int getMaxHotwordPhraseId(); method public static int getMaxScore(); @@ -13132,6 +13134,7 @@ package android.service.voice { method public boolean isHotwordDetectionPersonalized(); method public void writeToParcel(@NonNull android.os.Parcel, int); field public static final int AUDIO_CHANNEL_UNSET = -1; // 0xffffffff + field public static final int BACKGROUND_AUDIO_POWER_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 @@ -13151,6 +13154,7 @@ package android.service.voice { method @NonNull public android.service.voice.HotwordDetectedResult build(); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setAudioChannel(int); method @NonNull public android.service.voice.HotwordDetectedResult.Builder setAudioStreams(@NonNull java.util.List); + method @NonNull public android.service.voice.HotwordDetectedResult.Builder setBackgroundAudioPower(int); 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); diff --git a/core/java/android/service/voice/HotwordDetectedResult.java b/core/java/android/service/voice/HotwordDetectedResult.java index dd3f99cc27efa..ab6f05535a2f9 100644 --- a/core/java/android/service/voice/HotwordDetectedResult.java +++ b/core/java/android/service/voice/HotwordDetectedResult.java @@ -94,6 +94,9 @@ public final class HotwordDetectedResult implements Parcelable { /** Represents unset value for the triggered audio channel. */ public static final int AUDIO_CHANNEL_UNSET = -1; + /** Represents unset value for the background audio signal power. */ + public static final int BACKGROUND_AUDIO_POWER_UNSET = -1; + /** Limits the max value for the hotword offset. */ private static final int LIMIT_HOTWORD_OFFSET_MAX_VALUE = 60 * 60 * 1000; // 1 hour @@ -295,6 +298,24 @@ public final class HotwordDetectedResult implements Parcelable { private DetectedPhrase mDetectedPhrase = new DetectedPhrase.Builder().build(); + /** + * Power of the background audio signal in which the hotword phrase was detected. + * + *

Only values between 0 and {@link #getMaxBackgroundAudioPower} (inclusive) + * and the special value {@link #BACKGROUND_AUDIO_POWER_UNSET} are valid. + */ + private final int mBackgroundAudioPower; + private static int defaultBackgroundAudioPower() { + return BACKGROUND_AUDIO_POWER_UNSET; + } + + /** + * Returns the maximum value of {@link #getBackgroundAudioPower()}. + */ + public static int getMaxBackgroundAudioPower() { + return 255; + } + /** * Returns how many bytes should be written into the Parcel * @@ -346,6 +367,10 @@ public final class HotwordDetectedResult implements Parcelable { if (!persistableBundle.isEmpty()) { totalBits += getParcelableSize(persistableBundle) * Byte.SIZE; } + if (hotwordDetectedResult.getBackgroundAudioPower() != defaultBackgroundAudioPower()) { + totalBits += bitCount(HotwordDetectedResult.getMaxBackgroundAudioPower()); + } + return totalBits; } @@ -362,6 +387,10 @@ public final class HotwordDetectedResult implements Parcelable { Preconditions.checkArgumentInRange(mScore, 0, getMaxScore(), "score"); Preconditions.checkArgumentInRange(mPersonalizedScore, 0, getMaxScore(), "personalizedScore"); + if (mBackgroundAudioPower != BACKGROUND_AUDIO_POWER_UNSET) { + Preconditions.checkArgumentInRange(mBackgroundAudioPower, + 0, getMaxBackgroundAudioPower(), "backgroundAudioPower"); + } Preconditions.checkArgumentInRange((long) mHotwordDurationMillis, 0, AudioRecord.getMaxSharedAudioHistoryMillis(), "hotwordDurationMillis"); if (mHotwordOffsetMillis != HOTWORD_OFFSET_UNSET) { @@ -493,7 +522,8 @@ public final class HotwordDetectedResult implements Parcelable { .setPersonalizedScore(mPersonalizedScore) .setAudioStreams(mAudioStreams) .setExtras(mExtras) - .setDetectedPhrase(mDetectedPhrase); + .setDetectedPhrase(mDetectedPhrase) + .setBackgroundAudioPower(mBackgroundAudioPower); } @@ -604,7 +634,8 @@ public final class HotwordDetectedResult implements Parcelable { int personalizedScore, @NonNull List audioStreams, @NonNull PersistableBundle extras, - @NonNull DetectedPhrase detectedPhrase) { + @NonNull DetectedPhrase detectedPhrase, + int backgroundAudioPower) { this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( HotwordConfidenceLevelValue.class, null, mConfidenceLevel); @@ -624,6 +655,7 @@ public final class HotwordDetectedResult implements Parcelable { this.mDetectedPhrase = detectedPhrase; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mDetectedPhrase); + this.mBackgroundAudioPower = backgroundAudioPower; onConstructed(); } @@ -732,6 +764,17 @@ public final class HotwordDetectedResult implements Parcelable { return mDetectedPhrase; } + /** + * Power of the background audio signal in which the hotword phrase was detected. + * + *

Only values between 0 and {@link #getMaxBackgroundAudioPower} (inclusive) + * and the special value {@link #BACKGROUND_AUDIO_POWER_UNSET} are valid. + */ + @DataClass.Generated.Member + public int getBackgroundAudioPower() { + return mBackgroundAudioPower; + } + @Override @DataClass.Generated.Member public String toString() { @@ -749,7 +792,8 @@ public final class HotwordDetectedResult implements Parcelable { "personalizedScore = " + mPersonalizedScore + ", " + "audioStreams = " + mAudioStreams + ", " + "extras = " + mExtras + ", " + - "detectedPhrase = " + mDetectedPhrase + + "detectedPhrase = " + mDetectedPhrase + ", " + + "backgroundAudioPower = " + mBackgroundAudioPower + " }"; } @@ -776,7 +820,8 @@ public final class HotwordDetectedResult implements Parcelable { && mPersonalizedScore == that.mPersonalizedScore && Objects.equals(mAudioStreams, that.mAudioStreams) && Objects.equals(mExtras, that.mExtras) - && Objects.equals(mDetectedPhrase, that.mDetectedPhrase); + && Objects.equals(mDetectedPhrase, that.mDetectedPhrase) + && mBackgroundAudioPower == that.mBackgroundAudioPower; } @Override @@ -797,6 +842,7 @@ public final class HotwordDetectedResult implements Parcelable { _hash = 31 * _hash + Objects.hashCode(mAudioStreams); _hash = 31 * _hash + Objects.hashCode(mExtras); _hash = 31 * _hash + Objects.hashCode(mDetectedPhrase); + _hash = 31 * _hash + mBackgroundAudioPower; return _hash; } @@ -820,6 +866,7 @@ public final class HotwordDetectedResult implements Parcelable { dest.writeParcelableList(mAudioStreams, flags); dest.writeTypedObject(mExtras, flags); dest.writeTypedObject(mDetectedPhrase, flags); + dest.writeInt(mBackgroundAudioPower); } @Override @@ -846,6 +893,7 @@ public final class HotwordDetectedResult implements Parcelable { in.readParcelableList(audioStreams, HotwordAudioStream.class.getClassLoader()); PersistableBundle extras = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR); DetectedPhrase detectedPhrase = (DetectedPhrase) in.readTypedObject(DetectedPhrase.CREATOR); + int backgroundAudioPower = in.readInt(); this.mConfidenceLevel = confidenceLevel; com.android.internal.util.AnnotationValidations.validate( @@ -866,6 +914,7 @@ public final class HotwordDetectedResult implements Parcelable { this.mDetectedPhrase = detectedPhrase; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mDetectedPhrase); + this.mBackgroundAudioPower = backgroundAudioPower; onConstructed(); } @@ -902,6 +951,7 @@ public final class HotwordDetectedResult implements Parcelable { private @NonNull List mAudioStreams; private @NonNull PersistableBundle mExtras; private @NonNull DetectedPhrase mDetectedPhrase; + private int mBackgroundAudioPower; private long mBuilderFieldsSet = 0L; @@ -1052,10 +1102,24 @@ public final class HotwordDetectedResult implements Parcelable { return this; } + /** + * Power of the background audio signal in which the hotword phrase was detected. + * + *

Only values between 0 and {@link #getMaxBackgroundAudioPower} (inclusive) + * and the special value {@link #BACKGROUND_AUDIO_POWER_UNSET} are valid. + */ + @DataClass.Generated.Member + public @NonNull Builder setBackgroundAudioPower(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x800; + mBackgroundAudioPower = value; + return this; + } + /** Builds the instance. This builder should not be touched after calling this! */ public @NonNull HotwordDetectedResult build() { checkNotUsed(); - mBuilderFieldsSet |= 0x800; // Mark builder used + mBuilderFieldsSet |= 0x1000; // Mark builder used if ((mBuilderFieldsSet & 0x1) == 0) { mConfidenceLevel = defaultConfidenceLevel(); @@ -1090,6 +1154,9 @@ public final class HotwordDetectedResult implements Parcelable { if ((mBuilderFieldsSet & 0x400) == 0) { mDetectedPhrase = new DetectedPhrase.Builder().build(); } + if ((mBuilderFieldsSet & 0x800) == 0) { + mBackgroundAudioPower = defaultBackgroundAudioPower(); + } HotwordDetectedResult o = new HotwordDetectedResult( mConfidenceLevel, mMediaSyncEvent, @@ -1101,12 +1168,13 @@ public final class HotwordDetectedResult implements Parcelable { mPersonalizedScore, mAudioStreams, mExtras, - mDetectedPhrase); + mDetectedPhrase, + mBackgroundAudioPower); return o; } private void checkNotUsed() { - if ((mBuilderFieldsSet & 0x800) != 0) { + if ((mBuilderFieldsSet & 0x1000) != 0) { throw new IllegalStateException( "This Builder should not be reused. Use a new Builder instance instead"); } @@ -1114,10 +1182,10 @@ public final class HotwordDetectedResult implements Parcelable { } @DataClass.Generated( - time = 1676870324215L, + time = 1679010159293L, 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 @android.annotation.NonNull java.util.List 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 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 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)\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)\npublic @java.lang.Deprecated @android.annotation.NonNull android.service.voice.HotwordDetectedResult.Builder setHotwordPhraseId(int)\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\npublic static final int BACKGROUND_AUDIO_POWER_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 mAudioStreams\nprivate final @android.annotation.NonNull android.os.PersistableBundle mExtras\nprivate static int sMaxBundleSize\nprivate @android.annotation.NonNull android.service.voice.DetectedPhrase mDetectedPhrase\nprivate final int mBackgroundAudioPower\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 defaultAudioStreams()\nprivate static android.os.PersistableBundle defaultExtras()\npublic static int getMaxBundleSize()\npublic @android.annotation.Nullable android.media.MediaSyncEvent getMediaSyncEvent()\nprivate static int defaultBackgroundAudioPower()\npublic static int getMaxBackgroundAudioPower()\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 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)\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)\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() {}