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

Commit a68f0af5 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Use the Telecom lock in Telecom.Runnable

To prevent deadlocks in Telecom when using Session Runnables, we will
now lock on the main Telecom Lock instead of an independent lock inside
of Telecom.

Bug: 31076766
Change-Id: I993d7f2e8b077f89daef72ce1ca7b7fad2ad8823
(cherry picked from commit f5e06660)
parent e680e662
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class BluetoothManager {

    private BluetoothHeadsetProxy mBluetoothHeadset;
    private long mBluetoothConnectionRequestTime;
    private final Runnable mBluetoothConnectionTimeout = new Runnable("BM.cBA") {
    private final Runnable mBluetoothConnectionTimeout = new Runnable("BM.cBA", null /*lock*/) {
        @Override
        public void loggedRun() {
            if (!isBluetoothAudioConnected()) {
@@ -132,7 +132,7 @@ public class BluetoothManager {
        }
    };

    private final Runnable mRetryConnectAudio = new Runnable("BM.rCA") {
    private final Runnable mRetryConnectAudio = new Runnable("BM.rCA", null /*lock*/) {
        @Override
        public void loggedRun() {
            Log.i(this, "Retrying connecting to bluetooth audio.");
+2 −2
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public class CallerInfoLookupHelper {
            }
        }

        mHandler.post(new Runnable("CILH.sL") {
        mHandler.post(new Runnable("CILH.sL", mLock) {
            @Override
            public void loggedRun() {
                Session continuedSession = Log.createSubsession();
@@ -160,7 +160,7 @@ public class CallerInfoLookupHelper {
    }

    private void startPhotoLookup(final Uri handle, final Uri contactPhotoUri) {
        mHandler.post(new Runnable("CILH.sPL") {
        mHandler.post(new Runnable("CILH.sPL", mLock) {
            @Override
            public void loggedRun() {
                Session continuedSession = Log.createSubsession();
+8 −13
Original line number Diff line number Diff line
@@ -446,16 +446,13 @@ public class CallsManager extends Call.ListenerBase

            mDtmfLocalTonePlayer.playTone(call, nextChar);

            // TODO: Create a LockedRunnable class that does the synchronization automatically.
            mStopTone = new Runnable("CM.oPDC") {
            mStopTone = new Runnable("CM.oPDC", mLock) {
                @Override
                public void loggedRun() {
                    synchronized (mLock) {
                    // Set a timeout to stop the tone in case there isn't another tone to
                    // follow.
                    mDtmfLocalTonePlayer.stopTone(call);
                }
                }
            };
            mHandler.postDelayed(mStopTone.prepare(),
                    Timeouts.getDelayBetweenDtmfTonesMillis(mContext.getContentResolver()));
@@ -508,16 +505,14 @@ public class CallsManager extends Call.ListenerBase
    @Override
    public boolean onCanceledViaNewOutgoingCallBroadcast(final Call call) {
        mPendingCallsToDisconnect.add(call);
        mHandler.postDelayed(new Runnable("CM.oCVNOCB") {
        mHandler.postDelayed(new Runnable("CM.oCVNOCB", mLock) {
            @Override
            public void loggedRun() {
                synchronized (mLock) {
                if (mPendingCallsToDisconnect.remove(call)) {
                    Log.i(this, "Delayed disconnection of call: %s", call);
                    call.disconnect();
                }
            }
            }
        }.prepare(), Timeouts.getNewOutgoingCallCancelMillis(mContext.getContentResolver()));

        return true;
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ final class CreateConnectionTimeout extends Runnable {

    CreateConnectionTimeout(Context context, PhoneAccountRegistrar phoneAccountRegistrar,
            ConnectionServiceWrapper service, Call call) {
        super("CCT");
        super("CCT", null /*lock*/);
        mContext = context;
        mPhoneAccountRegistrar = phoneAccountRegistrar;
        mConnectionService = service;
+4 −6
Original line number Diff line number Diff line
@@ -661,16 +661,14 @@ public final class InCallController extends CallsManagerListenerBase {
             *  give them enough time to process all the pending messages.
             */
            Handler handler = new Handler(Looper.getMainLooper());
            handler.postDelayed(new Runnable("ICC.oCR") {
            handler.postDelayed(new Runnable("ICC.oCR", mLock) {
                @Override
                public void loggedRun() {
                    synchronized (mLock) {
                    // Check again to make sure there are no active calls.
                    if (mCallsManager.getCalls().isEmpty()) {
                        unbindFromServices();
                    }
                }
                }
            }.prepare(), Timeouts.getCallRemoveUnbindInCallServicesDelay(
                            mContext.getContentResolver()));
        }
Loading