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

Commit 3b3d2ceb authored by William Escande's avatar William Escande
Browse files

Notification: Allow 1 hour window + fix time delta

The alarm that trigger the Bluetooth restart is a low power alarm. It's
wake up time may not be accurate.

To represent that from the notification point of view, we should look to
the date with a window

Also fix the condition for the notification to be displayed after 1 week
and after 6 months

Bug: 348884917
Fix: 348884917
Test: m .
Flag: Exempt trivial
Change-Id: If7e09143f347c6405e5d9259aa7a66101f5cc0ac
parent bcc2880e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -172,15 +172,18 @@ public class NotificationHelperService extends Service {
            // The notification is always displayed the first time and if it has been at least…:
            //  * … 1 week since the first display (aka recurring only once)
            //  * … 6 months since the last display (aka recurring forever)
            //
            // Comparison is +/- 1 hour, allowing for both battery optimisation and consistency

            if (date != null) {
                savedDate = LocalDateTime.parse(date);
                if ((countShown == 1 && now.isBefore(savedDate.plusWeeks(1)))
                        || now.isBefore(savedDate.plusMonths(6))) {
                if ((countShown != 1 && now.isBefore(savedDate.plusMonths(6).minusHours(1)))
                        || now.isBefore(savedDate.plusWeeks(1).minusHours(1))) {
                    Log.i(
                            TAG,
                            ("shouldDisplayNotification(" + countKey + "): Notification discarded.")
                                    + (" countShown=" + countShown)
                                    + (" now=" + now)
                                    + (" savedDate=" + savedDate));
                    return false;
                }
@@ -193,6 +196,7 @@ public class NotificationHelperService extends Service {
                TAG,
                ("shouldDisplayNotification(" + countKey + "): Notification is being shown.")
                        + (" countShown=" + countShown)
                        + (" now=" + now)
                        + (" savedDate=" + savedDate));
        return true;
    }