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

Commit 33ee4bf1 authored by Joe LaPenna's avatar Joe LaPenna
Browse files

Fix NPE in AlarmManager.cancel(...)

If AlarmManager.cancel is called before any component has had a chance
to register an alarm, sWrappers will not have been set, as it is only
initialized in setImpl.

When cancelling an alarm and sWrappers does not exist, log a warning and
return early.

BUG: 27972657
Change-Id: Ied10719ba1d154f97eecfc32f429fd9ce39bf747
parent 9d5aadd5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -905,12 +905,14 @@ public class AlarmManager {

        ListenerWrapper wrapper = null;
        synchronized (AlarmManager.class) {
            if (sWrappers != null) {
                final WeakReference<ListenerWrapper> wrapperRef;
                wrapperRef = sWrappers.get(listener);
                if (wrapperRef != null) {
                    wrapper = wrapperRef.get();
                }
            }
        }

        if (wrapper == null) {
            Log.w(TAG, "Unrecognized alarm listener " + listener);