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

Commit 1073ee63 authored by jiabin's avatar jiabin
Browse files

Treat FLAG_MUTE_HAPTIC separately from mFlags.

For get/set APIs, FLAG_MUTE_HAPTIC is known as a boolean value instead
of a flag. In that case, it should not be changed when calling set flags
API to modify the flags. By doing this, it helps the FLAG_MUTE_HAPTIC is
set correctly.

Bug: 130670988
Test: Manually
Change-Id: I6a507d1f6f82e5ea6520f83279f73f851605c93f
parent b47bcf0e
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -388,10 +388,12 @@ public final class AudioAttributes implements Parcelable {
     */
     */
    public static final int FLAG_NO_SYSTEM_CAPTURE = 0x1 << 12;
    public static final int FLAG_NO_SYSTEM_CAPTURE = 0x1 << 12;


    // Note that even though FLAG_MUTE_HAPTIC is stored as a flag bit, it is not here since
    // it is known as a boolean value outside of AudioAttributes.
    private static final int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO
    private static final int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO
            | FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD | FLAG_BYPASS_INTERRUPTION_POLICY
            | FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD | FLAG_BYPASS_INTERRUPTION_POLICY
            | FLAG_BYPASS_MUTE | FLAG_LOW_LATENCY | FLAG_DEEP_BUFFER | FLAG_NO_MEDIA_PROJECTION
            | FLAG_BYPASS_MUTE | FLAG_LOW_LATENCY | FLAG_DEEP_BUFFER | FLAG_NO_MEDIA_PROJECTION
            | FLAG_MUTE_HAPTIC | FLAG_NO_SYSTEM_CAPTURE;
            | FLAG_NO_SYSTEM_CAPTURE;
    private final static int FLAG_ALL_PUBLIC = FLAG_AUDIBILITY_ENFORCED |
    private final static int FLAG_ALL_PUBLIC = FLAG_AUDIBILITY_ENFORCED |
            FLAG_HW_AV_SYNC | FLAG_LOW_LATENCY;
            FLAG_HW_AV_SYNC | FLAG_LOW_LATENCY;


@@ -598,8 +600,9 @@ public final class AudioAttributes implements Parcelable {
        public Builder(AudioAttributes aa) {
        public Builder(AudioAttributes aa) {
            mUsage = aa.mUsage;
            mUsage = aa.mUsage;
            mContentType = aa.mContentType;
            mContentType = aa.mContentType;
            mFlags = aa.mFlags;
            mFlags = aa.getAllFlags();
            mTags = (HashSet<String>) aa.mTags.clone();
            mTags = (HashSet<String>) aa.mTags.clone();
            mMuteHapticChannels = aa.areHapticChannelsMuted();
        }
        }


        /**
        /**
@@ -812,7 +815,7 @@ public final class AudioAttributes implements Parcelable {
                        AudioProductStrategy.getAudioAttributesForStrategyWithLegacyStreamType(
                        AudioProductStrategy.getAudioAttributesForStrategyWithLegacyStreamType(
                                streamType);
                                streamType);
                if (attributes != null) {
                if (attributes != null) {
                    return new Builder(attributes);
                    return new Builder(attributes).setHapticChannelsMuted(mMuteHapticChannels);
                }
                }
            }
            }
            switch(streamType) {
            switch(streamType) {