enable FM tuner and hotword capture for system apps.

AudioRecord constructor with AudioAttributes and session ID as well
as HOTWORD and RADIO_TUNER audio sources are now system APIs.
Renamed MediaRecorder.AudioSource.FM_TUNER to
MediaRecorder.AudioSource.RADIO_TUNER.

Change-Id: I231c20c21e3e8cffe1837482976ebe284c9af541
This commit is contained in:
Eric Laurent
2015-03-09 09:25:45 -07:00
parent 93891686eb
commit 00a009204e
4 changed files with 18 additions and 9 deletions

View File

@@ -15139,6 +15139,7 @@ package android.media {
public final class AudioAttributes implements android.os.Parcelable {
method public int describeContents();
method public int getAllFlags();
method public int getCapturePreset();
method public int getContentType();
method public int getFlags();
@@ -15180,6 +15181,7 @@ package android.media {
method public android.media.AudioAttributes.Builder setCapturePreset(int);
method public android.media.AudioAttributes.Builder setContentType(int);
method public android.media.AudioAttributes.Builder setFlags(int);
method public android.media.AudioAttributes.Builder setInternalCapturePreset(int);
method public android.media.AudioAttributes.Builder setLegacyStreamType(int);
method public android.media.AudioAttributes.Builder setUsage(int);
}
@@ -15412,6 +15414,7 @@ package android.media {
public class AudioRecord {
ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
ctor public AudioRecord(android.media.AudioAttributes, android.media.AudioFormat, int, int) throws java.lang.IllegalArgumentException;
method public int getAudioFormat();
method public int getAudioSessionId();
method public int getAudioSource();
@@ -16550,7 +16553,9 @@ package android.media {
public final class MediaRecorder.AudioSource {
field public static final int CAMCORDER = 5; // 0x5
field public static final int DEFAULT = 0; // 0x0
field public static final int HOTWORD = 1999; // 0x7cf
field public static final int MIC = 1; // 0x1
field public static final int RADIO_TUNER = 1998; // 0x7ce
field public static final int REMOTE_SUBMIX = 8; // 0x8
field public static final int VOICE_CALL = 4; // 0x4
field public static final int VOICE_COMMUNICATION = 7; // 0x7

View File

@@ -279,6 +279,7 @@ public final class AudioAttributes implements Parcelable {
* Internal use only
* @return a combined mask of all flags
*/
@SystemApi
public int getAllFlags() {
return (mFlags & FLAG_ALL);
}
@@ -541,14 +542,15 @@ public final class AudioAttributes implements Parcelable {
/**
* @hide
* Same as {@link #setCapturePreset(int)} but authorizes the use of HOTWORD,
* REMOTE_SUBMIX and FM_TUNER.
* REMOTE_SUBMIX and RADIO_TUNER.
* @param preset
* @return the same Builder instance.
*/
@SystemApi
public Builder setInternalCapturePreset(int preset) {
if ((preset == MediaRecorder.AudioSource.HOTWORD)
|| (preset == MediaRecorder.AudioSource.REMOTE_SUBMIX)
|| (preset == MediaRecorder.AudioSource.FM_TUNER)) {
|| (preset == MediaRecorder.AudioSource.RADIO_TUNER)) {
mSource = preset;
} else {
setCapturePreset(preset);

View File

@@ -20,6 +20,7 @@ import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.Iterator;
import android.annotation.SystemApi;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -238,7 +239,6 @@ public class AudioRecord
/**
* @hide
* CANDIDATE FOR PUBLIC API
* Class constructor with {@link AudioAttributes} and {@link AudioFormat}.
* @param attributes a non-null {@link AudioAttributes} instance. Use
* {@link AudioAttributes.Builder#setCapturePreset(int)} for configuring the capture
@@ -257,6 +257,7 @@ public class AudioRecord
* construction.
* @throws IllegalArgumentException
*/
@SystemApi
public AudioRecord(AudioAttributes attributes, AudioFormat format, int bufferSizeInBytes,
int sessionId) throws IllegalArgumentException {
mRecordingState = RECORDSTATE_STOPPED;
@@ -376,7 +377,7 @@ public class AudioRecord
// audio source
if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) ||
((audioSource > MediaRecorder.getAudioSourceMax()) &&
(audioSource != MediaRecorder.AudioSource.FM_TUNER) &&
(audioSource != MediaRecorder.AudioSource.RADIO_TUNER) &&
(audioSource != MediaRecorder.AudioSource.HOTWORD)) ) {
throw new IllegalArgumentException("Invalid audio source.");
}

View File

@@ -16,6 +16,7 @@
package android.media;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.hardware.Camera;
import android.os.Handler;
@@ -222,12 +223,11 @@ public class MediaRecorder
public static final int REMOTE_SUBMIX = 8;
/**
* Audio source for FM, which is used to capture current FM tuner output by FMRadio app.
* There are two use cases, one is for record FM stream for later listening, another is
* for FM indirect mode(the routing except FM to headset(headphone) device routing).
* Audio source for capturing broadcast radio tuner output.
* @hide
*/
public static final int FM_TUNER = 1998;
@SystemApi
public static final int RADIO_TUNER = 1998;
/**
* Audio source for preemptible, low-priority software hotword detection
@@ -240,7 +240,8 @@ public class MediaRecorder
* This is a hidden audio source.
* @hide
*/
protected static final int HOTWORD = 1999;
@SystemApi
public static final int HOTWORD = 1999;
}
/**