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

Commit e8d82e5d authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge "audio service: simplify becoming noisy intent logic" into oc-dev

am: 910311b3

Change-Id: I13cbf5a51eaa884527f4df79fe215e4b012082e0
parents c611b7ae 910311b3
Loading
Loading
Loading
Loading
+8 −21
Original line number Diff line number Diff line
@@ -5189,7 +5189,9 @@ public class AudioService extends IAudioService.Stub
    }

    // Devices which removal triggers intent ACTION_AUDIO_BECOMING_NOISY. The intent is only
    // sent if none of these devices is connected.
    // sent if:
    // - none of these devices are connected anymore after one is disconnected AND
    // - the device being disconnected is actually used for music.
    // Access synchronized on mConnectedDevices
    int mBecomingNoisyIntentDevices =
            AudioSystem.DEVICE_OUT_WIRED_HEADSET | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE |
@@ -5210,7 +5212,8 @@ public class AudioService extends IAudioService.Stub
                    devices |= dev;
                }
            }
            if (devices == device) {
            int musicDevice = getDeviceForStream(AudioSystem.STREAM_MUSIC);
            if ((device == musicDevice) && (device == devices)) {
                sendMsg(mAudioHandler,
                        MSG_BROADCAST_AUDIO_BECOMING_NOISY,
                        SENDMSG_REPLACE,
@@ -5829,25 +5832,9 @@ public class AudioService extends IAudioService.Stub

    // Must be called synchronized on mConnectedDevices
    private void setForceUseInt_SyncDevices(int usage, int config) {
        switch (usage) {
            case AudioSystem.FOR_MEDIA:
                if (config == AudioSystem.FORCE_NO_BT_A2DP) {
                    mBecomingNoisyIntentDevices &= ~AudioSystem.DEVICE_OUT_ALL_A2DP;
                } else { // config == AudioSystem.FORCE_NONE
                    mBecomingNoisyIntentDevices |= AudioSystem.DEVICE_OUT_ALL_A2DP;
                }
        if (usage == AudioSystem.FOR_MEDIA) {
            sendMsg(mAudioHandler, MSG_REPORT_NEW_ROUTES,
                    SENDMSG_NOOP, 0, 0, null, 0);
                break;
            case AudioSystem.FOR_DOCK:
                if (config == AudioSystem.FORCE_ANALOG_DOCK) {
                    mBecomingNoisyIntentDevices |= AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET;
                } else { // config == AudioSystem.FORCE_NONE
                    mBecomingNoisyIntentDevices &= ~AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET;
                }
                break;
            default:
                // usage doesn't affect the broadcast of ACTION_AUDIO_BECOMING_NOISY
        }
        AudioSystem.setForceUse(usage, config);
    }