Merge changes I640f6470,Idca3ccc6

* changes:
  add java doc for SoundTriggerManager.Model
  fix naming discrepancy in SoundTrigger
This commit is contained in:
TreeHugger Robot
2020-02-07 01:07:14 +00:00
committed by Android (Google) Code Review
6 changed files with 53 additions and 22 deletions

View File

@@ -3704,8 +3704,8 @@ package android.hardware.soundtrigger {
public static final class SoundTrigger.ModuleProperties implements android.os.Parcelable {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
field public static final int CAPABILITY_NOISE_SUPPRESSION = 2; // 0x2
field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
field public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION = 2; // 0x2
field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.ModuleProperties> CREATOR;
field public final int audioCapabilities;
field @NonNull public final String description;

View File

@@ -17,7 +17,6 @@
package android.hardware.soundtrigger;
import android.annotation.Nullable;
import android.hardware.soundtrigger.ModelParams;
import android.media.AudioFormat;
import android.media.audio.common.AudioConfig;
import android.media.soundtrigger_middleware.AudioCapabilities;
@@ -333,20 +332,22 @@ class ConversionUtil {
public static int aidl2apiAudioCapabilities(int aidlCapabilities) {
int result = 0;
if ((aidlCapabilities & AudioCapabilities.ECHO_CANCELLATION) != 0) {
result |= SoundTrigger.ModuleProperties.CAPABILITY_ECHO_CANCELLATION;
result |= SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_ECHO_CANCELLATION;
}
if ((aidlCapabilities & AudioCapabilities.NOISE_SUPPRESSION) != 0) {
result |= SoundTrigger.ModuleProperties.CAPABILITY_NOISE_SUPPRESSION;
result |= SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_NOISE_SUPPRESSION;
}
return result;
}
public static int api2aidlAudioCapabilities(int apiCapabilities) {
int result = 0;
if ((apiCapabilities & SoundTrigger.ModuleProperties.CAPABILITY_ECHO_CANCELLATION) != 0) {
if ((apiCapabilities & SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_ECHO_CANCELLATION)
!= 0) {
result |= AudioCapabilities.ECHO_CANCELLATION;
}
if ((apiCapabilities & SoundTrigger.ModuleProperties.CAPABILITY_NOISE_SUPPRESSION) != 0) {
if ((apiCapabilities & SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_NOISE_SUPPRESSION)
!= 0) {
result |= AudioCapabilities.NOISE_SUPPRESSION;
}
return result;

View File

@@ -97,8 +97,8 @@ public class SoundTrigger {
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, prefix = { "AUDIO_CAPABILITY_" }, value = {
CAPABILITY_ECHO_CANCELLATION,
CAPABILITY_NOISE_SUPPRESSION
AUDIO_CAPABILITY_ECHO_CANCELLATION,
AUDIO_CAPABILITY_NOISE_SUPPRESSION
})
public @interface AudioCapabilities {}
@@ -106,12 +106,12 @@ public class SoundTrigger {
* If set the underlying module supports AEC.
* Describes bit field {@link ModuleProperties#audioCapabilities}
*/
public static final int CAPABILITY_ECHO_CANCELLATION = 0x1;
public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 0x1;
/**
* If set, the underlying module supports noise suppression.
* Describes bit field {@link ModuleProperties#audioCapabilities}
*/
public static final int CAPABILITY_NOISE_SUPPRESSION = 0x2;
public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION = 0x2;
/** Unique module ID provided by the native service */
public final int id;

View File

@@ -181,14 +181,14 @@ public class AlwaysOnHotwordDetector {
* Returned by {@link #getSupportedAudioCapabilities()}
*/
public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION =
SoundTrigger.ModuleProperties.CAPABILITY_ECHO_CANCELLATION;
SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_ECHO_CANCELLATION;
/**
* If set, the underlying module supports noise suppression.
* Returned by {@link #getSupportedAudioCapabilities()}
*/
public static final int AUDIO_CAPABILITY_NOISE_SUPPRESSION =
SoundTrigger.ModuleProperties.CAPABILITY_NOISE_SUPPRESSION;
SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_NOISE_SUPPRESSION;
/** @hide */
@Retention(RetentionPolicy.SOURCE)

View File

@@ -113,7 +113,7 @@ public final class SoundTriggerDetector {
* This capability may or may not be supported by the system, and support can be queried
* by calling {@link SoundTriggerManager#getModuleProperties()} and checking
* {@link ModuleProperties#audioCapabilities}. The corresponding capabilities field for
* this flag is {@link SoundTrigger.ModuleProperties#CAPABILITY_ECHO_CANCELLATION}.
* this flag is {@link SoundTrigger.ModuleProperties#AUDIO_CAPABILITY_ECHO_CANCELLATION}.
* If this flag is passed without the audio capability supported, there will be no audio effect
* applied.
*/
@@ -125,8 +125,9 @@ public final class SoundTriggerDetector {
* This capability may or may not be supported by the system, and support can be queried
* by calling {@link SoundTriggerManager#getModuleProperties()} and checking
* {@link ModuleProperties#audioCapabilities}. The corresponding capabilities field for
* this flag is {@link SoundTrigger.ModuleProperties#CAPABILITY_NOISE_SUPPRESSION}. If this flag
* is passed without the audio capability supported, there will be no audio effect applied.
* this flag is {@link SoundTrigger.ModuleProperties#AUDIO_CAPABILITY_NOISE_SUPPRESSION}.
* If this flag is passed without the audio capability supported, there will be no audio effect
* applied.
*/
public static final int RECOGNITION_FLAG_ENABLE_AUDIO_NOISE_SUPPRESSION = 0x8;
@@ -296,10 +297,10 @@ public final class SoundTriggerDetector {
int audioCapabilities = 0;
if ((recognitionFlags & RECOGNITION_FLAG_ENABLE_AUDIO_ECHO_CANCELLATION) != 0) {
audioCapabilities |= SoundTrigger.ModuleProperties.CAPABILITY_ECHO_CANCELLATION;
audioCapabilities |= SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_ECHO_CANCELLATION;
}
if ((recognitionFlags & RECOGNITION_FLAG_ENABLE_AUDIO_NOISE_SUPPRESSION) != 0) {
audioCapabilities |= SoundTrigger.ModuleProperties.CAPABILITY_NOISE_SUPPRESSION;
audioCapabilities |= SoundTrigger.ModuleProperties.AUDIO_CAPABILITY_NOISE_SUPPRESSION;
}
int status;

View File

@@ -173,8 +173,13 @@ public final class SoundTriggerManager {
}
/**
* Factory constructor to create a SoundModel instance for use with methods in this
* class.
* Factory constructor to a voice model to be used with {@link SoundTriggerManager}
*
* @param modelUuid Unique identifier associated with the model.
* @param vendorUuid Unique identifier associated the calling vendor.
* @param data Model's data.
* @param version Version identifier for the model.
* @return Voice model
*/
@NonNull
public static Model create(@NonNull UUID modelUuid, @NonNull UUID vendorUuid,
@@ -186,8 +191,12 @@ public final class SoundTriggerManager {
}
/**
* Factory constructor to create a SoundModel instance for use with methods in this
* class.
* Factory constructor to a voice model to be used with {@link SoundTriggerManager}
*
* @param modelUuid Unique identifier associated with the model.
* @param vendorUuid Unique identifier associated the calling vendor.
* @param data Model's data.
* @return Voice model
*/
@NonNull
public static Model create(@NonNull UUID modelUuid, @NonNull UUID vendorUuid,
@@ -195,20 +204,40 @@ public final class SoundTriggerManager {
return create(modelUuid, vendorUuid, data, -1);
}
/**
* Get the model's unique identifier
*
* @return UUID associated with the model
*/
@NonNull
public UUID getModelUuid() {
return mGenericSoundModel.uuid;
}
/**
* Get the model's vendor identifier
*
* @return UUID associated with the vendor of the model
*/
@NonNull
public UUID getVendorUuid() {
return mGenericSoundModel.vendorUuid;
}
/**
* Get the model's version
*
* @return Version associated with the model
*/
public int getVersion() {
return mGenericSoundModel.version;
}
/**
* Get the underlying model data
*
* @return Backing data of the model
*/
@Nullable
public byte[] getModelData() {
return mGenericSoundModel.data;