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

Commit bb0e88de authored by James Lemieux's avatar James Lemieux
Browse files

Avoid displaying two copies of the same alarm

Bug: 17903090

When an alarm is missed the alarm_instances table actually contains two
entries for the same alarm.

- one represents the missed alarm
- one represents the next upcoming alarm

The query that joins alarm_templates to alarm_instances would return
two rows for the same alarm in this case. Since the alarm_instance data
is used offer a predismiss button in the UI, it is fine to ignore the
missed alarm in this join.

Change-Id: I720e48c9274b42d3cda9d57d3eef099c5dcd3902
parent 00b18f16
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -95,6 +95,9 @@ public class ClockProvider extends ContentProvider {
            ALARMS_TABLE_NAME + " LEFT JOIN " + INSTANCES_TABLE_NAME + " ON (" +
            ALARMS_TABLE_NAME + "." + AlarmsColumns._ID + " = " + InstancesColumns.ALARM_ID + ")";

    private static final String ALARM_JOIN_INSTANCE_WHERE_STATEMENT =
            InstancesColumns.ALARM_STATE + " != " + InstancesColumns.MISSED_STATE;

    private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
    static {
        sURIMatcher.addURI(ClockContract.AUTHORITY, "alarms", ALARMS);
@@ -140,6 +143,7 @@ public class ClockProvider extends ContentProvider {
                break;
            case ALARMS_WITH_INSTANCES:
                qb.setTables(ALARM_JOIN_INSTANCE_TABLE_STATEMENT);
                qb.appendWhere(ALARM_JOIN_INSTANCE_WHERE_STATEMENT);
                qb.setProjectionMap(sAlarmsWithInstancesProjection);
                break;
            default: