blob: 5d34aa65937d9163eaba5c9d14593f28469be0f8 [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 /**
yuemingw67b21502019-02-28 17:55:46 +0000186 * The content:// style URL for the top-level cross-profile calendar uris.
187 * {@link android.database.ContentObserver} for this URL in the primary profile will be
188 * notified when there is a change in the managed profile calendar provider.
189 *
190 * @see Events#ENTERPRISE_CONTENT_URI
191 * @see Calendars#ENTERPRISE_CONTENT_URI
192 * @see Instances#ENTERPRISE_CONTENT_URI
193 * @see Instances#ENTERPRISE_CONTENT_BY_DAY_URI
194 * @see Instances#ENTERPRISE_CONTENT_SEARCH_URI
195 * @see Instances#ENTERPRISE_CONTENT_SEARCH_BY_DAY_URI
196 * @hide
197 */
198 public static final Uri ENTERPRISE_CONTENT_URI = Uri.parse(
199 "content://" + AUTHORITY + "/enterprise");
200
201 /**
Ken Shirriff5b387e12009-10-23 09:50:41 -0700202 * An optional insert, update or delete URI parameter that allows the caller
RoboErikc2d53302011-06-03 09:37:58 -0700203 * to specify that it is a sync adapter. The default value is false. If set
204 * to true, the modified row is not marked as "dirty" (needs to be synced)
205 * and when the provider calls
206 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}
207 * , the third parameter "syncToNetwork" is set to false. Furthermore, if
208 * set to true, the caller must also include
Andy McFadden6f5b4552011-06-09 15:43:59 -0700209 * {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as
RoboErikc2d53302011-06-03 09:37:58 -0700210 * query parameters.
211 *
Andy McFadden6f5b4552011-06-09 15:43:59 -0700212 * @see Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)
Ken Shirriff5b387e12009-10-23 09:50:41 -0700213 */
214 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
215
RoboErikc2d53302011-06-03 09:37:58 -0700216 /**
217 * A special account type for calendars not associated with any account.
218 * Normally calendars that do not match an account on the device will be
219 * removed. Setting the account_type on a calendar to this will prevent it
220 * from being wiped if it does not match an existing account.
221 *
222 * @see SyncColumns#ACCOUNT_TYPE
223 */
224 public static final String ACCOUNT_TYPE_LOCAL = "LOCAL";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700225
226 /**
RoboErik36726962011-06-14 14:01:15 -0700227 * This utility class cannot be instantiated
228 */
229 private CalendarContract() {}
230
231 /**
yuemingw369f96d2018-12-05 22:07:04 +0000232 * Starts an activity to view calendar events in the managed profile.
233 *
234 * When this API is called, the system will attempt to start an activity
235 * in the managed profile with an intent targeting the same caller package.
236 * The intent will have its action set to
yuemingw05896da2019-01-29 11:30:42 +0000237 * {@link CalendarContract#ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT} and contain extras
yuemingw369f96d2018-12-05 22:07:04 +0000238 * corresponding to the API's arguments. A calendar app intending to support
yuemingwd2bfbc82019-01-02 11:42:25 +0000239 * cross-profile events viewing should handle this intent, parse the arguments
yuemingw369f96d2018-12-05 22:07:04 +0000240 * and show the appropriate UI.
241 *
242 * @param context the context.
243 * @param eventId the id of the event to be viewed. Will be put into {@link #EXTRA_EVENT_ID}
244 * field of the intent.
yuemingw05896da2019-01-29 11:30:42 +0000245 * @param startMs the start time of the event in milliseconds since epoch.
246 * Will be put into {@link #EXTRA_EVENT_BEGIN_TIME} field of the intent.
247 * @param endMs the end time of the event in milliseconds since epoch.
248 * Will be put into {@link #EXTRA_EVENT_END_TIME} field of the intent.
yuemingw369f96d2018-12-05 22:07:04 +0000249 * @param allDay if the event is an all-day event. Will be put into
250 * {@link #EXTRA_EVENT_ALL_DAY} field of the intent.
251 * @param flags flags to be set on the intent via {@link Intent#setFlags}
252 * @return {@code true} if the activity is started successfully. {@code false} otherwise.
253 *
254 * @see #EXTRA_EVENT_ID
255 * @see #EXTRA_EVENT_BEGIN_TIME
256 * @see #EXTRA_EVENT_END_TIME
257 * @see #EXTRA_EVENT_ALL_DAY
258 */
259 public static boolean startViewCalendarEventInManagedProfile(@NonNull Context context,
yuemingw05896da2019-01-29 11:30:42 +0000260 long eventId, long startMs, long endMs, boolean allDay, int flags) {
yuemingw369f96d2018-12-05 22:07:04 +0000261 Preconditions.checkNotNull(context, "Context is null");
262 final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
263 Context.DEVICE_POLICY_SERVICE);
yuemingw05896da2019-01-29 11:30:42 +0000264 return dpm.startViewCalendarEventInManagedProfile(eventId, startMs,
265 endMs, allDay, flags);
yuemingw369f96d2018-12-05 22:07:04 +0000266 }
267
268 /**
RoboErikc2d53302011-06-03 09:37:58 -0700269 * Generic columns for use by sync adapters. The specific functions of these
270 * columns are private to the sync adapter. Other clients of the API should
271 * not attempt to either read or write this column. These columns are
272 * editable as part of the Calendars Uri, but can only be read if accessed
273 * through any other Uri.
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700274 */
RoboErikc2d53302011-06-03 09:37:58 -0700275 protected interface CalendarSyncColumns {
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700276
RoboErik9734df52011-06-09 14:11:25 -0700277
278 /**
279 * Generic column for use by sync adapters. Column name.
280 * <P>Type: TEXT</P>
281 */
RoboErikbe010392011-05-26 12:28:38 -0700282 public static final String CAL_SYNC1 = "cal_sync1";
RoboErik9734df52011-06-09 14:11:25 -0700283
284 /**
285 * Generic column for use by sync adapters. Column name.
286 * <P>Type: TEXT</P>
287 */
RoboErikbe010392011-05-26 12:28:38 -0700288 public static final String CAL_SYNC2 = "cal_sync2";
RoboErik9734df52011-06-09 14:11:25 -0700289
290 /**
291 * Generic column for use by sync adapters. Column name.
292 * <P>Type: TEXT</P>
293 */
RoboErikbe010392011-05-26 12:28:38 -0700294 public static final String CAL_SYNC3 = "cal_sync3";
RoboErik9734df52011-06-09 14:11:25 -0700295
296 /**
297 * Generic column for use by sync adapters. Column name.
298 * <P>Type: TEXT</P>
299 */
RoboErikbe010392011-05-26 12:28:38 -0700300 public static final String CAL_SYNC4 = "cal_sync4";
RoboErik9734df52011-06-09 14:11:25 -0700301
302 /**
303 * Generic column for use by sync adapters. Column name.
304 * <P>Type: TEXT</P>
305 */
RoboErikbe010392011-05-26 12:28:38 -0700306 public static final String CAL_SYNC5 = "cal_sync5";
RoboErik9734df52011-06-09 14:11:25 -0700307
308 /**
309 * Generic column for use by sync adapters. Column name.
310 * <P>Type: TEXT</P>
311 */
RoboErikbe010392011-05-26 12:28:38 -0700312 public static final String CAL_SYNC6 = "cal_sync6";
RoboErik9734df52011-06-09 14:11:25 -0700313
314 /**
315 * Generic column for use by sync adapters. Column name.
316 * <P>Type: TEXT</P>
317 */
318 public static final String CAL_SYNC7 = "cal_sync7";
319
320 /**
321 * Generic column for use by sync adapters. Column name.
322 * <P>Type: TEXT</P>
323 */
324 public static final String CAL_SYNC8 = "cal_sync8";
325
326 /**
327 * Generic column for use by sync adapters. Column name.
328 * <P>Type: TEXT</P>
329 */
330 public static final String CAL_SYNC9 = "cal_sync9";
331
332 /**
333 * Generic column for use by sync adapters. Column name.
334 * <P>Type: TEXT</P>
335 */
336 public static final String CAL_SYNC10 = "cal_sync10";
Fabrice Di Meglio36f77842010-06-29 19:33:45 -0700337 }
338
339 /**
RoboErikc2d53302011-06-03 09:37:58 -0700340 * Columns for Sync information used by Calendars and Events tables. These
341 * have specific uses which are expected to be consistent by the app and
342 * sync adapter.
343 *
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700344 */
RoboErik00258602011-06-13 13:47:59 -0700345 protected interface SyncColumns extends CalendarSyncColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700346 /**
RoboErikc2d53302011-06-03 09:37:58 -0700347 * The account that was used to sync the entry to the device. If the
348 * account_type is not {@link #ACCOUNT_TYPE_LOCAL} then the name and
349 * type must match an account on the device or the calendar will be
350 * deleted.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700351 * <P>Type: TEXT</P>
352 */
RoboErik651c02e2011-05-05 15:14:31 -0700353 public static final String ACCOUNT_NAME = "account_name";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700354
355 /**
RoboErikc2d53302011-06-03 09:37:58 -0700356 * The type of the account that was used to sync the entry to the
357 * device. A type of {@link #ACCOUNT_TYPE_LOCAL} will keep this event
358 * form being deleted if there are no matching accounts on the device.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700359 * <P>Type: TEXT</P>
360 */
RoboErik651c02e2011-05-05 15:14:31 -0700361 public static final String ACCOUNT_TYPE = "account_type";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700362
363 /**
RoboErikc2d53302011-06-03 09:37:58 -0700364 * The unique ID for a row assigned by the sync source. NULL if the row
365 * has never been synced. This is used as a reference id for exceptions
366 * along with {@link BaseColumns#_ID}.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700367 * <P>Type: TEXT</P>
368 */
369 public static final String _SYNC_ID = "_sync_id";
370
371 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700372 * Used to indicate that local, unsynced, changes are present.
373 * <P>Type: INTEGER (long)</P>
374 */
Alon Albert8ac6a632012-12-17 17:21:18 -0800375
RoboErik651c02e2011-05-05 15:14:31 -0700376 public static final String DIRTY = "dirty";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700377
Alon Albert866f40a2011-06-06 14:04:00 -0700378 /**
Alon Albert8ac6a632012-12-17 17:21:18 -0800379 * Used in conjunction with {@link #DIRTY} to indicate what packages wrote local changes.
380 * <P>Type: TEXT</P>
381 */
382 public static final String MUTATORS = "mutators";
383
384 /**
RoboErik9734df52011-06-09 14:11:25 -0700385 * Whether the row has been deleted but not synced to the server. A
386 * deleted row should be ignored.
387 * <P>
388 * Type: INTEGER (boolean)
389 * </P>
390 */
391 public static final String DELETED = "deleted";
392
393 /**
Alon Albert866f40a2011-06-06 14:04:00 -0700394 * If set to 1 this causes events on this calendar to be duplicated with
RoboErik00258602011-06-13 13:47:59 -0700395 * {@link Events#LAST_SYNCED} set to 1 whenever the event
RoboErik9734df52011-06-09 14:11:25 -0700396 * transitions from non-dirty to dirty. The duplicated event will not be
397 * expanded in the instances table and will only show up in sync adapter
398 * queries of the events table. It will also be deleted when the
Alon Albert866f40a2011-06-06 14:04:00 -0700399 * originating event has its dirty flag cleared by the sync adapter.
400 * <P>Type: INTEGER (boolean)</P>
401 */
402 public static final String CAN_PARTIALLY_UPDATE = "canPartiallyUpdate";
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700403 }
404
405 /**
RoboErikc2d53302011-06-03 09:37:58 -0700406 * Columns specific to the Calendars Uri that other Uris can query.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 */
RoboErike00d5892011-06-23 15:16:55 -0700408 protected interface CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 /**
RoboErik4f520612011-09-19 17:47:53 -0700410 * The color of the calendar. This should only be updated by the sync
411 * adapter, not other apps, as changing a calendar's color can adversely
412 * affect its display.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800413 * <P>Type: INTEGER (color value)</P>
414 */
RoboErik651c02e2011-05-05 15:14:31 -0700415 public static final String CALENDAR_COLOR = "calendar_color";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800416
417 /**
RoboErik4172d952011-10-25 13:59:13 -0700418 * A key for looking up a color from the {@link Colors} table. NULL or
419 * an empty string are reserved for indicating that the calendar does
420 * not use a key for looking up the color. The provider will update
421 * {@link #CALENDAR_COLOR} automatically when a valid key is written to
422 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -0700423 * {@link Colors} table. @see Colors
RoboErikf8143c52011-09-28 15:16:00 -0700424 * <P>
425 * Type: TEXT
426 * </P>
RoboErikf8143c52011-09-28 15:16:00 -0700427 */
RoboErik4172d952011-10-25 13:59:13 -0700428 public static final String CALENDAR_COLOR_KEY = "calendar_color_index";
RoboErikf8143c52011-09-28 15:16:00 -0700429
430 /**
RoboErik9734df52011-06-09 14:11:25 -0700431 * The display name of the calendar. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700432 * <P>
433 * Type: TEXT
434 * </P>
RoboErik9734df52011-06-09 14:11:25 -0700435 */
436 public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName";
437
438 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439 * The level of access that the user has for the calendar
440 * <P>Type: INTEGER (one of the values below)</P>
441 */
RoboErik9734df52011-06-09 14:11:25 -0700442 public static final String CALENDAR_ACCESS_LEVEL = "calendar_access_level";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443
444 /** Cannot access the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700445 public static final int CAL_ACCESS_NONE = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 /** Can only see free/busy information about the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700447 public static final int CAL_ACCESS_FREEBUSY = 100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800448 /** Can read all event details */
RoboErik9734df52011-06-09 14:11:25 -0700449 public static final int CAL_ACCESS_READ = 200;
RoboErikc2d53302011-06-03 09:37:58 -0700450 /** Can reply yes/no/maybe to an event */
RoboErik9734df52011-06-09 14:11:25 -0700451 public static final int CAL_ACCESS_RESPOND = 300;
RoboErikc2d53302011-06-03 09:37:58 -0700452 /** not used */
RoboErik9734df52011-06-09 14:11:25 -0700453 public static final int CAL_ACCESS_OVERRIDE = 400;
RoboErikc2d53302011-06-03 09:37:58 -0700454 /** Full access to modify the calendar, but not the access control
455 * settings
456 */
RoboErik9734df52011-06-09 14:11:25 -0700457 public static final int CAL_ACCESS_CONTRIBUTOR = 500;
RoboErikc2d53302011-06-03 09:37:58 -0700458 /** Full access to modify the calendar, but not the access control
459 * settings
460 */
RoboErik9734df52011-06-09 14:11:25 -0700461 public static final int CAL_ACCESS_EDITOR = 600;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800462 /** Full access to the calendar */
RoboErik9734df52011-06-09 14:11:25 -0700463 public static final int CAL_ACCESS_OWNER = 700;
Debajit Ghosh2dcaafd2009-09-18 18:29:37 -0700464 /** Domain admin */
RoboErik9734df52011-06-09 14:11:25 -0700465 public static final int CAL_ACCESS_ROOT = 800;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800466
467 /**
468 * Is the calendar selected to be displayed?
RoboErikc2d53302011-06-03 09:37:58 -0700469 * 0 - do not show events associated with this calendar.
470 * 1 - show events associated with this calendar
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471 * <P>Type: INTEGER (boolean)</P>
472 */
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700473 public static final String VISIBLE = "visible";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800474
475 /**
RoboErikc2d53302011-06-03 09:37:58 -0700476 * The time zone the calendar is associated with.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800477 * <P>Type: TEXT</P>
478 */
RoboErik9734df52011-06-09 14:11:25 -0700479 public static final String CALENDAR_TIME_ZONE = "calendar_timezone";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480
481 /**
RoboErikc2d53302011-06-03 09:37:58 -0700482 * Is this calendar synced and are its events stored on the device?
483 * 0 - Do not sync this calendar or store events for this calendar.
484 * 1 - Sync down events for this calendar.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800485 * <p>Type: INTEGER (boolean)</p>
486 */
487 public static final String SYNC_EVENTS = "sync_events";
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700488
489 /**
RoboErik9734df52011-06-09 14:11:25 -0700490 * The owner account for this calendar, based on the calendar feed.
491 * This will be different from the _SYNC_ACCOUNT for delegated calendars.
492 * Column name.
493 * <P>Type: String</P>
Ken Shirriff1d6442f2009-07-09 13:50:17 -0700494 */
RoboErik9734df52011-06-09 14:11:25 -0700495 public static final String OWNER_ACCOUNT = "ownerAccount";
Fred Quintana328c0e72009-12-07 14:52:28 -0800496
497 /**
RoboErik9734df52011-06-09 14:11:25 -0700498 * Can the organizer respond to the event? If no, the status of the
499 * organizer should not be shown by the UI. Defaults to 1. Column name.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700500 * <P>Type: INTEGER (boolean)</P>
Fred Quintana328c0e72009-12-07 14:52:28 -0800501 */
RoboErik9734df52011-06-09 14:11:25 -0700502 public static final String CAN_ORGANIZER_RESPOND = "canOrganizerRespond";
503
504 /**
505 * Can the organizer modify the time zone of the event? Column name.
506 * <P>Type: INTEGER (boolean)</P>
507 */
508 public static final String CAN_MODIFY_TIME_ZONE = "canModifyTimeZone";
509
510 /**
511 * The maximum number of reminders allowed for an event. Column name.
512 * <P>Type: INTEGER</P>
513 */
514 public static final String MAX_REMINDERS = "maxReminders";
515
516 /**
517 * A comma separated list of reminder methods supported for this
518 * calendar in the format "#,#,#". Valid types are
519 * {@link Reminders#METHOD_DEFAULT}, {@link Reminders#METHOD_ALERT},
Alon Albertbd251612012-02-23 10:30:51 -0800520 * {@link Reminders#METHOD_EMAIL}, {@link Reminders#METHOD_SMS},
521 * {@link Reminders#METHOD_ALARM}. Column name.
RoboErik9734df52011-06-09 14:11:25 -0700522 * <P>Type: TEXT</P>
523 */
524 public static final String ALLOWED_REMINDERS = "allowedReminders";
RoboErikf8143c52011-09-28 15:16:00 -0700525
526 /**
527 * A comma separated list of availability types supported for this
528 * calendar in the format "#,#,#". Valid types are
529 * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE},
530 * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only
531 * {@link Events#AVAILABILITY_BUSY} should be used to indicate that
532 * changing the availability is not supported.
533 *
RoboErikf8143c52011-09-28 15:16:00 -0700534 */
535 public static final String ALLOWED_AVAILABILITY = "allowedAvailability";
536
537 /**
538 * A comma separated list of attendee types supported for this calendar
539 * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE},
540 * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED},
541 * {@link Attendees#TYPE_RESOURCE}. Setting this field to only
542 * {@link Attendees#TYPE_NONE} should be used to indicate that changing
543 * the attendee type is not supported.
544 *
RoboErikf8143c52011-09-28 15:16:00 -0700545 */
546 public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes";
Alon Albert0a9a2192012-09-18 11:10:49 -0700547
548 /**
549 * Is this the primary calendar for this account. If this column is not explicitly set, the
550 * provider will return 1 if {@link Calendars#ACCOUNT_NAME} is equal to
551 * {@link Calendars#OWNER_ACCOUNT}.
552 */
553 public static final String IS_PRIMARY = "isPrimary";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800554 }
555
556 /**
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700557 * Class that represents a Calendar Entity. There is one entry per calendar.
RoboErikc2d53302011-06-03 09:37:58 -0700558 * This is a helper class to make batch operations easier.
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700559 */
RoboErik36726962011-06-14 14:01:15 -0700560 public static final class CalendarEntity implements BaseColumns, SyncColumns, CalendarColumns {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700561
RoboErikc2d53302011-06-03 09:37:58 -0700562 /**
563 * The default Uri used when creating a new calendar EntityIterator.
564 */
565 @SuppressWarnings("hiding")
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700566 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
567 "/calendar_entities");
568
RoboErikc2d53302011-06-03 09:37:58 -0700569 /**
RoboErik36726962011-06-14 14:01:15 -0700570 * This utility class cannot be instantiated
571 */
572 private CalendarEntity() {}
573
574 /**
RoboErikc2d53302011-06-03 09:37:58 -0700575 * Creates an entity iterator for the given cursor. It assumes the
576 * cursor contains a calendars query.
577 *
578 * @param cursor query on {@link #CONTENT_URI}
579 * @return an EntityIterator of calendars
580 */
581 public static EntityIterator newEntityIterator(Cursor cursor) {
582 return new EntityIteratorImpl(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700583 }
584
585 private static class EntityIteratorImpl extends CursorEntityIterator {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700586
RoboErikc2d53302011-06-03 09:37:58 -0700587 public EntityIteratorImpl(Cursor cursor) {
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700588 super(cursor);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700589 }
590
591 @Override
592 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
593 // we expect the cursor is already at the row we need to read from
594 final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));
595
596 // Create the content value
597 ContentValues cv = new ContentValues();
598 cv.put(_ID, calendarId);
599
RoboErik651c02e2011-05-05 15:14:31 -0700600 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
601 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700602
603 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -0700604 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Alon Albert8ac6a632012-12-17 17:21:18 -0800605 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700606
RoboErik9734df52011-06-09 14:11:25 -0700607 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
608 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
609 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
610 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
611 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
612 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
613 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
614 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
615 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
616 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700617
618 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME);
619 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
RoboErik9734df52011-06-09 14:11:25 -0700620 Calendars.CALENDAR_DISPLAY_NAME);
Alon Albert866f40a2011-06-06 14:04:00 -0700621 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
622 Calendars.CALENDAR_COLOR);
Alon Albert01141122013-02-07 11:50:27 -0800623 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
624 Calendars.CALENDAR_COLOR_KEY);
RoboErik9734df52011-06-09 14:11:25 -0700625 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL);
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700626 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700627 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS);
RoboErik651c02e2011-05-05 15:14:31 -0700628 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
629 Calendars.CALENDAR_LOCATION);
RoboErik9734df52011-06-09 14:11:25 -0700630 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700631 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
632 Calendars.OWNER_ACCOUNT);
633 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700634 Calendars.CAN_ORGANIZER_RESPOND);
635 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
636 Calendars.CAN_MODIFY_TIME_ZONE);
637 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
638 Calendars.MAX_REMINDERS);
Alon Albert866f40a2011-06-06 14:04:00 -0700639 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
640 Calendars.CAN_PARTIALLY_UPDATE);
RoboErik9734df52011-06-09 14:11:25 -0700641 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
642 Calendars.ALLOWED_REMINDERS);
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700643
644 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
645
646 // Create the Entity from the ContentValue
647 Entity entity = new Entity(cv);
648
649 // Set cursor to next row
650 cursor.moveToNext();
651
652 // Return the created Entity
653 return entity;
654 }
655 }
656 }
657
658 /**
RoboErikf4010c52011-06-17 11:04:26 -0700659 * Constants and helpers for the Calendars table, which contains details for
660 * individual calendars. <h3>Operations</h3> All operations can be done
661 * either as an app or as a sync adapter. To perform an operation as a sync
662 * adapter {@link #CALLER_IS_SYNCADAPTER} should be set to true and
663 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
664 * parameters. See
665 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
666 * for details on adding parameters. Sync adapters have write access to more
667 * columns but are restricted to a single account at a time. Calendars are
668 * designed to be primarily managed by a sync adapter and inserting new
669 * calendars should be done as a sync adapter. For the most part, apps
670 * should only update calendars (such as changing the color or display
671 * name). If a local calendar is required an app can do so by inserting as a
672 * sync adapter and using an {@link #ACCOUNT_TYPE} of
673 * {@link #ACCOUNT_TYPE_LOCAL} .
674 * <dl>
675 * <dt><b>Insert</b></dt>
676 * <dd>When inserting a new calendar the following fields must be included:
677 * <ul>
678 * <li>{@link #ACCOUNT_NAME}</li>
679 * <li>{@link #ACCOUNT_TYPE}</li>
680 * <li>{@link #NAME}</li>
681 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
682 * <li>{@link #CALENDAR_COLOR}</li>
683 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
684 * <li>{@link #OWNER_ACCOUNT}</li>
685 * </ul>
686 * The following fields are not required when inserting a Calendar but are
687 * generally a good idea to include:
688 * <ul>
689 * <li>{@link #SYNC_EVENTS} set to 1</li>
RoboErikf92ccfb2011-06-17 15:24:02 -0700690 * <li>{@link #CALENDAR_TIME_ZONE}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700691 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700692 * <li>{@link #ALLOWED_AVAILABILITY}</li>
693 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700694 * </ul>
695 * <dt><b>Update</b></dt>
696 * <dd>To perform an update on a calendar the {@link #_ID} of the calendar
697 * should be provided either as an appended id to the Uri (
698 * {@link ContentUris#withAppendedId}) or as the first selection item--the
699 * selection should start with "_id=?" and the first selectionArg should be
700 * the _id of the calendar. Calendars may also be updated using a selection
701 * without the id. In general, the {@link #ACCOUNT_NAME} and
702 * {@link #ACCOUNT_TYPE} should not be changed after a calendar is created
703 * as this can cause issues for sync adapters.
704 * <dt><b>Delete</b></dt>
705 * <dd>Calendars can be deleted either by the {@link #_ID} as an appended id
706 * on the Uri or using any standard selection. Deleting a calendar should
707 * generally be handled by a sync adapter as it will remove the calendar
708 * from the database and all associated data (aka events).</dd>
709 * <dt><b>Query</b></dt>
710 * <dd>Querying the Calendars table will get you all information about a set
711 * of calendars. There will be one row returned for each calendar that
712 * matches the query selection, or at most a single row if the {@link #_ID}
713 * is appended to the Uri.</dd>
714 * </dl>
715 * <h3>Calendar Columns</h3> The following Calendar columns are writable by
716 * both an app and a sync adapter.
717 * <ul>
718 * <li>{@link #NAME}</li>
719 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700720 * <li>{@link #VISIBLE}</li>
721 * <li>{@link #SYNC_EVENTS}</li>
722 * </ul>
723 * The following Calendars columns are writable only by a sync adapter
724 * <ul>
725 * <li>{@link #ACCOUNT_NAME}</li>
726 * <li>{@link #ACCOUNT_TYPE}</li>
RoboErik4f520612011-09-19 17:47:53 -0700727 * <li>{@link #CALENDAR_COLOR}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700728 * <li>{@link #_SYNC_ID}</li>
729 * <li>{@link #DIRTY}</li>
Alon Albert8ac6a632012-12-17 17:21:18 -0800730 * <li>{@link #MUTATORS}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700731 * <li>{@link #OWNER_ACCOUNT}</li>
732 * <li>{@link #MAX_REMINDERS}</li>
733 * <li>{@link #ALLOWED_REMINDERS}</li>
RoboErik4172d952011-10-25 13:59:13 -0700734 * <li>{@link #ALLOWED_AVAILABILITY}</li>
735 * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li>
RoboErikf4010c52011-06-17 11:04:26 -0700736 * <li>{@link #CAN_MODIFY_TIME_ZONE}</li>
737 * <li>{@link #CAN_ORGANIZER_RESPOND}</li>
738 * <li>{@link #CAN_PARTIALLY_UPDATE}</li>
739 * <li>{@link #CALENDAR_LOCATION}</li>
740 * <li>{@link #CALENDAR_TIME_ZONE}</li>
741 * <li>{@link #CALENDAR_ACCESS_LEVEL}</li>
742 * <li>{@link #DELETED}</li>
743 * <li>{@link #CAL_SYNC1}</li>
744 * <li>{@link #CAL_SYNC2}</li>
745 * <li>{@link #CAL_SYNC3}</li>
746 * <li>{@link #CAL_SYNC4}</li>
747 * <li>{@link #CAL_SYNC5}</li>
748 * <li>{@link #CAL_SYNC6}</li>
749 * <li>{@link #CAL_SYNC7}</li>
750 * <li>{@link #CAL_SYNC8}</li>
751 * <li>{@link #CAL_SYNC9}</li>
752 * <li>{@link #CAL_SYNC10}</li>
753 * </ul>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800754 */
RoboErik36726962011-06-14 14:01:15 -0700755 public static final class Calendars implements BaseColumns, SyncColumns, CalendarColumns {
756
757 /**
758 * This utility class cannot be instantiated
759 */
760 private Calendars() {}
761
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800762 /**
RoboErikc2d53302011-06-03 09:37:58 -0700763 * The content:// style URL for accessing Calendars
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800764 */
RoboErikc2d53302011-06-03 09:37:58 -0700765 @SuppressWarnings("hiding")
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800766 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/calendars");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800767
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800768 /**
yuemingw369f96d2018-12-05 22:07:04 +0000769 * The content:// style URL for querying Calendars table in the managed profile. Appending a
yuemingwb714ba02018-10-26 18:54:44 +0100770 * calendar id using {@link ContentUris#withAppendedId(Uri, long)} will
771 * specify a single calendar.
772 *
773 * <p>The following columns are allowed to be queried via this uri:
774 * <ul>
775 * <li>{@link #_ID}</li>
776 * <li>{@link #NAME}</li>
777 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
778 * <li>{@link #CALENDAR_COLOR}</li>
779 * <li>{@link #VISIBLE}</li>
780 * <li>{@link #CALENDAR_LOCATION}</li>
781 * <li>{@link #CALENDAR_TIME_ZONE}</li>
782 * <li>{@link #IS_PRIMARY}</li>
783 * </ul>
784 *
785 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
786 * projection of the query to this uri that are not contained in the above list.
787 *
788 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +0000789 * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
yuemingw369f96d2018-12-05 22:07:04 +0000790 * queried from a package that is not whitelisted by profile owner of the managed profile
yuemingwd2bfbc82019-01-02 11:42:25 +0000791 * via
792 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +0100793 *
794 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
795 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
796 */
797 public static final Uri ENTERPRISE_CONTENT_URI =
798 Uri.parse("content://" + AUTHORITY + "/enterprise/calendars");
799
800 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800801 * The default sort order for this table
802 */
Michael Chane5e02502011-09-01 10:46:14 -0700803 public static final String DEFAULT_SORT_ORDER = CALENDAR_DISPLAY_NAME;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800804
805 /**
RoboErikc2d53302011-06-03 09:37:58 -0700806 * The name of the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800807 * <P>Type: TEXT</P>
808 */
809 public static final String NAME = "name";
810
811 /**
RoboErikc2d53302011-06-03 09:37:58 -0700812 * The default location for the calendar. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800813 * <P>Type: TEXT</P>
814 */
RoboErik651c02e2011-05-05 15:14:31 -0700815 public static final String CALENDAR_LOCATION = "calendar_location";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800816
817 /**
RoboErik6efb30f2011-05-05 10:11:47 -0700818 * These fields are only writable by a sync adapter. To modify them the
RoboErikc2d53302011-06-03 09:37:58 -0700819 * caller must include {@link #CALLER_IS_SYNCADAPTER},
RoboErik9734df52011-06-09 14:11:25 -0700820 * {@link #ACCOUNT_NAME}, and {@link #ACCOUNT_TYPE} in the Uri's query
RoboErik083cd2d2011-06-30 11:53:05 -0700821 * parameters. TODO move to provider
822 *
823 * @hide
RoboErik6efb30f2011-05-05 10:11:47 -0700824 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -0700825 @TestApi
RoboErik6efb30f2011-05-05 10:11:47 -0700826 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
RoboErik651c02e2011-05-05 15:14:31 -0700827 ACCOUNT_NAME,
828 ACCOUNT_TYPE,
RoboErik6efb30f2011-05-05 10:11:47 -0700829 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -0700830 DIRTY,
Alon Albert8ac6a632012-12-17 17:21:18 -0800831 MUTATORS,
RoboErik6efb30f2011-05-05 10:11:47 -0700832 OWNER_ACCOUNT,
833 MAX_REMINDERS,
RoboErikf4010c52011-06-17 11:04:26 -0700834 ALLOWED_REMINDERS,
RoboErik6efb30f2011-05-05 10:11:47 -0700835 CAN_MODIFY_TIME_ZONE,
836 CAN_ORGANIZER_RESPOND,
Alon Albert866f40a2011-06-06 14:04:00 -0700837 CAN_PARTIALLY_UPDATE,
RoboErik651c02e2011-05-05 15:14:31 -0700838 CALENDAR_LOCATION,
RoboErik9734df52011-06-09 14:11:25 -0700839 CALENDAR_TIME_ZONE,
840 CALENDAR_ACCESS_LEVEL,
RoboErik6efb30f2011-05-05 10:11:47 -0700841 DELETED,
RoboErikbe010392011-05-26 12:28:38 -0700842 CAL_SYNC1,
843 CAL_SYNC2,
844 CAL_SYNC3,
845 CAL_SYNC4,
RoboErikc2d53302011-06-03 09:37:58 -0700846 CAL_SYNC5,
847 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -0700848 CAL_SYNC7,
849 CAL_SYNC8,
850 CAL_SYNC9,
851 CAL_SYNC10,
RoboErik6efb30f2011-05-05 10:11:47 -0700852 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800853 }
854
Fabrice Di Meglioc3cc1332010-05-21 20:01:52 -0700855 /**
856 * Columns from the Attendees table that other tables join into themselves.
857 */
RoboErikb2c75602011-06-13 12:53:48 -0700858 protected interface AttendeesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800859
860 /**
RoboErikc2d53302011-06-03 09:37:58 -0700861 * The id of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800862 * <P>Type: INTEGER</P>
863 */
864 public static final String EVENT_ID = "event_id";
865
866 /**
RoboErikc2d53302011-06-03 09:37:58 -0700867 * The name of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800868 * <P>Type: STRING</P>
869 */
870 public static final String ATTENDEE_NAME = "attendeeName";
871
872 /**
RoboErikc2d53302011-06-03 09:37:58 -0700873 * The email address of the attendee. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800874 * <P>Type: STRING</P>
875 */
876 public static final String ATTENDEE_EMAIL = "attendeeEmail";
877
878 /**
RoboErikc2d53302011-06-03 09:37:58 -0700879 * The relationship of the attendee to the user. Column name.
880 * <P>Type: INTEGER (one of {@link #RELATIONSHIP_ATTENDEE}, ...}.</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800881 */
882 public static final String ATTENDEE_RELATIONSHIP = "attendeeRelationship";
883
884 public static final int RELATIONSHIP_NONE = 0;
885 public static final int RELATIONSHIP_ATTENDEE = 1;
886 public static final int RELATIONSHIP_ORGANIZER = 2;
887 public static final int RELATIONSHIP_PERFORMER = 3;
888 public static final int RELATIONSHIP_SPEAKER = 4;
889
890 /**
RoboErikc2d53302011-06-03 09:37:58 -0700891 * The type of attendee. Column name.
RoboErikf8143c52011-09-28 15:16:00 -0700892 * <P>
RoboErik4172d952011-10-25 13:59:13 -0700893 * Type: Integer (one of {@link #TYPE_NONE}, {@link #TYPE_REQUIRED},
894 * {@link #TYPE_OPTIONAL}, {@link #TYPE_RESOURCE})
RoboErikf8143c52011-09-28 15:16:00 -0700895 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800896 */
897 public static final String ATTENDEE_TYPE = "attendeeType";
898
899 public static final int TYPE_NONE = 0;
900 public static final int TYPE_REQUIRED = 1;
901 public static final int TYPE_OPTIONAL = 2;
RoboErikf8143c52011-09-28 15:16:00 -0700902 /**
RoboErik4172d952011-10-25 13:59:13 -0700903 * This specifies that an attendee is a resource, like a room, a
904 * cabbage, or something and not an actual person.
RoboErikf8143c52011-09-28 15:16:00 -0700905 */
906 public static final int TYPE_RESOURCE = 3;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800907
908 /**
RoboErikc2d53302011-06-03 09:37:58 -0700909 * The attendance status of the attendee. Column name.
910 * <P>Type: Integer (one of {@link #ATTENDEE_STATUS_ACCEPTED}, ...).</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800911 */
912 public static final String ATTENDEE_STATUS = "attendeeStatus";
913
914 public static final int ATTENDEE_STATUS_NONE = 0;
915 public static final int ATTENDEE_STATUS_ACCEPTED = 1;
916 public static final int ATTENDEE_STATUS_DECLINED = 2;
917 public static final int ATTENDEE_STATUS_INVITED = 3;
918 public static final int ATTENDEE_STATUS_TENTATIVE = 4;
Michael Chan48ec6222012-04-17 15:58:28 -0700919
920 /**
921 * The identity of the attendee as referenced in
922 * {@link ContactsContract.CommonDataKinds.Identity#IDENTITY}.
Michael Chan37f1d292012-04-17 18:40:51 -0700923 * This is required only if {@link #ATTENDEE_ID_NAMESPACE} is present. Column name.
Michael Chan48ec6222012-04-17 15:58:28 -0700924 * <P>Type: STRING</P>
Michael Chan48ec6222012-04-17 15:58:28 -0700925 */
926 public static final String ATTENDEE_IDENTITY = "attendeeIdentity";
927
928 /**
929 * The identity name space of the attendee as referenced in
930 * {@link ContactsContract.CommonDataKinds.Identity#NAMESPACE}.
Michael Chan37f1d292012-04-17 18:40:51 -0700931 * This is required only if {@link #ATTENDEE_IDENTITY} is present. Column name.
Michael Chan48ec6222012-04-17 15:58:28 -0700932 * <P>Type: STRING</P>
Michael Chan48ec6222012-04-17 15:58:28 -0700933 */
934 public static final String ATTENDEE_ID_NAMESPACE = "attendeeIdNamespace";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800935 }
936
RoboErikc2d53302011-06-03 09:37:58 -0700937 /**
RoboErik3771fcb2011-06-16 15:41:31 -0700938 * Fields and helpers for interacting with Attendees. Each row of this table
939 * represents a single attendee or guest of an event. Calling
RoboErik58644022011-07-08 13:39:05 -0700940 * {@link #query(ContentResolver, long, String[])} will return a list of attendees for
RoboErik3771fcb2011-06-16 15:41:31 -0700941 * the event with the given eventId. Both apps and sync adapters may write
942 * to this table. There are six writable fields and all of them except
943 * {@link #ATTENDEE_NAME} must be included when inserting a new attendee.
944 * They are:
945 * <ul>
946 * <li>{@link #EVENT_ID}</li>
947 * <li>{@link #ATTENDEE_NAME}</li>
948 * <li>{@link #ATTENDEE_EMAIL}</li>
949 * <li>{@link #ATTENDEE_RELATIONSHIP}</li>
950 * <li>{@link #ATTENDEE_TYPE}</li>
951 * <li>{@link #ATTENDEE_STATUS}</li>
Michael Chan48ec6222012-04-17 15:58:28 -0700952 * <li>{@link #ATTENDEE_IDENTITY}</li>
953 * <li>{@link #ATTENDEE_ID_NAMESPACE}</li>
RoboErik3771fcb2011-06-16 15:41:31 -0700954 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -0700955 */
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -0800956 public static final class Attendees implements BaseColumns, AttendeesColumns, EventsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800957
RoboErikc2d53302011-06-03 09:37:58 -0700958 /**
959 * The content:// style URL for accessing Attendees data
960 */
961 @SuppressWarnings("hiding")
962 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees");
RoboErikc2d53302011-06-03 09:37:58 -0700963 private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?";
964
965 /**
RoboErik36726962011-06-14 14:01:15 -0700966 * This utility class cannot be instantiated
967 */
968 private Attendees() {}
969
970 /**
RoboErikc2d53302011-06-03 09:37:58 -0700971 * Queries all attendees associated with the given event. This is a
972 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -0700973 *
RoboErikc2d53302011-06-03 09:37:58 -0700974 * @param cr The content resolver to use for the query
975 * @param eventId The id of the event to retrieve attendees for
RoboErik58644022011-07-08 13:39:05 -0700976 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -0700977 * @return A Cursor containing all attendees for the event
978 */
RoboErik58644022011-07-08 13:39:05 -0700979 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -0700980 String[] attArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -0700981 return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */,
RoboErikc2d53302011-06-03 09:37:58 -0700982 null /* sort order */);
983 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984 }
985
986 /**
987 * Columns from the Events table that other tables join into themselves.
988 */
RoboErikb2c75602011-06-13 12:53:48 -0700989 protected interface EventsColumns {
Andy McFaddendf2e2c82011-04-19 15:08:37 -0700990
991 /**
RoboErikc2d53302011-06-03 09:37:58 -0700992 * The {@link Calendars#_ID} of the calendar the event belongs to.
993 * Column name.
994 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800995 */
996 public static final String CALENDAR_ID = "calendar_id";
997
998 /**
RoboErikc2d53302011-06-03 09:37:58 -0700999 * The title of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001000 * <P>Type: TEXT</P>
1001 */
1002 public static final String TITLE = "title";
1003
1004 /**
RoboErikc2d53302011-06-03 09:37:58 -07001005 * The description of the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001006 * <P>Type: TEXT</P>
1007 */
1008 public static final String DESCRIPTION = "description";
1009
1010 /**
RoboErikc2d53302011-06-03 09:37:58 -07001011 * Where the event takes place. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001012 * <P>Type: TEXT</P>
1013 */
1014 public static final String EVENT_LOCATION = "eventLocation";
1015
1016 /**
RoboErikf8143c52011-09-28 15:16:00 -07001017 * A secondary color for the individual event. This should only be
1018 * updated by the sync adapter for a given account.
RoboErik9734df52011-06-09 14:11:25 -07001019 * <P>Type: INTEGER</P>
1020 */
1021 public static final String EVENT_COLOR = "eventColor";
1022
1023 /**
RoboErik4172d952011-10-25 13:59:13 -07001024 * A secondary color key for the individual event. NULL or an empty
1025 * string are reserved for indicating that the event does not use a key
1026 * for looking up the color. The provider will update
1027 * {@link #EVENT_COLOR} automatically when a valid key is written to
1028 * this column. The key must reference an existing row of the
RoboErik8a8eebc2011-10-20 16:57:18 -07001029 * {@link Colors} table. @see Colors
1030 * <P>
1031 * Type: TEXT
1032 * </P>
RoboErikf8143c52011-09-28 15:16:00 -07001033 */
RoboErik4172d952011-10-25 13:59:13 -07001034 public static final String EVENT_COLOR_KEY = "eventColor_index";
RoboErikf8143c52011-09-28 15:16:00 -07001035
1036 /**
Alon Albertdc927302012-03-01 16:05:55 -08001037 * This will be {@link #EVENT_COLOR} if it is not null; otherwise, this will be
1038 * {@link Calendars#CALENDAR_COLOR}.
1039 * Read-only value. To modify, write to {@link #EVENT_COLOR} or
1040 * {@link Calendars#CALENDAR_COLOR} directly.
1041 *<P>
1042 * Type: INTEGER
1043 *</P>
1044 */
1045 public static final String DISPLAY_COLOR = "displayColor";
1046
1047 /**
RoboErikc2d53302011-06-03 09:37:58 -07001048 * The event status. Column name.
1049 * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050 */
1051 public static final String STATUS = "eventStatus";
1052
1053 public static final int STATUS_TENTATIVE = 0;
1054 public static final int STATUS_CONFIRMED = 1;
1055 public static final int STATUS_CANCELED = 2;
1056
1057 /**
1058 * This is a copy of the attendee status for the owner of this event.
1059 * This field is copied here so that we can efficiently filter out
1060 * events that are declined without having to look in the Attendees
RoboErikc2d53302011-06-03 09:37:58 -07001061 * table. Column name.
Ken Shirriff5b387e12009-10-23 09:50:41 -07001062 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001063 * <P>Type: INTEGER (int)</P>
1064 */
1065 public static final String SELF_ATTENDEE_STATUS = "selfAttendeeStatus";
Ken Shirriff5b387e12009-10-23 09:50:41 -07001066
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001067 /**
RoboErikc2d53302011-06-03 09:37:58 -07001068 * This column is available for use by sync adapters. Column name.
Marc Blank64a556d2010-02-25 12:53:16 -08001069 * <P>Type: TEXT</P>
1070 */
RoboErik651c02e2011-05-05 15:14:31 -07001071 public static final String SYNC_DATA1 = "sync_data1";
Marc Blank64a556d2010-02-25 12:53:16 -08001072
1073 /**
RoboErik9734df52011-06-09 14:11:25 -07001074 * This column is available for use by sync adapters. Column name.
1075 * <P>Type: TEXT</P>
1076 */
1077 public static final String SYNC_DATA2 = "sync_data2";
1078
1079 /**
1080 * This column is available for use by sync adapters. Column name.
1081 * <P>Type: TEXT</P>
1082 */
1083 public static final String SYNC_DATA3 = "sync_data3";
1084
1085 /**
1086 * This column is available for use by sync adapters. Column name.
1087 * <P>Type: TEXT</P>
1088 */
1089 public static final String SYNC_DATA4 = "sync_data4";
1090
1091 /**
1092 * This column is available for use by sync adapters. Column name.
1093 * <P>Type: TEXT</P>
1094 */
1095 public static final String SYNC_DATA5 = "sync_data5";
1096
1097 /**
1098 * This column is available for use by sync adapters. Column name.
1099 * <P>Type: TEXT</P>
1100 */
1101 public static final String SYNC_DATA6 = "sync_data6";
1102
1103 /**
1104 * This column is available for use by sync adapters. Column name.
Alon Albert866f40a2011-06-06 14:04:00 -07001105 * <P>Type: TEXT</P>
1106 */
1107 public static final String SYNC_DATA7 = "sync_data7";
1108
1109 /**
RoboErik9734df52011-06-09 14:11:25 -07001110 * This column is available for use by sync adapters. Column name.
1111 * <P>Type: TEXT</P>
1112 */
1113 public static final String SYNC_DATA8 = "sync_data8";
1114
1115 /**
1116 * This column is available for use by sync adapters. Column name.
1117 * <P>Type: TEXT</P>
1118 */
1119 public static final String SYNC_DATA9 = "sync_data9";
1120
1121 /**
1122 * This column is available for use by sync adapters. Column name.
1123 * <P>Type: TEXT</P>
1124 */
1125 public static final String SYNC_DATA10 = "sync_data10";
1126
1127 /**
Alon Albert866f40a2011-06-06 14:04:00 -07001128 * Used to indicate that a row is not a real event but an original copy of a locally
1129 * modified event. A copy is made when an event changes from non-dirty to dirty and the
1130 * event is on a calendar with {@link Calendars#CAN_PARTIALLY_UPDATE} set to 1. This copy
1131 * does not get expanded in the instances table and is only visible in queries made by a
1132 * sync adapter. The copy gets removed when the event is changed back to non-dirty by a
1133 * sync adapter.
1134 * <P>Type: INTEGER (boolean)</P>
1135 */
1136 public static final String LAST_SYNCED = "lastSynced";
1137
1138 /**
RoboErikc2d53302011-06-03 09:37:58 -07001139 * The time the event starts in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001140 * <P>Type: INTEGER (long; millis since epoch)</P>
1141 */
1142 public static final String DTSTART = "dtstart";
1143
1144 /**
RoboErikc2d53302011-06-03 09:37:58 -07001145 * The time the event ends in UTC millis since epoch. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001146 * <P>Type: INTEGER (long; millis since epoch)</P>
1147 */
1148 public static final String DTEND = "dtend";
1149
1150 /**
RoboErikc2d53302011-06-03 09:37:58 -07001151 * The duration of the event in RFC2445 format. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001152 * <P>Type: TEXT (duration in RFC2445 format)</P>
1153 */
1154 public static final String DURATION = "duration";
1155
1156 /**
RoboErikc2d53302011-06-03 09:37:58 -07001157 * The timezone for the event. Column name.
1158 * <P>Type: TEXT</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001159 */
1160 public static final String EVENT_TIMEZONE = "eventTimezone";
1161
1162 /**
RoboErikc2d53302011-06-03 09:37:58 -07001163 * The timezone for the end time of the event. Column name.
1164 * <P>Type: TEXT</P>
Erikc07b06f2010-05-03 11:37:31 -07001165 */
RoboErik651c02e2011-05-05 15:14:31 -07001166 public static final String EVENT_END_TIMEZONE = "eventEndTimezone";
Erikc07b06f2010-05-03 11:37:31 -07001167
1168 /**
RoboErikc2d53302011-06-03 09:37:58 -07001169 * Is the event all day (time zone independent). Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001170 * <P>Type: INTEGER (boolean)</P>
1171 */
1172 public static final String ALL_DAY = "allDay";
1173
1174 /**
RoboErik651c02e2011-05-05 15:14:31 -07001175 * Defines how the event shows up for others when the calendar is
RoboErikc2d53302011-06-03 09:37:58 -07001176 * shared. Column name.
1177 * <P>Type: INTEGER (One of {@link #ACCESS_DEFAULT}, ...)</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001178 */
RoboErik651c02e2011-05-05 15:14:31 -07001179 public static final String ACCESS_LEVEL = "accessLevel";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001180
1181 /**
RoboErik651c02e2011-05-05 15:14:31 -07001182 * Default access is controlled by the server and will be treated as
1183 * public on the device.
1184 */
1185 public static final int ACCESS_DEFAULT = 0;
1186 /**
1187 * Confidential is not used by the app.
1188 */
1189 public static final int ACCESS_CONFIDENTIAL = 1;
1190 /**
RoboErikc2d53302011-06-03 09:37:58 -07001191 * Private shares the event as a free/busy slot with no details.
RoboErik651c02e2011-05-05 15:14:31 -07001192 */
1193 public static final int ACCESS_PRIVATE = 2;
1194 /**
RoboErikc2d53302011-06-03 09:37:58 -07001195 * Public makes the contents visible to anyone with access to the
RoboErik651c02e2011-05-05 15:14:31 -07001196 * calendar.
1197 */
1198 public static final int ACCESS_PUBLIC = 3;
1199
1200 /**
1201 * If this event counts as busy time or is still free time that can be
RoboErikc2d53302011-06-03 09:37:58 -07001202 * scheduled over. Column name.
RoboErik4172d952011-10-25 13:59:13 -07001203 * <P>
1204 * Type: INTEGER (One of {@link #AVAILABILITY_BUSY},
1205 * {@link #AVAILABILITY_FREE}, {@link #AVAILABILITY_TENTATIVE})
1206 * </P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001207 */
RoboErik651c02e2011-05-05 15:14:31 -07001208 public static final String AVAILABILITY = "availability";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001209
RoboErik651c02e2011-05-05 15:14:31 -07001210 /**
1211 * Indicates that this event takes up time and will conflict with other
1212 * events.
1213 */
1214 public static final int AVAILABILITY_BUSY = 0;
1215 /**
1216 * Indicates that this event is free time and will not conflict with
1217 * other events.
1218 */
1219 public static final int AVAILABILITY_FREE = 1;
RoboErikf8143c52011-09-28 15:16:00 -07001220 /**
1221 * Indicates that the owner's availability may change, but should be
1222 * considered busy time that will conflict.
RoboErikf8143c52011-09-28 15:16:00 -07001223 */
1224 public static final int AVAILABILITY_TENTATIVE = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001225
1226 /**
RoboErikc2d53302011-06-03 09:37:58 -07001227 * Whether the event has an alarm or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001228 * <P>Type: INTEGER (boolean)</P>
1229 */
1230 public static final String HAS_ALARM = "hasAlarm";
1231
1232 /**
RoboErikc2d53302011-06-03 09:37:58 -07001233 * Whether the event has extended properties or not. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001234 * <P>Type: INTEGER (boolean)</P>
1235 */
1236 public static final String HAS_EXTENDED_PROPERTIES = "hasExtendedProperties";
1237
1238 /**
RoboErikc2d53302011-06-03 09:37:58 -07001239 * The recurrence rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001240 * <P>Type: TEXT</P>
1241 */
1242 public static final String RRULE = "rrule";
1243
1244 /**
RoboErikc2d53302011-06-03 09:37:58 -07001245 * The recurrence dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001246 * <P>Type: TEXT</P>
1247 */
1248 public static final String RDATE = "rdate";
1249
1250 /**
RoboErikc2d53302011-06-03 09:37:58 -07001251 * The recurrence exception rule for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001252 * <P>Type: TEXT</P>
1253 */
1254 public static final String EXRULE = "exrule";
1255
1256 /**
RoboErikc2d53302011-06-03 09:37:58 -07001257 * The recurrence exception dates for the event. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001258 * <P>Type: TEXT</P>
1259 */
1260 public static final String EXDATE = "exdate";
1261
1262 /**
RoboErikc2d53302011-06-03 09:37:58 -07001263 * The {@link Events#_ID} of the original recurring event for which this
1264 * event is an exception. Column name.
RoboErikc0bd9bc2011-05-13 17:54:24 -07001265 * <P>Type: TEXT</P>
1266 */
1267 public static final String ORIGINAL_ID = "original_id";
1268
1269 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001270 * The _sync_id of the original recurring event for which this event is
RoboErikc0bd9bc2011-05-13 17:54:24 -07001271 * an exception. The provider should keep the original_id in sync when
RoboErikc2d53302011-06-03 09:37:58 -07001272 * this is updated. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001273 * <P>Type: TEXT</P>
1274 */
RoboErik651c02e2011-05-05 15:14:31 -07001275 public static final String ORIGINAL_SYNC_ID = "original_sync_id";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001276
1277 /**
1278 * The original instance time of the recurring event for which this
RoboErikc2d53302011-06-03 09:37:58 -07001279 * event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001280 * <P>Type: INTEGER (long; millis since epoch)</P>
1281 */
1282 public static final String ORIGINAL_INSTANCE_TIME = "originalInstanceTime";
1283
1284 /**
1285 * The allDay status (true or false) of the original recurring event
RoboErikc2d53302011-06-03 09:37:58 -07001286 * for which this event is an exception. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001287 * <P>Type: INTEGER (boolean)</P>
1288 */
1289 public static final String ORIGINAL_ALL_DAY = "originalAllDay";
1290
1291 /**
RoboErikc2d53302011-06-03 09:37:58 -07001292 * The last date this event repeats on, or NULL if it never ends. Column
1293 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001294 * <P>Type: INTEGER (long; millis since epoch)</P>
1295 */
1296 public static final String LAST_DATE = "lastDate";
Ken Shirriff79f0c562009-08-05 13:29:42 -07001297
1298 /**
1299 * Whether the event has attendee information. True if the event
1300 * has full attendee data, false if the event has information about
RoboErikc2d53302011-06-03 09:37:58 -07001301 * self only. Column name.
Ken Shirriff79f0c562009-08-05 13:29:42 -07001302 * <P>Type: INTEGER (boolean)</P>
1303 */
1304 public static final String HAS_ATTENDEE_DATA = "hasAttendeeData";
Ken Shirriff3d037072009-08-17 15:43:21 -07001305
1306 /**
RoboErikc2d53302011-06-03 09:37:58 -07001307 * Whether guests can modify the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001308 * <P>Type: INTEGER (boolean)</P>
1309 */
1310 public static final String GUESTS_CAN_MODIFY = "guestsCanModify";
1311
1312 /**
RoboErikc2d53302011-06-03 09:37:58 -07001313 * Whether guests can invite other guests. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001314 * <P>Type: INTEGER (boolean)</P>
1315 */
1316 public static final String GUESTS_CAN_INVITE_OTHERS = "guestsCanInviteOthers";
1317
1318 /**
RoboErikc2d53302011-06-03 09:37:58 -07001319 * Whether guests can see the list of attendees. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001320 * <P>Type: INTEGER (boolean)</P>
1321 */
1322 public static final String GUESTS_CAN_SEE_GUESTS = "guestsCanSeeGuests";
1323
1324 /**
RoboErikc2d53302011-06-03 09:37:58 -07001325 * Email of the organizer (owner) of the event. Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001326 * <P>Type: STRING</P>
1327 */
1328 public static final String ORGANIZER = "organizer";
1329
1330 /**
Alon Albert0a9a2192012-09-18 11:10:49 -07001331 * Are we the organizer of this event. If this column is not explicitly set, the provider
1332 * will return 1 if {@link #ORGANIZER} is equal to {@link Calendars#OWNER_ACCOUNT}.
1333 * Column name.
1334 * <P>Type: STRING</P>
1335 */
1336 public static final String IS_ORGANIZER = "isOrganizer";
1337
1338 /**
RoboErikc2d53302011-06-03 09:37:58 -07001339 * Whether the user can invite others to the event. The
1340 * GUESTS_CAN_INVITE_OTHERS is a setting that applies to an arbitrary
1341 * guest, while CAN_INVITE_OTHERS indicates if the user can invite
1342 * others (either through GUESTS_CAN_INVITE_OTHERS or because the user
1343 * has modify access to the event). Column name.
Ken Shirriff3d037072009-08-17 15:43:21 -07001344 * <P>Type: INTEGER (boolean, readonly)</P>
1345 */
1346 public static final String CAN_INVITE_OTHERS = "canInviteOthers";
Michael Chan37960c72012-04-19 00:18:13 -07001347
1348 /**
1349 * The package name of the custom app that can provide a richer
1350 * experience for the event. See the ACTION TYPE
1351 * {@link CalendarContract#ACTION_HANDLE_CUSTOM_EVENT} for details.
1352 * Column name.
1353 * <P> Type: TEXT </P>
1354 */
1355 public static final String CUSTOM_APP_PACKAGE = "customAppPackage";
1356
1357 /**
1358 * The URI used by the custom app for the event. Column name.
1359 * <P>Type: TEXT</P>
1360 */
1361 public static final String CUSTOM_APP_URI = "customAppUri";
1362
Sara Ting4d6f90e2012-09-17 11:17:15 -07001363 /**
1364 * The UID for events added from the RFC 2445 iCalendar format.
1365 * Column name.
1366 * <P>Type: TEXT</P>
1367 */
1368 public static final String UID_2445 = "uid2445";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001369 }
1370
1371 /**
RoboErikc2d53302011-06-03 09:37:58 -07001372 * Class that represents an Event Entity. There is one entry per event.
1373 * Recurring events show up as a single entry. This is a helper class to
1374 * make batch operations easier. A {@link ContentResolver} or
1375 * {@link ContentProviderClient} is required as the helper does additional
1376 * queries to add reminders and attendees to each entry.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001377 */
RoboErik651c02e2011-05-05 15:14:31 -07001378 public static final class EventsEntity implements BaseColumns, SyncColumns, EventsColumns {
Fred Quintana328c0e72009-12-07 14:52:28 -08001379 /**
1380 * The content:// style URL for this table
1381 */
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001382 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1383 "/event_entities");
Fred Quintana328c0e72009-12-07 14:52:28 -08001384
RoboErikc2d53302011-06-03 09:37:58 -07001385 /**
RoboErik36726962011-06-14 14:01:15 -07001386 * This utility class cannot be instantiated
1387 */
1388 private EventsEntity() {}
1389
1390 /**
RoboErikc2d53302011-06-03 09:37:58 -07001391 * Creates a new iterator for events
1392 *
1393 * @param cursor An event query
1394 * @param resolver For performing additional queries
1395 * @return an EntityIterator containing one entity per event in the
1396 * cursor
1397 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001398 public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) {
1399 return new EntityIteratorImpl(cursor, resolver);
1400 }
1401
RoboErikc2d53302011-06-03 09:37:58 -07001402 /**
1403 * Creates a new iterator for events
1404 *
1405 * @param cursor An event query
1406 * @param provider For performing additional queries
1407 * @return an EntityIterator containing one entity per event in the
1408 * cursor
1409 */
Fred Quintana328c0e72009-12-07 14:52:28 -08001410 public static EntityIterator newEntityIterator(Cursor cursor,
1411 ContentProviderClient provider) {
1412 return new EntityIteratorImpl(cursor, provider);
1413 }
1414
1415 private static class EntityIteratorImpl extends CursorEntityIterator {
1416 private final ContentResolver mResolver;
1417 private final ContentProviderClient mProvider;
1418
1419 private static final String[] REMINDERS_PROJECTION = new String[] {
1420 Reminders.MINUTES,
1421 Reminders.METHOD,
1422 };
1423 private static final int COLUMN_MINUTES = 0;
1424 private static final int COLUMN_METHOD = 1;
1425
1426 private static final String[] ATTENDEES_PROJECTION = new String[] {
1427 Attendees.ATTENDEE_NAME,
1428 Attendees.ATTENDEE_EMAIL,
1429 Attendees.ATTENDEE_RELATIONSHIP,
1430 Attendees.ATTENDEE_TYPE,
1431 Attendees.ATTENDEE_STATUS,
Michael Chan48ec6222012-04-17 15:58:28 -07001432 Attendees.ATTENDEE_IDENTITY,
1433 Attendees.ATTENDEE_ID_NAMESPACE
Fred Quintana328c0e72009-12-07 14:52:28 -08001434 };
1435 private static final int COLUMN_ATTENDEE_NAME = 0;
1436 private static final int COLUMN_ATTENDEE_EMAIL = 1;
1437 private static final int COLUMN_ATTENDEE_RELATIONSHIP = 2;
1438 private static final int COLUMN_ATTENDEE_TYPE = 3;
1439 private static final int COLUMN_ATTENDEE_STATUS = 4;
Michael Chan48ec6222012-04-17 15:58:28 -07001440 private static final int COLUMN_ATTENDEE_IDENTITY = 5;
1441 private static final int COLUMN_ATTENDEE_ID_NAMESPACE = 6;
1442
Fred Quintana328c0e72009-12-07 14:52:28 -08001443 private static final String[] EXTENDED_PROJECTION = new String[] {
Marc Blank8f643c12010-04-29 14:16:48 -07001444 ExtendedProperties._ID,
Fred Quintana328c0e72009-12-07 14:52:28 -08001445 ExtendedProperties.NAME,
Marc Blank8f643c12010-04-29 14:16:48 -07001446 ExtendedProperties.VALUE
Fred Quintana328c0e72009-12-07 14:52:28 -08001447 };
Marc Blank8f643c12010-04-29 14:16:48 -07001448 private static final int COLUMN_ID = 0;
1449 private static final int COLUMN_NAME = 1;
1450 private static final int COLUMN_VALUE = 2;
Fred Quintana328c0e72009-12-07 14:52:28 -08001451
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001452 private static final String WHERE_EVENT_ID = "event_id=?";
1453
Fred Quintana328c0e72009-12-07 14:52:28 -08001454 public EntityIteratorImpl(Cursor cursor, ContentResolver resolver) {
1455 super(cursor);
1456 mResolver = resolver;
1457 mProvider = null;
1458 }
1459
1460 public EntityIteratorImpl(Cursor cursor, ContentProviderClient provider) {
1461 super(cursor);
1462 mResolver = null;
1463 mProvider = provider;
1464 }
1465
Marc Blank64a556d2010-02-25 12:53:16 -08001466 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08001467 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
1468 // we expect the cursor is already at the row we need to read from
1469 final long eventId = cursor.getLong(cursor.getColumnIndexOrThrow(Events._ID));
1470 ContentValues cv = new ContentValues();
1471 cv.put(Events._ID, eventId);
1472 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001473 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, TITLE);
1474 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DESCRIPTION);
1475 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_LOCATION);
1476 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, STATUS);
1477 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SELF_ATTENDEE_STATUS);
Fred Quintana328c0e72009-12-07 14:52:28 -08001478 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTSTART);
1479 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTEND);
1480 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DURATION);
1481 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_TIMEZONE);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001482 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_END_TIMEZONE);
Fred Quintana328c0e72009-12-07 14:52:28 -08001483 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ALL_DAY);
RoboErik651c02e2011-05-05 15:14:31 -07001484 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL);
1485 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, AVAILABILITY);
Alon Albert971c28b2013-02-04 13:49:50 -08001486 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, EVENT_COLOR);
Alon Albert0a35dd52013-02-05 11:07:56 -08001487 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_COLOR_KEY);
Fred Quintana328c0e72009-12-07 14:52:28 -08001488 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, HAS_ALARM);
1489 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
1490 HAS_EXTENDED_PROPERTIES);
1491 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RRULE);
1492 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RDATE);
1493 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXRULE);
1494 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXDATE);
RoboErik651c02e2011-05-05 15:14:31 -07001495 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_SYNC_ID);
RoboErikc0bd9bc2011-05-13 17:54:24 -07001496 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_ID);
Fred Quintana328c0e72009-12-07 14:52:28 -08001497 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
1498 ORIGINAL_INSTANCE_TIME);
1499 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ORIGINAL_ALL_DAY);
1500 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_DATE);
1501 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, HAS_ATTENDEE_DATA);
1502 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
1503 GUESTS_CAN_INVITE_OTHERS);
1504 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_MODIFY);
1505 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_SEE_GUESTS);
Michael Chanbb9fd4a2012-04-24 17:32:03 -07001506 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_PACKAGE);
1507 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_URI);
Sara Ting4d6f90e2012-09-17 11:17:15 -07001508 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, UID_2445);
Fred Quintana328c0e72009-12-07 14:52:28 -08001509 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORGANIZER);
Alon Albert0a9a2192012-09-18 11:10:49 -07001510 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, IS_ORGANIZER);
Fred Quintana328c0e72009-12-07 14:52:28 -08001511 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
RoboErik651c02e2011-05-05 15:14:31 -07001512 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
Alon Albert8ac6a632012-12-17 17:21:18 -08001513 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
Alon Albert866f40a2011-06-06 14:04:00 -07001514 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED);
RoboErikc2d53302011-06-03 09:37:58 -07001515 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
RoboErik9734df52011-06-09 14:11:25 -07001516 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA1);
1517 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA2);
1518 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA3);
1519 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA4);
1520 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA5);
1521 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA6);
1522 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA7);
1523 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA8);
1524 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA9);
1525 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA10);
RoboErikbe010392011-05-26 12:28:38 -07001526 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
1527 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
1528 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
1529 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
1530 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
1531 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
RoboErik9734df52011-06-09 14:11:25 -07001532 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
1533 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
1534 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
1535 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);
Fred Quintana328c0e72009-12-07 14:52:28 -08001536
1537 Entity entity = new Entity(cv);
1538 Cursor subCursor;
1539 if (mResolver != null) {
1540 subCursor = mResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001541 WHERE_EVENT_ID,
1542 new String[] { Long.toString(eventId) } /* selectionArgs */,
1543 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001544 } else {
1545 subCursor = mProvider.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001546 WHERE_EVENT_ID,
1547 new String[] { Long.toString(eventId) } /* selectionArgs */,
1548 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001549 }
1550 try {
1551 while (subCursor.moveToNext()) {
1552 ContentValues reminderValues = new ContentValues();
1553 reminderValues.put(Reminders.MINUTES, subCursor.getInt(COLUMN_MINUTES));
1554 reminderValues.put(Reminders.METHOD, subCursor.getInt(COLUMN_METHOD));
1555 entity.addSubValue(Reminders.CONTENT_URI, reminderValues);
1556 }
1557 } finally {
1558 subCursor.close();
1559 }
1560
1561 if (mResolver != null) {
1562 subCursor = mResolver.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001563 WHERE_EVENT_ID,
1564 new String[] { Long.toString(eventId) } /* selectionArgs */,
1565 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001566 } else {
1567 subCursor = mProvider.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001568 WHERE_EVENT_ID,
1569 new String[] { Long.toString(eventId) } /* selectionArgs */,
1570 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001571 }
1572 try {
1573 while (subCursor.moveToNext()) {
1574 ContentValues attendeeValues = new ContentValues();
1575 attendeeValues.put(Attendees.ATTENDEE_NAME,
1576 subCursor.getString(COLUMN_ATTENDEE_NAME));
1577 attendeeValues.put(Attendees.ATTENDEE_EMAIL,
1578 subCursor.getString(COLUMN_ATTENDEE_EMAIL));
1579 attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP,
1580 subCursor.getInt(COLUMN_ATTENDEE_RELATIONSHIP));
1581 attendeeValues.put(Attendees.ATTENDEE_TYPE,
1582 subCursor.getInt(COLUMN_ATTENDEE_TYPE));
1583 attendeeValues.put(Attendees.ATTENDEE_STATUS,
1584 subCursor.getInt(COLUMN_ATTENDEE_STATUS));
Michael Chan48ec6222012-04-17 15:58:28 -07001585 attendeeValues.put(Attendees.ATTENDEE_IDENTITY,
Michael Chana07ea5d2012-07-13 14:10:40 -07001586 subCursor.getString(COLUMN_ATTENDEE_IDENTITY));
Michael Chan48ec6222012-04-17 15:58:28 -07001587 attendeeValues.put(Attendees.ATTENDEE_ID_NAMESPACE,
Michael Chana07ea5d2012-07-13 14:10:40 -07001588 subCursor.getString(COLUMN_ATTENDEE_ID_NAMESPACE));
Fred Quintana328c0e72009-12-07 14:52:28 -08001589 entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);
1590 }
1591 } finally {
1592 subCursor.close();
1593 }
1594
1595 if (mResolver != null) {
1596 subCursor = mResolver.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001597 WHERE_EVENT_ID,
1598 new String[] { Long.toString(eventId) } /* selectionArgs */,
1599 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001600 } else {
1601 subCursor = mProvider.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION,
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001602 WHERE_EVENT_ID,
1603 new String[] { Long.toString(eventId) } /* selectionArgs */,
1604 null /* sortOrder */);
Fred Quintana328c0e72009-12-07 14:52:28 -08001605 }
1606 try {
1607 while (subCursor.moveToNext()) {
1608 ContentValues extendedValues = new ContentValues();
Marc Blank8f643c12010-04-29 14:16:48 -07001609 extendedValues.put(ExtendedProperties._ID,
1610 subCursor.getString(COLUMN_ID));
Ken Shirriff3b168922010-01-27 12:27:28 -08001611 extendedValues.put(ExtendedProperties.NAME,
1612 subCursor.getString(COLUMN_NAME));
Fred Quintana328c0e72009-12-07 14:52:28 -08001613 extendedValues.put(ExtendedProperties.VALUE,
Ken Shirriff3b168922010-01-27 12:27:28 -08001614 subCursor.getString(COLUMN_VALUE));
Fred Quintana328c0e72009-12-07 14:52:28 -08001615 entity.addSubValue(ExtendedProperties.CONTENT_URI, extendedValues);
1616 }
1617 } finally {
1618 subCursor.close();
1619 }
1620
1621 cursor.moveToNext();
1622 return entity;
1623 }
1624 }
1625 }
1626
1627 /**
RoboErikf4010c52011-06-17 11:04:26 -07001628 * Constants and helpers for the Events table, which contains details for
1629 * individual events. <h3>Operations</h3> All operations can be done either
1630 * as an app or as a sync adapter. To perform an operation as a sync adapter
1631 * {@link #CALLER_IS_SYNCADAPTER} should be set to true and
1632 * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri
1633 * parameters. See
1634 * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)}
1635 * for details on adding parameters. Sync adapters have write access to more
1636 * columns but are restricted to a single account at a time.
RoboErikfe37b492011-06-16 12:31:56 -07001637 * <dl>
1638 * <dt><b>Insert</b></dt>
1639 * <dd>When inserting a new event the following fields must be included:
1640 * <ul>
1641 * <li>dtstart</li>
Michael Chane6fbf652011-10-18 14:43:11 -07001642 * <li>dtend if the event is non-recurring</li>
1643 * <li>duration if the event is recurring</li>
1644 * <li>rrule or rdate if the event is recurring</li>
RoboErik4172d952011-10-25 13:59:13 -07001645 * <li>eventTimezone</li>
RoboErikfe37b492011-06-16 12:31:56 -07001646 * <li>a calendar_id</li>
1647 * </ul>
1648 * There are also further requirements when inserting or updating an event.
1649 * See the section on Writing to Events.</dd>
1650 * <dt><b>Update</b></dt>
RoboErikf4010c52011-06-17 11:04:26 -07001651 * <dd>To perform an update of an Event the {@link Events#_ID} of the event
1652 * should be provided either as an appended id to the Uri (
RoboErikfe37b492011-06-16 12:31:56 -07001653 * {@link ContentUris#withAppendedId}) or as the first selection item--the
1654 * selection should start with "_id=?" and the first selectionArg should be
RoboErikf4010c52011-06-17 11:04:26 -07001655 * the _id of the event. Updates may also be done using a selection and no
1656 * id. Updating an event must respect the same rules as inserting and is
1657 * further restricted in the fields that can be written. See the section on
1658 * Writing to Events.</dd>
RoboErikfe37b492011-06-16 12:31:56 -07001659 * <dt><b>Delete</b></dt>
1660 * <dd>Events can be deleted either by the {@link Events#_ID} as an appended
1661 * id on the Uri or using any standard selection. If an appended id is used
1662 * a selection is not allowed. There are two versions of delete: as an app
1663 * and as a sync adapter. An app delete will set the deleted column on an
1664 * event and remove all instances of that event. A sync adapter delete will
1665 * remove the event from the database and all associated data.</dd>
1666 * <dt><b>Query</b></dt>
1667 * <dd>Querying the Events table will get you all information about a set of
1668 * events except their reminders, attendees, and extended properties. There
1669 * will be one row returned for each event that matches the query selection,
1670 * or at most a single row if the {@link Events#_ID} is appended to the Uri.
1671 * Recurring events will only return a single row regardless of the number
1672 * of times that event repeats.</dd>
1673 * </dl>
1674 * <h3>Writing to Events</h3> There are further restrictions on all Updates
1675 * and Inserts in the Events table:
1676 * <ul>
1677 * <li>If allDay is set to 1 eventTimezone must be {@link Time#TIMEZONE_UTC}
1678 * and the time must correspond to a midnight boundary.</li>
1679 * <li>Exceptions are not allowed to recur. If rrule or rdate is not empty,
1680 * original_id and original_sync_id must be empty.</li>
1681 * <li>In general a calendar_id should not be modified after insertion. This
1682 * is not explicitly forbidden but many sync adapters will not behave in an
1683 * expected way if the calendar_id is modified.</li>
1684 * </ul>
1685 * The following Events columns are writable by both an app and a sync
1686 * adapter.
1687 * <ul>
1688 * <li>{@link #CALENDAR_ID}</li>
1689 * <li>{@link #ORGANIZER}</li>
1690 * <li>{@link #TITLE}</li>
1691 * <li>{@link #EVENT_LOCATION}</li>
1692 * <li>{@link #DESCRIPTION}</li>
1693 * <li>{@link #EVENT_COLOR}</li>
1694 * <li>{@link #DTSTART}</li>
1695 * <li>{@link #DTEND}</li>
1696 * <li>{@link #EVENT_TIMEZONE}</li>
1697 * <li>{@link #EVENT_END_TIMEZONE}</li>
1698 * <li>{@link #DURATION}</li>
1699 * <li>{@link #ALL_DAY}</li>
1700 * <li>{@link #RRULE}</li>
1701 * <li>{@link #RDATE}</li>
1702 * <li>{@link #EXRULE}</li>
1703 * <li>{@link #EXDATE}</li>
1704 * <li>{@link #ORIGINAL_ID}</li>
1705 * <li>{@link #ORIGINAL_SYNC_ID}</li>
1706 * <li>{@link #ORIGINAL_INSTANCE_TIME}</li>
1707 * <li>{@link #ORIGINAL_ALL_DAY}</li>
1708 * <li>{@link #ACCESS_LEVEL}</li>
1709 * <li>{@link #AVAILABILITY}</li>
1710 * <li>{@link #GUESTS_CAN_MODIFY}</li>
1711 * <li>{@link #GUESTS_CAN_INVITE_OTHERS}</li>
1712 * <li>{@link #GUESTS_CAN_SEE_GUESTS}</li>
Michael Chanbb9fd4a2012-04-24 17:32:03 -07001713 * <li>{@link #CUSTOM_APP_PACKAGE}</li>
1714 * <li>{@link #CUSTOM_APP_URI}</li>
Sara Ting4d6f90e2012-09-17 11:17:15 -07001715 * <li>{@link #UID_2445}</li>
RoboErikfe37b492011-06-16 12:31:56 -07001716 * </ul>
1717 * The following Events columns are writable only by a sync adapter
1718 * <ul>
1719 * <li>{@link #DIRTY}</li>
Alon Albert8ac6a632012-12-17 17:21:18 -08001720 * <li>{@link #MUTATORS}</li>
RoboErikfe37b492011-06-16 12:31:56 -07001721 * <li>{@link #_SYNC_ID}</li>
1722 * <li>{@link #SYNC_DATA1}</li>
1723 * <li>{@link #SYNC_DATA2}</li>
1724 * <li>{@link #SYNC_DATA3}</li>
1725 * <li>{@link #SYNC_DATA4}</li>
1726 * <li>{@link #SYNC_DATA5}</li>
1727 * <li>{@link #SYNC_DATA6}</li>
1728 * <li>{@link #SYNC_DATA7}</li>
1729 * <li>{@link #SYNC_DATA8}</li>
1730 * <li>{@link #SYNC_DATA9}</li>
1731 * <li>{@link #SYNC_DATA10}</li>
1732 * </ul>
1733 * The remaining columns are either updated by the provider only or are
1734 * views into other tables and cannot be changed through the Events table.
Fred Quintana328c0e72009-12-07 14:52:28 -08001735 */
RoboErik9734df52011-06-09 14:11:25 -07001736 public static final class Events implements BaseColumns, SyncColumns, EventsColumns,
RoboErike00d5892011-06-23 15:16:55 -07001737 CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001738
RoboErikc2d53302011-06-03 09:37:58 -07001739 /**
RoboErikc2d53302011-06-03 09:37:58 -07001740 * The content:// style URL for interacting with events. Appending an
1741 * event id using {@link ContentUris#withAppendedId(Uri, long)} will
1742 * specify a single event.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001743 */
RoboErikc2d53302011-06-03 09:37:58 -07001744 @SuppressWarnings("hiding")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001745 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001746 Uri.parse("content://" + AUTHORITY + "/events");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001747
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001748 /**
yuemingw369f96d2018-12-05 22:07:04 +00001749 * The content:// style URL for querying Events table in the managed profile. Appending an
yuemingwb714ba02018-10-26 18:54:44 +01001750 * event id using {@link ContentUris#withAppendedId(Uri, long)} will
1751 * specify a single event.
1752 *
1753 * <p>The following columns are allowed to be queried via this uri:
1754 * <ul>
1755 * <li>{@link #_ID}</li>
1756 * <li>{@link #CALENDAR_ID}</li>
1757 * <li>{@link #TITLE}</li>
1758 * <li>{@link #EVENT_LOCATION}</li>
1759 * <li>{@link #EVENT_COLOR}</li>
1760 * <li>{@link #STATUS}</li>
1761 * <li>{@link #DTSTART}</li>
1762 * <li>{@link #DTEND}</li>
1763 * <li>{@link #EVENT_TIMEZONE}</li>
1764 * <li>{@link #EVENT_END_TIMEZONE}</li>
1765 * <li>{@link #DURATION}</li>
1766 * <li>{@link #ALL_DAY}</li>
1767 * <li>{@link #AVAILABILITY}</li>
1768 * <li>{@link #RRULE}</li>
1769 * <li>{@link #RDATE}</li>
1770 * <li>{@link #EXRULE}</li>
1771 * <li>{@link #EXDATE}</li>
1772 * <li>{@link #CALENDAR_DISPLAY_NAME}</li>
1773 * <li>{@link #CALENDAR_COLOR}</li>
1774 * <li>{@link #VISIBLE}</li>
1775 * <li>{@link #CALENDAR_TIME_ZONE}</li>
1776 * </ul>
1777 *
1778 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
1779 * projection of the query to this uri that are not contained in the above list.
1780 *
1781 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001782 * of a managed profile, or cross-profile calendar is disabled in Settings, or this uri is
yuemingw369f96d2018-12-05 22:07:04 +00001783 * queried from a package that is not whitelisted by profile owner of the managed profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001784 * via
1785 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +01001786 *
1787 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
1788 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
1789 */
1790 public static final Uri ENTERPRISE_CONTENT_URI =
1791 Uri.parse("content://" + AUTHORITY + "/enterprise/events");
1792
1793 /**
Andy McFadden4a8c4782011-05-24 13:00:29 -07001794 * The content:// style URI for recurring event exceptions. Insertions require an
1795 * appended event ID. Deletion of exceptions requires both the original event ID and
1796 * the exception event ID (see {@link Uri.Builder#appendPath}).
1797 */
RoboErik083cd2d2011-06-30 11:53:05 -07001798 public static final Uri CONTENT_EXCEPTION_URI =
Andy McFadden4a8c4782011-05-24 13:00:29 -07001799 Uri.parse("content://" + AUTHORITY + "/exception");
1800
1801 /**
RoboErik36726962011-06-14 14:01:15 -07001802 * This utility class cannot be instantiated
1803 */
1804 private Events() {}
1805
1806 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001807 * The default sort order for this table
1808 */
RoboErikc2d53302011-06-03 09:37:58 -07001809 private static final String DEFAULT_SORT_ORDER = "";
RoboErik651c02e2011-05-05 15:14:31 -07001810
1811 /**
1812 * These are columns that should only ever be updated by the provider,
1813 * either because they are views mapped to another table or because they
RoboErik083cd2d2011-06-30 11:53:05 -07001814 * are used for provider only functionality. TODO move to provider
1815 *
1816 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001817 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01001818 @UnsupportedAppUsage
RoboErik651c02e2011-05-05 15:14:31 -07001819 public static String[] PROVIDER_WRITABLE_COLUMNS = new String[] {
1820 ACCOUNT_NAME,
RoboErikc2d53302011-06-03 09:37:58 -07001821 ACCOUNT_TYPE,
1822 CAL_SYNC1,
1823 CAL_SYNC2,
1824 CAL_SYNC3,
1825 CAL_SYNC4,
1826 CAL_SYNC5,
Alon Albert866f40a2011-06-06 14:04:00 -07001827 CAL_SYNC6,
RoboErik9734df52011-06-09 14:11:25 -07001828 CAL_SYNC7,
1829 CAL_SYNC8,
1830 CAL_SYNC9,
1831 CAL_SYNC10,
1832 ALLOWED_REMINDERS,
RoboErikc7ef9392011-10-27 14:11:44 -07001833 ALLOWED_ATTENDEE_TYPES,
1834 ALLOWED_AVAILABILITY,
RoboErik9734df52011-06-09 14:11:25 -07001835 CALENDAR_ACCESS_LEVEL,
1836 CALENDAR_COLOR,
1837 CALENDAR_TIME_ZONE,
1838 CAN_MODIFY_TIME_ZONE,
1839 CAN_ORGANIZER_RESPOND,
1840 CALENDAR_DISPLAY_NAME,
Alon Albert866f40a2011-06-06 14:04:00 -07001841 CAN_PARTIALLY_UPDATE,
RoboErik9734df52011-06-09 14:11:25 -07001842 SYNC_EVENTS,
1843 VISIBLE,
RoboErik651c02e2011-05-05 15:14:31 -07001844 };
1845
1846 /**
1847 * These fields are only writable by a sync adapter. To modify them the
1848 * caller must include CALLER_IS_SYNCADAPTER, _SYNC_ACCOUNT, and
RoboErik083cd2d2011-06-30 11:53:05 -07001849 * _SYNC_ACCOUNT_TYPE in the query parameters. TODO move to provider.
1850 *
1851 * @hide
RoboErik651c02e2011-05-05 15:14:31 -07001852 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -07001853 @TestApi
RoboErik651c02e2011-05-05 15:14:31 -07001854 public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
1855 _SYNC_ID,
RoboErik651c02e2011-05-05 15:14:31 -07001856 DIRTY,
Alon Albert8ac6a632012-12-17 17:21:18 -08001857 MUTATORS,
RoboErik9734df52011-06-09 14:11:25 -07001858 SYNC_DATA1,
1859 SYNC_DATA2,
1860 SYNC_DATA3,
1861 SYNC_DATA4,
1862 SYNC_DATA5,
1863 SYNC_DATA6,
1864 SYNC_DATA7,
1865 SYNC_DATA8,
1866 SYNC_DATA9,
1867 SYNC_DATA10,
RoboErik651c02e2011-05-05 15:14:31 -07001868 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001869 }
1870
1871 /**
RoboErikc2d53302011-06-03 09:37:58 -07001872 * Fields and helpers for interacting with Instances. An instance is a
1873 * single occurrence of an event including time zone specific start and end
RoboErik3771fcb2011-06-16 15:41:31 -07001874 * days and minutes. The instances table is not writable and only provides a
1875 * way to query event occurrences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001876 */
RoboErike00d5892011-06-23 15:16:55 -07001877 public static final class Instances implements BaseColumns, EventsColumns, CalendarColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001878
RoboErike00d5892011-06-23 15:16:55 -07001879 private static final String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?";
1880 private static final String[] WHERE_CALENDARS_ARGS = {
1881 "1"
1882 };
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001883
RoboErikc2d53302011-06-03 09:37:58 -07001884 /**
RoboErik36726962011-06-14 14:01:15 -07001885 * This utility class cannot be instantiated
1886 */
1887 private Instances() {}
1888
1889 /**
RoboErikc2d53302011-06-03 09:37:58 -07001890 * Performs a query to return all visible instances in the given range.
1891 * This is a blocking function and should not be done on the UI thread.
1892 * This will cause an expansion of recurring events to fill this time
1893 * range if they are not already expanded and will slow down for larger
1894 * time ranges with many recurring events.
1895 *
1896 * @param cr The ContentResolver to use for the query
1897 * @param projection The columns to return
1898 * @param begin The start of the time range to query in UTC millis since
1899 * epoch
1900 * @param end The end of the time range to query in UTC millis since
1901 * epoch
1902 * @return A Cursor containing all instances in the given range
1903 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001904 public static final Cursor query(ContentResolver cr, String[] projection,
1905 long begin, long end) {
1906 Uri.Builder builder = CONTENT_URI.buildUpon();
1907 ContentUris.appendId(builder, begin);
1908 ContentUris.appendId(builder, end);
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08001909 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
RoboErike00d5892011-06-23 15:16:55 -07001910 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001911 }
1912
RoboErikc2d53302011-06-03 09:37:58 -07001913 /**
1914 * Performs a query to return all visible instances in the given range
1915 * that match the given query. This is a blocking function and should
1916 * not be done on the UI thread. This will cause an expansion of
1917 * recurring events to fill this time range if they are not already
1918 * expanded and will slow down for larger time ranges with many
1919 * recurring events.
1920 *
1921 * @param cr The ContentResolver to use for the query
1922 * @param projection The columns to return
1923 * @param begin The start of the time range to query in UTC millis since
1924 * epoch
1925 * @param end The end of the time range to query in UTC millis since
1926 * epoch
1927 * @param searchQuery A string of space separated search terms. Segments
1928 * enclosed by double quotes will be treated as a single
1929 * term.
1930 * @return A Cursor of instances matching the search terms in the given
1931 * time range
1932 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001933 public static final Cursor query(ContentResolver cr, String[] projection,
Mason Tang19f84582010-07-08 18:01:41 -07001934 long begin, long end, String searchQuery) {
1935 Uri.Builder builder = CONTENT_SEARCH_URI.buildUpon();
1936 ContentUris.appendId(builder, begin);
1937 ContentUris.appendId(builder, end);
RoboErikc2d53302011-06-03 09:37:58 -07001938 builder = builder.appendPath(searchQuery);
RoboErike00d5892011-06-23 15:16:55 -07001939 return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED,
1940 WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER);
RoboErikc2d53302011-06-03 09:37:58 -07001941 }
1942
1943 /**
1944 * The content:// style URL for querying an instance range. The begin
1945 * and end of the range to query should be added as path segments if
1946 * this is used directly.
1947 */
1948 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001949 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
1950 "/instances/when");
RoboErikc2d53302011-06-03 09:37:58 -07001951 /**
1952 * The content:// style URL for querying an instance range by Julian
1953 * Day. The start and end day should be added as path segments if this
1954 * is used directly.
1955 */
Michael Chan2cfb0d12009-06-30 18:11:23 -07001956 public static final Uri CONTENT_BY_DAY_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08001957 Uri.parse("content://" + AUTHORITY + "/instances/whenbyday");
RoboErikc2d53302011-06-03 09:37:58 -07001958 /**
1959 * The content:// style URL for querying an instance range with a search
1960 * term. The begin, end, and search string should be appended as path
1961 * segments if this is used directly.
1962 */
Mason Tang19f84582010-07-08 18:01:41 -07001963 public static final Uri CONTENT_SEARCH_URI = Uri.parse("content://" + AUTHORITY +
1964 "/instances/search");
RoboErikc2d53302011-06-03 09:37:58 -07001965 /**
1966 * The content:// style URL for querying an instance range with a search
1967 * term. The start day, end day, and search string should be appended as
1968 * path segments if this is used directly.
1969 */
Mason Tang19f84582010-07-08 18:01:41 -07001970 public static final Uri CONTENT_SEARCH_BY_DAY_URI =
1971 Uri.parse("content://" + AUTHORITY + "/instances/searchbyday");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001972
1973 /**
yuemingw369f96d2018-12-05 22:07:04 +00001974 * The content:// style URL for querying an instance range in the managed profile.
yuemingwb714ba02018-10-26 18:54:44 +01001975 * It supports similar semantics as {@link #CONTENT_URI}.
1976 *
1977 * <p>The following columns plus the columns that are whitelisted by
1978 * {@link Events#ENTERPRISE_CONTENT_URI} are allowed to be queried via this uri:
1979 * <ul>
1980 * <li>{@link #_ID}</li>
1981 * <li>{@link #EVENT_ID}</li>
1982 * <li>{@link #BEGIN}</li>
1983 * <li>{@link #END}</li>
1984 * <li>{@link #START_DAY}</li>
1985 * <li>{@link #END_DAY}</li>
1986 * <li>{@link #START_MINUTE}</li>
1987 * <li>{@link #END_MINUTE}</li>
1988 * </ul>
1989 *
1990 * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the
1991 * projection of the query to this uri that are not contained in the above list.
1992 *
1993 * <p>This uri will return an empty cursor if the calling user is not a parent profile
yuemingwd2bfbc82019-01-02 11:42:25 +00001994 * of a managed profile, or cross-profile calendar for the managed profile is disabled in
yuemingwb714ba02018-10-26 18:54:44 +01001995 * Settings, or this uri is queried from a package that is not whitelisted by
yuemingw369f96d2018-12-05 22:07:04 +00001996 * profile owner of the managed profile via
yuemingwd2bfbc82019-01-02 11:42:25 +00001997 * {@link DevicePolicyManager#setCrossProfileCalendarPackages(ComponentName, Set)}.
yuemingwb714ba02018-10-26 18:54:44 +01001998 *
1999 * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName)
2000 * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED
2001 */
2002 public static final Uri ENTERPRISE_CONTENT_URI =
2003 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/when");
2004
2005 /**
2006 * The content:// style URL for querying an instance range by Julian
yuemingw369f96d2018-12-05 22:07:04 +00002007 * Day in the managed profile. It supports similar semantics as {@link #CONTENT_BY_DAY_URI}
yuemingwb714ba02018-10-26 18:54:44 +01002008 * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}.
2009 */
2010 public static final Uri ENTERPRISE_CONTENT_BY_DAY_URI =
2011 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/whenbyday");
2012
2013 /**
2014 * The content:// style URL for querying an instance range with a search
yuemingw369f96d2018-12-05 22:07:04 +00002015 * term in the managed profile. It supports similar semantics as {@link #CONTENT_SEARCH_URI}
yuemingwb714ba02018-10-26 18:54:44 +01002016 * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}.
2017 */
2018 public static final Uri ENTERPRISE_CONTENT_SEARCH_URI =
2019 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/search");
2020
2021 /**
2022 * The content:// style URL for querying an instance range with a search
yuemingw369f96d2018-12-05 22:07:04 +00002023 * term in the managed profile. It supports similar semantics as
yuemingwb714ba02018-10-26 18:54:44 +01002024 * {@link #CONTENT_SEARCH_BY_DAY_URI} and performs similar checks as
2025 * {@link #ENTERPRISE_CONTENT_URI}.
2026 */
2027 public static final Uri ENTERPRISE_CONTENT_SEARCH_BY_DAY_URI =
2028 Uri.parse("content://" + AUTHORITY + "/enterprise/instances/searchbyday");
2029
2030 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002031 * The default sort order for this table.
2032 */
RoboErikc2d53302011-06-03 09:37:58 -07002033 private static final String DEFAULT_SORT_ORDER = "begin ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002034
2035 /**
RoboErikc2d53302011-06-03 09:37:58 -07002036 * The beginning time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002037 * <P>Type: INTEGER (long; millis since epoch)</P>
2038 */
2039 public static final String BEGIN = "begin";
2040
2041 /**
RoboErikc2d53302011-06-03 09:37:58 -07002042 * The ending time of the instance, in UTC milliseconds. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002043 * <P>Type: INTEGER (long; millis since epoch)</P>
2044 */
2045 public static final String END = "end";
2046
2047 /**
RoboErikc2d53302011-06-03 09:37:58 -07002048 * The _id of the event for this instance. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002049 * <P>Type: INTEGER (long, foreign key to the Events table)</P>
2050 */
2051 public static final String EVENT_ID = "event_id";
2052
2053 /**
RoboErikc2d53302011-06-03 09:37:58 -07002054 * The Julian start day of the instance, relative to the local time
2055 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002056 * <P>Type: INTEGER (int)</P>
2057 */
2058 public static final String START_DAY = "startDay";
2059
2060 /**
RoboErikc2d53302011-06-03 09:37:58 -07002061 * The Julian end day of the instance, relative to the local time
2062 * zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002063 * <P>Type: INTEGER (int)</P>
2064 */
2065 public static final String END_DAY = "endDay";
2066
2067 /**
2068 * The start minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07002069 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002070 * <P>Type: INTEGER (int)</P>
2071 */
2072 public static final String START_MINUTE = "startMinute";
2073
2074 /**
2075 * The end minute of the instance measured from midnight in the
RoboErikc2d53302011-06-03 09:37:58 -07002076 * local time zone. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002077 * <P>Type: INTEGER (int)</P>
2078 */
2079 public static final String END_MINUTE = "endMinute";
2080 }
2081
RoboErikb2c75602011-06-13 12:53:48 -07002082 protected interface CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07002083 /**
RoboErikc2d53302011-06-03 09:37:58 -07002084 * The key for the setting. Keys are defined in {@link CalendarCache}.
Erik71ad58c2010-09-13 16:41:35 -07002085 */
2086 public static final String KEY = "key";
2087
2088 /**
2089 * The value of the given setting.
2090 */
2091 public static final String VALUE = "value";
2092 }
2093
RoboErik083cd2d2011-06-30 11:53:05 -07002094 /**
2095 * CalendarCache stores some settings for calendar including the current
2096 * time zone for the instances. These settings are stored using a key/value
2097 * scheme. A {@link #KEY} must be specified when updating these values.
2098 */
RoboErik36726962011-06-14 14:01:15 -07002099 public static final class CalendarCache implements CalendarCacheColumns {
Erik71ad58c2010-09-13 16:41:35 -07002100 /**
2101 * The URI to use for retrieving the properties from the Calendar db.
2102 */
2103 public static final Uri URI =
2104 Uri.parse("content://" + AUTHORITY + "/properties");
Erik71ad58c2010-09-13 16:41:35 -07002105
2106 /**
RoboErik36726962011-06-14 14:01:15 -07002107 * This utility class cannot be instantiated
2108 */
2109 private CalendarCache() {}
2110
2111 /**
Erik71ad58c2010-09-13 16:41:35 -07002112 * They key for updating the use of auto/home time zones in Calendar.
2113 * Valid values are {@link #TIMEZONE_TYPE_AUTO} or
2114 * {@link #TIMEZONE_TYPE_HOME}.
2115 */
RoboErik083cd2d2011-06-30 11:53:05 -07002116 public static final String KEY_TIMEZONE_TYPE = "timezoneType";
Erik71ad58c2010-09-13 16:41:35 -07002117
2118 /**
2119 * The key for updating the time zone used by the provider when it
2120 * generates the instances table. This should only be written if the
2121 * type is set to {@link #TIMEZONE_TYPE_HOME}. A valid time zone id
2122 * should be written to this field.
2123 */
RoboErik083cd2d2011-06-30 11:53:05 -07002124 public static final String KEY_TIMEZONE_INSTANCES = "timezoneInstances";
Erik71ad58c2010-09-13 16:41:35 -07002125
2126 /**
2127 * The key for reading the last time zone set by the user. This should
2128 * only be read by apps and it will be automatically updated whenever
RoboErik083cd2d2011-06-30 11:53:05 -07002129 * {@link #KEY_TIMEZONE_INSTANCES} is updated with
Erik71ad58c2010-09-13 16:41:35 -07002130 * {@link #TIMEZONE_TYPE_HOME} set.
2131 */
RoboErik083cd2d2011-06-30 11:53:05 -07002132 public static final String KEY_TIMEZONE_INSTANCES_PREVIOUS = "timezoneInstancesPrevious";
Erik71ad58c2010-09-13 16:41:35 -07002133
2134 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002135 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07002136 * should stay in sync with the device's time zone.
2137 */
2138 public static final String TIMEZONE_TYPE_AUTO = "auto";
2139
2140 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002141 * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider
Erik71ad58c2010-09-13 16:41:35 -07002142 * should use a fixed time zone set by the user.
2143 */
2144 public static final String TIMEZONE_TYPE_HOME = "home";
2145 }
2146
2147 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002148 * A few Calendar globals are needed in the CalendarProvider for expanding
RoboErik59dab492011-06-17 11:09:36 -07002149 * the Instances table and these are all stored in the first (and only) row
2150 * of the CalendarMetaData table.
2151 *
2152 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002153 */
RoboErikb2c75602011-06-13 12:53:48 -07002154 protected interface CalendarMetaDataColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 /**
2156 * The local timezone that was used for precomputing the fields
2157 * in the Instances table.
2158 */
2159 public static final String LOCAL_TIMEZONE = "localTimezone";
2160
2161 /**
2162 * The minimum time used in expanding the Instances table,
2163 * in UTC milliseconds.
2164 * <P>Type: INTEGER</P>
2165 */
2166 public static final String MIN_INSTANCE = "minInstance";
2167
2168 /**
2169 * The maximum time used in expanding the Instances table,
2170 * in UTC milliseconds.
2171 * <P>Type: INTEGER</P>
2172 */
2173 public static final String MAX_INSTANCE = "maxInstance";
2174
2175 /**
Erik37634642009-12-23 15:24:14 -08002176 * The minimum Julian day in the EventDays table.
2177 * <P>Type: INTEGER</P>
2178 */
2179 public static final String MIN_EVENTDAYS = "minEventDays";
2180
2181 /**
2182 * The maximum Julian day in the EventDays table.
2183 * <P>Type: INTEGER</P>
2184 */
2185 public static final String MAX_EVENTDAYS = "maxEventDays";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002186 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002187
RoboErikc2d53302011-06-03 09:37:58 -07002188 /**
2189 * @hide
2190 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002191 public static final class CalendarMetaData implements CalendarMetaDataColumns, BaseColumns {
RoboErik36726962011-06-14 14:01:15 -07002192
2193 /**
2194 * This utility class cannot be instantiated
2195 */
2196 private CalendarMetaData() {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002197 }
Erik37634642009-12-23 15:24:14 -08002198
RoboErikb2c75602011-06-13 12:53:48 -07002199 protected interface EventDaysColumns {
Erik37634642009-12-23 15:24:14 -08002200 /**
RoboErikc2d53302011-06-03 09:37:58 -07002201 * The Julian starting day number. Column name.
Erik37634642009-12-23 15:24:14 -08002202 * <P>Type: INTEGER (int)</P>
2203 */
2204 public static final String STARTDAY = "startDay";
RoboErikc2d53302011-06-03 09:37:58 -07002205 /**
2206 * The Julian ending day number. Column name.
2207 * <P>Type: INTEGER (int)</P>
2208 */
Erikbd8e2e22010-01-07 11:56:46 -08002209 public static final String ENDDAY = "endDay";
Erik37634642009-12-23 15:24:14 -08002210
2211 }
2212
RoboErikc2d53302011-06-03 09:37:58 -07002213 /**
2214 * Fields and helpers for querying for a list of days that contain events.
2215 */
Erik37634642009-12-23 15:24:14 -08002216 public static final class EventDays implements EventDaysColumns {
RoboErikb2c75602011-06-13 12:53:48 -07002217 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
RoboErikc2d53302011-06-03 09:37:58 -07002218 + "/instances/groupbyday");
RoboErikc2d53302011-06-03 09:37:58 -07002219 private static final String SELECTION = "selected=1";
2220
2221 /**
RoboErik36726962011-06-14 14:01:15 -07002222 * This utility class cannot be instantiated
2223 */
2224 private EventDays() {}
2225
2226 /**
RoboErikc2d53302011-06-03 09:37:58 -07002227 * Retrieves the days with events for the Julian days starting at
2228 * "startDay" for "numDays". It returns a cursor containing startday and
2229 * endday representing the max range of days for all events beginning on
2230 * each startday.This is a blocking function and should not be done on
2231 * the UI thread.
RoboErik36726962011-06-14 14:01:15 -07002232 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002233 * @param cr the ContentResolver
2234 * @param startDay the first Julian day in the range
2235 * @param numDays the number of days to load (must be at least 1)
RoboErik58644022011-07-08 13:39:05 -07002236 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07002237 * @return a database cursor containing a list of start and end days for
2238 * events
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002239 */
RoboErik58644022011-07-08 13:39:05 -07002240 public static final Cursor query(ContentResolver cr, int startDay, int numDays,
2241 String[] projection) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002242 if (numDays < 1) {
2243 return null;
2244 }
2245 int endDay = startDay + numDays - 1;
2246 Uri.Builder builder = CONTENT_URI.buildUpon();
2247 ContentUris.appendId(builder, startDay);
2248 ContentUris.appendId(builder, endDay);
RoboErik58644022011-07-08 13:39:05 -07002249 return cr.query(builder.build(), projection, SELECTION,
Erik37634642009-12-23 15:24:14 -08002250 null /* selection args */, STARTDAY);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002251 }
2252 }
2253
RoboErikb2c75602011-06-13 12:53:48 -07002254 protected interface RemindersColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002255 /**
RoboErikc2d53302011-06-03 09:37:58 -07002256 * The event the reminder belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002257 * <P>Type: INTEGER (foreign key to the Events table)</P>
2258 */
2259 public static final String EVENT_ID = "event_id";
2260
2261 /**
2262 * The minutes prior to the event that the alarm should ring. -1
2263 * specifies that we should use the default value for the system.
RoboErikc2d53302011-06-03 09:37:58 -07002264 * Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002265 * <P>Type: INTEGER</P>
2266 */
2267 public static final String MINUTES = "minutes";
2268
RoboErikc2d53302011-06-03 09:37:58 -07002269 /**
2270 * Passing this as a minutes value will use the default reminder
2271 * minutes.
2272 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002273 public static final int MINUTES_DEFAULT = -1;
2274
2275 /**
RoboErikc2d53302011-06-03 09:37:58 -07002276 * The alarm method, as set on the server. {@link #METHOD_DEFAULT},
Alon Albertbd251612012-02-23 10:30:51 -08002277 * {@link #METHOD_ALERT}, {@link #METHOD_EMAIL}, {@link #METHOD_SMS} and
2278 * {@link #METHOD_ALARM} are possible values; the device will only
2279 * process {@link #METHOD_DEFAULT} and {@link #METHOD_ALERT} reminders
2280 * (the other types are simply stored so we can send the same reminder
2281 * info back to the server when we make changes).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002282 */
2283 public static final String METHOD = "method";
2284
2285 public static final int METHOD_DEFAULT = 0;
2286 public static final int METHOD_ALERT = 1;
2287 public static final int METHOD_EMAIL = 2;
2288 public static final int METHOD_SMS = 3;
Alon Albertbd251612012-02-23 10:30:51 -08002289 public static final int METHOD_ALARM = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002290 }
2291
RoboErikc2d53302011-06-03 09:37:58 -07002292 /**
RoboErik3771fcb2011-06-16 15:41:31 -07002293 * Fields and helpers for accessing reminders for an event. Each row of this
2294 * table represents a single reminder for an event. Calling
RoboErik58644022011-07-08 13:39:05 -07002295 * {@link #query(ContentResolver, long, String[])} will return a list of reminders for
RoboErik3771fcb2011-06-16 15:41:31 -07002296 * the event with the given eventId. Both apps and sync adapters may write
2297 * to this table. There are three writable fields and all of them must be
2298 * included when inserting a new reminder. They are:
2299 * <ul>
2300 * <li>{@link #EVENT_ID}</li>
2301 * <li>{@link #MINUTES}</li>
2302 * <li>{@link #METHOD}</li>
2303 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07002304 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002305 public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns {
RoboErikbec6c362011-06-14 11:06:01 -07002306 private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?";
RoboErikc2d53302011-06-03 09:37:58 -07002307 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002308 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders");
RoboErikc2d53302011-06-03 09:37:58 -07002309
2310 /**
RoboErik36726962011-06-14 14:01:15 -07002311 * This utility class cannot be instantiated
2312 */
2313 private Reminders() {}
2314
2315 /**
RoboErikc2d53302011-06-03 09:37:58 -07002316 * Queries all reminders associated with the given event. This is a
2317 * blocking call and should not be done on the UI thread.
RoboErik36726962011-06-14 14:01:15 -07002318 *
RoboErikc2d53302011-06-03 09:37:58 -07002319 * @param cr The content resolver to use for the query
2320 * @param eventId The id of the event to retrieve reminders for
RoboErik58644022011-07-08 13:39:05 -07002321 * @param projection the columns to return in the cursor
RoboErikc2d53302011-06-03 09:37:58 -07002322 * @return A Cursor containing all reminders for the event
2323 */
RoboErik58644022011-07-08 13:39:05 -07002324 public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
RoboErikc2d53302011-06-03 09:37:58 -07002325 String[] remArgs = {Long.toString(eventId)};
RoboErik58644022011-07-08 13:39:05 -07002326 return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/,
RoboErikc2d53302011-06-03 09:37:58 -07002327 null /* sort order */);
2328 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002329 }
2330
RoboErikb2c75602011-06-13 12:53:48 -07002331 protected interface CalendarAlertsColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002332 /**
RoboErikc2d53302011-06-03 09:37:58 -07002333 * The event that the alert belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002334 * <P>Type: INTEGER (foreign key to the Events table)</P>
2335 */
2336 public static final String EVENT_ID = "event_id";
2337
2338 /**
RoboErikc2d53302011-06-03 09:37:58 -07002339 * The start time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002340 * <P>Type: INTEGER (long; millis since epoch)</P>
2341 */
2342 public static final String BEGIN = "begin";
2343
2344 /**
RoboErikc2d53302011-06-03 09:37:58 -07002345 * The end time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002346 * <P>Type: INTEGER (long; millis since epoch)</P>
2347 */
2348 public static final String END = "end";
2349
2350 /**
RoboErikc2d53302011-06-03 09:37:58 -07002351 * The alarm time of the event, in UTC. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002352 * <P>Type: INTEGER (long; millis since epoch)</P>
2353 */
2354 public static final String ALARM_TIME = "alarmTime";
2355
2356 /**
2357 * The creation time of this database entry, in UTC.
RoboErikc2d53302011-06-03 09:37:58 -07002358 * Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002359 * <P>Type: INTEGER (long; millis since epoch)</P>
2360 */
2361 public static final String CREATION_TIME = "creationTime";
2362
2363 /**
2364 * The time that the alarm broadcast was received by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002365 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002366 * <P>Type: INTEGER (long; millis since epoch)</P>
2367 */
2368 public static final String RECEIVED_TIME = "receivedTime";
2369
2370 /**
2371 * The time that the notification was created by the Calendar app,
RoboErikc2d53302011-06-03 09:37:58 -07002372 * in UTC. Useful for debugging missed reminders. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002373 * <P>Type: INTEGER (long; millis since epoch)</P>
2374 */
2375 public static final String NOTIFY_TIME = "notifyTime";
2376
2377 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002378 * The state of this alert. It starts out as {@link #STATE_SCHEDULED}, then
2379 * when the alarm goes off, it changes to {@link #STATE_FIRED}, and then when
2380 * the user dismisses the alarm it changes to {@link #STATE_DISMISSED}. Column
RoboErikc2d53302011-06-03 09:37:58 -07002381 * name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002382 * <P>Type: INTEGER</P>
2383 */
2384 public static final String STATE = "state";
2385
RoboErik083cd2d2011-06-30 11:53:05 -07002386 /**
2387 * An alert begins in this state when it is first created.
2388 */
2389 public static final int STATE_SCHEDULED = 0;
2390 /**
2391 * After a notification for an alert has been created it should be
2392 * updated to fired.
2393 */
2394 public static final int STATE_FIRED = 1;
2395 /**
2396 * Once the user has dismissed the notification the alert's state should
2397 * be set to dismissed so it is not fired again.
2398 */
2399 public static final int STATE_DISMISSED = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002400
2401 /**
RoboErikc2d53302011-06-03 09:37:58 -07002402 * The number of minutes that this alarm precedes the start time. Column
2403 * name.
2404 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002405 */
2406 public static final String MINUTES = "minutes";
2407
2408 /**
RoboErikc2d53302011-06-03 09:37:58 -07002409 * The default sort order for this alerts queries
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002410 */
Michael Chancdaeafd2009-10-29 00:11:58 -07002411 public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002412 }
2413
RoboErikc2d53302011-06-03 09:37:58 -07002414 /**
2415 * Fields and helpers for accessing calendar alerts information. These
RoboErik3771fcb2011-06-16 15:41:31 -07002416 * fields are for tracking which alerts have been fired. Scheduled alarms
RoboErike00d5892011-06-23 15:16:55 -07002417 * will generate an intent using {@link #ACTION_EVENT_REMINDER}. Apps that
RoboErik3771fcb2011-06-16 15:41:31 -07002418 * receive this action may update the {@link #STATE} for the reminder when
2419 * they have finished handling it. Apps that have their notifications
2420 * disabled should not modify the table to ensure that they do not conflict
2421 * with another app that is generating a notification. In general, apps
2422 * should not need to write to this table directly except to update the
2423 * state of a reminder.
RoboErikc2d53302011-06-03 09:37:58 -07002424 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002425 public static final class CalendarAlerts implements BaseColumns,
RoboErike00d5892011-06-23 15:16:55 -07002426 CalendarAlertsColumns, EventsColumns, CalendarColumns {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002427
RoboErikc2d53302011-06-03 09:37:58 -07002428 /**
2429 * @hide
2430 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002431 public static final String TABLE_NAME = "CalendarAlerts";
RoboErikc2d53302011-06-03 09:37:58 -07002432 /**
2433 * The Uri for querying calendar alert information
2434 */
2435 @SuppressWarnings("hiding")
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002436 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY +
2437 "/calendar_alerts");
Ken Shirriff5b387e12009-10-23 09:50:41 -07002438
RoboErik36726962011-06-14 14:01:15 -07002439 /**
2440 * This utility class cannot be instantiated
2441 */
2442 private CalendarAlerts() {}
2443
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002444 private static final String WHERE_ALARM_EXISTS = EVENT_ID + "=?"
2445 + " AND " + BEGIN + "=?"
2446 + " AND " + ALARM_TIME + "=?";
2447
2448 private static final String WHERE_FINDNEXTALARMTIME = ALARM_TIME + ">=?";
2449 private static final String SORT_ORDER_ALARMTIME_ASC = ALARM_TIME + " ASC";
2450
RoboErik083cd2d2011-06-30 11:53:05 -07002451 private static final String WHERE_RESCHEDULE_MISSED_ALARMS = STATE + "=" + STATE_SCHEDULED
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002452 + " AND " + ALARM_TIME + "<?"
2453 + " AND " + ALARM_TIME + ">?"
2454 + " AND " + END + ">=?";
2455
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002456 /**
2457 * This URI is for grouping the query results by event_id and begin
2458 * time. This will return one result per instance of an event. So
2459 * events with multiple alarms will appear just once, but multiple
2460 * instances of a repeating event will show up multiple times.
2461 */
Ken Shirriff5b387e12009-10-23 09:50:41 -07002462 public static final Uri CONTENT_URI_BY_INSTANCE =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002463 Uri.parse("content://" + AUTHORITY + "/calendar_alerts/by_instance");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002464
RoboErik083cd2d2011-06-30 11:53:05 -07002465 private static final boolean DEBUG = false;
Michael Chancdaeafd2009-10-29 00:11:58 -07002466
RoboErikc2d53302011-06-03 09:37:58 -07002467 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002468 * Helper for inserting an alarm time associated with an event TODO move
2469 * to Provider
RoboErikc2d53302011-06-03 09:37:58 -07002470 *
2471 * @hide
2472 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002473 public static final Uri insert(ContentResolver cr, long eventId,
2474 long begin, long end, long alarmTime, int minutes) {
2475 ContentValues values = new ContentValues();
2476 values.put(CalendarAlerts.EVENT_ID, eventId);
2477 values.put(CalendarAlerts.BEGIN, begin);
2478 values.put(CalendarAlerts.END, end);
2479 values.put(CalendarAlerts.ALARM_TIME, alarmTime);
2480 long currentTime = System.currentTimeMillis();
2481 values.put(CalendarAlerts.CREATION_TIME, currentTime);
2482 values.put(CalendarAlerts.RECEIVED_TIME, 0);
2483 values.put(CalendarAlerts.NOTIFY_TIME, 0);
RoboErik083cd2d2011-06-30 11:53:05 -07002484 values.put(CalendarAlerts.STATE, STATE_SCHEDULED);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002485 values.put(CalendarAlerts.MINUTES, minutes);
2486 return cr.insert(CONTENT_URI, values);
2487 }
2488
RoboErikc2d53302011-06-03 09:37:58 -07002489 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002490 * Finds the next alarm after (or equal to) the given time and returns
RoboErikc2d53302011-06-03 09:37:58 -07002491 * the time of that alarm or -1 if no such alarm exists. This is a
RoboErik083cd2d2011-06-30 11:53:05 -07002492 * blocking call and should not be done on the UI thread. TODO move to
2493 * provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002494 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002495 * @param cr the ContentResolver
2496 * @param millis the time in UTC milliseconds
2497 * @return the next alarm time greater than or equal to "millis", or -1
RoboErikc2d53302011-06-03 09:37:58 -07002498 * if no such alarm exists.
RoboErik083cd2d2011-06-30 11:53:05 -07002499 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002500 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002501 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002502 public static final long findNextAlarmTime(ContentResolver cr, long millis) {
2503 String selection = ALARM_TIME + ">=" + millis;
2504 // TODO: construct an explicit SQL query so that we can add
2505 // "LIMIT 1" to the end and get just one result.
2506 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002507 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_FINDNEXTALARMTIME,
2508 (new String[] {
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002509 Long.toString(millis)
RoboErik083cd2d2011-06-30 11:53:05 -07002510 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002511 long alarmTime = -1;
2512 try {
2513 if (cursor != null && cursor.moveToFirst()) {
2514 alarmTime = cursor.getLong(0);
2515 }
2516 } finally {
2517 if (cursor != null) {
2518 cursor.close();
2519 }
2520 }
2521 return alarmTime;
2522 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002523
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002524 /**
2525 * Searches the CalendarAlerts table for alarms that should have fired
RoboErik083cd2d2011-06-30 11:53:05 -07002526 * but have not and then reschedules them. This method can be called at
2527 * boot time to restore alarms that may have been lost due to a phone
2528 * reboot. TODO move to provider
Ken Shirriff5b387e12009-10-23 09:50:41 -07002529 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002530 * @param cr the ContentResolver
2531 * @param context the Context
2532 * @param manager the AlarmManager
RoboErik083cd2d2011-06-30 11:53:05 -07002533 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002534 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002535 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002536 public static final void rescheduleMissedAlarms(ContentResolver cr,
2537 Context context, AlarmManager manager) {
2538 // Get all the alerts that have been scheduled but have not fired
2539 // and should have fired by now and are not too old.
2540 long now = System.currentTimeMillis();
Michael Chancdaeafd2009-10-29 00:11:58 -07002541 long ancient = now - DateUtils.DAY_IN_MILLIS;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002542 String[] projection = new String[] {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002543 ALARM_TIME,
2544 };
Michael Chancdaeafd2009-10-29 00:11:58 -07002545
2546 // TODO: construct an explicit SQL query so that we can add
2547 // "GROUPBY" instead of doing a sort and de-dup
RoboErik083cd2d2011-06-30 11:53:05 -07002548 Cursor cursor = cr.query(CalendarAlerts.CONTENT_URI, projection,
2549 WHERE_RESCHEDULE_MISSED_ALARMS, (new String[] {
2550 Long.toString(now), Long.toString(ancient), Long.toString(now)
2551 }), SORT_ORDER_ALARMTIME_ASC);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002552 if (cursor == null) {
2553 return;
2554 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002555
2556 if (DEBUG) {
The Android Open Source Project10592532009-03-18 17:39:46 -07002557 Log.d(TAG, "missed alarms found: " + cursor.getCount());
2558 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002559
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002560 try {
Michael Chancdaeafd2009-10-29 00:11:58 -07002561 long alarmTime = -1;
2562
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002563 while (cursor.moveToNext()) {
Michael Chancdaeafd2009-10-29 00:11:58 -07002564 long newAlarmTime = cursor.getLong(0);
2565 if (alarmTime != newAlarmTime) {
2566 if (DEBUG) {
2567 Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime);
2568 }
2569 scheduleAlarm(context, manager, newAlarmTime);
2570 alarmTime = newAlarmTime;
2571 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002572 }
2573 } finally {
2574 cursor.close();
2575 }
Michael Chancdaeafd2009-10-29 00:11:58 -07002576 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002577
RoboErikc2d53302011-06-03 09:37:58 -07002578 /**
2579 * Schedules an alarm intent with the system AlarmManager that will
RoboErik3771fcb2011-06-16 15:41:31 -07002580 * notify listeners when a reminder should be fired. The provider will
2581 * keep scheduled reminders up to date but apps may use this to
2582 * implement snooze functionality without modifying the reminders table.
2583 * Scheduled alarms will generate an intent using
RoboErik083cd2d2011-06-30 11:53:05 -07002584 * {@link #ACTION_EVENT_REMINDER}. TODO Move to provider
RoboErikc2d53302011-06-03 09:37:58 -07002585 *
2586 * @param context A context for referencing system resources
2587 * @param manager The AlarmManager to use or null
2588 * @param alarmTime The time to fire the intent in UTC millis since
2589 * epoch
RoboErik083cd2d2011-06-30 11:53:05 -07002590 * @hide
RoboErikc2d53302011-06-03 09:37:58 -07002591 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002592 @UnsupportedAppUsage
Michael Chancdaeafd2009-10-29 00:11:58 -07002593 public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) {
2594 if (DEBUG) {
2595 Time time = new Time();
2596 time.set(alarmTime);
2597 String schedTime = time.format(" %a, %b %d, %Y %I:%M%P");
2598 Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime);
2599 }
2600
2601 if (manager == null) {
2602 manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
2603 }
2604
RoboErike00d5892011-06-23 15:16:55 -07002605 Intent intent = new Intent(ACTION_EVENT_REMINDER);
RoboErikbec6c362011-06-14 11:06:01 -07002606 intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime));
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002607 intent.putExtra(ALARM_TIME, alarmTime);
Makoto Onukib63830a2017-02-09 17:06:28 -08002608 intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
Erik42f19572010-03-17 16:17:22 -07002609 PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
Tony Makfaf96ebc2015-07-02 17:05:35 +01002610 manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002611 }
Ken Shirriff5b387e12009-10-23 09:50:41 -07002612
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002613 /**
RoboErik083cd2d2011-06-30 11:53:05 -07002614 * Searches for an entry in the CalendarAlerts table that matches the
2615 * given event id, begin time and alarm time. If one is found then this
2616 * alarm already exists and this method returns true. TODO Move to
2617 * provider
RoboErik58644022011-07-08 13:39:05 -07002618 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002619 * @param cr the ContentResolver
2620 * @param eventId the event id to match
2621 * @param begin the start time of the event in UTC millis
2622 * @param alarmTime the alarm time of the event in UTC millis
RoboErik083cd2d2011-06-30 11:53:05 -07002623 * @return true if there is already an alarm for the given event with
2624 * the same start time and alarm time.
2625 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002626 */
2627 public static final boolean alarmExists(ContentResolver cr, long eventId,
2628 long begin, long alarmTime) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002629 // TODO: construct an explicit SQL query so that we can add
2630 // "LIMIT 1" to the end and get just one result.
Fabrice Di Meglio1dfc8a22010-03-10 17:49:46 -08002631 String[] projection = new String[] { ALARM_TIME };
RoboErik083cd2d2011-06-30 11:53:05 -07002632 Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_ALARM_EXISTS,
2633 (new String[] {
2634 Long.toString(eventId), Long.toString(begin), Long.toString(alarmTime)
2635 }), null);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002636 boolean found = false;
2637 try {
2638 if (cursor != null && cursor.getCount() > 0) {
2639 found = true;
2640 }
2641 } finally {
2642 if (cursor != null) {
2643 cursor.close();
2644 }
2645 }
2646 return found;
2647 }
2648 }
2649
RoboErikf8143c52011-09-28 15:16:00 -07002650 protected interface ColorsColumns extends SyncStateContract.Columns {
2651
2652 /**
2653 * The type of color, which describes how it should be used. Valid types
2654 * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name.
2655 * <P>
2656 * Type: INTEGER (NOT NULL)
2657 * </P>
2658 */
2659 public static final String COLOR_TYPE = "color_type";
2660
2661 /**
2662 * This indicateds a color that can be used for calendars.
2663 */
2664 public static final int TYPE_CALENDAR = 0;
2665 /**
2666 * This indicates a color that can be used for events.
2667 */
2668 public static final int TYPE_EVENT = 1;
2669
2670 /**
RoboErik4172d952011-10-25 13:59:13 -07002671 * The key used to reference this color. This can be any non-empty
RoboErikf8143c52011-09-28 15:16:00 -07002672 * string, but must be unique for a given {@link #ACCOUNT_TYPE} and
RoboErik8a8eebc2011-10-20 16:57:18 -07002673 * {@link #ACCOUNT_NAME}. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002674 * <P>
2675 * Type: TEXT
2676 * </P>
2677 */
RoboErik4172d952011-10-25 13:59:13 -07002678 public static final String COLOR_KEY = "color_index";
RoboErikf8143c52011-09-28 15:16:00 -07002679
2680 /**
RoboErik05b36e52011-10-14 15:31:15 -07002681 * The color as an 8-bit ARGB integer value. Colors should specify alpha
2682 * as fully opaque (eg 0xFF993322) as the alpha may be ignored or
2683 * modified for display. It is reccomended that colors be usable with
2684 * light (near white) text. Apps should not depend on that assumption,
2685 * however. Column name.
RoboErikf8143c52011-09-28 15:16:00 -07002686 * <P>
2687 * Type: INTEGER (NOT NULL)
2688 * </P>
2689 */
RoboErik05b36e52011-10-14 15:31:15 -07002690 public static final String COLOR = "color";
RoboErikf8143c52011-09-28 15:16:00 -07002691
2692 }
2693
2694 /**
2695 * Fields for accessing colors available for a given account. Colors are
RoboErik4172d952011-10-25 13:59:13 -07002696 * referenced by {@link #COLOR_KEY} which must be unique for a given
RoboErik0c559c62011-10-21 11:20:51 -07002697 * account name/type. These values can only be updated by the sync
RoboErik8a8eebc2011-10-20 16:57:18 -07002698 * adapter. Only {@link #COLOR} may be updated after the initial insert. In
2699 * addition, a row can only be deleted once all references to that color
2700 * have been removed from the {@link Calendars} or {@link Events} tables.
RoboErikf8143c52011-09-28 15:16:00 -07002701 */
2702 public static final class Colors implements ColorsColumns {
2703 /**
2704 * @hide
2705 */
2706 public static final String TABLE_NAME = "Colors";
2707 /**
2708 * The Uri for querying color information
2709 */
2710 @SuppressWarnings("hiding")
2711 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors");
2712
2713 /**
2714 * This utility class cannot be instantiated
2715 */
2716 private Colors() {
2717 }
2718 }
2719
RoboErikb2c75602011-06-13 12:53:48 -07002720 protected interface ExtendedPropertiesColumns {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002721 /**
RoboErikc2d53302011-06-03 09:37:58 -07002722 * The event the extended property belongs to. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002723 * <P>Type: INTEGER (foreign key to the Events table)</P>
2724 */
2725 public static final String EVENT_ID = "event_id";
2726
2727 /**
2728 * The name of the extended property. This is a uri of the form
RoboErikc2d53302011-06-03 09:37:58 -07002729 * {scheme}#{local-name} convention. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002730 * <P>Type: TEXT</P>
2731 */
2732 public static final String NAME = "name";
2733
2734 /**
RoboErikc2d53302011-06-03 09:37:58 -07002735 * The value of the extended property. Column name.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002736 * <P>Type: TEXT</P>
2737 */
2738 public static final String VALUE = "value";
2739 }
2740
RoboErikc2d53302011-06-03 09:37:58 -07002741 /**
2742 * Fields for accessing the Extended Properties. This is a generic set of
Michael Chan73bddfc2011-10-19 18:21:49 -07002743 * name/value pairs for use by sync adapters to add extra
RoboErik3771fcb2011-06-16 15:41:31 -07002744 * information to events. There are three writable columns and all three
2745 * must be present when inserting a new value. They are:
2746 * <ul>
2747 * <li>{@link #EVENT_ID}</li>
2748 * <li>{@link #NAME}</li>
2749 * <li>{@link #VALUE}</li>
2750 * </ul>
RoboErikc2d53302011-06-03 09:37:58 -07002751 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002752 public static final class ExtendedProperties implements BaseColumns,
2753 ExtendedPropertiesColumns, EventsColumns {
2754 public static final Uri CONTENT_URI =
Ken Shirriffa69a23b2010-01-21 17:32:39 -08002755 Uri.parse("content://" + AUTHORITY + "/extendedproperties");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002756
RoboErik36726962011-06-14 14:01:15 -07002757 /**
2758 * This utility class cannot be instantiated
2759 */
2760 private ExtendedProperties() {}
2761
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002762 // TODO: fill out this class when we actually start utilizing extendedproperties
2763 // in the calendar application.
2764 }
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002765
2766 /**
2767 * A table provided for sync adapters to use for storing private sync state data.
2768 *
2769 * @see SyncStateContract
2770 */
2771 public static final class SyncState implements SyncStateContract.Columns {
2772 /**
2773 * This utility class cannot be instantiated
2774 */
2775 private SyncState() {}
2776
RoboErikc2d53302011-06-03 09:37:58 -07002777 private static final String CONTENT_DIRECTORY =
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002778 SyncStateContract.Constants.CONTENT_DIRECTORY;
2779
2780 /**
2781 * The content:// style URI for this table
2782 */
2783 public static final Uri CONTENT_URI =
RoboErikbec6c362011-06-14 11:06:01 -07002784 Uri.withAppendedPath(CalendarContract.CONTENT_URI, CONTENT_DIRECTORY);
Ken Shirriffead4f9c2010-01-22 12:26:02 -08002785 }
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002786
2787 /**
2788 * Columns from the EventsRawTimes table
RoboErik3771fcb2011-06-16 15:41:31 -07002789 *
2790 * @hide
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002791 */
RoboErikb2c75602011-06-13 12:53:48 -07002792 protected interface EventsRawTimesColumns {
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002793 /**
RoboErikc2d53302011-06-03 09:37:58 -07002794 * The corresponding event id. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002795 * <P>Type: INTEGER (long)</P>
2796 */
2797 public static final String EVENT_ID = "event_id";
2798
2799 /**
RoboErikc2d53302011-06-03 09:37:58 -07002800 * The RFC2445 compliant time the event starts. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002801 * <P>Type: TEXT</P>
2802 */
2803 public static final String DTSTART_2445 = "dtstart2445";
2804
2805 /**
RoboErikc2d53302011-06-03 09:37:58 -07002806 * The RFC2445 compliant time the event ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002807 * <P>Type: TEXT</P>
2808 */
2809 public static final String DTEND_2445 = "dtend2445";
2810
2811 /**
RoboErikc2d53302011-06-03 09:37:58 -07002812 * The RFC2445 compliant original instance time of the recurring event
2813 * for which this event is an exception. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002814 * <P>Type: TEXT</P>
2815 */
2816 public static final String ORIGINAL_INSTANCE_TIME_2445 = "originalInstanceTime2445";
2817
2818 /**
RoboErikc2d53302011-06-03 09:37:58 -07002819 * The RFC2445 compliant last date this event repeats on, or NULL if it
2820 * never ends. Column name.
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002821 * <P>Type: TEXT</P>
2822 */
2823 public static final String LAST_DATE_2445 = "lastDate2445";
2824 }
2825
RoboErikc2d53302011-06-03 09:37:58 -07002826 /**
2827 * @hide
2828 */
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002829 public static final class EventsRawTimes implements BaseColumns, EventsRawTimesColumns {
RoboErik36726962011-06-14 14:01:15 -07002830
2831 /**
2832 * This utility class cannot be instantiated
2833 */
2834 private EventsRawTimes() {}
Fabrice Di Meglio50563552010-06-15 16:35:20 -07002835 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002836}