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

Commit f32feedd authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

Merge "AudioDeviceBroker: fix communication route update" into sc-dev am: f1416043

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13806829

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic99420d8e2d88b1cb750e9289047ca8652328483
parents f0769536 f1416043
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
     * @return true if speakerphone is active, false otherwise.
     */
    /*package*/ boolean isSpeakerphoneOn() {
        AudioDeviceAttributes device = getPreferredDeviceForComm();
        AudioDeviceAttributes device = getPreferredCommunicationDevice();
        if (device == null) {
            return false;
        }
@@ -595,7 +595,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
     * @return true if Bluetooth SCO is active , false otherwise.
     */
    /*package*/ boolean isBluetoothScoOn() {
        AudioDeviceAttributes device = getPreferredDeviceForComm();
        AudioDeviceAttributes device = getPreferredCommunicationDevice();
        if (device == null) {
            return false;
        }
@@ -1021,9 +1021,11 @@ import java.util.concurrent.atomic.AtomicBoolean;

        pw.println("\n" + prefix + "mPreferredCommunicationDevice: "
                +  mPreferredCommunicationDevice);

        pw.println(prefix + "Selected Communication Device: "
                +  ((getCommunicationDevice() == null) ? "None"
                        : new AudioDeviceAttributes(getCommunicationDevice())));

        pw.println(prefix + "mCommunicationStrategyId: "
                +  mCommunicationStrategyId);

@@ -1213,14 +1215,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
                case MSG_I_SET_MODE_OWNER_PID:
                    synchronized (mSetModeLock) {
                        synchronized (mDeviceStateLock) {
                            if (mModeOwnerPid != msg.arg1) {
                            mModeOwnerPid = msg.arg1;
                            if (msg.arg2 != AudioSystem.MODE_RINGTONE) {
                                onUpdateCommunicationRoute("setNewModeOwner");
                            }
                        }
                    }
                    }
                    break;
                case MSG_L_COMMUNICATION_ROUTE_CLIENT_DIED:
                    synchronized (mSetModeLock) {
@@ -1676,7 +1676,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
     * @return selected forced usage for communication.
     */
    @GuardedBy("mDeviceStateLock")
    @Nullable private AudioDeviceAttributes getPreferredDeviceForComm() {
    @Nullable private AudioDeviceAttributes getPreferredCommunicationDevice() {
        boolean btSCoOn = mBluetoothScoOn && mBtHelper.isBluetoothScoOn();
        if (btSCoOn) {
            // Use the SCO device known to BtHelper so that it matches exactly
@@ -1704,11 +1704,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
    // @GuardedBy("mSetModeLock")
    @GuardedBy("mDeviceStateLock")
    private void onUpdateCommunicationRoute(String eventSource) {
        mPreferredCommunicationDevice = getPreferredDeviceForComm();
        mPreferredCommunicationDevice = getPreferredCommunicationDevice();
        if (AudioService.DEBUG_COMM_RTE) {
            Log.v(TAG, "onUpdateCommunicationRoute, mPreferredCommunicationDevice: "
                    + mPreferredCommunicationDevice + " eventSource: " + eventSource);
        }
        AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
                "onUpdateCommunicationRoute, mPreferredCommunicationDevice: "
                + mPreferredCommunicationDevice + " eventSource: " + eventSource)));

        if (mPreferredCommunicationDevice == null
                || !AudioSystem.DEVICE_OUT_ALL_SCO_SET.contains(
+5 −0
Original line number Diff line number Diff line
@@ -662,6 +662,11 @@ public class AudioDeviceInventory {

    /*package*/ int removePreferredDevicesForStrategySync(int strategy) {
        final long identity = Binder.clearCallingIdentity();

        AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
                "removePreferredDevicesForStrategySync, strategy: "
                + strategy)).printLog(TAG));

        final int status = mAudioSystem.removeDevicesRoleForStrategy(
                strategy, AudioSystem.DEVICE_ROLE_PREFERRED);
        Binder.restoreCallingIdentity(identity);