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

Commit 5a2f0790 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by android-build-merger
Browse files

AudioService: more stringent on dropping ACTION_AUDIO_BECOMING_NOISY

am: c1adecd6

Change-Id: Ie2a7f82f97605c4e3684cecb128ad64bf14b9dc3
parents 1e577c1c c1adecd6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -406,6 +406,10 @@ import java.util.ArrayList;
        mAudioService.checkVolumeCecOnHdmiConnection(state, caller);
    }

    /*package*/ boolean hasAudioFocusUsers() {
        return mAudioService.hasAudioFocusUsers();
    }

    //---------------------------------------------------------------------
    // Message handling on behalf of helper classes
    /*package*/ void postBroadcastScoConnectionState(int state) {
+3 −2
Original line number Diff line number Diff line
@@ -819,11 +819,12 @@ public final class AudioDeviceInventory {
        if (((device == musicDevice) || mDeviceBroker.isInCommunication())
                && (device == devices) && !mDeviceBroker.hasMediaDynamicPolicy()
                        && ((musicDevice & AudioSystem.DEVICE_OUT_REMOTE_SUBMIX) == 0)) {
            if (!AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0 /*not looking in past*/)) {
            if (!AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0 /*not looking in past*/)
                    && !mDeviceBroker.hasAudioFocusUsers()) {
                // no media playback, not a "becoming noisy" situation, otherwise it could cause
                // the pausing of some apps that are playing remotely
                AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
                        "dropping ACTION_AUDIO_BECOMING_NOISY, no media playback")).printLog(TAG));
                        "dropping ACTION_AUDIO_BECOMING_NOISY")).printLog(TAG));
                return 0;
            }
            mDeviceBroker.postBroadcastBecomingNoisy();
+4 −0
Original line number Diff line number Diff line
@@ -5580,6 +5580,10 @@ public class AudioService extends IAudioService.Stub
        return mMediaFocusControl.getFocusRampTimeMs(focusGain, attr);
    }

    /*package*/ boolean hasAudioFocusUsers() {
        return mMediaFocusControl.hasAudioFocusUsers();
    }

    //==========================================================================================
    private boolean readCameraSoundForced() {
        return SystemProperties.getBoolean("audio.camerasound.force", false) ||
+6 −0
Original line number Diff line number Diff line
@@ -162,6 +162,12 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
        }
    }

    /*package*/ boolean hasAudioFocusUsers() {
        synchronized (mAudioFocusLock) {
            return !mFocusStack.empty();
        }
    }

    /**
     * Discard the current audio focus owner.
     * Notify top of audio focus stack that it lost focus (regardless of possibility to reassign