Merge "AudioAttributes: add ability to set Hotword mode for capture" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
42679e26a4
@@ -4811,6 +4811,7 @@ package android.media {
|
||||
public static class AudioAttributes.Builder {
|
||||
method public android.media.AudioAttributes.Builder addBundle(@NonNull android.os.Bundle);
|
||||
method public android.media.AudioAttributes.Builder setCapturePreset(int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_HOTWORD) public android.media.AudioAttributes.Builder setHotwordMode();
|
||||
method public android.media.AudioAttributes.Builder setInternalCapturePreset(int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING) public android.media.AudioAttributes.Builder setSystemUsage(int);
|
||||
}
|
||||
|
||||
@@ -739,6 +739,13 @@ public final class AudioAttributes implements Parcelable {
|
||||
if (mBundle != null) {
|
||||
aa.mBundle = new Bundle(mBundle);
|
||||
}
|
||||
|
||||
// Allow the FLAG_HW_HOTWORD only for AudioSource.VOICE_RECOGNITION
|
||||
if (mSource != MediaRecorder.AudioSource.VOICE_RECOGNITION
|
||||
&& (mFlags & FLAG_HW_HOTWORD) == FLAG_HW_HOTWORD) {
|
||||
aa.mFlags &= ~FLAG_HW_HOTWORD;
|
||||
}
|
||||
|
||||
return aa;
|
||||
}
|
||||
|
||||
@@ -851,6 +858,23 @@ public final class AudioAttributes implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Request for capture in hotword mode.
|
||||
*
|
||||
* Requests an audio path optimized for Hotword detection use cases from
|
||||
* the low power audio DSP. This is valid only for capture with
|
||||
* audio source {@link MediaRecorder.AudioSource#VOICE_RECOGNITION}.
|
||||
* There is no guarantee that this mode is available on the device.
|
||||
* @return the same Builder instance.
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_HOTWORD)
|
||||
public @NonNull Builder setHotwordMode() {
|
||||
mFlags |= FLAG_HW_HOTWORD;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the audio may or may not be captured by other apps or the system.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user