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

Commit a6cec8fe authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

Synchronize SipWakeupTimer.onReceive()

to fix the race of two threads that change mPendingIntent; one assigns a new one
and the other nullifies it.

Change-Id: I5e01f83ea1ac437811d2073839adef9bd0a30ec9
parent 54fa6196
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ class SipWakeupTimer extends BroadcastReceiver {
        mEventQueue = null;
    }

    private synchronized boolean stopped() {
    private boolean stopped() {
        if (mEventQueue == null) {
            Log.w(TAG, "Timer stopped");
            return true;
@@ -233,7 +233,7 @@ class SipWakeupTimer extends BroadcastReceiver {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
    public synchronized void onReceive(Context context, Intent intent) {
        // This callback is already protected by AlarmManager's wake lock.
        String action = intent.getAction();
        if (getAction().equals(action)
@@ -261,7 +261,7 @@ class SipWakeupTimer extends BroadcastReceiver {
        }
    }

    private synchronized void execute(long triggerTime) {
    private void execute(long triggerTime) {
        if (DEBUG_TIMER) Log.d(TAG, "time's up, triggerTime = "
                + showTime(triggerTime) + ": " + mEventQueue.size());
        if (stopped() || mEventQueue.isEmpty()) return;