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

Commit f1cef973 authored by Tomoharu Kasahara's avatar Tomoharu Kasahara Committed by android-build-merger
Browse files

Merge "Enable phone apps to mute the BLUETOOTH_SCO stream" am: 09d13a22 am: b0395aca

am: b4425070

Change-Id: I0f1f761460a27d510271e2110bd3588f34ce086c
parents 242a7d8f b4425070
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1100,7 +1100,8 @@ public class AudioSystem
            (1 << STREAM_RING) |
            (1 << STREAM_NOTIFICATION) |
            (1 << STREAM_SYSTEM) |
            (1 << STREAM_VOICE_CALL);
            (1 << STREAM_VOICE_CALL) |
            (1 << STREAM_BLUETOOTH_SCO);

    /**
     * Event posted by AudioTrack and AudioRecord JNI (JNIDeviceCallback) when routing changes.
+11 −6
Original line number Diff line number Diff line
@@ -1223,11 +1223,13 @@ public class AudioService extends IAudioService.Stub

    private void checkMuteAffectedStreams() {
        // any stream with a min level > 0 is not muteable by definition
        // STREAM_VOICE_CALL can be muted by applications that has the the MODIFY_PHONE_STATE permission.
        // STREAM_VOICE_CALL and STREAM_BLUETOOTH_SCO can be muted by applications
        // that has the the MODIFY_PHONE_STATE permission.
        for (int i = 0; i < mStreamStates.length; i++) {
            final VolumeStreamState vss = mStreamStates[i];
            if (vss.mIndexMin > 0 &&
                vss.mStreamType != AudioSystem.STREAM_VOICE_CALL) {
                (vss.mStreamType != AudioSystem.STREAM_VOICE_CALL &&
                vss.mStreamType != AudioSystem.STREAM_BLUETOOTH_SCO)) {
                mMuteAffectedStreams &= ~(1 << vss.mStreamType);
            }
        }
@@ -1711,10 +1713,11 @@ public class AudioService extends IAudioService.Stub
            return;
        }

        // If adjust is mute and the stream is STREAM_VOICE_CALL, make sure
        // If adjust is mute and the stream is STREAM_VOICE_CALL or STREAM_BLUETOOTH_SCO, make sure
        // that the calling app have the MODIFY_PHONE_STATE permission.
        if (isMuteAdjust &&
            streamType == AudioSystem.STREAM_VOICE_CALL &&
            (streamType == AudioSystem.STREAM_VOICE_CALL ||
                streamType == AudioSystem.STREAM_BLUETOOTH_SCO) &&
            mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.MODIFY_PHONE_STATE)
                    != PackageManager.PERMISSION_GRANTED) {
@@ -2038,12 +2041,14 @@ public class AudioService extends IAudioService.Stub
                    + " CHANGE_ACCESSIBILITY_VOLUME  callingPackage=" + callingPackage);
            return;
        }
        if ((streamType == AudioManager.STREAM_VOICE_CALL) &&
        if ((streamType == AudioManager.STREAM_VOICE_CALL ||
                streamType == AudioManager.STREAM_BLUETOOTH_SCO) &&
                (index == 0) &&
                (mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.MODIFY_PHONE_STATE)
                    != PackageManager.PERMISSION_GRANTED)) {
            Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL and index 0 without"
            Log.w(TAG, "Trying to call setStreamVolume() for STREAM_VOICE_CALL or"
                    + " STREAM_BLUETOOTH_SCO and index 0 without"
                    + " MODIFY_PHONE_STATE  callingPackage=" + callingPackage);
            return;
        }