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

Commit 785dfe7f authored by Hall Liu's avatar Hall Liu
Browse files

Fix race condition in Ringer

Race condition is as follows:
Initially: mIsVibrating == false

Thread 1: mVibrator.vibrate (maybeStartVibration)
Thread 2: checks mIsVibrating == false, doesn't bother stopping it
Thread 1: sets mVibrating = true
Thread 2: *never stops the vibrator*

Fix is to set mIsVibrating to true before actually starting the ringer.

Fixes: 140013629
Test: manual
Change-Id: I1eb0ee02ae54494691499e1c4fbf4dd6ae7760b5
parent 728c412a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -374,12 +374,12 @@ public class Ringer {
                    && mSystemSettingsUtil.enableRampingRingerFromDeviceConfig()
                    && isRingerAudible) {
                Log.i(this, "start vibration for ramping ringer.");
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
                mIsVibrating = true;
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
            } else {
                Log.i(this, "start normal vibration.");
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
                mIsVibrating = true;
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
            }
        } else if (mIsVibrating) {
            Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION, "already vibrating");