Don't leak alarm wakelock when delivery fails

If an app sets an alarm and then cancels the underlying PendingIntent,
delivery will fail in such a way that the OnFinished callback is not
invoked.  The Alarm Manager relies on that callback for managing
wakelock lifetime, however; this meant that the wakelock acquisition
would leak, burning down the battery.

We now detect these sorts of delivery failures and manage the
wakelock appropriately.

Bug 25864361

Change-Id: I74af48e81002b29b129c41a76c0a8329c647390d
1 file changed