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

Commit ca49d311 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioService: do not update ringer mode with broker lock held

Do not update ringer mode with AudioDeviceBroker state lock
  held from a BT event, by making the update run on the
  AudioService's event thread.

Bug: 124193282
Test: see bug

Change-Id: I46568c35846077905c33434054cd2c6566104b9e
parent 88d6fd81
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -280,9 +280,9 @@ import java.util.ArrayList;
                    AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, eventSource);
            sendIILMsgNoDelay(MSG_IIL_SET_FORCE_USE, SENDMSG_QUEUE,
                    AudioSystem.FOR_RECORD, mForcedUseForComm, eventSource);
            // Un-mute ringtone stream volume
            mAudioService.setUpdateRingerModeServiceInt();
        }
        // Un-mute ringtone stream volume
        mAudioService.postUpdateRingerModeServiceInt();
    }

    /*package*/ AudioRoutesInfo startWatchingRoutes(IAudioRoutesObserver observer) {
+10 −1
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@ public class AudioService extends IAudioService.Stub
    private static final int MSG_NOTIFY_VOL_EVENT = 22;
    private static final int MSG_DISPATCH_AUDIO_SERVER_STATE = 23;
    private static final int MSG_ENABLE_SURROUND_FORMATS = 24;
    private static final int MSG_UPDATE_RINGER_MODE = 25;
    // start of messages handled under wakelock
    //   these messages can only be queued, i.e. sent with queueMsgUnderWakeLock(),
    //   and not with sendMsg(..., ..., SENDMSG_QUEUE, ...)
@@ -2720,7 +2721,11 @@ public class AudioService extends IAudioService.Stub
        }
    }

    /*package*/ void setUpdateRingerModeServiceInt() {
    /*package*/ void postUpdateRingerModeServiceInt() {
        sendMsg(mAudioHandler, MSG_UPDATE_RINGER_MODE, SENDMSG_QUEUE, 0, 0, null, 0);
    }

    private void onUpdateRingerModeServiceInt() {
        setRingerModeInt(getRingerModeInternal(), false);
    }

@@ -4944,6 +4949,10 @@ public class AudioService extends IAudioService.Stub
                case MSG_ENABLE_SURROUND_FORMATS:
                    onEnableSurroundFormats((ArrayList<Integer>) msg.obj);
                    break;

                case MSG_UPDATE_RINGER_MODE:
                    onUpdateRingerModeServiceInt();
                    break;
            }
        }
    }