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

Commit fd45ba59 authored by Justin Klaassen's avatar Justin Klaassen Committed by android-build-merger
Browse files

Re-post notifs removed when AlarmService is destroyed

am: 460a4e02

* commit '460a4e02':
  Re-post notifs removed when AlarmService is destroyed
parents 2a781815 460a4e02
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -160,11 +160,23 @@ public class AlarmService extends Service {
            return;
        }

        LogUtils.v("AlarmService.stop with instance: %s", (Object) mCurrentAlarm.mId);
        final long instanceId = mCurrentAlarm.mId;
        LogUtils.v("AlarmService.stop with instance: %s", instanceId);

        AlarmKlaxon.stop(this);
        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
        sendBroadcast(new Intent(ALARM_DONE_ACTION));

        // Since we use the same id for all notifications, the system has no way to distinguish the
        // firing notification we were bound to from other subsequent notifications posted for the
        // same AlarmInstance (e.g. after snoozing). We workaround the issue by forcing removal of
        // the notification and re-posting it.
        stopForeground(true /* removeNotification */);
        mCurrentAlarm = AlarmInstance.getInstance(getContentResolver(), instanceId);
        if (mCurrentAlarm != null) {
            AlarmNotifications.updateNotification(this, mCurrentAlarm);
        }

        mCurrentAlarm = null;
        AlarmAlertWakeLock.releaseCpuLock();
    }