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

Commit 09d7d8f6 authored by Christopher Tate's avatar Christopher Tate
Browse files

Don't bother with WeakHashMap for direct alarm bookkeeping

Call cancel() explicitly before dropping local references to your
callback objects; they won't just quietly go away.

Bug 28987260

Change-Id: Id9da66ed86a46b4fb38127e2ddd7a7d84fd2313a
parent 9801a926
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -28,12 +28,12 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.WorkSource;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;

import libcore.util.ZoneInfoDB;

import java.io.IOException;
import java.util.WeakHashMap;

/**
 * This class provides access to the system alarm services.  These allow you
@@ -244,7 +244,7 @@ public class AlarmManager {

    // Tracking of the OnAlarmListener -> wrapper mapping, for cancel() support.
    // Access is synchronized on the AlarmManager class object.
    private static WeakHashMap<OnAlarmListener, ListenerWrapper> sWrappers;
    private static ArrayMap<OnAlarmListener, ListenerWrapper> sWrappers;

    /**
     * package private on purpose
@@ -631,7 +631,7 @@ public class AlarmManager {
        if (listener != null) {
            synchronized (AlarmManager.class) {
                if (sWrappers == null) {
                    sWrappers = new WeakHashMap<OnAlarmListener, ListenerWrapper>();
                    sWrappers = new ArrayMap<OnAlarmListener, ListenerWrapper>();
                }

                recipientWrapper = sWrappers.get(listener);