Accept the calendar name in addition to the owner as a calendar filter.
Because that's what settings has been storing in the rule definition
since M.
Bug: 25974117
Change-Id: I54aa3f06b143948aa7c826fc069bdb76055a6413
diff --git a/services/core/java/com/android/server/notification/CalendarTracker.java b/services/core/java/com/android/server/notification/CalendarTracker.java
index 783b16f..5d50f3b 100644
--- a/services/core/java/com/android/server/notification/CalendarTracker.java
+++ b/services/core/java/com/android/server/notification/CalendarTracker.java
@@ -43,14 +43,15 @@
private static final int EVENT_CHECK_LOOKAHEAD = 24 * 60 * 60 * 1000;
private static final String[] INSTANCE_PROJECTION = {
- Instances.BEGIN,
- Instances.END,
- Instances.TITLE,
- Instances.VISIBLE,
- Instances.EVENT_ID,
- Instances.OWNER_ACCOUNT,
- Instances.CALENDAR_ID,
- Instances.AVAILABILITY,
+ Instances.BEGIN,
+ Instances.END,
+ Instances.TITLE,
+ Instances.VISIBLE,
+ Instances.EVENT_ID,
+ Instances.CALENDAR_DISPLAY_NAME,
+ Instances.OWNER_ACCOUNT,
+ Instances.CALENDAR_ID,
+ Instances.AVAILABILITY,
};
private static final String INSTANCE_ORDER_BY = Instances.BEGIN + " ASC";
@@ -87,49 +88,6 @@
pw.print(prefix); pw.print("u="); pw.println(mUserContext.getUserId());
}
- public void dumpContent(Uri uri) {
- Log.d(TAG, "dumpContent: " + uri);
- final Cursor cursor = mUserContext.getContentResolver().query(uri, null, null, null, null);
- try {
- int r = 0;
- while (cursor.moveToNext()) {
- Log.d(TAG, "Row " + (++r) + ": id="
- + cursor.getInt(cursor.getColumnIndex(BaseColumns._ID)));
- for (int i = 0; i < cursor.getColumnCount(); i++) {
- final String name = cursor.getColumnName(i);
- final int type = cursor.getType(i);
- Object o = null;
- String typeName = null;
- switch (type) {
- case Cursor.FIELD_TYPE_INTEGER:
- o = cursor.getLong(i);
- typeName = "INTEGER";
- break;
- case Cursor.FIELD_TYPE_STRING:
- o = cursor.getString(i);
- typeName = "STRING";
- break;
- case Cursor.FIELD_TYPE_NULL:
- o = null;
- typeName = "NULL";
- break;
- default:
- throw new UnsupportedOperationException("type: " + type);
- }
- if (name.equals(BaseColumns._ID)
- || name.toLowerCase().contains("sync")
- || o == null) {
- continue;
- }
- Log.d(TAG, " " + name + "(" + typeName + ")=" + o);
- }
- }
- Log.d(TAG, " " + uri + " " + r + " rows");
- } finally {
- cursor.close();
- }
- }
-
private ArraySet<Long> getPrimaryCalendars() {
final long start = System.currentTimeMillis();
final ArraySet<Long> rt = new ArraySet<>();
@@ -170,18 +128,21 @@
final String title = cursor.getString(2);
final boolean calendarVisible = cursor.getInt(3) == 1;
final int eventId = cursor.getInt(4);
- final String owner = cursor.getString(5);
- final long calendarId = cursor.getLong(6);
- final int availability = cursor.getInt(7);
+ final String name = cursor.getString(5);
+ final String owner = cursor.getString(6);
+ final long calendarId = cursor.getLong(7);
+ final int availability = cursor.getInt(8);
final boolean calendarPrimary = primaryCalendars.contains(calendarId);
- if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s a=%s eid=%s o=%s cid=%s p=%s",
+ if (DEBUG) Log.d(TAG, String.format(
+ "%s %s-%s v=%s a=%s eid=%s n=%s o=%s cid=%s p=%s",
title,
new Date(begin), new Date(end), calendarVisible,
- availabilityToString(availability), eventId, owner, calendarId,
+ availabilityToString(availability), eventId, name, owner, calendarId,
calendarPrimary));
final boolean meetsTime = time >= begin && time < end;
final boolean meetsCalendar = calendarVisible && calendarPrimary
- && (filter.calendar == null || Objects.equals(filter.calendar, owner));
+ && (filter.calendar == null || Objects.equals(filter.calendar, owner)
+ || Objects.equals(filter.calendar, name));
final boolean meetsAvailability = availability != Instances.AVAILABILITY_FREE;
if (meetsCalendar && meetsAvailability) {
if (DEBUG) Log.d(TAG, " MEETS CALENDAR & AVAILABILITY");