blob: 3e5bd4b7251372c488ae02e16ef60024868011ae [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.provider;
18
yuemingw369f96d2018-12-05 22:07:04 +000019import android.annotation.NonNull;
RoboErik36726962011-06-14 14:01:15 -070020import android.annotation.SdkConstant;
21import android.annotation.SdkConstant.SdkConstantType;
Jeff Sharkeycb269aac2019-01-25 11:15:38 -070022import android.annotation.TestApi;
Mathew Inwood6750f2e2018-08-10 09:29:25 +010023import android.annotation.UnsupportedAppUsage;
Michael Chan37960c72012-04-19 00:18:13 -070024import android.app.Activity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.app.AlarmManager;
26import android.app.PendingIntent;
yuemingwb714ba02018-10-26 18:54:44 +010027import android.app.admin.DevicePolicyManager;
28import android.content.ComponentName;
Marc Blank64a556d2010-02-25 12:53:16 -080029import android.content.ContentProviderClient;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.ContentResolver;
31import android.content.ContentUris;
32import android.content.ContentValues;
33import android.content.Context;
Fred Quintana328c0e72009-12-07 14:52:28 -080034import android.content.CursorEntityIterator;
35import android.content.Entity;
Marc Blank64a556d2010-02-25 12:53:16 -080036import android.content.EntityIterator;
37import android.content.Intent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038import android.database.Cursor;
Fred Quintana328c0e72009-12-07 14:52:28 -080039import android.database.DatabaseUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.net.Uri;
Michael Chancdaeafd2009-10-29 00:11:58 -070041import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import android.text.format.DateUtils;
43import android.text.format.Time;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045
yuemingw369f96d2018-12-05 22:07:04 +000046import com.android.internal.util.Preconditions;
47
yuemingwd2bfbc82019-01-02 11:42:25 +000048import java.util.Set;
49
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050/**
RoboErik260598d2011-06-13 17:12:12 -070051 * <p>
52 * The contract between the calendar provider and applications. Contains
53 * definitions for the supported URIs and data columns.
54 * </p>
55 * <h3>Overview</h3>
56 * <p>
57 * CalendarContract defines the data model of calendar and event related
58 * information. This data is stored in a number of tables:
59 * </p>
60 * <ul>
61 * <li>The {@link Calendars} table holds the calendar specific information. Each
62 * row in this table contains the details for a single calendar, such as the
63 * name, color, sync info, etc.</li>
64 * <li>The {@link Events} table holds the event specific information. Each row
65 * in this table has the info for a single event. It contains information such
66 * as event title, location, start time, end time, etc. The event can occur
67 * one-time or can recur multiple times. Attendees, reminders, and extended
68 * properties are stored on separate tables and reference the {@link Events#_ID}
69 * to link them with the event.</li>
70 * <li>The {@link Instances} table holds the start and end time for occurrences
71 * of an event. Each row in this table represents a single occurrence. For
72 * one-time events there will be a 1:1 mapping of instances to events. For
73 * recurring events, multiple rows will automatically be generated which
74 * correspond to multiple occurrences of that event.</li>
75 * <li>The {@link Attendees} table holds the event attendee or guest
76 * information. Each row represents a single guest of an event. It specifies the
77 * type of guest they are and their attendance response for the event.</li>
78 * <li>The {@link Reminders} table holds the alert/notification data. Each row
79 * represents a single alert for an event. An event can have multiple reminders.
80 * The number of reminders per event is specified in
81 * {@link Calendars#MAX_REMINDERS} which is set by the Sync Adapter that owns
82 * the given calendar. Reminders are specified in minutes before the event and
83 * have a type.</li>
Michael Chan73bddfc2011-10-19 18:21:49 -070084 * <li>The {@link ExtendedProperties} table holds opaque data fields used by the
RoboErik260598d2011-06-13 17:12:12 -070085 * sync adapter. The provider takes no action with items in this table except to
86 * delete them when their related events are deleted.</li>
87 * </ul>
88 * <p>
89 * Other tables include:
90 * </p>
91 * <ul>
92 * <li>
93 * {@link SyncState}, which contains free-form data maintained by the sync
94 * adapters</li>
95 * </ul>
RoboErikbec6c362011-06-14 11:06:01 -070096 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 */
RoboErikbec6c362011-06-14 11:06:01 -070098public final class CalendarContract {
RoboErikc2d53302011-06-03 09:37:58 -070099 private static final String TAG = "Calendar";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100
101 /**
RoboErikc2d53302011-06-03 09:37:58 -0700102 * Broadcast Action: This is the intent that gets fired when an alarm
103 * notification needs to be posted for a reminder.
RoboErik083cd2d2011-06-30 11:53:05 -0700104 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 */
RoboErik36726962011-06-14 14:01:15 -0700106 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
RoboErike00d5892011-06-23 15:16:55 -0700107 public static final String ACTION_EVENT_REMINDER = "android.intent.action.EVENT_REMINDER";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108
109 /**
Michael Chan37960c72012-04-19 00:18:13 -0700110 * Activity Action: Display the event to the user in the custom app as
111 * specified in {@link EventsColumns#CUSTOM_APP_PACKAGE}. The custom app
112 * will be started via {@link Activity#startActivityForResult(Intent, int)}
113 * and it should call {@link Activity#setResult(int)} with
114 * {@link Activity#RESULT_OK} or {@link Activity#RESULT_CANCELED} to
115 * acknowledge whether the action was handled or not.
Michael Chan9a9001f2012-05-14 18:27:27 -0700116 *
kmccormicke4ce5022013-04-03 14:00:19 -0700117 * The custom app should have an intent filter like the following:
Michael Chan9a9001f2012-05-14 18:27:27 -0700118 * <pre>
kmccormicke4ce5022013-04-03 14:00:19 -0700119 * &lt;intent-filter&gt;
120 * &lt;action android:name="android.provider.calendar.action.HANDLE_CUSTOM_EVENT" /&gt;
121 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
122 * &lt;data android:mimeType="vnd.android.cursor.item/event" /&gt;
123 * &lt;/intent-filter&gt;</pre>
Michael Chan37960c72012-04-19 00:18:13 -0700124 * <p>
125 * Input: {@link Intent#getData} has the event URI. The extra
126 * {@link #EXTRA_EVENT_BEGIN_TIME} has the start time of the instance. The
127 * extra {@link #EXTRA_CUSTOM_APP_URI} will have the
128 * {@link EventsColumns#CUSTOM_APP_URI}.
129 * <p>
130 * Output: {@link Activity#RESULT_OK} if this was handled; otherwise
kmccormicke4ce5022013-04-03 14:00:19 -0700131 * {@link Activity#RESULT_CANCELED}.
Michael Chan37960c72012-04-19 00:18:13 -0700132 */
133 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
134 public static final String ACTION_HANDLE_CUSTOM_EVENT =
135 "android.provider.calendar.action.HANDLE_CUSTOM_EVENT";
136
137 /**
yuemingw369f96d2018-12-05 22:07:04 +0000138 * Action used to help apps show calendar events in the managed profile.
139 */
140 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
yuemingw05896da2019-01-29 11:30:42 +0000141 public static final String ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT =
142 "android.provider.calendar.action.VIEW_MANAGED_PROFILE_CALENDAR_EVENT";
yuemingw369f96d2018-12-05 22:07:04 +0000143
144 /**
Michael Chan37960c72012-04-19 00:18:13 -0700145 * Intent Extras key: {@link EventsColumns#CUSTOM_APP_URI} for the event in
146 * the {@link #ACTION_HANDLE_CUSTOM_EVENT} intent
147 */
Michael Chanf0c4c652012-04-19 16:27:46 -0700148 public static final String EXTRA_CUSTOM_APP_URI = "customAppUri";
Michael Chan37960c72012-04-19 00:18:13 -0700149
150 /**
RoboErikc2d53302011-06-03 09:37:58 -0700151 * Intent Extras key: The start time of an event or an instance of a
152 * recurring event. (milliseconds since epoch)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153 */
RoboErike00d5892011-06-23 15:16:55 -0700154 public static final String EXTRA_EVENT_BEGIN_TIME = "beginTime";
RoboErikc2d53302011-06-03 09:37:58 -0700155
156 /**
157 * Intent Extras key: The end time of an event or an instance of a recurring
158 * event. (milliseconds since epoch)
159 */
RoboErike00d5892011-06-23 15:16:55 -0700160 public static final String EXTRA_EVENT_END_TIME = "endTime";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161
Erike9b734d2011-02-14 13:32:19 -0800162 /**
Michael Chan7420f132011-08-25 00:54:25 -0700163 * Intent Extras key: When creating an event, set this to true to create an
164 * all-day event by default
165 */
166 public static final String EXTRA_EVENT_ALL_DAY = "allDay";
167
168 /**
yuemingw05896da2019-01-29 11:30:42 +0000169 * Intent Extras key: An extra of type {@code long} holding the id of an event.
yuemingw369f96d2018-12-05 22:07:04 +0000170 */
171 public static final String EXTRA_EVENT_ID = "id";
172
173 /**
RoboErikc2d53302011-06-03 09:37:58 -0700174 * This authority is used for writing to or querying from the calendar
175 * provider. Note: This is set at first run and cannot be changed without
176 * breaking apps that access the provider.
Erike9b734d2011-02-14 13:32:19 -0800177 */
Ken Shirriff1790c132010-01-22 13:45:31 -0800178 public static final String AUTHORITY = "com.android.calendar";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179
180 /**
181 * The content:// style URL for the top-level calendar authority
182 */
RoboErik083cd2d2011-06-30 11:53:05 -0700183 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184
185 /**
Ken Shirriff5b387e12009-10-23 09:50:41 -0700186 * An optional insert, update or delete URI parameter that allows the caller
RoboErikc2d53302011-06-03 09:37:58 -0700187 * to specify that it is a sync adapter. The default value is false. If set
188 * to true, the modified row is not marked as "dirty" (needs to be synced)
189 * and when the provider calls
190 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}
191 * , the third parameter "syncToNetwork" is set to false. Furthermore, if
192 * set to true, the caller must also include
Andy McFadden6f5b4552011-06-09 15:43:59 -0700193 * {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as
RoboErikc2d53302011-06-03 09:37:58 -0700194 * query parameters.
195 *
Andy McFadden6f5b4552011-06-09 15:43:59 -0700196 * @see Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)
Ken Shirriff5b387e12009-10-23 09:50:41 -0700197 */
198 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
199
RoboErikc2d53302011-06-03 09:37:58 -0700200 /**
201 * A special account type for calendars not associated with any account.
202 * Normally calendars that do not match an account on the device will be
203 * removed. Setting the account_type on a calendar to this will prevent it
204 * from being wiped if it does not match an existing account.
205 *
206 * @see SyncColumns#ACCOUNT_TYPE
207 */
208 public static final String ACCOUNT_TYPE_LOCAL = "LOCAL";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700209
210 /**
RoboErik36726962011-06-14 14:01:15 -0700211 * This utility class cannot be instantiated
212 */
213 private CalendarContract() {}
214
215 /**
yuemingw369f96d2018-12-05 22:07:04 +0000216 * Starts an activity to view calendar events in the managed profile.
217 *
218 * When this API is called, the system will attempt to start an activity
219 * in the managed profile with an intent targeting the same caller package.
220 * The intent will have its action set to
yuemingw05896da2019-01-29 11:30:42 +0000221 * {@link CalendarContract#ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT} and contain extras
yuemingw369f96d2018-12-05 22:07:04 +0000222 * corresponding to the API's arguments. A calendar app intending to support
yuemingwd2bfbc82019-01-02 11:42:25 +0000223 * cross-profile events viewing should handle this intent, parse the arguments
yuemingw369f96d2018-12-05 22:07:04 +0000224 * and show the appropriate UI.
225 *
226 * @param context the context.
227 * @param eventId the id of the event to be viewed. Will be put into {@link #EXTRA_EVENT_ID}
228 * field of the intent.
yuemingw05896da2019-01-29 11:30:42 +0000229 * @param startMs the start time of the event in milliseconds since epoch.
230 * Will be put into {@link #EXTRA_EVENT_BEGIN_TIME} field of the intent.
231 * @param endMs the end time of the event in milliseconds since epoch.
232 * Will be put into {@link #EXTRA_EVENT_END_TIME} field of the intent.
yuemingw369f96d2018-12-05 22:07:04 +0000233 * @param allDay if the event is an all-day event. Will be put into
234 * {@link #EXTRA_EVENT_ALL_DAY} field of the intent.
235 * @param flags flags to be set on the intent via {@link Intent#setFlags}
236 * @return {@code true} if the activity is started successfully. {@code false} otherwise.
237 *
238 * @see #EXTRA_EVENT_ID
239 * @see #EXTRA_EVENT_BEGIN_TIME
240 * @see #EXTRA_EVENT_END_TIME
241 * @see #EXTRA_EVENT_ALL_DAY
242 */
243 public static boolean startViewCalendarEventInManagedProfile(@NonNull Context context,
yuemingw05896da2019-01-29 11:30:42 +0000244 long eventId, long startMs, long endMs, boolean allDay, int flags) {
yuemingw369f96d2018-12-05 22:07:04 +0000245 Preconditions.checkNotNull(context, "Context is null");
246 final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
247 Context.DEVICE_POLICY_SERVICE);
yuemingw05896da2019-01-29 11:30:42 +0000248 return dpm.startViewCalendarEventInManagedProfile(eventId, startMs,
249 endMs, allDay, flags);
yuemingw369f96d2018-12-05 22:07:04 +0000250 }
251
252 /**
RoboErikc2d53302011-06-03 09:37:58 -0700253 * Generic columns for use by sync adapters. The specific functions of these
254 * columns are private to the sync adapter. Other clients of the API should
255 * not attempt to either read or write this column. These columns are
256 * editable as part of the Calendars Uri, but can only be read if accessed
257 * through any other Uri.
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700258 */
RoboErikc2d53302011-06-03 09:37:58 -0700259 protected interface CalendarSyncColumns {
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700260
RoboErik9734df52011-06-09 14:11:25 -0700261
262 /**
263 * Generic column for use by sync adapters. Column name.
264 * <P>Type: TEXT</P>
265 */
RoboErikbe010392011-05-26 12:28:38 -0700266 public static final String CAL_SYNC1 = "cal_sync1";
RoboErik9734df52011-06-09 14:11:25 -0700267
268 /**
269 * Generic column for use by sync adapters. Column name.
270 * <P>Type: TEXT</P>
271 */
RoboErikbe010392011-05-26 12:28:38 -0700272 public static final String CAL_SYNC2 = "cal_sync2";
RoboErik9734df52011-06-09 14:11:25 -0700273
274 /**
275 * Generic column for use by sync adapters. Column name.
276 * <P>Type: TEXT</P>
277 */
RoboErikbe010392011-05-26 12:28:38 -0700278 public static final String CAL_SYNC3 = "cal_sync3";
RoboErik9734df52011-06-09 14:11:25 -0700279
280 /**
281 * Generic column for use by sync adapters. Column name.
282 * <P>Type: TEXT</P>
283 */
RoboErikbe010392011-05-26 12:28:38 -0700284 public static final String CAL_SYNC4 = "cal_sync4";
RoboErik9734df52011-06-09 14:11:25 -0700285
286 /**
287 * Generic column for use by sync adapters. Column name.
288 * <P>Type: TEXT</P>
289 */
RoboErikbe010392011-05-26 12:28:38 -0700290 public static final String CAL_SYNC5 = "cal_sync5";
RoboErik9734df52011-06-09 14:11:25 -0700291
292 /**
293 * Generic column for use by sync adapters. Column name.
294 * <P>Type: TEXT</P>
295 */
RoboErikbe010392011-05-26 12:28:38 -0700296 public static final String CAL_SYNC6 = "cal_sync6";
RoboErik9734df52011-06-09 14:11:25 -0700297
298 /**
299 * Generic column for use by sync adapters. Column name.
300 * <P>Type: TEXT</P>
301 */
302 public static final String CAL_SYNC7 = "cal_sync7";
303
304 /**
305 * Generic column for use by sync adapters. Column name.
306 * <P>Type: TEXT</P>
307 */
308 public static final String CAL_SYNC8 = "cal_sync8";
309
310 /**
311 * Generic column for use by sync adapters. Column name.
312 * <P>Type: TEXT</P>
313 */
314 public static final String CAL_SYNC9 = "cal_sync9";
315
316 /**
317 * Generic column for use by sync adapters. Column name.
318 * <P>Type: TEXT</P>
319 */
320 public static final String CAL_SYNC10 = "cal_sync10";
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700321 }
322
323 /**
RoboErikc2d53302011-06-03 09:37:58 -0700324 * Columns for Sync information used by Calendars and Events tables. These
325 * have specific uses which are expected to be consistent by the app and
326 * sync adapter.
327 *
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700328 */
RoboErik00258602011-06-13 13:47:59 -0700329 protected interface SyncColumns extends CalendarSyncColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700330 /**
RoboErikc2d53302011-06-03 09:37:58 -0700331 * The account that was used to sync the entry to the device. If the
332 * account_type is not {@link #ACCOUNT_TYPE_LOCAL} then the name and
333 * type must match an account on the device or the calendar will be
334 * deleted.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700335 * <P>Type: TEXT</P>
336 */
RoboErik651c02e2011-05-05 15:14:31 -0700337 public static final String ACCOUNT_NAME = "account_name";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700338
339 /**
RoboErikc2d53302011-06-03 09:37:58 -0700340 * The type of the account that was used to sync the entry to the
341 * device. A type of {@link #ACCOUNT_TYPE_LOCAL} will keep this event
342 * form being deleted if there are no matching accounts on the device.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700343 * <P>Type: TEXT</P>
344 */
RoboErik651c02e2011-05-05 15:14:31 -0700345 public static final String ACCOUNT_TYPE = "account_type";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700346
347 /**
RoboErikc2d53302011-06-03 09:37:58 -0700348 * The unique ID for a row assigned by the sync source. NULL if the row
349 * has never been synced. This is used as a reference id for exceptions
350 * along with {@link BaseColumns#_ID}.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700351 * <P>Type: TEXT</P>
352 */
353 public static final String _SYNC_ID = "_sync_id";
354
355 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700356 * Used to indicate that local, unsynced, changes are present.
357 * <P>Type: INTEGER (long)</P>
358 */
Alon Albert8ac6a632012-12-17 17:21:18 -0800359
RoboErik651c02e2011-05-05 15:14:31 -0700360 public static final String DIRTY = "dirty";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700361
Alon Albert866f40a2011-06-06 14:04:00 -0700362 /**
Alon Albert8ac6a632012-12-17 17:21:18 -0800363 * Used in conjunction with {@link #DIRTY} to indicate what packages wrote local changes.
364 * <P>Type: TEXT</P>
365 */
366 public static final String MUTATORS = "mutators";
367
368 /**
RoboErik9734df52011-06-09 14:11:25 -0700369 * Whether the row has been deleted but not synced to the server. A
370 * deleted row should be ignored.
371 * <P>
372 * Type: INTEGER (boolean)
373 * </P>
374 */
375 public static final String DELETED = "deleted";
376
377 /**
Alon Albert866f40a2011-06-06 14:04:00 -0700378 * If set to 1 this causes events on this calendar to be duplicated with
RoboErik00258602011-06-13 13:47:59 -0700379 * {@link Events#LAST_SYNCED} set to 1 whenever the event
RoboErik9734df52011-06-09 14:11:25 -0700380 * transitions from non-dirty to dirty. The duplicated event will not be
381 * expanded in the instances table and will only show up in sync adapter
382 * queries of the events table. It will also be deleted when the
Alon Albert866f40a2011-06-06 14:04:00 -0700383 * originating event has its dirty flag cleared by the sync adapter.
384 * <P>Type: INTEGER (boolean)</P>
385 */
386 public static final String CAN_PARTIALLY_UPDATE = "canPartiallyUpdate";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700387 }
388
389 /**
RoboErikc2d53302011-06-03 09:37:58 -0700390 * Columns specific to the Calendars Uri that other Uris can query.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800391 */
RoboErike00d5892011-06-23 15:16:55 -0700392 protected interface CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393 /**
RoboErik4f520612011-09-19 17:47:53 -0700394 * The color of the calendar. This should only be updated by the sync
395 * adapter, not other apps, as changing a calendar's color can adversely
396 * affect its display.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 * <P>Type: INTEGER (color value)</P>
398 */
RoboErik651c02e2011-05-05 15:14:31 -0700399 public static final String CALENDAR_COLOR = "calendar_color";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400
401 /**
RoboErik4172d952011-10-25 13:59:13 -0700402 * A key for looking up a color from the {@link Colors} table. NULL or
403 * an empty string are reserved for indicating that the calendar does
404 * not use a key for looking up the color. The provider will update
405 * {@link #CALENDAR_COLOR} automatically when a valid key is written to
406 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -0700407 * {@link Colors} table. @see Colors
RoboErikf8143c52011-09-28 15:16:00 -0700408 * <P>
409 * Type: TEXT
410 * </P>
RoboErikf8143c52011-09-28 15:16:00 -0700411 */
RoboErik4172d952011-10-25 13:59:13 -0700412 public static final String CALENDAR_COLOR_KEY = "calendar_color_index";
RoboErikf8143c52011-09-28 15:16:00 -0700413
414 /**
RoboErik9734df52011-06-09 14:11:25 -0700415 * The display name of the calendar. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700416 * <P>
417 * Type: TEXT
418 * </P>
RoboErik9734df52011-06-09 14:11:25 -0700419 */
420 public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName";
421
422 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 * The level of access that the user has for the calendar
424 * <P>Type: INTEGER (one of the values below)</P>
425 */
RoboErik9734df52011-06-09 14:11:25 -0700426 public static final String CALENDAR_ACCESS_LEVEL = "calendar_access_level";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800427
428 /** Cannot access the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700429 public static final int CAL_ACCESS_NONE = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800430 /** Can only see free/busy information about the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700431 public static final int CAL_ACCESS_FREEBUSY = 100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 /** Can read all event details */
RoboErik9734df52011-06-09 14:11:25 -0700433 public static final int CAL_ACCESS_READ = 200;
RoboErikc2d53302011-06-03 09:37:58 -0700434 /** Can reply yes/no/maybe to an event */
RoboErik9734df52011-06-09 14:11:25 -0700435 public static final int CAL_ACCESS_RESPOND = 300;
RoboErikc2d53302011-06-03 09:37:58 -0700436 /** not used */
RoboErik9734df52011-06-09 14:11:25 -0700437 public static final int CAL_ACCESS_OVERRIDE = 400;
RoboErikc2d53302011-06-03 09:37:58 -0700438 /** Full access to modify the calendar, but not the access control
439 * settings
440 */
RoboErik9734df52011-06-09 14:11:25 -0700441 public static final int CAL_ACCESS_CONTRIBUTOR = 500;
RoboErikc2d53302011-06-03 09:37:58 -0700442 /** Full access to modify the calendar, but not the access control
443 * settings
444 */
RoboErik9734df52011-06-09 14:11:25 -0700445 public static final int CAL_ACCESS_EDITOR = 600;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 /** Full access to the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700447 public static final int CAL_ACCESS_OWNER = 700;
Debajit Ghosh2dcaafd2009-09-18 18:29:37 -0700448 /** Domain admin */
RoboErik9734df52011-06-09 14:11:25 -0700449 public static final int CAL_ACCESS_ROOT = 800;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450
451 /**
452 * Is the calendar selected to be displayed?
RoboErikc2d53302011-06-03 09:37:58 -0700453 * 0 - do not show events associated with this calendar.
454 * 1 - show events associated with this calendar
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 * <P>Type: INTEGER (boolean)</P>
456 */
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700457 public static final String VISIBLE = "visible";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458
459 /**
RoboErikc2d53302011-06-03 09:37:58 -0700460 * The time zone the calendar is associated with.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800461 * <P>Type: TEXT</P>
462 */
RoboErik9734df52011-06-09 14:11:25 -0700463 public static final String CALENDAR_TIME_ZONE = "calendar_timezone";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800464
465 /**
RoboErikc2d53302011-06-03 09:37:58 -0700466 * Is this calendar synced and are its events stored on the device?
467 * 0 - Do not sync this calendar or store events for this calendar.
468 * 1 - Sync down events for this calendar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800469 * <p>Type: INTEGER (boolean)</p>
470 */
471 public static final String SYNC_EVENTS = "sync_events";
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700472
473 /**
RoboErik9734df52011-06-09 14:11:25 -0700474 * The owner account for this calendar, based on the calendar feed.
475 * This will be different from the _SYNC_ACCOUNT for delegated calendars.
476 * Column name.
477 * <P>Type: String</P>
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700478 */
RoboErik9734df52011-06-09 14:11:25 -0700479 public static final String OWNER_ACCOUNT = "ownerAccount";
Fred Quintana328c0e72009-12-07 14:52:28 -0800480
481 /**
RoboErik9734df52011-06-09 14:11:25 -0700482 * Can the organizer respond to the event? If no, the status of the
483 * organizer should not be shown by the UI. Defaults to 1. Column name.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700484 * <P>Type: INTEGER (boolean)</P>
Fred Quintana328c0e72009-12-07 14:52:28 -0800485 */
RoboErik9734df52011-06-09 14:11:25 -0700486 public static final String CAN_ORGANIZER_RESPOND = "canOrganizerRespond";
487
488 /**
489 * Can the organizer modify the time zone of the event? Column name.
490 * <P>Type: INTEGER (boolean)</P>
491 */
492 public static final String CAN_MODIFY_TIME_ZONE = "canModifyTimeZone";
493
494 /**
495 * The maximum number of reminders allowed for an event. Column name.
496 * <P>Type: INTEGER</P>
497 */
498 public static final String MAX_REMINDERS = "maxReminders";
499
500 /**
501 * A comma separated list of reminder methods supported for this
502 * calendar in the format "#,#,#". Valid types are
503 * {@link Reminders#METHOD_DEFAULT}, {@link Reminders#METHOD_ALERT},
Alon Albertbd251612012-02-23 10:30:51 -0800504 * {@link Reminders#METHOD_EMAIL}, {@link Reminders#METHOD_SMS},
505 * {@link Reminders#METHOD_ALARM}. Column name.
RoboErik9734df52011-06-09 14:11:25 -0700506 * <P>Type: TEXT</P>
507 */
508 public static final String ALLOWED_REMINDERS = "allowedReminders";
RoboErikf8143c52011-09-28 15:16:00 -0700509
510 /**
511 * A comma separated list of availability types supported for this
512 * calendar in the format "#,#,#". Valid types are
513 * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE},
514 * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only
515 * {@link Events#AVAILABILITY_BUSY} should be used to indicate that
516 * changing the availability is not supported.
517 *
RoboErikf8143c52011-09-28 15:16:00 -0700518 */
519 public static final String ALLOWED_AVAILABILITY = "allowedAvailability";
520
521 /**
522 * A comma separated list of attendee types supported for this calendar
523 * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE},
524 * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED},
525 * {@link Attendees#TYPE_RESOURCE}. Setting this field to only
526 * {@link Attendees#TYPE_NONE} should be used to indicate that changing
527 * the attendee type is not supported.
528 *
RoboErikf8143c52011-09-28 15:16:00 -0700529 */
530 public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes";
Alon Albert0a9a2192012-09-18 11:10:49 -0700531
532 /**
533 * Is this the primary calendar for this account. If this column is not explicitly set, the
534 * provider will return 1 if {@link Calendars#ACCOUNT_NAME} is equal to
535 * {@link Calendars#OWNER_ACCOUNT}.
536 */
537 public static final String IS_PRIMARY = "isPrimary";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800538 }
539
540 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700541 * Class that represents a Calendar Entity. There is one entry per calendar.
RoboErikc2d53302011-06-03 09:37:58 -0700542 * This is a helper class to make batch operations easier.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700543 */
RoboErik36726962011-06-14 14:01:15 -0700544 public static final class CalendarEntity implements BaseColumns, SyncColumns, CalendarColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700545
RoboErikc2d53302011-06-03 09:37:58 -0700546 /**
547 * The default Uri used when creating a new calendar EntityIterator.
548 */
549 @SuppressWarnings("hiding")
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700550 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
551 "/calendar_entities");
552
RoboErikc2d53302011-06-03 09:37:58 -0700553 /**
RoboErik36726962011-06-14 14:01:15 -0700554 * This utility class cannot be instantiated
555 */
556 private CalendarEntity() {}
557
558 /**
RoboErikc2d53302011-06-03 09:37:58 -0700559 * Creates an entity iterator for the given cursor. It assumes the
560 * cursor contains a calendars query.
561 *
562 * @param cursor query on {@link #CONTENT_URI}
563 * @return an EntityIterator of calendars
564 */
565 public static EntityIterator newEntityIterator(Cursor cursor) {
566 return new EntityIteratorImpl(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700567 }
568
569 private static class EntityIteratorImpl extends CursorEntityIterator {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700570
RoboErikc2d53302011-06-03 09:37:58 -0700571 public EntityIteratorImpl(Cursor cursor) {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700572 super(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700573 }
574
575 @Override
576 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
577 // we expect the cursor is already at the row we need to read from
578 final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
579
580 // Create the content value
581 ContentValues cv = new ContentValues();
582 cv.put(_ID, calendarId);
583
RoboErik651c02e2011-05-05 15:14:31 -0700584 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
585 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700586
587 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -0700588 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Alon Albert8ac6a632012-12-17 17:21:18 -0800589 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700590
RoboErik9734df52011-06-09 14:11:25 -0700591 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
592 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
593 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
594 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
595 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
596 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
597 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
598 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
599 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
600 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700601
602 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME);
603 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
RoboErik9734df52011-06-09 14:11:25 -0700604 Calendars.CALENDAR_DISPLAY_NAME);
Alon Albert866f40a2011-06-06 14:04:00 -0700605 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
606 Calendars.CALENDAR_COLOR);
Alon Albert01141122013-02-07 11:50:27 -0800607 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
608 Calendars.CALENDAR_COLOR_KEY);
RoboErik9734df52011-06-09 14:11:25 -0700609 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL);
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700610 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700611 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS);
RoboErik651c02e2011-05-05 15:14:31 -0700612 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
613 Calendars.CALENDAR_LOCATION);
RoboErik9734df52011-06-09 14:11:25 -0700614 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700615 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
616 Calendars.OWNER_ACCOUNT);
617 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700618 Calendars.CAN_ORGANIZER_RESPOND);
619 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
620 Calendars.CAN_MODIFY_TIME_ZONE);
621 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
622 Calendars.MAX_REMINDERS);
Alon Albert866f40a2011-06-06 14:04:00 -0700623 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
624 Calendars.CAN_PARTIALLY_UPDATE);
RoboErik9734df52011-06-09 14:11:25 -0700625 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
626 Calendars.ALLOWED_REMINDERS);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700627
628 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
629
630 // Create the Entity from the ContentValue
631 Entity entity = new Entity(cv);
632
633 // Set cursor to next row
634 cursor.moveToNext();
635
636 // Return the created Entity
637 return entity;
638 }
639 }
640 }
641
642 /**
RoboErikf4010c52011-06-17 11:04:26 -0700643 * Constants and helpers for the Calendars table, which contains details for
644 * individual calendars. <h3>Operations</h3> All operations can be done
645 * either as an app or as a sync adapter. To perform an operation as a sync
646 * adapter {@link #CALLER_IS_SYNCADAPTER} should be set to true and
647 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
648 * parameters. See
649 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
650 * for details on adding parameters. Sync adapters have write access to more
651 * columns but are restricted to a single account at a time. Calendars are
652 * designed to be primarily managed by a sync adapter and inserting new
653 * calendars should be done as a sync adapter. For the most part, apps
654 * should only update calendars (such as changing the color or display
655 * name). If a local calendar is required an app can do so by inserting as a
656 * sync adapter and using an {@link #ACCOUNT_TYPE} of
657 * {@link #ACCOUNT_TYPE_LOCAL} .
658 * <dl>
659 * <dt><b>Insert</b></dt>
660 * <dd>When inserting a new calendar the following fields must be included:
661 * <ul>
662 * <li>{@link #ACCOUNT_NAME}</li>
663 * <li>{@link #ACCOUNT_TYPE}</li>
664 * <li>{@link #NAME}</li>
665 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
666 * <li>{@link #CALENDAR_COLOR}</li>
667 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
668 * <li>{@link #OWNER_ACCOUNT}</li>
669 * </ul>
670 * The following fields are not required when inserting a Calendar but are
671 * generally a good idea to include:
672 * <ul>
673 * <li>{@link #SYNC_EVENTS} set to 1</li>
RoboErikf92ccfb2011-06-17 15:24:02 -0700674 * <li>{@link #CALENDAR_TIME_ZONE}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700675 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700676 * <li>{@link #ALLOWED_AVAILABILITY}</li>
677 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700678 * </ul>
679 * <dt><b>Update</b></dt>
680 * <dd>To perform an update on a calendar the {@link #_ID} of the calendar
681 * should be provided either as an appended id to the Uri (
682 * {@link ContentUris#withAppendedId}) or as the first selection item--the
683 * selection should start with "_id=?" and the first selectionArg should be
684 * the _id of the calendar. Calendars may also be updated using a selection
685 * without the id. In general, the {@link #ACCOUNT_NAME} and
686 * {@link #ACCOUNT_TYPE} should not be changed after a calendar is created
687 * as this can cause issues for sync adapters.
688 * <dt><b>Delete</b></dt>
689 * <dd>Calendars can be deleted either by the {@link #_ID} as an appended id
690 * on the Uri or using any standard selection. Deleting a calendar should
691 * generally be handled by a sync adapter as it will remove the calendar
692 * from the database and all associated data (aka events).</dd>
693 * <dt><b>Query</b></dt>
694 * <dd>Querying the Calendars table will get you all information about a set
695 * of calendars. There will be one row returned for each calendar that
696 * matches the query selection, or at most a single row if the {@link #_ID}
697 * is appended to the Uri.</dd>
698 * </dl>
699 * <h3>Calendar Columns</h3> The following Calendar columns are writable by
700 * both an app and a sync adapter.
701 * <ul>
702 * <li>{@link #NAME}</li>
703 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700704 * <li>{@link #VISIBLE}</li>
705 * <li>{@link #SYNC_EVENTS}</li>
706 * </ul>
707 * The following Calendars columns are writable only by a sync adapter
708 * <ul>
709 * <li>{@link #ACCOUNT_NAME}</li>
710 * <li>{@link #ACCOUNT_TYPE}</li>
RoboErik4f520612011-09-19 17:47:53 -0700711 * <li>{@link #CALENDAR_COLOR}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700712 * <li>{@link #_SYNC_ID}</li>
713 * <li>{@link #DIRTY}</li>
Alon Albert8ac6a632012-12-17 17:21:18 -0800714 * <li>{@link #MUTATORS}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700715 * <li>{@link #OWNER_ACCOUNT}</li>
716 * <li>{@link #MAX_REMINDERS}</li>
717 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700718 * <li>{@link #ALLOWED_AVAILABILITY}</li>
719 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700720 * <li>{@link #CAN_MODIFY_TIME_ZONE}</li>
721 * <li>{@link #CAN_ORGANIZER_RESPOND}</li>
722 * <li>{@link #CAN_PARTIALLY_UPDATE}</li>
723 * <li>{@link #CALENDAR_LOCATION}</li>
724 * <li>{@link #CALENDAR_TIME_ZONE}</li>
725 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
726 * <li>{@link #DELETED}</li>
727 * <li>{@link #CAL_SYNC1}</li>
728 * <li>{@link #CAL_SYNC2}</li>
729 * <li>{@link #CAL_SYNC3}</li>
730 * <li>{@link #CAL_SYNC4}</li>
731 * <li>{@link #CAL_SYNC5}</li>
732 * <li>{@link #CAL_SYNC6}</li>
733 * <li>{@link #CAL_SYNC7}</li>
734 * <li>{@link #CAL_SYNC8}</li>
735 * <li>{@link #CAL_SYNC9}</li>
736 * <li>{@link #CAL_SYNC10}</li>
737 * </ul>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800738 */
RoboErik36726962011-06-14 14:01:15 -0700739 public static final class Calendars implements BaseColumns, SyncColumns, CalendarColumns {
740
741 /**
742 * This utility class cannot be instantiated
743 */
744 private Calendars() {}
745
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800746 /**
RoboErikc2d53302011-06-03 09:37:58 -0700747 * The content:// style URL for accessing Calendars
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800748 */
RoboErikc2d53302011-06-03 09:37:58 -0700749 @SuppressWarnings("hiding")
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800750 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/calendars");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800752 /**
yuemingw369f96d2018-12-05 22:07:04 +0000753 * The content:// style URL for querying Calendars table in the managed profile. Appending a
yuemingwb714ba02018-10-26 18:54:44 +0100754 * calendar id using {@link ContentUris#withAppendedId(Uri, long)} will
755 * specify a single calendar.
756 *
757 * <p>The following columns are allowed to be queried via this uri:
758 * <ul>
759 * <li>{@link #_ID}</li>
760 * <li>{@link #NAME}</li>
761 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
762 * <li>{@link #CALENDAR_COLOR}</li>
763 * <li>{@link #VISIBLE}</li>
764 * <li>{@link #CALENDAR_LOCATION}</li>
765 * <li>{@link #CALENDAR_TIME_ZONE}</li>
766 * <li>{@link #IS_PRIMARY}</li>
767 * </ul>
768 *
769 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
770 * projection of the query to this uri that are not contained in the above list.
771 *
772 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +0000773 * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
yuemingw369f96d2018-12-05 22:07:04 +0000774 * queried from a package that is not whitelisted by profile owner of the managed profile
yuemingwd2bfbc82019-01-02 11:42:25 +0000775 * via
776 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +0100777 *
778 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
779 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
780 */
781 public static final Uri ENTERPRISE_CONTENT_URI =
782 Uri.parse("content://" + AUTHORITY + "/enterprise/calendars");
783
784 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800785 * The default sort order for this table
786 */
Michael Chane5e02502011-09-01 10:46:14 -0700787 public static final String DEFAULT_SORT_ORDER = CALENDAR_DISPLAY_NAME;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788
789 /**
RoboErikc2d53302011-06-03 09:37:58 -0700790 * The name of the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800791 * <P>Type: TEXT</P>
792 */
793 public static final String NAME = "name";
794
795 /**
RoboErikc2d53302011-06-03 09:37:58 -0700796 * The default location for the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 * <P>Type: TEXT</P>
798 */
RoboErik651c02e2011-05-05 15:14:31 -0700799 public static final String CALENDAR_LOCATION = "calendar_location";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800800
801 /**
RoboErik6efb30f2011-05-05 10:11:47 -0700802 * These fields are only writable by a sync adapter. To modify them the
RoboErikc2d53302011-06-03 09:37:58 -0700803 * caller must include {@link #CALLER_IS_SYNCADAPTER},
RoboErik9734df52011-06-09 14:11:25 -0700804 * {@link #ACCOUNT_NAME}, and {@link #ACCOUNT_TYPE} in the Uri's query
RoboErik083cd2d2011-06-30 11:53:05 -0700805 * parameters. TODO move to provider
806 *
807 * @hide
RoboErik6efb30f2011-05-05 10:11:47 -0700808 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -0700809 @TestApi
RoboErik6efb30f2011-05-05 10:11:47 -0700810 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
RoboErik651c02e2011-05-05 15:14:31 -0700811 ACCOUNT_NAME,
812 ACCOUNT_TYPE,
RoboErik6efb30f2011-05-05 10:11:47 -0700813 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -0700814 DIRTY,
Alon Albert8ac6a632012-12-17 17:21:18 -0800815 MUTATORS,
RoboErik6efb30f2011-05-05 10:11:47 -0700816 OWNER_ACCOUNT,
817 MAX_REMINDERS,
RoboErikf4010c52011-06-17 11:04:26 -0700818 ALLOWED_REMINDERS,
RoboErik6efb30f2011-05-05 10:11:47 -0700819 CAN_MODIFY_TIME_ZONE,
820 CAN_ORGANIZER_RESPOND,
Alon Albert866f40a2011-06-06 14:04:00 -0700821 CAN_PARTIALLY_UPDATE,
RoboErik651c02e2011-05-05 15:14:31 -0700822 CALENDAR_LOCATION,
RoboErik9734df52011-06-09 14:11:25 -0700823 CALENDAR_TIME_ZONE,
824 CALENDAR_ACCESS_LEVEL,
RoboErik6efb30f2011-05-05 10:11:47 -0700825 DELETED,
RoboErikbe010392011-05-26 12:28:38 -0700826 CAL_SYNC1,
827 CAL_SYNC2,
828 CAL_SYNC3,
829 CAL_SYNC4,
RoboErikc2d53302011-06-03 09:37:58 -0700830 CAL_SYNC5,
831 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -0700832 CAL_SYNC7,
833 CAL_SYNC8,
834 CAL_SYNC9,
835 CAL_SYNC10,
RoboErik6efb30f2011-05-05 10:11:47 -0700836 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837 }
838
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700839 /**
840 * Columns from the Attendees table that other tables join into themselves.
841 */
RoboErikb2c75602011-06-13 12:53:48 -0700842 protected interface AttendeesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800843
844 /**
RoboErikc2d53302011-06-03 09:37:58 -0700845 * The id of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800846 * <P>Type: INTEGER</P>
847 */
848 public static final String EVENT_ID = "event_id";
849
850 /**
RoboErikc2d53302011-06-03 09:37:58 -0700851 * The name of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800852 * <P>Type: STRING</P>
853 */
854 public static final String ATTENDEE_NAME = "attendeeName";
855
856 /**
RoboErikc2d53302011-06-03 09:37:58 -0700857 * The email address of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800858 * <P>Type: STRING</P>
859 */
860 public static final String ATTENDEE_EMAIL = "attendeeEmail";
861
862 /**
RoboErikc2d53302011-06-03 09:37:58 -0700863 * The relationship of the attendee to the user. Column name.
864 * <P>Type: INTEGER (one of {@link #RELATIONSHIP_ATTENDEE}, ...}.</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800865 */
866 public static final String ATTENDEE_RELATIONSHIP = "attendeeRelationship";
867
868 public static final int RELATIONSHIP_NONE = 0;
869 public static final int RELATIONSHIP_ATTENDEE = 1;
870 public static final int RELATIONSHIP_ORGANIZER = 2;
871 public static final int RELATIONSHIP_PERFORMER = 3;
872 public static final int RELATIONSHIP_SPEAKER = 4;
873
874 /**
RoboErikc2d53302011-06-03 09:37:58 -0700875 * The type of attendee. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700876 * <P>
RoboErik4172d952011-10-25 13:59:13 -0700877 * Type: Integer (one of {@link #TYPE_NONE}, {@link #TYPE_REQUIRED},
878 * {@link #TYPE_OPTIONAL}, {@link #TYPE_RESOURCE})
RoboErikf8143c52011-09-28 15:16:00 -0700879 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800880 */
881 public static final String ATTENDEE_TYPE = "attendeeType";
882
883 public static final int TYPE_NONE = 0;
884 public static final int TYPE_REQUIRED = 1;
885 public static final int TYPE_OPTIONAL = 2;
RoboErikf8143c52011-09-28 15:16:00 -0700886 /**
RoboErik4172d952011-10-25 13:59:13 -0700887 * This specifies that an attendee is a resource, like a room, a
888 * cabbage, or something and not an actual person.
RoboErikf8143c52011-09-28 15:16:00 -0700889 */
890 public static final int TYPE_RESOURCE = 3;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800891
892 /**
RoboErikc2d53302011-06-03 09:37:58 -0700893 * The attendance status of the attendee. Column name.
894 * <P>Type: Integer (one of {@link #ATTENDEE_STATUS_ACCEPTED}, ...).</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800895 */
896 public static final String ATTENDEE_STATUS = "attendeeStatus";
897
898 public static final int ATTENDEE_STATUS_NONE = 0;
899 public static final int ATTENDEE_STATUS_ACCEPTED = 1;
900 public static final int ATTENDEE_STATUS_DECLINED = 2;
901 public static final int ATTENDEE_STATUS_INVITED = 3;
902 public static final int ATTENDEE_STATUS_TENTATIVE = 4;
Michael Chan48ec6222012-04-17 15:58:28 -0700903
904 /**
905 * The identity of the attendee as referenced in
906 * {@link ContactsContract.CommonDataKinds.Identity#IDENTITY}.
Michael Chan37f1d292012-04-17 18:40:51 -0700907 * This is required only if {@link #ATTENDEE_ID_NAMESPACE} is present. Column name.
Michael Chan48ec6222012-04-17 15:58:28 -0700908 * <P>Type: STRING</P>
Michael Chan48ec6222012-04-17 15:58:28 -0700909 */
910 public static final String ATTENDEE_IDENTITY = "attendeeIdentity";
911
912 /**
913 * The identity name space of the attendee as referenced in
914 * {@link ContactsContract.CommonDataKinds.Identity#NAMESPACE}.
Michael Chan37f1d292012-04-17 18:40:51 -0700915 * This is required only if {@link #ATTENDEE_IDENTITY} is present. Column name.
Michael Chan48ec6222012-04-17 15:58:28 -0700916 * <P>Type: STRING</P>
Michael Chan48ec6222012-04-17 15:58:28 -0700917 */
918 public static final String ATTENDEE_ID_NAMESPACE = "attendeeIdNamespace";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800919 }
920
RoboErikc2d53302011-06-03 09:37:58 -0700921 /**
RoboErik3771fcb2011-06-16 15:41:31 -0700922 * Fields and helpers for interacting with Attendees. Each row of this table
923 * represents a single attendee or guest of an event. Calling
RoboErik58644022011-07-08 13:39:05 -0700924 * {@link #query(ContentResolver, long, String[])} will return a list of attendees for
RoboErik3771fcb2011-06-16 15:41:31 -0700925 * the event with the given eventId. Both apps and sync adapters may write
926 * to this table. There are six writable fields and all of them except
927 * {@link #ATTENDEE_NAME} must be included when inserting a new attendee.
928 * They are:
929 * <ul>
930 * <li>{@link #EVENT_ID}</li>
931 * <li>{@link #ATTENDEE_NAME}</li>
932 * <li>{@link #ATTENDEE_EMAIL}</li>
933 * <li>{@link #ATTENDEE_RELATIONSHIP}</li>
934 * <li>{@link #ATTENDEE_TYPE}</li>
935 * <li>{@link #ATTENDEE_STATUS}</li>
Michael Chan48ec6222012-04-17 15:58:28 -0700936 * <li>{@link #ATTENDEE_IDENTITY}</li>
937 * <li>{@link #ATTENDEE_ID_NAMESPACE}</li>
RoboErik3771fcb2011-06-16 15:41:31 -0700938 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -0700939 */
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800940 public static final class Attendees implements BaseColumns, AttendeesColumns, EventsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800941
RoboErikc2d53302011-06-03 09:37:58 -0700942 /**
943 * The content:// style URL for accessing Attendees data
944 */
945 @SuppressWarnings("hiding")
946 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees");
RoboErikc2d53302011-06-03 09:37:58 -0700947 private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?";
948
949 /**
RoboErik36726962011-06-14 14:01:15 -0700950 * This utility class cannot be instantiated
951 */
952 private Attendees() {}
953
954 /**
RoboErikc2d53302011-06-03 09:37:58 -0700955 * Queries all attendees associated with the given event. This is a
956 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -0700957 *
RoboErikc2d53302011-06-03 09:37:58 -0700958 * @param cr The content resolver to use for the query
959 * @param eventId The id of the event to retrieve attendees for
RoboErik58644022011-07-08 13:39:05 -0700960 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -0700961 * @return A Cursor containing all attendees for the event
962 */
RoboErik58644022011-07-08 13:39:05 -0700963 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -0700964 String[] attArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -0700965 return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */,
RoboErikc2d53302011-06-03 09:37:58 -0700966 null /* sort order */);
967 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800968 }
969
970 /**
971 * Columns from the Events table that other tables join into themselves.
972 */
RoboErikb2c75602011-06-13 12:53:48 -0700973 protected interface EventsColumns {
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700974
975 /**
RoboErikc2d53302011-06-03 09:37:58 -0700976 * The {@link Calendars#_ID} of the calendar the event belongs to.
977 * Column name.
978 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 */
980 public static final String CALENDAR_ID = "calendar_id";
981
982 /**
RoboErikc2d53302011-06-03 09:37:58 -0700983 * The title of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984 * <P>Type: TEXT</P>
985 */
986 public static final String TITLE = "title";
987
988 /**
RoboErikc2d53302011-06-03 09:37:58 -0700989 * The description of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800990 * <P>Type: TEXT</P>
991 */
992 public static final String DESCRIPTION = "description";
993
994 /**
RoboErikc2d53302011-06-03 09:37:58 -0700995 * Where the event takes place. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800996 * <P>Type: TEXT</P>
997 */
998 public static final String EVENT_LOCATION = "eventLocation";
999
1000 /**
RoboErikf8143c52011-09-28 15:16:00 -07001001 * A secondary color for the individual event. This should only be
1002 * updated by the sync adapter for a given account.
RoboErik9734df52011-06-09 14:11:25 -07001003 * <P>Type: INTEGER</P>
1004 */
1005 public static final String EVENT_COLOR = "eventColor";
1006
1007 /**
RoboErik4172d952011-10-25 13:59:13 -07001008 * A secondary color key for the individual event. NULL or an empty
1009 * string are reserved for indicating that the event does not use a key
1010 * for looking up the color. The provider will update
1011 * {@link #EVENT_COLOR} automatically when a valid key is written to
1012 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -07001013 * {@link Colors} table. @see Colors
1014 * <P>
1015 * Type: TEXT
1016 * </P>
RoboErikf8143c52011-09-28 15:16:00 -07001017 */
RoboErik4172d952011-10-25 13:59:13 -07001018 public static final String EVENT_COLOR_KEY = "eventColor_index";
RoboErikf8143c52011-09-28 15:16:00 -07001019
1020 /**
Alon Albertdc927302012-03-01 16:05:55 -08001021 * This will be {@link #EVENT_COLOR} if it is not null; otherwise, this will be
1022 * {@link Calendars#CALENDAR_COLOR}.
1023 * Read-only value. To modify, write to {@link #EVENT_COLOR} or
1024 * {@link Calendars#CALENDAR_COLOR} directly.
1025 *<P>
1026 * Type: INTEGER
1027 *</P>
1028 */
1029 public static final String DISPLAY_COLOR = "displayColor";
1030
1031 /**
RoboErikc2d53302011-06-03 09:37:58 -07001032 * The event status. Column name.
1033 * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001034 */
1035 public static final String STATUS = "eventStatus";
1036
1037 public static final int STATUS_TENTATIVE = 0;
1038 public static final int STATUS_CONFIRMED = 1;
1039 public static final int STATUS_CANCELED = 2;
1040
1041 /**
1042 * This is a copy of the attendee status for the owner of this event.
1043 * This field is copied here so that we can efficiently filter out
1044 * events that are declined without having to look in the Attendees
RoboErikc2d53302011-06-03 09:37:58 -07001045 * table. Column name.
Ken Shirriff5b387e12009-10-23 09:50:41 -07001046 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001047 * <P>Type: INTEGER (int)</P>
1048 */
1049 public static final String SELF_ATTENDEE_STATUS = "selfAttendeeStatus";
Ken Shirriff5b387e12009-10-23 09:50:41 -07001050
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001051 /**
RoboErikc2d53302011-06-03 09:37:58 -07001052 * This column is available for use by sync adapters. Column name.
Marc Blank64a556d2010-02-25 12:53:16 -08001053 * <P>Type: TEXT</P>
1054 */
RoboErik651c02e2011-05-05 15:14:31 -07001055 public static final String SYNC_DATA1 = "sync_data1";
Marc Blank64a556d2010-02-25 12:53:16 -08001056
1057 /**
RoboErik9734df52011-06-09 14:11:25 -07001058 * This column is available for use by sync adapters. Column name.
1059 * <P>Type: TEXT</P>
1060 */
1061 public static final String SYNC_DATA2 = "sync_data2";
1062
1063 /**
1064 * This column is available for use by sync adapters. Column name.
1065 * <P>Type: TEXT</P>
1066 */
1067 public static final String SYNC_DATA3 = "sync_data3";
1068
1069 /**
1070 * This column is available for use by sync adapters. Column name.
1071 * <P>Type: TEXT</P>
1072 */
1073 public static final String SYNC_DATA4 = "sync_data4";
1074
1075 /**
1076 * This column is available for use by sync adapters. Column name.
1077 * <P>Type: TEXT</P>
1078 */
1079 public static final String SYNC_DATA5 = "sync_data5";
1080
1081 /**
1082 * This column is available for use by sync adapters. Column name.
1083 * <P>Type: TEXT</P>
1084 */
1085 public static final String SYNC_DATA6 = "sync_data6";
1086
1087 /**
1088 * This column is available for use by sync adapters. Column name.
Alon Albert866f40a2011-06-06 14:04:00 -07001089 * <P>Type: TEXT</P>
1090 */
1091 public static final String SYNC_DATA7 = "sync_data7";
1092
1093 /**
RoboErik9734df52011-06-09 14:11:25 -07001094 * This column is available for use by sync adapters. Column name.
1095 * <P>Type: TEXT</P>
1096 */
1097 public static final String SYNC_DATA8 = "sync_data8";
1098
1099 /**
1100 * This column is available for use by sync adapters. Column name.
1101 * <P>Type: TEXT</P>
1102 */
1103 public static final String SYNC_DATA9 = "sync_data9";
1104
1105 /**
1106 * This column is available for use by sync adapters. Column name.
1107 * <P>Type: TEXT</P>
1108 */
1109 public static final String SYNC_DATA10 = "sync_data10";
1110
1111 /**
Alon Albert866f40a2011-06-06 14:04:00 -07001112 * Used to indicate that a row is not a real event but an original copy of a locally
1113 * modified event. A copy is made when an event changes from non-dirty to dirty and the
1114 * event is on a calendar with {@link Calendars#CAN_PARTIALLY_UPDATE} set to 1. This copy
1115 * does not get expanded in the instances table and is only visible in queries made by a
1116 * sync adapter. The copy gets removed when the event is changed back to non-dirty by a
1117 * sync adapter.
1118 * <P>Type: INTEGER (boolean)</P>
1119 */
1120 public static final String LAST_SYNCED = "lastSynced";
1121
1122 /**
RoboErikc2d53302011-06-03 09:37:58 -07001123 * The time the event starts in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001124 * <P>Type: INTEGER (long; millis since epoch)</P>
1125 */
1126 public static final String DTSTART = "dtstart";
1127
1128 /**
RoboErikc2d53302011-06-03 09:37:58 -07001129 * The time the event ends in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001130 * <P>Type: INTEGER (long; millis since epoch)</P>
1131 */
1132 public static final String DTEND = "dtend";
1133
1134 /**
RoboErikc2d53302011-06-03 09:37:58 -07001135 * The duration of the event in RFC2445 format. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136 * <P>Type: TEXT (duration in RFC2445 format)</P>
1137 */
1138 public static final String DURATION = "duration";
1139
1140 /**
RoboErikc2d53302011-06-03 09:37:58 -07001141 * The timezone for the event. Column name.
1142 * <P>Type: TEXT</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001143 */
1144 public static final String EVENT_TIMEZONE = "eventTimezone";
1145
1146 /**
RoboErikc2d53302011-06-03 09:37:58 -07001147 * The timezone for the end time of the event. Column name.
1148 * <P>Type: TEXT</P>
Erikc07b06f2010-05-03 11:37:31 -07001149 */
RoboErik651c02e2011-05-05 15:14:31 -07001150 public static final String EVENT_END_TIMEZONE = "eventEndTimezone";
Erikc07b06f2010-05-03 11:37:31 -07001151
1152 /**
RoboErikc2d53302011-06-03 09:37:58 -07001153 * Is the event all day (time zone independent). Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001154 * <P>Type: INTEGER (boolean)</P>
1155 */
1156 public static final String ALL_DAY = "allDay";
1157
1158 /**
RoboErik651c02e2011-05-05 15:14:31 -07001159 * Defines how the event shows up for others when the calendar is
RoboErikc2d53302011-06-03 09:37:58 -07001160 * shared. Column name.
1161 * <P>Type: INTEGER (One of {@link #ACCESS_DEFAULT}, ...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001162 */
RoboErik651c02e2011-05-05 15:14:31 -07001163 public static final String ACCESS_LEVEL = "accessLevel";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001164
1165 /**
RoboErik651c02e2011-05-05 15:14:31 -07001166 * Default access is controlled by the server and will be treated as
1167 * public on the device.
1168 */
1169 public static final int ACCESS_DEFAULT = 0;
1170 /**
1171 * Confidential is not used by the app.
1172 */
1173 public static final int ACCESS_CONFIDENTIAL = 1;
1174 /**
RoboErikc2d53302011-06-03 09:37:58 -07001175 * Private shares the event as a free/busy slot with no details.
RoboErik651c02e2011-05-05 15:14:31 -07001176 */
1177 public static final int ACCESS_PRIVATE = 2;
1178 /**
RoboErikc2d53302011-06-03 09:37:58 -07001179 * Public makes the contents visible to anyone with access to the
RoboErik651c02e2011-05-05 15:14:31 -07001180 * calendar.
1181 */
1182 public static final int ACCESS_PUBLIC = 3;
1183
1184 /**
1185 * If this event counts as busy time or is still free time that can be
RoboErikc2d53302011-06-03 09:37:58 -07001186 * scheduled over. Column name.
RoboErik4172d952011-10-25 13:59:13 -07001187 * <P>
1188 * Type: INTEGER (One of {@link #AVAILABILITY_BUSY},
1189 * {@link #AVAILABILITY_FREE}, {@link #AVAILABILITY_TENTATIVE})
1190 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 */
RoboErik651c02e2011-05-05 15:14:31 -07001192 public static final String AVAILABILITY = "availability";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001193
RoboErik651c02e2011-05-05 15:14:31 -07001194 /**
1195 * Indicates that this event takes up time and will conflict with other
1196 * events.
1197 */
1198 public static final int AVAILABILITY_BUSY = 0;
1199 /**
1200 * Indicates that this event is free time and will not conflict with
1201 * other events.
1202 */
1203 public static final int AVAILABILITY_FREE = 1;
RoboErikf8143c52011-09-28 15:16:00 -07001204 /**
1205 * Indicates that the owner's availability may change, but should be
1206 * considered busy time that will conflict.
RoboErikf8143c52011-09-28 15:16:00 -07001207 */
1208 public static final int AVAILABILITY_TENTATIVE = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001209
1210 /**
RoboErikc2d53302011-06-03 09:37:58 -07001211 * Whether the event has an alarm or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 * <P>Type: INTEGER (boolean)</P>
1213 */
1214 public static final String HAS_ALARM = "hasAlarm";
1215
1216 /**
RoboErikc2d53302011-06-03 09:37:58 -07001217 * Whether the event has extended properties or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001218 * <P>Type: INTEGER (boolean)</P>
1219 */
1220 public static final String HAS_EXTENDED_PROPERTIES = "hasExtendedProperties";
1221
1222 /**
RoboErikc2d53302011-06-03 09:37:58 -07001223 * The recurrence rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001224 * <P>Type: TEXT</P>
1225 */
1226 public static final String RRULE = "rrule";
1227
1228 /**
RoboErikc2d53302011-06-03 09:37:58 -07001229 * The recurrence dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001230 * <P>Type: TEXT</P>
1231 */
1232 public static final String RDATE = "rdate";
1233
1234 /**
RoboErikc2d53302011-06-03 09:37:58 -07001235 * The recurrence exception rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001236 * <P>Type: TEXT</P>
1237 */
1238 public static final String EXRULE = "exrule";
1239
1240 /**
RoboErikc2d53302011-06-03 09:37:58 -07001241 * The recurrence exception dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001242 * <P>Type: TEXT</P>
1243 */
1244 public static final String EXDATE = "exdate";
1245
1246 /**
RoboErikc2d53302011-06-03 09:37:58 -07001247 * The {@link Events#_ID} of the original recurring event for which this
1248 * event is an exception. Column name.
RoboErikc0bd9bc2011-05-13 17:54:24 -07001249 * <P>Type: TEXT</P>
1250 */
1251 public static final String ORIGINAL_ID = "original_id";
1252
1253 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001254 * The _sync_id of the original recurring event for which this event is
RoboErikc0bd9bc2011-05-13 17:54:24 -07001255 * an exception. The provider should keep the original_id in sync when
RoboErikc2d53302011-06-03 09:37:58 -07001256 * this is updated. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001257 * <P>Type: TEXT</P>
1258 */
RoboErik651c02e2011-05-05 15:14:31 -07001259 public static final String ORIGINAL_SYNC_ID = "original_sync_id";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001260
1261 /**
1262 * The original instance time of the recurring event for which this
RoboErikc2d53302011-06-03 09:37:58 -07001263 * event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001264 * <P>Type: INTEGER (long; millis since epoch)</P>
1265 */
1266 public static final String ORIGINAL_INSTANCE_TIME = "originalInstanceTime";
1267
1268 /**
1269 * The allDay status (true or false) of the original recurring event
RoboErikc2d53302011-06-03 09:37:58 -07001270 * for which this event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001271 * <P>Type: INTEGER (boolean)</P>
1272 */
1273 public static final String ORIGINAL_ALL_DAY = "originalAllDay";
1274
1275 /**
RoboErikc2d53302011-06-03 09:37:58 -07001276 * The last date this event repeats on, or NULL if it never ends. Column
1277 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001278 * <P>Type: INTEGER (long; millis since epoch)</P>
1279 */
1280 public static final String LAST_DATE = "lastDate";
Ken Shirriff79f0c562009-08-05 13:29:42 -07001281
1282 /**
1283 * Whether the event has attendee information. True if the event
1284 * has full attendee data, false if the event has information about
RoboErikc2d53302011-06-03 09:37:58 -07001285 * self only. Column name.
Ken Shirriff79f0c562009-08-05 13:29:42 -07001286 * <P>Type: INTEGER (boolean)</P>
1287 */
1288 public static final String HAS_ATTENDEE_DATA = "hasAttendeeData";
Ken Shirriff3d037072009-08-17 15:43:21 -07001289
1290 /**
RoboErikc2d53302011-06-03 09:37:58 -07001291 * Whether guests can modify the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001292 * <P>Type: INTEGER (boolean)</P>
1293 */
1294 public static final String GUESTS_CAN_MODIFY = "guestsCanModify";
1295
1296 /**
RoboErikc2d53302011-06-03 09:37:58 -07001297 * Whether guests can invite other guests. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001298 * <P>Type: INTEGER (boolean)</P>
1299 */
1300 public static final String GUESTS_CAN_INVITE_OTHERS = "guestsCanInviteOthers";
1301
1302 /**
RoboErikc2d53302011-06-03 09:37:58 -07001303 * Whether guests can see the list of attendees. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001304 * <P>Type: INTEGER (boolean)</P>
1305 */
1306 public static final String GUESTS_CAN_SEE_GUESTS = "guestsCanSeeGuests";
1307
1308 /**
RoboErikc2d53302011-06-03 09:37:58 -07001309 * Email of the organizer (owner) of the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001310 * <P>Type: STRING</P>
1311 */
1312 public static final String ORGANIZER = "organizer";
1313
1314 /**
Alon Albert0a9a2192012-09-18 11:10:49 -07001315 * Are we the organizer of this event. If this column is not explicitly set, the provider
1316 * will return 1 if {@link #ORGANIZER} is equal to {@link Calendars#OWNER_ACCOUNT}.
1317 * Column name.
1318 * <P>Type: STRING</P>
1319 */
1320 public static final String IS_ORGANIZER = "isOrganizer";
1321
1322 /**
RoboErikc2d53302011-06-03 09:37:58 -07001323 * Whether the user can invite others to the event. The
1324 * GUESTS_CAN_INVITE_OTHERS is a setting that applies to an arbitrary
1325 * guest, while CAN_INVITE_OTHERS indicates if the user can invite
1326 * others (either through GUESTS_CAN_INVITE_OTHERS or because the user
1327 * has modify access to the event). Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001328 * <P>Type: INTEGER (boolean, readonly)</P>
1329 */
1330 public static final String CAN_INVITE_OTHERS = "canInviteOthers";
Michael Chan37960c72012-04-19 00:18:13 -07001331
1332 /**
1333 * The package name of the custom app that can provide a richer
1334 * experience for the event. See the ACTION TYPE
1335 * {@link CalendarContract#ACTION_HANDLE_CUSTOM_EVENT} for details.
1336 * Column name.
1337 * <P> Type: TEXT </P>
1338 */
1339 public static final String CUSTOM_APP_PACKAGE = "customAppPackage";
1340
1341 /**
1342 * The URI used by the custom app for the event. Column name.
1343 * <P>Type: TEXT</P>
1344 */
1345 public static final String CUSTOM_APP_URI = "customAppUri";
1346
Sara Ting4d6f90e2012-09-17 11:17:15 -07001347 /**
1348 * The UID for events added from the RFC 2445 iCalendar format.
1349 * Column name.
1350 * <P>Type: TEXT</P>
1351 */
1352 public static final String UID_2445 = "uid2445";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001353 }
1354
1355 /**
RoboErikc2d53302011-06-03 09:37:58 -07001356 * Class that represents an Event Entity. There is one entry per event.
1357 * Recurring events show up as a single entry. This is a helper class to
1358 * make batch operations easier. A {@link ContentResolver} or
1359 * {@link ContentProviderClient} is required as the helper does additional
1360 * queries to add reminders and attendees to each entry.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001361 */
RoboErik651c02e2011-05-05 15:14:31 -07001362 public static final class EventsEntity implements BaseColumns, SyncColumns, EventsColumns {
Fred Quintana328c0e72009-12-07 14:52:28 -08001363 /**
1364 * The content:// style URL for this table
1365 */
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001366 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1367 "/event_entities");
Fred Quintana328c0e72009-12-07 14:52:28 -08001368
RoboErikc2d53302011-06-03 09:37:58 -07001369 /**
RoboErik36726962011-06-14 14:01:15 -07001370 * This utility class cannot be instantiated
1371 */
1372 private EventsEntity() {}
1373
1374 /**
RoboErikc2d53302011-06-03 09:37:58 -07001375 * Creates a new iterator for events
1376 *
1377 * @param cursor An event query
1378 * @param resolver For performing additional queries
1379 * @return an EntityIterator containing one entity per event in the
1380 * cursor
1381 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001382 public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) {
1383 return new EntityIteratorImpl(cursor, resolver);
1384 }
1385
RoboErikc2d53302011-06-03 09:37:58 -07001386 /**
1387 * Creates a new iterator for events
1388 *
1389 * @param cursor An event query
1390 * @param provider For performing additional queries
1391 * @return an EntityIterator containing one entity per event in the
1392 * cursor
1393 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001394 public static EntityIterator newEntityIterator(Cursor cursor,
1395 ContentProviderClient provider) {
1396 return new EntityIteratorImpl(cursor, provider);
1397 }
1398
1399 private static class EntityIteratorImpl extends CursorEntityIterator {
1400 private final ContentResolver mResolver;
1401 private final ContentProviderClient mProvider;
1402
1403 private static final String[] REMINDERS_PROJECTION = new String[] {
1404 Reminders.MINUTES,
1405 Reminders.METHOD,
1406 };
1407 private static final int COLUMN_MINUTES = 0;
1408 private static final int COLUMN_METHOD = 1;
1409
1410 private static final String[] ATTENDEES_PROJECTION = new String[] {
1411 Attendees.ATTENDEE_NAME,
1412 Attendees.ATTENDEE_EMAIL,
1413 Attendees.ATTENDEE_RELATIONSHIP,
1414 Attendees.ATTENDEE_TYPE,
1415 Attendees.ATTENDEE_STATUS,
Michael Chan48ec6222012-04-17 15:58:28 -07001416 Attendees.ATTENDEE_IDENTITY,
1417 Attendees.ATTENDEE_ID_NAMESPACE
Fred Quintana328c0e72009-12-07 14:52:28 -08001418 };
1419 private static final int COLUMN_ATTENDEE_NAME = 0;
1420 private static final int COLUMN_ATTENDEE_EMAIL = 1;
1421 private static final int COLUMN_ATTENDEE_RELATIONSHIP = 2;
1422 private static final int COLUMN_ATTENDEE_TYPE = 3;
1423 private static final int COLUMN_ATTENDEE_STATUS = 4;
Michael Chan48ec6222012-04-17 15:58:28 -07001424 private static final int COLUMN_ATTENDEE_IDENTITY = 5;
1425 private static final int COLUMN_ATTENDEE_ID_NAMESPACE = 6;
1426
Fred Quintana328c0e72009-12-07 14:52:28 -08001427 private static final String[] EXTENDED_PROJECTION = new String[] {
Marc Blank8f643c12010-04-29 14:16:48 -07001428 ExtendedProperties._ID,
Fred Quintana328c0e72009-12-07 14:52:28 -08001429 ExtendedProperties.NAME,
Marc Blank8f643c12010-04-29 14:16:48 -07001430 ExtendedProperties.VALUE
Fred Quintana328c0e72009-12-07 14:52:28 -08001431 };
Marc Blank8f643c12010-04-29 14:16:48 -07001432 private static final int COLUMN_ID = 0;
1433 private static final int COLUMN_NAME = 1;
1434 private static final int COLUMN_VALUE = 2;
Fred Quintana328c0e72009-12-07 14:52:28 -08001435
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001436 private static final String WHERE_EVENT_ID = "event_id=?";
1437
Fred Quintana328c0e72009-12-07 14:52:28 -08001438 public EntityIteratorImpl(Cursor cursor, ContentResolver resolver) {
1439 super(cursor);
1440 mResolver = resolver;
1441 mProvider = null;
1442 }
1443
1444 public EntityIteratorImpl(Cursor cursor, ContentProviderClient provider) {
1445 super(cursor);
1446 mResolver = null;
1447 mProvider = provider;
1448 }
1449
Marc Blank64a556d2010-02-25 12:53:16 -08001450 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08001451 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
1452 // we expect the cursor is already at the row we need to read from
1453 final long eventId = cursor.getLong(cursor.getColumnIndexOrThrow(Events._ID));
1454 ContentValues cv = new ContentValues();
1455 cv.put(Events._ID, eventId);
1456 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001457 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, TITLE);
1458 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DESCRIPTION);
1459 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_LOCATION);
1460 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, STATUS);
1461 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SELF_ATTENDEE_STATUS);
Fred Quintana328c0e72009-12-07 14:52:28 -08001462 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTSTART);
1463 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTEND);
1464 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DURATION);
1465 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_TIMEZONE);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001466 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_END_TIMEZONE);
Fred Quintana328c0e72009-12-07 14:52:28 -08001467 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ALL_DAY);
RoboErik651c02e2011-05-05 15:14:31 -07001468 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL);
1469 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, AVAILABILITY);
Alon Albert971c28b2013-02-04 13:49:50 -08001470 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, EVENT_COLOR);
Alon Albert0a35dd52013-02-05 11:07:56 -08001471 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_COLOR_KEY);
Fred Quintana328c0e72009-12-07 14:52:28 -08001472 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, HAS_ALARM);
1473 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1474 HAS_EXTENDED_PROPERTIES);
1475 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RRULE);
1476 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RDATE);
1477 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXRULE);
1478 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXDATE);
RoboErik651c02e2011-05-05 15:14:31 -07001479 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_SYNC_ID);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001480 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001481 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
1482 ORIGINAL_INSTANCE_TIME);
1483 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ORIGINAL_ALL_DAY);
1484 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_DATE);
1485 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, HAS_ATTENDEE_DATA);
1486 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
1487 GUESTS_CAN_INVITE_OTHERS);
1488 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_MODIFY);
1489 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_SEE_GUESTS);
Michael Chanbb9fd4a2012-04-24 17:32:03 -07001490 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_PACKAGE);
1491 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_URI);
Sara Ting4d6f90e2012-09-17 11:17:15 -07001492 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, UID_2445);
Fred Quintana328c0e72009-12-07 14:52:28 -08001493 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORGANIZER);
Alon Albert0a9a2192012-09-18 11:10:49 -07001494 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, IS_ORGANIZER);
Fred Quintana328c0e72009-12-07 14:52:28 -08001495 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -07001496 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Alon Albert8ac6a632012-12-17 17:21:18 -08001497 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
Alon Albert866f40a2011-06-06 14:04:00 -07001498 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED);
RoboErikc2d53302011-06-03 09:37:58 -07001499 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
RoboErik9734df52011-06-09 14:11:25 -07001500 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA1);
1501 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA2);
1502 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA3);
1503 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA4);
1504 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA5);
1505 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA6);
1506 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA7);
1507 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA8);
1508 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA9);
1509 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA10);
RoboErikbe010392011-05-26 12:28:38 -07001510 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
1511 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
1512 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
1513 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
1514 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
1515 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
RoboErik9734df52011-06-09 14:11:25 -07001516 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
1517 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
1518 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
1519 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fred Quintana328c0e72009-12-07 14:52:28 -08001520
1521 Entity entity = new Entity(cv);
1522 Cursor subCursor;
1523 if (mResolver != null) {
1524 subCursor = mResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001525 WHERE_EVENT_ID,
1526 new String[] { Long.toString(eventId) } /* selectionArgs */,
1527 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001528 } else {
1529 subCursor = mProvider.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001530 WHERE_EVENT_ID,
1531 new String[] { Long.toString(eventId) } /* selectionArgs */,
1532 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001533 }
1534 try {
1535 while (subCursor.moveToNext()) {
1536 ContentValues reminderValues = new ContentValues();
1537 reminderValues.put(Reminders.MINUTES, subCursor.getInt(COLUMN_MINUTES));
1538 reminderValues.put(Reminders.METHOD, subCursor.getInt(COLUMN_METHOD));
1539 entity.addSubValue(Reminders.CONTENT_URI, reminderValues);
1540 }
1541 } finally {
1542 subCursor.close();
1543 }
1544
1545 if (mResolver != null) {
1546 subCursor = mResolver.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001547 WHERE_EVENT_ID,
1548 new String[] { Long.toString(eventId) } /* selectionArgs */,
1549 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001550 } else {
1551 subCursor = mProvider.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001552 WHERE_EVENT_ID,
1553 new String[] { Long.toString(eventId) } /* selectionArgs */,
1554 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001555 }
1556 try {
1557 while (subCursor.moveToNext()) {
1558 ContentValues attendeeValues = new ContentValues();
1559 attendeeValues.put(Attendees.ATTENDEE_NAME,
1560 subCursor.getString(COLUMN_ATTENDEE_NAME));
1561 attendeeValues.put(Attendees.ATTENDEE_EMAIL,
1562 subCursor.getString(COLUMN_ATTENDEE_EMAIL));
1563 attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP,
1564 subCursor.getInt(COLUMN_ATTENDEE_RELATIONSHIP));
1565 attendeeValues.put(Attendees.ATTENDEE_TYPE,
1566 subCursor.getInt(COLUMN_ATTENDEE_TYPE));
1567 attendeeValues.put(Attendees.ATTENDEE_STATUS,
1568 subCursor.getInt(COLUMN_ATTENDEE_STATUS));
Michael Chan48ec6222012-04-17 15:58:28 -07001569 attendeeValues.put(Attendees.ATTENDEE_IDENTITY,
Michael Chana07ea5d2012-07-13 14:10:40 -07001570 subCursor.getString(COLUMN_ATTENDEE_IDENTITY));
Michael Chan48ec6222012-04-17 15:58:28 -07001571 attendeeValues.put(Attendees.ATTENDEE_ID_NAMESPACE,
Michael Chana07ea5d2012-07-13 14:10:40 -07001572 subCursor.getString(COLUMN_ATTENDEE_ID_NAMESPACE));
Fred Quintana328c0e72009-12-07 14:52:28 -08001573 entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);
1574 }
1575 } finally {
1576 subCursor.close();
1577 }
1578
1579 if (mResolver != null) {
1580 subCursor = mResolver.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001581 WHERE_EVENT_ID,
1582 new String[] { Long.toString(eventId) } /* selectionArgs */,
1583 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001584 } else {
1585 subCursor = mProvider.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001586 WHERE_EVENT_ID,
1587 new String[] { Long.toString(eventId) } /* selectionArgs */,
1588 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001589 }
1590 try {
1591 while (subCursor.moveToNext()) {
1592 ContentValues extendedValues = new ContentValues();
Marc Blank8f643c12010-04-29 14:16:48 -07001593 extendedValues.put(ExtendedProperties._ID,
1594 subCursor.getString(COLUMN_ID));
Ken Shirriff3b168922010-01-27 12:27:28 -08001595 extendedValues.put(ExtendedProperties.NAME,
1596 subCursor.getString(COLUMN_NAME));
Fred Quintana328c0e72009-12-07 14:52:28 -08001597 extendedValues.put(ExtendedProperties.VALUE,
Ken Shirriff3b168922010-01-27 12:27:28 -08001598 subCursor.getString(COLUMN_VALUE));
Fred Quintana328c0e72009-12-07 14:52:28 -08001599 entity.addSubValue(ExtendedProperties.CONTENT_URI, extendedValues);
1600 }
1601 } finally {
1602 subCursor.close();
1603 }
1604
1605 cursor.moveToNext();
1606 return entity;
1607 }
1608 }
1609 }
1610
1611 /**
RoboErikf4010c52011-06-17 11:04:26 -07001612 * Constants and helpers for the Events table, which contains details for
1613 * individual events. <h3>Operations</h3> All operations can be done either
1614 * as an app or as a sync adapter. To perform an operation as a sync adapter
1615 * {@link #CALLER_IS_SYNCADAPTER} should be set to true and
1616 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
1617 * parameters. See
1618 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
1619 * for details on adding parameters. Sync adapters have write access to more
1620 * columns but are restricted to a single account at a time.
RoboErikfe37b492011-06-16 12:31:56 -07001621 * <dl>
1622 * <dt><b>Insert</b></dt>
1623 * <dd>When inserting a new event the following fields must be included:
1624 * <ul>
1625 * <li>dtstart</li>
Michael Chane6fbf652011-10-18 14:43:11 -07001626 * <li>dtend if the event is non-recurring</li>
1627 * <li>duration if the event is recurring</li>
1628 * <li>rrule or rdate if the event is recurring</li>
RoboErik4172d952011-10-25 13:59:13 -07001629 * <li>eventTimezone</li>
RoboErikfe37b492011-06-16 12:31:56 -07001630 * <li>a calendar_id</li>
1631 * </ul>
1632 * There are also further requirements when inserting or updating an event.
1633 * See the section on Writing to Events.</dd>
1634 * <dt><b>Update</b></dt>
RoboErikf4010c52011-06-17 11:04:26 -07001635 * <dd>To perform an update of an Event the {@link Events#_ID} of the event
1636 * should be provided either as an appended id to the Uri (
RoboErikfe37b492011-06-16 12:31:56 -07001637 * {@link ContentUris#withAppendedId}) or as the first selection item--the
1638 * selection should start with "_id=?" and the first selectionArg should be
RoboErikf4010c52011-06-17 11:04:26 -07001639 * the _id of the event. Updates may also be done using a selection and no
1640 * id. Updating an event must respect the same rules as inserting and is
1641 * further restricted in the fields that can be written. See the section on
1642 * Writing to Events.</dd>
RoboErikfe37b492011-06-16 12:31:56 -07001643 * <dt><b>Delete</b></dt>
1644 * <dd>Events can be deleted either by the {@link Events#_ID} as an appended
1645 * id on the Uri or using any standard selection. If an appended id is used
1646 * a selection is not allowed. There are two versions of delete: as an app
1647 * and as a sync adapter. An app delete will set the deleted column on an
1648 * event and remove all instances of that event. A sync adapter delete will
1649 * remove the event from the database and all associated data.</dd>
1650 * <dt><b>Query</b></dt>
1651 * <dd>Querying the Events table will get you all information about a set of
1652 * events except their reminders, attendees, and extended properties. There
1653 * will be one row returned for each event that matches the query selection,
1654 * or at most a single row if the {@link Events#_ID} is appended to the Uri.
1655 * Recurring events will only return a single row regardless of the number
1656 * of times that event repeats.</dd>
1657 * </dl>
1658 * <h3>Writing to Events</h3> There are further restrictions on all Updates
1659 * and Inserts in the Events table:
1660 * <ul>
1661 * <li>If allDay is set to 1 eventTimezone must be {@link Time#TIMEZONE_UTC}
1662 * and the time must correspond to a midnight boundary.</li>
1663 * <li>Exceptions are not allowed to recur. If rrule or rdate is not empty,
1664 * original_id and original_sync_id must be empty.</li>
1665 * <li>In general a calendar_id should not be modified after insertion. This
1666 * is not explicitly forbidden but many sync adapters will not behave in an
1667 * expected way if the calendar_id is modified.</li>
1668 * </ul>
1669 * The following Events columns are writable by both an app and a sync
1670 * adapter.
1671 * <ul>
1672 * <li>{@link #CALENDAR_ID}</li>
1673 * <li>{@link #ORGANIZER}</li>
1674 * <li>{@link #TITLE}</li>
1675 * <li>{@link #EVENT_LOCATION}</li>
1676 * <li>{@link #DESCRIPTION}</li>
1677 * <li>{@link #EVENT_COLOR}</li>
1678 * <li>{@link #DTSTART}</li>
1679 * <li>{@link #DTEND}</li>
1680 * <li>{@link #EVENT_TIMEZONE}</li>
1681 * <li>{@link #EVENT_END_TIMEZONE}</li>
1682 * <li>{@link #DURATION}</li>
1683 * <li>{@link #ALL_DAY}</li>
1684 * <li>{@link #RRULE}</li>
1685 * <li>{@link #RDATE}</li>
1686 * <li>{@link #EXRULE}</li>
1687 * <li>{@link #EXDATE}</li>
1688 * <li>{@link #ORIGINAL_ID}</li>
1689 * <li>{@link #ORIGINAL_SYNC_ID}</li>
1690 * <li>{@link #ORIGINAL_INSTANCE_TIME}</li>
1691 * <li>{@link #ORIGINAL_ALL_DAY}</li>
1692 * <li>{@link #ACCESS_LEVEL}</li>
1693 * <li>{@link #AVAILABILITY}</li>
1694 * <li>{@link #GUESTS_CAN_MODIFY}</li>
1695 * <li>{@link #GUESTS_CAN_INVITE_OTHERS}</li>
1696 * <li>{@link #GUESTS_CAN_SEE_GUESTS}</li>
Michael Chanbb9fd4a2012-04-24 17:32:03 -07001697 * <li>{@link #CUSTOM_APP_PACKAGE}</li>
1698 * <li>{@link #CUSTOM_APP_URI}</li>
Sara Ting4d6f90e2012-09-17 11:17:15 -07001699 * <li>{@link #UID_2445}</li>
RoboErikfe37b492011-06-16 12:31:56 -07001700 * </ul>
1701 * The following Events columns are writable only by a sync adapter
1702 * <ul>
1703 * <li>{@link #DIRTY}</li>
Alon Albert8ac6a632012-12-17 17:21:18 -08001704 * <li>{@link #MUTATORS}</li>
RoboErikfe37b492011-06-16 12:31:56 -07001705 * <li>{@link #_SYNC_ID}</li>
1706 * <li>{@link #SYNC_DATA1}</li>
1707 * <li>{@link #SYNC_DATA2}</li>
1708 * <li>{@link #SYNC_DATA3}</li>
1709 * <li>{@link #SYNC_DATA4}</li>
1710 * <li>{@link #SYNC_DATA5}</li>
1711 * <li>{@link #SYNC_DATA6}</li>
1712 * <li>{@link #SYNC_DATA7}</li>
1713 * <li>{@link #SYNC_DATA8}</li>
1714 * <li>{@link #SYNC_DATA9}</li>
1715 * <li>{@link #SYNC_DATA10}</li>
1716 * </ul>
1717 * The remaining columns are either updated by the provider only or are
1718 * views into other tables and cannot be changed through the Events table.
Fred Quintana328c0e72009-12-07 14:52:28 -08001719 */
RoboErik9734df52011-06-09 14:11:25 -07001720 public static final class Events implements BaseColumns, SyncColumns, EventsColumns,
RoboErike00d5892011-06-23 15:16:55 -07001721 CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001722
RoboErikc2d53302011-06-03 09:37:58 -07001723 /**
RoboErikc2d53302011-06-03 09:37:58 -07001724 * The content:// style URL for interacting with events. Appending an
1725 * event id using {@link ContentUris#withAppendedId(Uri, long)} will
1726 * specify a single event.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001727 */
RoboErikc2d53302011-06-03 09:37:58 -07001728 @SuppressWarnings("hiding")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001729 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001730 Uri.parse("content://" + AUTHORITY + "/events");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001731
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001732 /**
yuemingw369f96d2018-12-05 22:07:04 +00001733 * The content:// style URL for querying Events table in the managed profile. Appending an
yuemingwb714ba02018-10-26 18:54:44 +01001734 * event id using {@link ContentUris#withAppendedId(Uri, long)} will
1735 * specify a single event.
1736 *
1737 * <p>The following columns are allowed to be queried via this uri:
1738 * <ul>
1739 * <li>{@link #_ID}</li>
1740 * <li>{@link #CALENDAR_ID}</li>
1741 * <li>{@link #TITLE}</li>
1742 * <li>{@link #EVENT_LOCATION}</li>
1743 * <li>{@link #EVENT_COLOR}</li>
1744 * <li>{@link #STATUS}</li>
1745 * <li>{@link #DTSTART}</li>
1746 * <li>{@link #DTEND}</li>
1747 * <li>{@link #EVENT_TIMEZONE}</li>
1748 * <li>{@link #EVENT_END_TIMEZONE}</li>
1749 * <li>{@link #DURATION}</li>
1750 * <li>{@link #ALL_DAY}</li>
1751 * <li>{@link #AVAILABILITY}</li>
1752 * <li>{@link #RRULE}</li>
1753 * <li>{@link #RDATE}</li>
1754 * <li>{@link #EXRULE}</li>
1755 * <li>{@link #EXDATE}</li>
1756 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
1757 * <li>{@link #CALENDAR_COLOR}</li>
1758 * <li>{@link #VISIBLE}</li>
1759 * <li>{@link #CALENDAR_TIME_ZONE}</li>
1760 * </ul>
1761 *
1762 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
1763 * projection of the query to this uri that are not contained in the above list.
1764 *
1765 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001766 * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
yuemingw369f96d2018-12-05 22:07:04 +00001767 * queried from a package that is not whitelisted by profile owner of the managed profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001768 * via
1769 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +01001770 *
1771 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
1772 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
1773 */
1774 public static final Uri ENTERPRISE_CONTENT_URI =
1775 Uri.parse("content://" + AUTHORITY + "/enterprise/events");
1776
1777 /**
Andy McFadden4a8c4782011-05-24 13:00:29 -07001778 * The content:// style URI for recurring event exceptions. Insertions require an
1779 * appended event ID. Deletion of exceptions requires both the original event ID and
1780 * the exception event ID (see {@link Uri.Builder#appendPath}).
1781 */
RoboErik083cd2d2011-06-30 11:53:05 -07001782 public static final Uri CONTENT_EXCEPTION_URI =
Andy McFadden4a8c4782011-05-24 13:00:29 -07001783 Uri.parse("content://" + AUTHORITY + "/exception");
1784
1785 /**
RoboErik36726962011-06-14 14:01:15 -07001786 * This utility class cannot be instantiated
1787 */
1788 private Events() {}
1789
1790 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001791 * The default sort order for this table
1792 */
RoboErikc2d53302011-06-03 09:37:58 -07001793 private static final String DEFAULT_SORT_ORDER = "";
RoboErik651c02e2011-05-05 15:14:31 -07001794
1795 /**
1796 * These are columns that should only ever be updated by the provider,
1797 * either because they are views mapped to another table or because they
RoboErik083cd2d2011-06-30 11:53:05 -07001798 * are used for provider only functionality. TODO move to provider
1799 *
1800 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001801 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01001802 @UnsupportedAppUsage
RoboErik651c02e2011-05-05 15:14:31 -07001803 public static String[] PROVIDER_WRITABLE_COLUMNS = new String[] {
1804 ACCOUNT_NAME,
RoboErikc2d53302011-06-03 09:37:58 -07001805 ACCOUNT_TYPE,
1806 CAL_SYNC1,
1807 CAL_SYNC2,
1808 CAL_SYNC3,
1809 CAL_SYNC4,
1810 CAL_SYNC5,
Alon Albert866f40a2011-06-06 14:04:00 -07001811 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -07001812 CAL_SYNC7,
1813 CAL_SYNC8,
1814 CAL_SYNC9,
1815 CAL_SYNC10,
1816 ALLOWED_REMINDERS,
RoboErikc7ef9392011-10-27 14:11:44 -07001817 ALLOWED_ATTENDEE_TYPES,
1818 ALLOWED_AVAILABILITY,
RoboErik9734df52011-06-09 14:11:25 -07001819 CALENDAR_ACCESS_LEVEL,
1820 CALENDAR_COLOR,
1821 CALENDAR_TIME_ZONE,
1822 CAN_MODIFY_TIME_ZONE,
1823 CAN_ORGANIZER_RESPOND,
1824 CALENDAR_DISPLAY_NAME,
Alon Albert866f40a2011-06-06 14:04:00 -07001825 CAN_PARTIALLY_UPDATE,
RoboErik9734df52011-06-09 14:11:25 -07001826 SYNC_EVENTS,
1827 VISIBLE,
RoboErik651c02e2011-05-05 15:14:31 -07001828 };
1829
1830 /**
1831 * These fields are only writable by a sync adapter. To modify them the
1832 * caller must include CALLER_IS_SYNCADAPTER, _SYNC_ACCOUNT, and
RoboErik083cd2d2011-06-30 11:53:05 -07001833 * _SYNC_ACCOUNT_TYPE in the query parameters. TODO move to provider.
1834 *
1835 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001836 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -07001837 @TestApi
RoboErik651c02e2011-05-05 15:14:31 -07001838 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
1839 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -07001840 DIRTY,
Alon Albert8ac6a632012-12-17 17:21:18 -08001841 MUTATORS,
RoboErik9734df52011-06-09 14:11:25 -07001842 SYNC_DATA1,
1843 SYNC_DATA2,
1844 SYNC_DATA3,
1845 SYNC_DATA4,
1846 SYNC_DATA5,
1847 SYNC_DATA6,
1848 SYNC_DATA7,
1849 SYNC_DATA8,
1850 SYNC_DATA9,
1851 SYNC_DATA10,
RoboErik651c02e2011-05-05 15:14:31 -07001852 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001853 }
1854
1855 /**
RoboErikc2d53302011-06-03 09:37:58 -07001856 * Fields and helpers for interacting with Instances. An instance is a
1857 * single occurrence of an event including time zone specific start and end
RoboErik3771fcb2011-06-16 15:41:31 -07001858 * days and minutes. The instances table is not writable and only provides a
1859 * way to query event occurrences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001860 */
RoboErike00d5892011-06-23 15:16:55 -07001861 public static final class Instances implements BaseColumns, EventsColumns, CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001862
RoboErike00d5892011-06-23 15:16:55 -07001863 private static final String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?";
1864 private static final String[] WHERE_CALENDARS_ARGS = {
1865 "1"
1866 };
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001867
RoboErikc2d53302011-06-03 09:37:58 -07001868 /**
RoboErik36726962011-06-14 14:01:15 -07001869 * This utility class cannot be instantiated
1870 */
1871 private Instances() {}
1872
1873 /**
RoboErikc2d53302011-06-03 09:37:58 -07001874 * Performs a query to return all visible instances in the given range.
1875 * This is a blocking function and should not be done on the UI thread.
1876 * This will cause an expansion of recurring events to fill this time
1877 * range if they are not already expanded and will slow down for larger
1878 * time ranges with many recurring events.
1879 *
1880 * @param cr The ContentResolver to use for the query
1881 * @param projection The columns to return
1882 * @param begin The start of the time range to query in UTC millis since
1883 * epoch
1884 * @param end The end of the time range to query in UTC millis since
1885 * epoch
1886 * @return A Cursor containing all instances in the given range
1887 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001888 public static final Cursor query(ContentResolver cr, String[] projection,
1889 long begin, long end) {
1890 Uri.Builder builder = CONTENT_URI.buildUpon();
1891 ContentUris.appendId(builder, begin);
1892 ContentUris.appendId(builder, end);
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001893 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
RoboErike00d5892011-06-23 15:16:55 -07001894 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001895 }
1896
RoboErikc2d53302011-06-03 09:37:58 -07001897 /**
1898 * Performs a query to return all visible instances in the given range
1899 * that match the given query. This is a blocking function and should
1900 * not be done on the UI thread. This will cause an expansion of
1901 * recurring events to fill this time range if they are not already
1902 * expanded and will slow down for larger time ranges with many
1903 * recurring events.
1904 *
1905 * @param cr The ContentResolver to use for the query
1906 * @param projection The columns to return
1907 * @param begin The start of the time range to query in UTC millis since
1908 * epoch
1909 * @param end The end of the time range to query in UTC millis since
1910 * epoch
1911 * @param searchQuery A string of space separated search terms. Segments
1912 * enclosed by double quotes will be treated as a single
1913 * term.
1914 * @return A Cursor of instances matching the search terms in the given
1915 * time range
1916 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001917 public static final Cursor query(ContentResolver cr, String[] projection,
Mason Tang19f84582010-07-08 18:01:41 -07001918 long begin, long end, String searchQuery) {
1919 Uri.Builder builder = CONTENT_SEARCH_URI.buildUpon();
1920 ContentUris.appendId(builder, begin);
1921 ContentUris.appendId(builder, end);
RoboErikc2d53302011-06-03 09:37:58 -07001922 builder = builder.appendPath(searchQuery);
RoboErike00d5892011-06-23 15:16:55 -07001923 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
1924 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
RoboErikc2d53302011-06-03 09:37:58 -07001925 }
1926
1927 /**
1928 * The content:// style URL for querying an instance range. The begin
1929 * and end of the range to query should be added as path segments if
1930 * this is used directly.
1931 */
1932 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001933 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1934 "/instances/when");
RoboErikc2d53302011-06-03 09:37:58 -07001935 /**
1936 * The content:// style URL for querying an instance range by Julian
1937 * Day. The start and end day should be added as path segments if this
1938 * is used directly.
1939 */
Michael Chan2cfb0d12009-06-30 18:11:23 -07001940 public static final Uri CONTENT_BY_DAY_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001941 Uri.parse("content://" + AUTHORITY + "/instances/whenbyday");
RoboErikc2d53302011-06-03 09:37:58 -07001942 /**
1943 * The content:// style URL for querying an instance range with a search
1944 * term. The begin, end, and search string should be appended as path
1945 * segments if this is used directly.
1946 */
Mason Tang19f84582010-07-08 18:01:41 -07001947 public static final Uri CONTENT_SEARCH_URI = Uri.parse("content://" + AUTHORITY +
1948 "/instances/search");
RoboErikc2d53302011-06-03 09:37:58 -07001949 /**
1950 * The content:// style URL for querying an instance range with a search
1951 * term. The start day, end day, and search string should be appended as
1952 * path segments if this is used directly.
1953 */
Mason Tang19f84582010-07-08 18:01:41 -07001954 public static final Uri CONTENT_SEARCH_BY_DAY_URI =
1955 Uri.parse("content://" + AUTHORITY + "/instances/searchbyday");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001956
1957 /**
yuemingw369f96d2018-12-05 22:07:04 +00001958 * The content:// style URL for querying an instance range in the managed profile.
yuemingwb714ba02018-10-26 18:54:44 +01001959 * It supports similar semantics as {@link #CONTENT_URI}.
1960 *
1961 * <p>The following columns plus the columns that are whitelisted by
1962 * {@link Events#ENTERPRISE_CONTENT_URI} are allowed to be queried via this uri:
1963 * <ul>
1964 * <li>{@link #_ID}</li>
1965 * <li>{@link #EVENT_ID}</li>
1966 * <li>{@link #BEGIN}</li>
1967 * <li>{@link #END}</li>
1968 * <li>{@link #START_DAY}</li>
1969 * <li>{@link #END_DAY}</li>
1970 * <li>{@link #START_MINUTE}</li>
1971 * <li>{@link #END_MINUTE}</li>
1972 * </ul>
1973 *
1974 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
1975 * projection of the query to this uri that are not contained in the above list.
1976 *
1977 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001978 * of a managed profile, or cross-profile calendar for the managed profile is disabled in
yuemingwb714ba02018-10-26 18:54:44 +01001979 * Settings, or this uri is queried from a package that is not whitelisted by
yuemingw369f96d2018-12-05 22:07:04 +00001980 * profile owner of the managed profile via
yuemingwd2bfbc82019-01-02 11:42:25 +00001981 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +01001982 *
1983 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
1984 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
1985 */
1986 public static final Uri ENTERPRISE_CONTENT_URI =
1987 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/when");
1988
1989 /**
1990 * The content:// style URL for querying an instance range by Julian
yuemingw369f96d2018-12-05 22:07:04 +00001991 * Day in the managed profile. It supports similar semantics as {@link #CONTENT_BY_DAY_URI}
yuemingwb714ba02018-10-26 18:54:44 +01001992 * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}.
1993 */
1994 public static final Uri ENTERPRISE_CONTENT_BY_DAY_URI =
1995 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/whenbyday");
1996
1997 /**
1998 * The content:// style URL for querying an instance range with a search
yuemingw369f96d2018-12-05 22:07:04 +00001999 * term in the managed profile. It supports similar semantics as {@link #CONTENT_SEARCH_URI}
yuemingwb714ba02018-10-26 18:54:44 +01002000 * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}.
2001 */
2002 public static final Uri ENTERPRISE_CONTENT_SEARCH_URI =
2003 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/search");
2004
2005 /**
2006 * The content:// style URL for querying an instance range with a search
yuemingw369f96d2018-12-05 22:07:04 +00002007 * term in the managed profile. It supports similar semantics as
yuemingwb714ba02018-10-26 18:54:44 +01002008 * {@link #CONTENT_SEARCH_BY_DAY_URI} and performs similar checks as
2009 * {@link #ENTERPRISE_CONTENT_URI}.
2010 */
2011 public static final Uri ENTERPRISE_CONTENT_SEARCH_BY_DAY_URI =
2012 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/searchbyday");
2013
2014 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002015 * The default sort order for this table.
2016 */
RoboErikc2d53302011-06-03 09:37:58 -07002017 private static final String DEFAULT_SORT_ORDER = "begin ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002018
2019 /**
RoboErikc2d53302011-06-03 09:37:58 -07002020 * The beginning time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002021 * <P>Type: INTEGER (long; millis since epoch)</P>
2022 */
2023 public static final String BEGIN = "begin";
2024
2025 /**
RoboErikc2d53302011-06-03 09:37:58 -07002026 * The ending time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002027 * <P>Type: INTEGER (long; millis since epoch)</P>
2028 */
2029 public static final String END = "end";
2030
2031 /**
RoboErikc2d53302011-06-03 09:37:58 -07002032 * The _id of the event for this instance. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002033 * <P>Type: INTEGER (long, foreign key to the Events table)</P>
2034 */
2035 public static final String EVENT_ID = "event_id";
2036
2037 /**
RoboErikc2d53302011-06-03 09:37:58 -07002038 * The Julian start day of the instance, relative to the local time
2039 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002040 * <P>Type: INTEGER (int)</P>
2041 */
2042 public static final String START_DAY = "startDay";
2043
2044 /**
RoboErikc2d53302011-06-03 09:37:58 -07002045 * The Julian end day of the instance, relative to the local time
2046 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002047 * <P>Type: INTEGER (int)</P>
2048 */
2049 public static final String END_DAY = "endDay";
2050
2051 /**
2052 * The start minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07002053 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002054 * <P>Type: INTEGER (int)</P>
2055 */
2056 public static final String START_MINUTE = "startMinute";
2057
2058 /**
2059 * The end minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07002060 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002061 * <P>Type: INTEGER (int)</P>
2062 */
2063 public static final String END_MINUTE = "endMinute";
2064 }
2065
RoboErikb2c75602011-06-13 12:53:48 -07002066 protected interface CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07002067 /**
RoboErikc2d53302011-06-03 09:37:58 -07002068 * The key for the setting. Keys are defined in {@link CalendarCache}.
Erik71ad58c2010-09-13 16:41:35 -07002069 */
2070 public static final String KEY = "key";
2071
2072 /**
2073 * The value of the given setting.
2074 */
2075 public static final String VALUE = "value";
2076 }
2077
RoboErik083cd2d2011-06-30 11:53:05 -07002078 /**
2079 * CalendarCache stores some settings for calendar including the current
2080 * time zone for the instances. These settings are stored using a key/value
2081 * scheme. A {@link #KEY} must be specified when updating these values.
2082 */
RoboErik36726962011-06-14 14:01:15 -07002083 public static final class CalendarCache implements CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07002084 /**
2085 * The URI to use for retrieving the properties from the Calendar db.
2086 */
2087 public static final Uri URI =
2088 Uri.parse("content://" + AUTHORITY + "/properties");
Erik71ad58c2010-09-13 16:41:35 -07002089
2090 /**
RoboErik36726962011-06-14 14:01:15 -07002091 * This utility class cannot be instantiated
2092 */
2093 private CalendarCache() {}
2094
2095 /**
Erik71ad58c2010-09-13 16:41:35 -07002096 * They key for updating the use of auto/home time zones in Calendar.
2097 * Valid values are {@link #TIMEZONE_TYPE_AUTO} or
2098 * {@link #TIMEZONE_TYPE_HOME}.
2099 */
RoboErik083cd2d2011-06-30 11:53:05 -07002100 public static final String KEY_TIMEZONE_TYPE = "timezoneType";
Erik71ad58c2010-09-13 16:41:35 -07002101
2102 /**
2103 * The key for updating the time zone used by the provider when it
2104 * generates the instances table. This should only be written if the
2105 * type is set to {@link #TIMEZONE_TYPE_HOME}. A valid time zone id
2106 * should be written to this field.
2107 */
RoboErik083cd2d2011-06-30 11:53:05 -07002108 public static final String KEY_TIMEZONE_INSTANCES = "timezoneInstances";
Erik71ad58c2010-09-13 16:41:35 -07002109
2110 /**
2111 * The key for reading the last time zone set by the user. This should
2112 * only be read by apps and it will be automatically updated whenever
RoboErik083cd2d2011-06-30 11:53:05 -07002113 * {@link #KEY_TIMEZONE_INSTANCES} is updated with
Erik71ad58c2010-09-13 16:41:35 -07002114 * {@link #TIMEZONE_TYPE_HOME} set.
2115 */
RoboErik083cd2d2011-06-30 11:53:05 -07002116 public static final String KEY_TIMEZONE_INSTANCES_PREVIOUS = "timezoneInstancesPrevious";
Erik71ad58c2010-09-13 16:41:35 -07002117
2118 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002119 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07002120 * should stay in sync with the device's time zone.
2121 */
2122 public static final String TIMEZONE_TYPE_AUTO = "auto";
2123
2124 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002125 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07002126 * should use a fixed time zone set by the user.
2127 */
2128 public static final String TIMEZONE_TYPE_HOME = "home";
2129 }
2130
2131 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002132 * A few Calendar globals are needed in the CalendarProvider for expanding
RoboErik59dab492011-06-17 11:09:36 -07002133 * the Instances table and these are all stored in the first (and only) row
2134 * of the CalendarMetaData table.
2135 *
2136 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002137 */
RoboErikb2c75602011-06-13 12:53:48 -07002138 protected interface CalendarMetaDataColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002139 /**
2140 * The local timezone that was used for precomputing the fields
2141 * in the Instances table.
2142 */
2143 public static final String LOCAL_TIMEZONE = "localTimezone";
2144
2145 /**
2146 * The minimum time used in expanding the Instances table,
2147 * in UTC milliseconds.
2148 * <P>Type: INTEGER</P>
2149 */
2150 public static final String MIN_INSTANCE = "minInstance";
2151
2152 /**
2153 * The maximum time used in expanding the Instances table,
2154 * in UTC milliseconds.
2155 * <P>Type: INTEGER</P>
2156 */
2157 public static final String MAX_INSTANCE = "maxInstance";
2158
2159 /**
Erik37634642009-12-23 15:24:14 -08002160 * The minimum Julian day in the EventDays table.
2161 * <P>Type: INTEGER</P>
2162 */
2163 public static final String MIN_EVENTDAYS = "minEventDays";
2164
2165 /**
2166 * The maximum Julian day in the EventDays table.
2167 * <P>Type: INTEGER</P>
2168 */
2169 public static final String MAX_EVENTDAYS = "maxEventDays";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002170 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002171
RoboErikc2d53302011-06-03 09:37:58 -07002172 /**
2173 * @hide
2174 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002175 public static final class CalendarMetaData implements CalendarMetaDataColumns, BaseColumns {
RoboErik36726962011-06-14 14:01:15 -07002176
2177 /**
2178 * This utility class cannot be instantiated
2179 */
2180 private CalendarMetaData() {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002181 }
Erik37634642009-12-23 15:24:14 -08002182
RoboErikb2c75602011-06-13 12:53:48 -07002183 protected interface EventDaysColumns {
Erik37634642009-12-23 15:24:14 -08002184 /**
RoboErikc2d53302011-06-03 09:37:58 -07002185 * The Julian starting day number. Column name.
Erik37634642009-12-23 15:24:14 -08002186 * <P>Type: INTEGER (int)</P>
2187 */
2188 public static final String STARTDAY = "startDay";
RoboErikc2d53302011-06-03 09:37:58 -07002189 /**
2190 * The Julian ending day number. Column name.
2191 * <P>Type: INTEGER (int)</P>
2192 */
Erikbd8e2e22010-01-07 11:56:46 -08002193 public static final String ENDDAY = "endDay";
Erik37634642009-12-23 15:24:14 -08002194
2195 }
2196
RoboErikc2d53302011-06-03 09:37:58 -07002197 /**
2198 * Fields and helpers for querying for a list of days that contain events.
2199 */
Erik37634642009-12-23 15:24:14 -08002200 public static final class EventDays implements EventDaysColumns {
RoboErikb2c75602011-06-13 12:53:48 -07002201 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
RoboErikc2d53302011-06-03 09:37:58 -07002202 + "/instances/groupbyday");
RoboErikc2d53302011-06-03 09:37:58 -07002203 private static final String SELECTION = "selected=1";
2204
2205 /**
RoboErik36726962011-06-14 14:01:15 -07002206 * This utility class cannot be instantiated
2207 */
2208 private EventDays() {}
2209
2210 /**
RoboErikc2d53302011-06-03 09:37:58 -07002211 * Retrieves the days with events for the Julian days starting at
2212 * "startDay" for "numDays". It returns a cursor containing startday and
2213 * endday representing the max range of days for all events beginning on
2214 * each startday.This is a blocking function and should not be done on
2215 * the UI thread.
RoboErik36726962011-06-14 14:01:15 -07002216 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002217 * @param cr the ContentResolver
2218 * @param startDay the first Julian day in the range
2219 * @param numDays the number of days to load (must be at least 1)
RoboErik58644022011-07-08 13:39:05 -07002220 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07002221 * @return a database cursor containing a list of start and end days for
2222 * events
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002223 */
RoboErik58644022011-07-08 13:39:05 -07002224 public static final Cursor query(ContentResolver cr, int startDay, int numDays,
2225 String[] projection) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 if (numDays < 1) {
2227 return null;
2228 }
2229 int endDay = startDay + numDays - 1;
2230 Uri.Builder builder = CONTENT_URI.buildUpon();
2231 ContentUris.appendId(builder, startDay);
2232 ContentUris.appendId(builder, endDay);
RoboErik58644022011-07-08 13:39:05 -07002233 return cr.query(builder.build(), projection, SELECTION,
Erik37634642009-12-23 15:24:14 -08002234 null /* selection args */, STARTDAY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002235 }
2236 }
2237
RoboErikb2c75602011-06-13 12:53:48 -07002238 protected interface RemindersColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002239 /**
RoboErikc2d53302011-06-03 09:37:58 -07002240 * The event the reminder belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002241 * <P>Type: INTEGER (foreign key to the Events table)</P>
2242 */
2243 public static final String EVENT_ID = "event_id";
2244
2245 /**
2246 * The minutes prior to the event that the alarm should ring. -1
2247 * specifies that we should use the default value for the system.
RoboErikc2d53302011-06-03 09:37:58 -07002248 * Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002249 * <P>Type: INTEGER</P>
2250 */
2251 public static final String MINUTES = "minutes";
2252
RoboErikc2d53302011-06-03 09:37:58 -07002253 /**
2254 * Passing this as a minutes value will use the default reminder
2255 * minutes.
2256 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002257 public static final int MINUTES_DEFAULT = -1;
2258
2259 /**
RoboErikc2d53302011-06-03 09:37:58 -07002260 * The alarm method, as set on the server. {@link #METHOD_DEFAULT},
Alon Albertbd251612012-02-23 10:30:51 -08002261 * {@link #METHOD_ALERT}, {@link #METHOD_EMAIL}, {@link #METHOD_SMS} and
2262 * {@link #METHOD_ALARM} are possible values; the device will only
2263 * process {@link #METHOD_DEFAULT} and {@link #METHOD_ALERT} reminders
2264 * (the other types are simply stored so we can send the same reminder
2265 * info back to the server when we make changes).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002266 */
2267 public static final String METHOD = "method";
2268
2269 public static final int METHOD_DEFAULT = 0;
2270 public static final int METHOD_ALERT = 1;
2271 public static final int METHOD_EMAIL = 2;
2272 public static final int METHOD_SMS = 3;
Alon Albertbd251612012-02-23 10:30:51 -08002273 public static final int METHOD_ALARM = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002274 }
2275
RoboErikc2d53302011-06-03 09:37:58 -07002276 /**
RoboErik3771fcb2011-06-16 15:41:31 -07002277 * Fields and helpers for accessing reminders for an event. Each row of this
2278 * table represents a single reminder for an event. Calling
RoboErik58644022011-07-08 13:39:05 -07002279 * {@link #query(ContentResolver, long, String[])} will return a list of reminders for
RoboErik3771fcb2011-06-16 15:41:31 -07002280 * the event with the given eventId. Both apps and sync adapters may write
2281 * to this table. There are three writable fields and all of them must be
2282 * included when inserting a new reminder. They are:
2283 * <ul>
2284 * <li>{@link #EVENT_ID}</li>
2285 * <li>{@link #MINUTES}</li>
2286 * <li>{@link #METHOD}</li>
2287 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07002288 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002289 public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns {
RoboErikbec6c362011-06-14 11:06:01 -07002290 private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?";
RoboErikc2d53302011-06-03 09:37:58 -07002291 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002292 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders");
RoboErikc2d53302011-06-03 09:37:58 -07002293
2294 /**
RoboErik36726962011-06-14 14:01:15 -07002295 * This utility class cannot be instantiated
2296 */
2297 private Reminders() {}
2298
2299 /**
RoboErikc2d53302011-06-03 09:37:58 -07002300 * Queries all reminders associated with the given event. This is a
2301 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -07002302 *
RoboErikc2d53302011-06-03 09:37:58 -07002303 * @param cr The content resolver to use for the query
2304 * @param eventId The id of the event to retrieve reminders for
RoboErik58644022011-07-08 13:39:05 -07002305 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07002306 * @return A Cursor containing all reminders for the event
2307 */
RoboErik58644022011-07-08 13:39:05 -07002308 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -07002309 String[] remArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -07002310 return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/,
RoboErikc2d53302011-06-03 09:37:58 -07002311 null /* sort order */);
2312 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002313 }
2314
RoboErikb2c75602011-06-13 12:53:48 -07002315 protected interface CalendarAlertsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002316 /**
RoboErikc2d53302011-06-03 09:37:58 -07002317 * The event that the alert belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002318 * <P>Type: INTEGER (foreign key to the Events table)</P>
2319 */
2320 public static final String EVENT_ID = "event_id";
2321
2322 /**
RoboErikc2d53302011-06-03 09:37:58 -07002323 * The start time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002324 * <P>Type: INTEGER (long; millis since epoch)</P>
2325 */
2326 public static final String BEGIN = "begin";
2327
2328 /**
RoboErikc2d53302011-06-03 09:37:58 -07002329 * The end time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002330 * <P>Type: INTEGER (long; millis since epoch)</P>
2331 */
2332 public static final String END = "end";
2333
2334 /**
RoboErikc2d53302011-06-03 09:37:58 -07002335 * The alarm time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002336 * <P>Type: INTEGER (long; millis since epoch)</P>
2337 */
2338 public static final String ALARM_TIME = "alarmTime";
2339
2340 /**
2341 * The creation time of this database entry, in UTC.
RoboErikc2d53302011-06-03 09:37:58 -07002342 * Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002343 * <P>Type: INTEGER (long; millis since epoch)</P>
2344 */
2345 public static final String CREATION_TIME = "creationTime";
2346
2347 /**
2348 * The time that the alarm broadcast was received by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002349 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002350 * <P>Type: INTEGER (long; millis since epoch)</P>
2351 */
2352 public static final String RECEIVED_TIME = "receivedTime";
2353
2354 /**
2355 * The time that the notification was created by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002356 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002357 * <P>Type: INTEGER (long; millis since epoch)</P>
2358 */
2359 public static final String NOTIFY_TIME = "notifyTime";
2360
2361 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002362 * The state of this alert. It starts out as {@link #STATE_SCHEDULED}, then
2363 * when the alarm goes off, it changes to {@link #STATE_FIRED}, and then when
2364 * the user dismisses the alarm it changes to {@link #STATE_DISMISSED}. Column
RoboErikc2d53302011-06-03 09:37:58 -07002365 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002366 * <P>Type: INTEGER</P>
2367 */
2368 public static final String STATE = "state";
2369
RoboErik083cd2d2011-06-30 11:53:05 -07002370 /**
2371 * An alert begins in this state when it is first created.
2372 */
2373 public static final int STATE_SCHEDULED = 0;
2374 /**
2375 * After a notification for an alert has been created it should be
2376 * updated to fired.
2377 */
2378 public static final int STATE_FIRED = 1;
2379 /**
2380 * Once the user has dismissed the notification the alert's state should
2381 * be set to dismissed so it is not fired again.
2382 */
2383 public static final int STATE_DISMISSED = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002384
2385 /**
RoboErikc2d53302011-06-03 09:37:58 -07002386 * The number of minutes that this alarm precedes the start time. Column
2387 * name.
2388 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002389 */
2390 public static final String MINUTES = "minutes";
2391
2392 /**
RoboErikc2d53302011-06-03 09:37:58 -07002393 * The default sort order for this alerts queries
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002394 */
Michael Chancdaeafd2009-10-29 00:11:58 -07002395 public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002396 }
2397
RoboErikc2d53302011-06-03 09:37:58 -07002398 /**
2399 * Fields and helpers for accessing calendar alerts information. These
RoboErik3771fcb2011-06-16 15:41:31 -07002400 * fields are for tracking which alerts have been fired. Scheduled alarms
RoboErike00d5892011-06-23 15:16:55 -07002401 * will generate an intent using {@link #ACTION_EVENT_REMINDER}. Apps that
RoboErik3771fcb2011-06-16 15:41:31 -07002402 * receive this action may update the {@link #STATE} for the reminder when
2403 * they have finished handling it. Apps that have their notifications
2404 * disabled should not modify the table to ensure that they do not conflict
2405 * with another app that is generating a notification. In general, apps
2406 * should not need to write to this table directly except to update the
2407 * state of a reminder.
RoboErikc2d53302011-06-03 09:37:58 -07002408 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002409 public static final class CalendarAlerts implements BaseColumns,
RoboErike00d5892011-06-23 15:16:55 -07002410 CalendarAlertsColumns, EventsColumns, CalendarColumns {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002411
RoboErikc2d53302011-06-03 09:37:58 -07002412 /**
2413 * @hide
2414 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002415 public static final String TABLE_NAME = "CalendarAlerts";
RoboErikc2d53302011-06-03 09:37:58 -07002416 /**
2417 * The Uri for querying calendar alert information
2418 */
2419 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002420 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
2421 "/calendar_alerts");
Ken Shirriff5b387e12009-10-23 09:50:41 -07002422
RoboErik36726962011-06-14 14:01:15 -07002423 /**
2424 * This utility class cannot be instantiated
2425 */
2426 private CalendarAlerts() {}
2427
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002428 private static final String WHERE_ALARM_EXISTS = EVENT_ID + "=?"
2429 + " AND " + BEGIN + "=?"
2430 + " AND " + ALARM_TIME + "=?";
2431
2432 private static final String WHERE_FINDNEXTALARMTIME = ALARM_TIME + ">=?";
2433 private static final String SORT_ORDER_ALARMTIME_ASC = ALARM_TIME + " ASC";
2434
RoboErik083cd2d2011-06-30 11:53:05 -07002435 private static final String WHERE_RESCHEDULE_MISSED_ALARMS = STATE + "=" + STATE_SCHEDULED
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002436 + " AND " + ALARM_TIME + "<?"
2437 + " AND " + ALARM_TIME + ">?"
2438 + " AND " + END + ">=?";
2439
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002440 /**
2441 * This URI is for grouping the query results by event_id and begin
2442 * time. This will return one result per instance of an event. So
2443 * events with multiple alarms will appear just once, but multiple
2444 * instances of a repeating event will show up multiple times.
2445 */
Ken Shirriff5b387e12009-10-23 09:50:41 -07002446 public static final Uri CONTENT_URI_BY_INSTANCE =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002447 Uri.parse("content://" + AUTHORITY + "/calendar_alerts/by_instance");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002448
RoboErik083cd2d2011-06-30 11:53:05 -07002449 private static final boolean DEBUG = false;
Michael Chancdaeafd2009-10-29 00:11:58 -07002450
RoboErikc2d53302011-06-03 09:37:58 -07002451 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002452 * Helper for inserting an alarm time associated with an event TODO move
2453 * to Provider
RoboErikc2d53302011-06-03 09:37:58 -07002454 *
2455 * @hide
2456 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002457 public static final Uri insert(ContentResolver cr, long eventId,
2458 long begin, long end, long alarmTime, int minutes) {
2459 ContentValues values = new ContentValues();
2460 values.put(CalendarAlerts.EVENT_ID, eventId);
2461 values.put(CalendarAlerts.BEGIN, begin);
2462 values.put(CalendarAlerts.END, end);
2463 values.put(CalendarAlerts.ALARM_TIME, alarmTime);
2464 long currentTime = System.currentTimeMillis();
2465 values.put(CalendarAlerts.CREATION_TIME, currentTime);
2466 values.put(CalendarAlerts.RECEIVED_TIME, 0);
2467 values.put(CalendarAlerts.NOTIFY_TIME, 0);
RoboErik083cd2d2011-06-30 11:53:05 -07002468 values.put(CalendarAlerts.STATE, STATE_SCHEDULED);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002469 values.put(CalendarAlerts.MINUTES, minutes);
2470 return cr.insert(CONTENT_URI, values);
2471 }
2472
RoboErikc2d53302011-06-03 09:37:58 -07002473 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002474 * Finds the next alarm after (or equal to) the given time and returns
RoboErikc2d53302011-06-03 09:37:58 -07002475 * the time of that alarm or -1 if no such alarm exists. This is a
RoboErik083cd2d2011-06-30 11:53:05 -07002476 * blocking call and should not be done on the UI thread. TODO move to
2477 * provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002478 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002479 * @param cr the ContentResolver
2480 * @param millis the time in UTC milliseconds
2481 * @return the next alarm time greater than or equal to "millis", or -1
RoboErikc2d53302011-06-03 09:37:58 -07002482 * if no such alarm exists.
RoboErik083cd2d2011-06-30 11:53:05 -07002483 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002484 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002485 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002486 public static final long findNextAlarmTime(ContentResolver cr, long millis) {
2487 String selection = ALARM_TIME + ">=" + millis;
2488 // TODO: construct an explicit SQL query so that we can add
2489 // "LIMIT 1" to the end and get just one result.
2490 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002491 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_FINDNEXTALARMTIME,
2492 (new String[] {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002493 Long.toString(millis)
RoboErik083cd2d2011-06-30 11:53:05 -07002494 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002495 long alarmTime = -1;
2496 try {
2497 if (cursor != null && cursor.moveToFirst()) {
2498 alarmTime = cursor.getLong(0);
2499 }
2500 } finally {
2501 if (cursor != null) {
2502 cursor.close();
2503 }
2504 }
2505 return alarmTime;
2506 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002507
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002508 /**
2509 * Searches the CalendarAlerts table for alarms that should have fired
RoboErik083cd2d2011-06-30 11:53:05 -07002510 * but have not and then reschedules them. This method can be called at
2511 * boot time to restore alarms that may have been lost due to a phone
2512 * reboot. TODO move to provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002513 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002514 * @param cr the ContentResolver
2515 * @param context the Context
2516 * @param manager the AlarmManager
RoboErik083cd2d2011-06-30 11:53:05 -07002517 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002518 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002519 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002520 public static final void rescheduleMissedAlarms(ContentResolver cr,
2521 Context context, AlarmManager manager) {
2522 // Get all the alerts that have been scheduled but have not fired
2523 // and should have fired by now and are not too old.
2524 long now = System.currentTimeMillis();
Michael Chancdaeafd2009-10-29 00:11:58 -07002525 long ancient = now - DateUtils.DAY_IN_MILLIS;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002526 String[] projection = new String[] {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002527 ALARM_TIME,
2528 };
Michael Chancdaeafd2009-10-29 00:11:58 -07002529
2530 // TODO: construct an explicit SQL query so that we can add
2531 // "GROUPBY" instead of doing a sort and de-dup
RoboErik083cd2d2011-06-30 11:53:05 -07002532 Cursor cursor = cr.query(CalendarAlerts.CONTENT_URI, projection,
2533 WHERE_RESCHEDULE_MISSED_ALARMS, (new String[] {
2534 Long.toString(now), Long.toString(ancient), Long.toString(now)
2535 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002536 if (cursor == null) {
2537 return;
2538 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002539
2540 if (DEBUG) {
The Android Open Source Project10592532009-03-18 17:39:46 -07002541 Log.d(TAG, "missed alarms found: " + cursor.getCount());
2542 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002543
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002544 try {
Michael Chancdaeafd2009-10-29 00:11:58 -07002545 long alarmTime = -1;
2546
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002547 while (cursor.moveToNext()) {
Michael Chancdaeafd2009-10-29 00:11:58 -07002548 long newAlarmTime = cursor.getLong(0);
2549 if (alarmTime != newAlarmTime) {
2550 if (DEBUG) {
2551 Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime);
2552 }
2553 scheduleAlarm(context, manager, newAlarmTime);
2554 alarmTime = newAlarmTime;
2555 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002556 }
2557 } finally {
2558 cursor.close();
2559 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002560 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002561
RoboErikc2d53302011-06-03 09:37:58 -07002562 /**
2563 * Schedules an alarm intent with the system AlarmManager that will
RoboErik3771fcb2011-06-16 15:41:31 -07002564 * notify listeners when a reminder should be fired. The provider will
2565 * keep scheduled reminders up to date but apps may use this to
2566 * implement snooze functionality without modifying the reminders table.
2567 * Scheduled alarms will generate an intent using
RoboErik083cd2d2011-06-30 11:53:05 -07002568 * {@link #ACTION_EVENT_REMINDER}. TODO Move to provider
RoboErikc2d53302011-06-03 09:37:58 -07002569 *
2570 * @param context A context for referencing system resources
2571 * @param manager The AlarmManager to use or null
2572 * @param alarmTime The time to fire the intent in UTC millis since
2573 * epoch
RoboErik083cd2d2011-06-30 11:53:05 -07002574 * @hide
RoboErikc2d53302011-06-03 09:37:58 -07002575 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002576 @UnsupportedAppUsage
Michael Chancdaeafd2009-10-29 00:11:58 -07002577 public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) {
2578 if (DEBUG) {
2579 Time time = new Time();
2580 time.set(alarmTime);
2581 String schedTime = time.format(" %a, %b %d, %Y %I:%M%P");
2582 Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime);
2583 }
2584
2585 if (manager == null) {
2586 manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
2587 }
2588
RoboErike00d5892011-06-23 15:16:55 -07002589 Intent intent = new Intent(ACTION_EVENT_REMINDER);
RoboErikbec6c362011-06-14 11:06:01 -07002590 intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime));
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002591 intent.putExtra(ALARM_TIME, alarmTime);
Makoto Onukib63830a2017-02-09 17:06:28 -08002592 intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
Erik42f19572010-03-17 16:17:22 -07002593 PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
Tony Makfaf96ebc2015-07-02 17:05:35 +01002594 manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002595 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002596
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002597 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002598 * Searches for an entry in the CalendarAlerts table that matches the
2599 * given event id, begin time and alarm time. If one is found then this
2600 * alarm already exists and this method returns true. TODO Move to
2601 * provider
RoboErik58644022011-07-08 13:39:05 -07002602 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002603 * @param cr the ContentResolver
2604 * @param eventId the event id to match
2605 * @param begin the start time of the event in UTC millis
2606 * @param alarmTime the alarm time of the event in UTC millis
RoboErik083cd2d2011-06-30 11:53:05 -07002607 * @return true if there is already an alarm for the given event with
2608 * the same start time and alarm time.
2609 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002610 */
2611 public static final boolean alarmExists(ContentResolver cr, long eventId,
2612 long begin, long alarmTime) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002613 // TODO: construct an explicit SQL query so that we can add
2614 // "LIMIT 1" to the end and get just one result.
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002615 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002616 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_ALARM_EXISTS,
2617 (new String[] {
2618 Long.toString(eventId), Long.toString(begin), Long.toString(alarmTime)
2619 }), null);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002620 boolean found = false;
2621 try {
2622 if (cursor != null && cursor.getCount() > 0) {
2623 found = true;
2624 }
2625 } finally {
2626 if (cursor != null) {
2627 cursor.close();
2628 }
2629 }
2630 return found;
2631 }
2632 }
2633
RoboErikf8143c52011-09-28 15:16:00 -07002634 protected interface ColorsColumns extends SyncStateContract.Columns {
2635
2636 /**
2637 * The type of color, which describes how it should be used. Valid types
2638 * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name.
2639 * <P>
2640 * Type: INTEGER (NOT NULL)
2641 * </P>
2642 */
2643 public static final String COLOR_TYPE = "color_type";
2644
2645 /**
2646 * This indicateds a color that can be used for calendars.
2647 */
2648 public static final int TYPE_CALENDAR = 0;
2649 /**
2650 * This indicates a color that can be used for events.
2651 */
2652 public static final int TYPE_EVENT = 1;
2653
2654 /**
RoboErik4172d952011-10-25 13:59:13 -07002655 * The key used to reference this color. This can be any non-empty
RoboErikf8143c52011-09-28 15:16:00 -07002656 * string, but must be unique for a given {@link #ACCOUNT_TYPE} and
RoboErik8a8eebc2011-10-20 16:57:18 -07002657 * {@link #ACCOUNT_NAME}. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002658 * <P>
2659 * Type: TEXT
2660 * </P>
2661 */
RoboErik4172d952011-10-25 13:59:13 -07002662 public static final String COLOR_KEY = "color_index";
RoboErikf8143c52011-09-28 15:16:00 -07002663
2664 /**
RoboErik05b36e52011-10-14 15:31:15 -07002665 * The color as an 8-bit ARGB integer value. Colors should specify alpha
2666 * as fully opaque (eg 0xFF993322) as the alpha may be ignored or
2667 * modified for display. It is reccomended that colors be usable with
2668 * light (near white) text. Apps should not depend on that assumption,
2669 * however. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002670 * <P>
2671 * Type: INTEGER (NOT NULL)
2672 * </P>
2673 */
RoboErik05b36e52011-10-14 15:31:15 -07002674 public static final String COLOR = "color";
RoboErikf8143c52011-09-28 15:16:00 -07002675
2676 }
2677
2678 /**
2679 * Fields for accessing colors available for a given account. Colors are
RoboErik4172d952011-10-25 13:59:13 -07002680 * referenced by {@link #COLOR_KEY} which must be unique for a given
RoboErik0c559c62011-10-21 11:20:51 -07002681 * account name/type. These values can only be updated by the sync
RoboErik8a8eebc2011-10-20 16:57:18 -07002682 * adapter. Only {@link #COLOR} may be updated after the initial insert. In
2683 * addition, a row can only be deleted once all references to that color
2684 * have been removed from the {@link Calendars} or {@link Events} tables.
RoboErikf8143c52011-09-28 15:16:00 -07002685 */
2686 public static final class Colors implements ColorsColumns {
2687 /**
2688 * @hide
2689 */
2690 public static final String TABLE_NAME = "Colors";
2691 /**
2692 * The Uri for querying color information
2693 */
2694 @SuppressWarnings("hiding")
2695 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors");
2696
2697 /**
2698 * This utility class cannot be instantiated
2699 */
2700 private Colors() {
2701 }
2702 }
2703
RoboErikb2c75602011-06-13 12:53:48 -07002704 protected interface ExtendedPropertiesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002705 /**
RoboErikc2d53302011-06-03 09:37:58 -07002706 * The event the extended property belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002707 * <P>Type: INTEGER (foreign key to the Events table)</P>
2708 */
2709 public static final String EVENT_ID = "event_id";
2710
2711 /**
2712 * The name of the extended property. This is a uri of the form
RoboErikc2d53302011-06-03 09:37:58 -07002713 * {scheme}#{local-name} convention. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002714 * <P>Type: TEXT</P>
2715 */
2716 public static final String NAME = "name";
2717
2718 /**
RoboErikc2d53302011-06-03 09:37:58 -07002719 * The value of the extended property. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002720 * <P>Type: TEXT</P>
2721 */
2722 public static final String VALUE = "value";
2723 }
2724
RoboErikc2d53302011-06-03 09:37:58 -07002725 /**
2726 * Fields for accessing the Extended Properties. This is a generic set of
Michael Chan73bddfc2011-10-19 18:21:49 -07002727 * name/value pairs for use by sync adapters to add extra
RoboErik3771fcb2011-06-16 15:41:31 -07002728 * information to events. There are three writable columns and all three
2729 * must be present when inserting a new value. They are:
2730 * <ul>
2731 * <li>{@link #EVENT_ID}</li>
2732 * <li>{@link #NAME}</li>
2733 * <li>{@link #VALUE}</li>
2734 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07002735 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002736 public static final class ExtendedProperties implements BaseColumns,
2737 ExtendedPropertiesColumns, EventsColumns {
2738 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002739 Uri.parse("content://" + AUTHORITY + "/extendedproperties");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002740
RoboErik36726962011-06-14 14:01:15 -07002741 /**
2742 * This utility class cannot be instantiated
2743 */
2744 private ExtendedProperties() {}
2745
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002746 // TODO: fill out this class when we actually start utilizing extendedproperties
2747 // in the calendar application.
2748 }
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002749
2750 /**
2751 * A table provided for sync adapters to use for storing private sync state data.
2752 *
2753 * @see SyncStateContract
2754 */
2755 public static final class SyncState implements SyncStateContract.Columns {
2756 /**
2757 * This utility class cannot be instantiated
2758 */
2759 private SyncState() {}
2760
RoboErikc2d53302011-06-03 09:37:58 -07002761 private static final String CONTENT_DIRECTORY =
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002762 SyncStateContract.Constants.CONTENT_DIRECTORY;
2763
2764 /**
2765 * The content:// style URI for this table
2766 */
2767 public static final Uri CONTENT_URI =
RoboErikbec6c362011-06-14 11:06:01 -07002768 Uri.withAppendedPath(CalendarContract.CONTENT_URI, CONTENT_DIRECTORY);
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002769 }
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002770
2771 /**
2772 * Columns from the EventsRawTimes table
RoboErik3771fcb2011-06-16 15:41:31 -07002773 *
2774 * @hide
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002775 */
RoboErikb2c75602011-06-13 12:53:48 -07002776 protected interface EventsRawTimesColumns {
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002777 /**
RoboErikc2d53302011-06-03 09:37:58 -07002778 * The corresponding event id. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002779 * <P>Type: INTEGER (long)</P>
2780 */
2781 public static final String EVENT_ID = "event_id";
2782
2783 /**
RoboErikc2d53302011-06-03 09:37:58 -07002784 * The RFC2445 compliant time the event starts. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002785 * <P>Type: TEXT</P>
2786 */
2787 public static final String DTSTART_2445 = "dtstart2445";
2788
2789 /**
RoboErikc2d53302011-06-03 09:37:58 -07002790 * The RFC2445 compliant time the event ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002791 * <P>Type: TEXT</P>
2792 */
2793 public static final String DTEND_2445 = "dtend2445";
2794
2795 /**
RoboErikc2d53302011-06-03 09:37:58 -07002796 * The RFC2445 compliant original instance time of the recurring event
2797 * for which this event is an exception. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002798 * <P>Type: TEXT</P>
2799 */
2800 public static final String ORIGINAL_INSTANCE_TIME_2445 = "originalInstanceTime2445";
2801
2802 /**
RoboErikc2d53302011-06-03 09:37:58 -07002803 * The RFC2445 compliant last date this event repeats on, or NULL if it
2804 * never ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002805 * <P>Type: TEXT</P>
2806 */
2807 public static final String LAST_DATE_2445 = "lastDate2445";
2808 }
2809
RoboErikc2d53302011-06-03 09:37:58 -07002810 /**
2811 * @hide
2812 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002813 public static final class EventsRawTimes implements BaseColumns, EventsRawTimesColumns {
RoboErik36726962011-06-14 14:01:15 -07002814
2815 /**
2816 * This utility class cannot be instantiated
2817 */
2818 private EventsRawTimes() {}
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002819 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002820}