Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ce6e56c authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Introduce playback capture opt-out



Test: adb shell audiorecorder --target /data/file.raw
Bug: 111453086
Change-Id: Ie09f7161bf19b158e31f4a18e9c9a27c70382686
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 98ab00f9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23038,6 +23038,7 @@ package android.media {
    ctor public AudioAttributes.Builder();
    ctor public AudioAttributes.Builder(android.media.AudioAttributes);
    method public android.media.AudioAttributes build();
    method public android.media.AudioAttributes.Builder setAllowCapture(boolean);
    method public android.media.AudioAttributes.Builder setContentType(int);
    method public android.media.AudioAttributes.Builder setFlags(int);
    method public android.media.AudioAttributes.Builder setLegacyStreamType(int);
+22 −0
Original line number Diff line number Diff line
@@ -368,6 +368,12 @@ public final class AudioAttributes implements Parcelable {
     */
    public final static int FLAG_DEEP_BUFFER = 0x1 << 9;

    /**
     * @hide
     * Flag specifying that the audio shall not be captured by other apps.
     */
    public static final int FLAG_NO_CAPTURE = 0x1 << 10;

    private final static int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO |
            FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD | FLAG_BYPASS_INTERRUPTION_POLICY |
            FLAG_BYPASS_MUTE | FLAG_LOW_LATENCY | FLAG_DEEP_BUFFER;
@@ -617,6 +623,22 @@ public final class AudioAttributes implements Parcelable {
            return this;
        }

        /**
         * Specifying if audio shall or shall not be captured by other apps.
         * By default, capture is allowed.
         * @param allowCapture false to forbid capture of the audio by any apps,
         *                     true to allow apps to capture the audio
         * @return the same Builder instance
         */
        public Builder setAllowCapture(boolean allowCapture) {
            if (allowCapture) {
                mFlags &= ~FLAG_NO_CAPTURE;
            } else {
                mFlags |= FLAG_NO_CAPTURE;
            }
            return this;
        }

        /**
         * @hide
         * Replaces flags.