Loading media/java/android/media/AudioAttributes.java +32 −4 Original line number Diff line number Diff line Loading @@ -598,6 +598,11 @@ public final class AudioAttributes implements Parcelable { private boolean mMuteHapticChannels = true; private HashSet<String> mTags = new HashSet<String>(); private Bundle mBundle; private int mPrivacySensitive = PRIVACY_SENSITIVE_DEFAULT; private static final int PRIVACY_SENSITIVE_DEFAULT = -1; private static final int PRIVACY_SENSITIVE_DISABLED = 0; private static final int PRIVACY_SENSITIVE_ENABLED = 1; /** * Constructs a new Builder with the defaults. Loading Loading @@ -638,11 +643,20 @@ public final class AudioAttributes implements Parcelable { if (mMuteHapticChannels) { aa.mFlags |= FLAG_MUTE_HAPTIC; } // capturing for camcorder of communication is private by default to if (mPrivacySensitive == PRIVACY_SENSITIVE_DEFAULT) { // capturing for camcorder or communication is private by default to // reflect legacy behavior if (aa.mSource == MediaRecorder.AudioSource.VOICE_COMMUNICATION || aa.mSource == MediaRecorder.AudioSource.CAMCORDER) { if (mSource == MediaRecorder.AudioSource.VOICE_COMMUNICATION || mSource == MediaRecorder.AudioSource.CAMCORDER) { aa.mFlags |= FLAG_CAPTURE_PRIVATE; } else { aa.mFlags &= ~FLAG_CAPTURE_PRIVATE; } } else if (mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) { aa.mFlags |= FLAG_CAPTURE_PRIVATE; } else { aa.mFlags &= ~FLAG_CAPTURE_PRIVATE; } aa.mTags = (HashSet<String>) mTags.clone(); aa.mFormattedTags = TextUtils.join(";", mTags); Loading Loading @@ -967,6 +981,20 @@ public final class AudioAttributes implements Parcelable { mMuteHapticChannels = muted; return this; } /** * @hide * Indicates if an AudioRecord build with this AudioAttributes is privacy sensitive or not. * See {@link AudioRecord.Builder#setPrivacySensitive(boolean)}. * @param privacySensitive True if capture must be marked as privacy sensitive, * false otherwise. * @return the same Builder instance. */ public @NonNull Builder setPrivacySensitive(boolean privacySensitive) { mPrivacySensitive = privacySensitive ? PRIVACY_SENSITIVE_ENABLED : PRIVACY_SENSITIVE_DISABLED; return this; } }; @Override Loading media/java/android/media/AudioRecord.java +5 −12 Original line number Diff line number Diff line Loading @@ -315,7 +315,7 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection, * @hide * Class constructor with {@link AudioAttributes} and {@link AudioFormat}. * @param attributes a non-null {@link AudioAttributes} instance. Use * {@link AudioAttributes.Builder#setAudioSource(int)} for configuring the audio * {@link AudioAttributes.Builder#setCapturePreset(int)} for configuring the audio * source for this instance. * @param format a non-null {@link AudioFormat} instance describing the format of the data * that will be recorded through this AudioRecord. See {@link AudioFormat.Builder} for Loading Loading @@ -754,18 +754,11 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection, "Cannot request private capture with source: " + source); } int flags = mAttributes.getAllFlags(); if (mPrivacySensitive == PRIVACY_SENSITIVE_DISABLED) { flags &= ~AudioAttributes.FLAG_CAPTURE_PRIVATE; } else if (mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) { flags |= AudioAttributes.FLAG_CAPTURE_PRIVATE; } if (flags != mAttributes.getAllFlags()) { mAttributes = new AudioAttributes.Builder(mAttributes) .replaceFlags(flags) .setInternalCapturePreset(source) .setPrivacySensitive(mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) .build(); } } try { // If the buffer size is not specified, Loading Loading
media/java/android/media/AudioAttributes.java +32 −4 Original line number Diff line number Diff line Loading @@ -598,6 +598,11 @@ public final class AudioAttributes implements Parcelable { private boolean mMuteHapticChannels = true; private HashSet<String> mTags = new HashSet<String>(); private Bundle mBundle; private int mPrivacySensitive = PRIVACY_SENSITIVE_DEFAULT; private static final int PRIVACY_SENSITIVE_DEFAULT = -1; private static final int PRIVACY_SENSITIVE_DISABLED = 0; private static final int PRIVACY_SENSITIVE_ENABLED = 1; /** * Constructs a new Builder with the defaults. Loading Loading @@ -638,11 +643,20 @@ public final class AudioAttributes implements Parcelable { if (mMuteHapticChannels) { aa.mFlags |= FLAG_MUTE_HAPTIC; } // capturing for camcorder of communication is private by default to if (mPrivacySensitive == PRIVACY_SENSITIVE_DEFAULT) { // capturing for camcorder or communication is private by default to // reflect legacy behavior if (aa.mSource == MediaRecorder.AudioSource.VOICE_COMMUNICATION || aa.mSource == MediaRecorder.AudioSource.CAMCORDER) { if (mSource == MediaRecorder.AudioSource.VOICE_COMMUNICATION || mSource == MediaRecorder.AudioSource.CAMCORDER) { aa.mFlags |= FLAG_CAPTURE_PRIVATE; } else { aa.mFlags &= ~FLAG_CAPTURE_PRIVATE; } } else if (mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) { aa.mFlags |= FLAG_CAPTURE_PRIVATE; } else { aa.mFlags &= ~FLAG_CAPTURE_PRIVATE; } aa.mTags = (HashSet<String>) mTags.clone(); aa.mFormattedTags = TextUtils.join(";", mTags); Loading Loading @@ -967,6 +981,20 @@ public final class AudioAttributes implements Parcelable { mMuteHapticChannels = muted; return this; } /** * @hide * Indicates if an AudioRecord build with this AudioAttributes is privacy sensitive or not. * See {@link AudioRecord.Builder#setPrivacySensitive(boolean)}. * @param privacySensitive True if capture must be marked as privacy sensitive, * false otherwise. * @return the same Builder instance. */ public @NonNull Builder setPrivacySensitive(boolean privacySensitive) { mPrivacySensitive = privacySensitive ? PRIVACY_SENSITIVE_ENABLED : PRIVACY_SENSITIVE_DISABLED; return this; } }; @Override Loading
media/java/android/media/AudioRecord.java +5 −12 Original line number Diff line number Diff line Loading @@ -315,7 +315,7 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection, * @hide * Class constructor with {@link AudioAttributes} and {@link AudioFormat}. * @param attributes a non-null {@link AudioAttributes} instance. Use * {@link AudioAttributes.Builder#setAudioSource(int)} for configuring the audio * {@link AudioAttributes.Builder#setCapturePreset(int)} for configuring the audio * source for this instance. * @param format a non-null {@link AudioFormat} instance describing the format of the data * that will be recorded through this AudioRecord. See {@link AudioFormat.Builder} for Loading Loading @@ -754,18 +754,11 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection, "Cannot request private capture with source: " + source); } int flags = mAttributes.getAllFlags(); if (mPrivacySensitive == PRIVACY_SENSITIVE_DISABLED) { flags &= ~AudioAttributes.FLAG_CAPTURE_PRIVATE; } else if (mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) { flags |= AudioAttributes.FLAG_CAPTURE_PRIVATE; } if (flags != mAttributes.getAllFlags()) { mAttributes = new AudioAttributes.Builder(mAttributes) .replaceFlags(flags) .setInternalCapturePreset(source) .setPrivacySensitive(mPrivacySensitive == PRIVACY_SENSITIVE_ENABLED) .build(); } } try { // If the buffer size is not specified, Loading