Hotword: Add HotwordAudioStream list in HotwordDetectedResult
- Create the new data class HotwordAudioStream - Add HowordAudioStream list into HotwordDetectedResult Test: atest CtsVoiceInteractionTestCases Bug: 243766281 Bug: 243597982 Change-Id: I0953a93195699b17d4a69bba6c4140bc91eecb79
This commit is contained in:
@@ -11982,9 +11982,29 @@ package android.service.voice {
|
|||||||
method public int getStart();
|
method public int getStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class HotwordAudioStream implements android.os.Parcelable {
|
||||||
|
method public int describeContents();
|
||||||
|
method @NonNull public android.media.AudioFormat getAudioFormat();
|
||||||
|
method @NonNull public android.os.ParcelFileDescriptor getAudioStream();
|
||||||
|
method @NonNull public android.os.PersistableBundle getMetadata();
|
||||||
|
method @Nullable public android.media.AudioTimestamp getTimestamp();
|
||||||
|
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||||
|
field @NonNull public static final android.os.Parcelable.Creator<android.service.voice.HotwordAudioStream> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class HotwordAudioStream.Builder {
|
||||||
|
ctor public HotwordAudioStream.Builder(@NonNull android.media.AudioFormat, @NonNull android.os.ParcelFileDescriptor);
|
||||||
|
method @NonNull public android.service.voice.HotwordAudioStream build();
|
||||||
|
method @NonNull public android.service.voice.HotwordAudioStream.Builder setAudioFormat(@NonNull android.media.AudioFormat);
|
||||||
|
method @NonNull public android.service.voice.HotwordAudioStream.Builder setAudioStream(@NonNull android.os.ParcelFileDescriptor);
|
||||||
|
method @NonNull public android.service.voice.HotwordAudioStream.Builder setMetadata(@NonNull android.os.PersistableBundle);
|
||||||
|
method @NonNull public android.service.voice.HotwordAudioStream.Builder setTimestamp(@NonNull android.media.AudioTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
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 getAudioChannel();
|
method public int getAudioChannel();
|
||||||
|
method @NonNull public java.util.List<android.service.voice.HotwordAudioStream> getAudioStreams();
|
||||||
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 getHotwordDurationMillis();
|
||||||
@@ -12014,6 +12034,7 @@ package android.service.voice {
|
|||||||
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 setAudioChannel(int);
|
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 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 setHotwordDetectionPersonalized(boolean);
|
method @NonNull public android.service.voice.HotwordDetectedResult.Builder setHotwordDetectionPersonalized(boolean);
|
||||||
|
|||||||
19
core/java/android/service/voice/HotwordAudioStream.aidl
Normal file
19
core/java/android/service/voice/HotwordAudioStream.aidl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 HotwordAudioStream;
|
||||||
447
core/java/android/service/voice/HotwordAudioStream.java
Normal file
447
core/java/android/service/voice/HotwordAudioStream.java
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.media.AudioFormat;
|
||||||
|
import android.media.AudioRecord;
|
||||||
|
import android.media.AudioTimestamp;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
|
|
||||||
|
import com.android.internal.util.DataClass;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an audio stream supporting the hotword detection.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@DataClass(
|
||||||
|
genConstructor = false,
|
||||||
|
genBuilder = true,
|
||||||
|
genEqualsHashCode = true,
|
||||||
|
genParcelable = true,
|
||||||
|
genToString = true
|
||||||
|
)
|
||||||
|
@SystemApi
|
||||||
|
public final class HotwordAudioStream implements Parcelable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AudioFormat} of the audio stream.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
private final AudioFormat mAudioFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This stream starts with the audio bytes used for hotword detection, but continues streaming
|
||||||
|
* the audio until the stream is shutdown by the {@link HotwordDetectionService}.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
private final ParcelFileDescriptor mAudioStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp when the {@link #getAudioStream()} was captured by the Audio platform.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The {@link HotwordDetectionService} egressing the audio is the owner of the underlying
|
||||||
|
* AudioRecord. The {@link HotwordDetectionService} is expected to optionally populate this
|
||||||
|
* field by {@link AudioRecord#getTimestamp}.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This timestamp can be used in conjunction with the
|
||||||
|
* {@link HotwordDetectedResult#getHotwordOffsetMillis()} and
|
||||||
|
* {@link HotwordDetectedResult#getHotwordDurationMillis()} to translate these durations to
|
||||||
|
* timestamps.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private final AudioTimestamp mTimestamp;
|
||||||
|
private static AudioTimestamp defaultTimestamp() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata associated with the audio stream.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
private final PersistableBundle mMetadata;
|
||||||
|
private static PersistableBundle defaultMetadata() {
|
||||||
|
return new PersistableBundle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String timestampToString() {
|
||||||
|
if (mTimestamp == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "TimeStamp:"
|
||||||
|
+ " framePos=" + mTimestamp.framePosition
|
||||||
|
+ " nanoTime=" + mTimestamp.nanoTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parcelTimestamp(Parcel dest, int flags) {
|
||||||
|
if (mTimestamp != null) {
|
||||||
|
// mTimestamp is not null, we write it to the parcel, set true.
|
||||||
|
dest.writeBoolean(true);
|
||||||
|
dest.writeLong(mTimestamp.framePosition);
|
||||||
|
dest.writeLong(mTimestamp.nanoTime);
|
||||||
|
} else {
|
||||||
|
// mTimestamp is null, we don't write any value out, set false.
|
||||||
|
dest.writeBoolean(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static AudioTimestamp unparcelTimestamp(Parcel in) {
|
||||||
|
// If it is true, it means we wrote the value to the parcel before, parse it.
|
||||||
|
// Otherwise, return null.
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
final AudioTimestamp timeStamp = new AudioTimestamp();
|
||||||
|
timeStamp.framePosition = in.readLong();
|
||||||
|
timeStamp.nanoTime = in.readLong();
|
||||||
|
return timeStamp;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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/HotwordAudioStream.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 */ HotwordAudioStream(
|
||||||
|
@NonNull AudioFormat audioFormat,
|
||||||
|
@NonNull ParcelFileDescriptor audioStream,
|
||||||
|
@Nullable AudioTimestamp timestamp,
|
||||||
|
@NonNull PersistableBundle metadata) {
|
||||||
|
this.mAudioFormat = audioFormat;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioFormat);
|
||||||
|
this.mAudioStream = audioStream;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioStream);
|
||||||
|
this.mTimestamp = timestamp;
|
||||||
|
this.mMetadata = metadata;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mMetadata);
|
||||||
|
|
||||||
|
// onConstructed(); // You can define this method to get a callback
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AudioFormat} of the audio stream.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull AudioFormat getAudioFormat() {
|
||||||
|
return mAudioFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This stream starts with the audio bytes used for hotword detection, but continues streaming
|
||||||
|
* the audio until the stream is shutdown by the {@link HotwordDetectionService}.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull ParcelFileDescriptor getAudioStream() {
|
||||||
|
return mAudioStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp when the {@link #getAudioStream()} was captured by the Audio platform.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The {@link HotwordDetectionService} egressing the audio is the owner of the underlying
|
||||||
|
* AudioRecord. The {@link HotwordDetectionService} is expected to optionally populate this
|
||||||
|
* field by {@link AudioRecord#getTimestamp}.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This timestamp can be used in conjunction with the
|
||||||
|
* {@link HotwordDetectedResult#getHotwordOffsetMillis()} and
|
||||||
|
* {@link HotwordDetectedResult#getHotwordDurationMillis()} to translate these durations to
|
||||||
|
* timestamps.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @Nullable AudioTimestamp getTimestamp() {
|
||||||
|
return mTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata associated with the audio stream.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull PersistableBundle getMetadata() {
|
||||||
|
return mMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public String toString() {
|
||||||
|
// You can override field toString logic by defining methods like:
|
||||||
|
// String fieldNameToString() { ... }
|
||||||
|
|
||||||
|
return "HotwordAudioStream { " +
|
||||||
|
"audioFormat = " + mAudioFormat + ", " +
|
||||||
|
"audioStream = " + mAudioStream + ", " +
|
||||||
|
"timestamp = " + timestampToString() + ", " +
|
||||||
|
"metadata = " + mMetadata +
|
||||||
|
" }";
|
||||||
|
}
|
||||||
|
|
||||||
|
@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(HotwordAudioStream other) { ... }
|
||||||
|
// boolean fieldNameEquals(FieldType otherValue) { ... }
|
||||||
|
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HotwordAudioStream that = (HotwordAudioStream) o;
|
||||||
|
//noinspection PointlessBooleanExpression
|
||||||
|
return true
|
||||||
|
&& Objects.equals(mAudioFormat, that.mAudioFormat)
|
||||||
|
&& Objects.equals(mAudioStream, that.mAudioStream)
|
||||||
|
&& Objects.equals(mTimestamp, that.mTimestamp)
|
||||||
|
&& Objects.equals(mMetadata, that.mMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 + Objects.hashCode(mAudioFormat);
|
||||||
|
_hash = 31 * _hash + Objects.hashCode(mAudioStream);
|
||||||
|
_hash = 31 * _hash + Objects.hashCode(mTimestamp);
|
||||||
|
_hash = 31 * _hash + Objects.hashCode(mMetadata);
|
||||||
|
return _hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
// You can override field parcelling by defining methods like:
|
||||||
|
// void parcelFieldName(Parcel dest, int flags) { ... }
|
||||||
|
|
||||||
|
byte flg = 0;
|
||||||
|
if (mTimestamp != null) flg |= 0x4;
|
||||||
|
dest.writeByte(flg);
|
||||||
|
dest.writeTypedObject(mAudioFormat, flags);
|
||||||
|
dest.writeTypedObject(mAudioStream, flags);
|
||||||
|
parcelTimestamp(dest, flags);
|
||||||
|
dest.writeTypedObject(mMetadata, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public int describeContents() { return 0; }
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@SuppressWarnings({"unchecked", "RedundantCast"})
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
/* package-private */ HotwordAudioStream(@NonNull Parcel in) {
|
||||||
|
// You can override field unparcelling by defining methods like:
|
||||||
|
// static FieldType unparcelFieldName(Parcel in) { ... }
|
||||||
|
|
||||||
|
byte flg = in.readByte();
|
||||||
|
AudioFormat audioFormat = (AudioFormat) in.readTypedObject(AudioFormat.CREATOR);
|
||||||
|
ParcelFileDescriptor audioStream = (ParcelFileDescriptor) in.readTypedObject(ParcelFileDescriptor.CREATOR);
|
||||||
|
AudioTimestamp timestamp = unparcelTimestamp(in);
|
||||||
|
PersistableBundle metadata = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR);
|
||||||
|
|
||||||
|
this.mAudioFormat = audioFormat;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioFormat);
|
||||||
|
this.mAudioStream = audioStream;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioStream);
|
||||||
|
this.mTimestamp = timestamp;
|
||||||
|
this.mMetadata = metadata;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mMetadata);
|
||||||
|
|
||||||
|
// onConstructed(); // You can define this method to get a callback
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public static final @NonNull Parcelable.Creator<HotwordAudioStream> CREATOR
|
||||||
|
= new Parcelable.Creator<HotwordAudioStream>() {
|
||||||
|
@Override
|
||||||
|
public HotwordAudioStream[] newArray(int size) {
|
||||||
|
return new HotwordAudioStream[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HotwordAudioStream createFromParcel(@NonNull Parcel in) {
|
||||||
|
return new HotwordAudioStream(in);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A builder for {@link HotwordAudioStream}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public static final class Builder {
|
||||||
|
|
||||||
|
private @NonNull AudioFormat mAudioFormat;
|
||||||
|
private @NonNull ParcelFileDescriptor mAudioStream;
|
||||||
|
private @Nullable AudioTimestamp mTimestamp;
|
||||||
|
private @NonNull PersistableBundle mMetadata;
|
||||||
|
|
||||||
|
private long mBuilderFieldsSet = 0L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Builder.
|
||||||
|
*
|
||||||
|
* @param audioFormat
|
||||||
|
* The {@link AudioFormat} of the audio stream.
|
||||||
|
* @param audioStream
|
||||||
|
* This stream starts with the audio bytes used for hotword detection, but continues streaming
|
||||||
|
* the audio until the stream is shutdown by the {@link HotwordDetectionService}.
|
||||||
|
*/
|
||||||
|
public Builder(
|
||||||
|
@NonNull AudioFormat audioFormat,
|
||||||
|
@NonNull ParcelFileDescriptor audioStream) {
|
||||||
|
mAudioFormat = audioFormat;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioFormat);
|
||||||
|
mAudioStream = audioStream;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AudioFormat} of the audio stream.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull Builder setAudioFormat(@NonNull AudioFormat value) {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x1;
|
||||||
|
mAudioFormat = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This stream starts with the audio bytes used for hotword detection, but continues streaming
|
||||||
|
* the audio until the stream is shutdown by the {@link HotwordDetectionService}.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull Builder setAudioStream(@NonNull ParcelFileDescriptor value) {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x2;
|
||||||
|
mAudioStream = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp when the {@link #getAudioStream()} was captured by the Audio platform.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The {@link HotwordDetectionService} egressing the audio is the owner of the underlying
|
||||||
|
* AudioRecord. The {@link HotwordDetectionService} is expected to optionally populate this
|
||||||
|
* field by {@link AudioRecord#getTimestamp}.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This timestamp can be used in conjunction with the
|
||||||
|
* {@link HotwordDetectedResult#getHotwordOffsetMillis()} and
|
||||||
|
* {@link HotwordDetectedResult#getHotwordDurationMillis()} to translate these durations to
|
||||||
|
* timestamps.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull Builder setTimestamp(@NonNull AudioTimestamp value) {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x4;
|
||||||
|
mTimestamp = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata associated with the audio stream.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull Builder setMetadata(@NonNull PersistableBundle value) {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x8;
|
||||||
|
mMetadata = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builds the instance. This builder should not be touched after calling this! */
|
||||||
|
public @NonNull HotwordAudioStream build() {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x10; // Mark builder used
|
||||||
|
|
||||||
|
if ((mBuilderFieldsSet & 0x4) == 0) {
|
||||||
|
mTimestamp = defaultTimestamp();
|
||||||
|
}
|
||||||
|
if ((mBuilderFieldsSet & 0x8) == 0) {
|
||||||
|
mMetadata = defaultMetadata();
|
||||||
|
}
|
||||||
|
HotwordAudioStream o = new HotwordAudioStream(
|
||||||
|
mAudioFormat,
|
||||||
|
mAudioStream,
|
||||||
|
mTimestamp,
|
||||||
|
mMetadata);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkNotUsed() {
|
||||||
|
if ((mBuilderFieldsSet & 0x10) != 0) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"This Builder should not be reused. Use a new Builder instance instead");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataClass.Generated(
|
||||||
|
time = 1665463434564L,
|
||||||
|
codegenVersion = "1.0.23",
|
||||||
|
sourceFile = "frameworks/base/core/java/android/service/voice/HotwordAudioStream.java",
|
||||||
|
inputSignatures = "private final @android.annotation.NonNull android.media.AudioFormat mAudioFormat\nprivate final @android.annotation.NonNull android.os.ParcelFileDescriptor mAudioStream\nprivate final @android.annotation.Nullable android.media.AudioTimestamp mTimestamp\nprivate final @android.annotation.NonNull android.os.PersistableBundle mMetadata\nprivate static android.media.AudioTimestamp defaultTimestamp()\nprivate static android.os.PersistableBundle defaultMetadata()\nprivate java.lang.String timestampToString()\nprivate void parcelTimestamp(android.os.Parcel,int)\nprivate static @android.annotation.Nullable android.media.AudioTimestamp unparcelTimestamp(android.os.Parcel)\nclass HotwordAudioStream extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genParcelable=true, genToString=true)")
|
||||||
|
@Deprecated
|
||||||
|
private void __metadata() {}
|
||||||
|
|
||||||
|
|
||||||
|
//@formatter:on
|
||||||
|
// End of generated code
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,6 +31,8 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.util.DataClass;
|
import com.android.internal.util.DataClass;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +197,15 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
return 63;
|
return 63;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of the audio streams containing audio bytes that were used for hotword detection.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
private final List<HotwordAudioStream> mAudioStreams;
|
||||||
|
private static List<HotwordAudioStream> defaultAudioStreams() {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App-specific extras to support trigger.
|
* App-specific extras to support trigger.
|
||||||
*
|
*
|
||||||
@@ -353,6 +364,11 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DataClass.Suppress("addAudioStreams")
|
||||||
|
abstract static class BaseBuilder {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Code below generated by codegen v1.0.23.
|
// Code below generated by codegen v1.0.23.
|
||||||
@@ -436,6 +452,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
int score,
|
int score,
|
||||||
int personalizedScore,
|
int personalizedScore,
|
||||||
int hotwordPhraseId,
|
int hotwordPhraseId,
|
||||||
|
@NonNull List<HotwordAudioStream> audioStreams,
|
||||||
@NonNull PersistableBundle extras) {
|
@NonNull PersistableBundle extras) {
|
||||||
this.mConfidenceLevel = confidenceLevel;
|
this.mConfidenceLevel = confidenceLevel;
|
||||||
com.android.internal.util.AnnotationValidations.validate(
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
@@ -448,6 +465,9 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
this.mScore = score;
|
this.mScore = score;
|
||||||
this.mPersonalizedScore = personalizedScore;
|
this.mPersonalizedScore = personalizedScore;
|
||||||
this.mHotwordPhraseId = hotwordPhraseId;
|
this.mHotwordPhraseId = hotwordPhraseId;
|
||||||
|
this.mAudioStreams = audioStreams;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioStreams);
|
||||||
this.mExtras = extras;
|
this.mExtras = extras;
|
||||||
com.android.internal.util.AnnotationValidations.validate(
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
NonNull.class, null, mExtras);
|
NonNull.class, null, mExtras);
|
||||||
@@ -534,6 +554,14 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
return mHotwordPhraseId;
|
return mHotwordPhraseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of the audio streams containing audio bytes that were used for hotword detection.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull List<HotwordAudioStream> getAudioStreams() {
|
||||||
|
return mAudioStreams;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App-specific extras to support trigger.
|
* App-specific extras to support trigger.
|
||||||
*
|
*
|
||||||
@@ -578,6 +606,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
"score = " + mScore + ", " +
|
"score = " + mScore + ", " +
|
||||||
"personalizedScore = " + mPersonalizedScore + ", " +
|
"personalizedScore = " + mPersonalizedScore + ", " +
|
||||||
"hotwordPhraseId = " + mHotwordPhraseId + ", " +
|
"hotwordPhraseId = " + mHotwordPhraseId + ", " +
|
||||||
|
"audioStreams = " + mAudioStreams + ", " +
|
||||||
"extras = " + mExtras +
|
"extras = " + mExtras +
|
||||||
" }";
|
" }";
|
||||||
}
|
}
|
||||||
@@ -604,6 +633,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
&& mScore == that.mScore
|
&& mScore == that.mScore
|
||||||
&& mPersonalizedScore == that.mPersonalizedScore
|
&& mPersonalizedScore == that.mPersonalizedScore
|
||||||
&& mHotwordPhraseId == that.mHotwordPhraseId
|
&& mHotwordPhraseId == that.mHotwordPhraseId
|
||||||
|
&& Objects.equals(mAudioStreams, that.mAudioStreams)
|
||||||
&& Objects.equals(mExtras, that.mExtras);
|
&& Objects.equals(mExtras, that.mExtras);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,6 +653,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
_hash = 31 * _hash + mScore;
|
_hash = 31 * _hash + mScore;
|
||||||
_hash = 31 * _hash + mPersonalizedScore;
|
_hash = 31 * _hash + mPersonalizedScore;
|
||||||
_hash = 31 * _hash + mHotwordPhraseId;
|
_hash = 31 * _hash + mHotwordPhraseId;
|
||||||
|
_hash = 31 * _hash + Objects.hashCode(mAudioStreams);
|
||||||
_hash = 31 * _hash + Objects.hashCode(mExtras);
|
_hash = 31 * _hash + Objects.hashCode(mExtras);
|
||||||
return _hash;
|
return _hash;
|
||||||
}
|
}
|
||||||
@@ -645,6 +676,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
dest.writeInt(mScore);
|
dest.writeInt(mScore);
|
||||||
dest.writeInt(mPersonalizedScore);
|
dest.writeInt(mPersonalizedScore);
|
||||||
dest.writeInt(mHotwordPhraseId);
|
dest.writeInt(mHotwordPhraseId);
|
||||||
|
dest.writeParcelableList(mAudioStreams, flags);
|
||||||
dest.writeTypedObject(mExtras, flags);
|
dest.writeTypedObject(mExtras, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,6 +701,8 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
int score = in.readInt();
|
int score = in.readInt();
|
||||||
int personalizedScore = in.readInt();
|
int personalizedScore = in.readInt();
|
||||||
int hotwordPhraseId = in.readInt();
|
int hotwordPhraseId = in.readInt();
|
||||||
|
List<HotwordAudioStream> audioStreams = new ArrayList<>();
|
||||||
|
in.readParcelableList(audioStreams, HotwordAudioStream.class.getClassLoader());
|
||||||
PersistableBundle extras = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR);
|
PersistableBundle extras = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR);
|
||||||
|
|
||||||
this.mConfidenceLevel = confidenceLevel;
|
this.mConfidenceLevel = confidenceLevel;
|
||||||
@@ -682,6 +716,9 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
this.mScore = score;
|
this.mScore = score;
|
||||||
this.mPersonalizedScore = personalizedScore;
|
this.mPersonalizedScore = personalizedScore;
|
||||||
this.mHotwordPhraseId = hotwordPhraseId;
|
this.mHotwordPhraseId = hotwordPhraseId;
|
||||||
|
this.mAudioStreams = audioStreams;
|
||||||
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
|
NonNull.class, null, mAudioStreams);
|
||||||
this.mExtras = extras;
|
this.mExtras = extras;
|
||||||
com.android.internal.util.AnnotationValidations.validate(
|
com.android.internal.util.AnnotationValidations.validate(
|
||||||
NonNull.class, null, mExtras);
|
NonNull.class, null, mExtras);
|
||||||
@@ -708,7 +745,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
@DataClass.Generated.Member
|
@DataClass.Generated.Member
|
||||||
public static final class Builder {
|
public static final class Builder extends BaseBuilder {
|
||||||
|
|
||||||
private @HotwordConfidenceLevelValue int mConfidenceLevel;
|
private @HotwordConfidenceLevelValue int mConfidenceLevel;
|
||||||
private @Nullable MediaSyncEvent mMediaSyncEvent;
|
private @Nullable MediaSyncEvent mMediaSyncEvent;
|
||||||
@@ -719,6 +756,7 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
private int mScore;
|
private int mScore;
|
||||||
private int mPersonalizedScore;
|
private int mPersonalizedScore;
|
||||||
private int mHotwordPhraseId;
|
private int mHotwordPhraseId;
|
||||||
|
private @NonNull List<HotwordAudioStream> mAudioStreams;
|
||||||
private @NonNull PersistableBundle mExtras;
|
private @NonNull PersistableBundle mExtras;
|
||||||
|
|
||||||
private long mBuilderFieldsSet = 0L;
|
private long mBuilderFieldsSet = 0L;
|
||||||
@@ -842,6 +880,17 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of the audio streams containing audio bytes that were used for hotword detection.
|
||||||
|
*/
|
||||||
|
@DataClass.Generated.Member
|
||||||
|
public @NonNull Builder setAudioStreams(@NonNull List<HotwordAudioStream> value) {
|
||||||
|
checkNotUsed();
|
||||||
|
mBuilderFieldsSet |= 0x200;
|
||||||
|
mAudioStreams = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App-specific extras to support trigger.
|
* App-specific extras to support trigger.
|
||||||
*
|
*
|
||||||
@@ -868,7 +917,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 |= 0x200;
|
mBuilderFieldsSet |= 0x400;
|
||||||
mExtras = value;
|
mExtras = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -876,7 +925,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 |= 0x400; // Mark builder used
|
mBuilderFieldsSet |= 0x800; // Mark builder used
|
||||||
|
|
||||||
if ((mBuilderFieldsSet & 0x1) == 0) {
|
if ((mBuilderFieldsSet & 0x1) == 0) {
|
||||||
mConfidenceLevel = defaultConfidenceLevel();
|
mConfidenceLevel = defaultConfidenceLevel();
|
||||||
@@ -906,6 +955,9 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
mHotwordPhraseId = defaultHotwordPhraseId();
|
mHotwordPhraseId = defaultHotwordPhraseId();
|
||||||
}
|
}
|
||||||
if ((mBuilderFieldsSet & 0x200) == 0) {
|
if ((mBuilderFieldsSet & 0x200) == 0) {
|
||||||
|
mAudioStreams = defaultAudioStreams();
|
||||||
|
}
|
||||||
|
if ((mBuilderFieldsSet & 0x400) == 0) {
|
||||||
mExtras = defaultExtras();
|
mExtras = defaultExtras();
|
||||||
}
|
}
|
||||||
HotwordDetectedResult o = new HotwordDetectedResult(
|
HotwordDetectedResult o = new HotwordDetectedResult(
|
||||||
@@ -918,12 +970,13 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
mScore,
|
mScore,
|
||||||
mPersonalizedScore,
|
mPersonalizedScore,
|
||||||
mHotwordPhraseId,
|
mHotwordPhraseId,
|
||||||
|
mAudioStreams,
|
||||||
mExtras);
|
mExtras);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNotUsed() {
|
private void checkNotUsed() {
|
||||||
if ((mBuilderFieldsSet & 0x400) != 0) {
|
if ((mBuilderFieldsSet & 0x800) != 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");
|
||||||
}
|
}
|
||||||
@@ -931,10 +984,10 @@ public final class HotwordDetectedResult implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DataClass.Generated(
|
@DataClass.Generated(
|
||||||
time = 1658357814396L,
|
time = 1664876310951L,
|
||||||
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 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\npublic static final java.lang.String EXTRA_PROXIMITY_METERS\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 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 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()\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 static final int LIMIT_HOTWORD_OFFSET_MAX_VALUE\nprivate static final int LIMIT_AUDIO_CHANNEL_MAX_VALUE\npublic static final java.lang.String EXTRA_PROXIMITY_METERS\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()\nclass HotwordDetectedResult extends java.lang.Object implements [android.os.Parcelable]\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)\nclass BaseBuilder extends java.lang.Object implements []")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private void __metadata() {}
|
private void __metadata() {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user