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

Commit eec8ee43 authored by Stanislav Zholnin's avatar Stanislav Zholnin Committed by Tej Singh
Browse files

Fix race condition on cancelling alarms

There was a race condition in which pulling alarms can be cancellled
after they are initialized, causing bucket boundary pulls to fail.

Test: manually verifified alarm consistently cancelled before being set
Test: manually verified alarms were properly cancelled on statsd crash
Fix: 156855909
Change-Id: I913b6f3e3d03269fb9283199f8b9d666a298e145
parent 1ecd4528
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -662,14 +662,19 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
            return;
        }

        // Cleann up from previous statsd - cancel any alarms that had been set. Do this here
        // instead of in binder death because statsd can come back and set different alarms, or not
        // want to set an alarm when it had been set. This guarantees that when we get a new statsd,
        // we cancel any alarms before it is able to set them.
        cancelAnomalyAlarm();
        cancelPullingAlarm();
        cancelAlarmForSubscriberTriggering();

        if (DEBUG) Log.d(TAG, "Saying hi to statsd");
        mStatsManagerService.statsdReady(statsd);
        try {
            statsd.statsCompanionReady();

            cancelAnomalyAlarm();
            cancelPullingAlarm();

            BroadcastReceiver appUpdateReceiver = new AppUpdateReceiver();
            BroadcastReceiver userUpdateReceiver = new UserUpdateReceiver();
            BroadcastReceiver shutdownEventReceiver = new ShutdownEventReceiver();