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

Commit 028a5397 authored by John Spurlock's avatar John Spurlock
Browse files

Zen: Calendar tracker should use event availability.

 - Ignore events that are marked as availability=free for consideration
   as DND trigger events.  All-day events are conventionally marked
   as free by default.

Bug: 20064962
Change-Id: Ie26c81a6b79bdd86444092886f9bc123470575a7
parent bc1a2ad8
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class CalendarTracker {
        Instances.EVENT_ID,
        Instances.OWNER_ACCOUNT,
        Instances.CALENDAR_ID,
        Instances.AVAILABILITY,
    };

    private static final String INSTANCE_ORDER_BY = Instances.BEGIN + " ASC";
@@ -143,11 +144,14 @@ public class CalendarTracker {
                final int eventId = cursor.getInt(4);
                final String owner = cursor.getString(5);
                final long calendarId = cursor.getLong(6);
                if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s eid=%s o=%s cid=%s", title,
                        new Date(begin), new Date(end), visible, eventId, owner, calendarId));
                final int availability = cursor.getInt(7);
                if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s a=%s eid=%s o=%s cid=%s", title,
                        new Date(begin), new Date(end), visible, availabilityToString(availability),
                        eventId, owner, calendarId));
                final boolean meetsTime = time >= begin && time < end;
                final boolean meetsCalendar = visible
                        && (filter.calendar == 0 || filter.calendar == calendarId);
                        && (filter.calendar == 0 || filter.calendar == calendarId)
                        && availability != Instances.AVAILABILITY_FREE;
                if (meetsCalendar) {
                    if (DEBUG) Log.d(TAG, "  MEETS CALENDAR");
                    final boolean meetsAttendee = meetsAttendee(filter, eventId, owner);
@@ -228,6 +232,15 @@ public class CalendarTracker {
        }
    }

    private static String availabilityToString(int availability) {
        switch (availability) {
            case Instances.AVAILABILITY_BUSY: return "AVAILABILITY_BUSY";
            case Instances.AVAILABILITY_FREE: return "AVAILABILITY_FREE";
            case Instances.AVAILABILITY_TENTATIVE: return "AVAILABILITY_TENTATIVE";
            default: return "AVAILABILITY_UNKNOWN_" + availability;
        }
    }

    private static boolean meetsReply(int reply, int attendeeStatus) {
        switch (reply) {
            case EventInfo.REPLY_YES: