Disallow empty eventTimezone values. Do not merge

We now reject insert and update requests from apps that could result
in an Event with a null/empty eventTimezone column.

Bug 5514124 and 5497100

Cherry pick of https://android-git.corp.google.com/g/#/c/145982/

Change-Id: I5f3d1f5f797b5d1da3b24c4ca85d9afaa90449dc
diff --git a/src/com/android/providers/calendar/CalendarProvider2.java b/src/com/android/providers/calendar/CalendarProvider2.java
index dfa0056..755f330 100644
--- a/src/com/android/providers/calendar/CalendarProvider2.java
+++ b/src/com/android/providers/calendar/CalendarProvider2.java
@@ -2104,6 +2104,7 @@
                 id = handleInsertException(originalEventId, values, callerIsSyncAdapter);
                 break;
             case CALENDARS:
+                // TODO: verify that all required fields are present
                 Integer syncEvents = values.getAsInteger(Calendars.SYNC_EVENTS);
                 if (syncEvents != null && syncEvents == 1) {
                     String accountName = values.getAsString(Calendars.ACCOUNT_NAME);
@@ -2357,15 +2358,18 @@
      * @throws IllegalArgumentException if bad data is found.
      */
     private void validateEventData(ContentValues values) {
+        if (TextUtils.isEmpty(values.getAsString(Events.CALENDAR_ID))) {
+            throw new IllegalArgumentException("Event values must include a calendar_id");
+        }
+        if (TextUtils.isEmpty(values.getAsString(Events.EVENT_TIMEZONE))) {
+            throw new IllegalArgumentException("Event values must include an eventTimezone");
+        }
+
         boolean hasDtstart = values.getAsLong(Events.DTSTART) != null;
         boolean hasDtend = values.getAsLong(Events.DTEND) != null;
         boolean hasDuration = !TextUtils.isEmpty(values.getAsString(Events.DURATION));
         boolean hasRrule = !TextUtils.isEmpty(values.getAsString(Events.RRULE));
         boolean hasRdate = !TextUtils.isEmpty(values.getAsString(Events.RDATE));
-        boolean hasCalId = !TextUtils.isEmpty(values.getAsString(Events.CALENDAR_ID));
-        if (!hasCalId) {
-            throw new IllegalArgumentException("New events must include a calendar_id.");
-        }
         if (hasRrule || hasRdate) {
             if (!validateRecurrenceRule(values)) {
                 throw new IllegalArgumentException("Invalid recurrence rule: " +
@@ -2700,7 +2704,9 @@
 
     /**
      * Add LAST_DATE to values.
-     * @param values the ContentValues (in/out)
+     * @param values the ContentValues (in/out); must include DTSTART and, if the event is
+     *   recurring, the columns necessary to process a recurrence rule (RRULE, DURATION,
+     *   EVENT_TIMEZONE, etc).
      * @return values on success, null on failure
      */
     private ContentValues updateLastDate(ContentValues values) {