The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.provider; |
| 18 | |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 19 | import android.annotation.NonNull; |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 20 | import android.annotation.SdkConstant; |
| 21 | import android.annotation.SdkConstant.SdkConstantType; |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 22 | import android.annotation.UnsupportedAppUsage; |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 23 | import android.app.Activity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.app.AlarmManager; |
| 25 | import android.app.PendingIntent; |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 26 | import android.app.admin.DevicePolicyManager; |
| 27 | import android.content.ComponentName; |
Marc Blank | 64a556d | 2010-02-25 12:53:16 -0800 | [diff] [blame] | 28 | import android.content.ContentProviderClient; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.content.ContentResolver; |
| 30 | import android.content.ContentUris; |
| 31 | import android.content.ContentValues; |
| 32 | import android.content.Context; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 33 | import android.content.CursorEntityIterator; |
| 34 | import android.content.Entity; |
Marc Blank | 64a556d | 2010-02-25 12:53:16 -0800 | [diff] [blame] | 35 | import android.content.EntityIterator; |
| 36 | import android.content.Intent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | import android.database.Cursor; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 38 | import android.database.DatabaseUtils; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.net.Uri; |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 40 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import android.text.format.DateUtils; |
| 42 | import android.text.format.Time; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.util.Log; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 45 | import com.android.internal.util.Preconditions; |
| 46 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | /** |
RoboErik | 260598d | 2011-06-13 17:12:12 -0700 | [diff] [blame] | 48 | * <p> |
| 49 | * The contract between the calendar provider and applications. Contains |
| 50 | * definitions for the supported URIs and data columns. |
| 51 | * </p> |
| 52 | * <h3>Overview</h3> |
| 53 | * <p> |
| 54 | * CalendarContract defines the data model of calendar and event related |
| 55 | * information. This data is stored in a number of tables: |
| 56 | * </p> |
| 57 | * <ul> |
| 58 | * <li>The {@link Calendars} table holds the calendar specific information. Each |
| 59 | * row in this table contains the details for a single calendar, such as the |
| 60 | * name, color, sync info, etc.</li> |
| 61 | * <li>The {@link Events} table holds the event specific information. Each row |
| 62 | * in this table has the info for a single event. It contains information such |
| 63 | * as event title, location, start time, end time, etc. The event can occur |
| 64 | * one-time or can recur multiple times. Attendees, reminders, and extended |
| 65 | * properties are stored on separate tables and reference the {@link Events#_ID} |
| 66 | * to link them with the event.</li> |
| 67 | * <li>The {@link Instances} table holds the start and end time for occurrences |
| 68 | * of an event. Each row in this table represents a single occurrence. For |
| 69 | * one-time events there will be a 1:1 mapping of instances to events. For |
| 70 | * recurring events, multiple rows will automatically be generated which |
| 71 | * correspond to multiple occurrences of that event.</li> |
| 72 | * <li>The {@link Attendees} table holds the event attendee or guest |
| 73 | * information. Each row represents a single guest of an event. It specifies the |
| 74 | * type of guest they are and their attendance response for the event.</li> |
| 75 | * <li>The {@link Reminders} table holds the alert/notification data. Each row |
| 76 | * represents a single alert for an event. An event can have multiple reminders. |
| 77 | * The number of reminders per event is specified in |
| 78 | * {@link Calendars#MAX_REMINDERS} which is set by the Sync Adapter that owns |
| 79 | * the given calendar. Reminders are specified in minutes before the event and |
| 80 | * have a type.</li> |
Michael Chan | 73bddfc | 2011-10-19 18:21:49 -0700 | [diff] [blame] | 81 | * <li>The {@link ExtendedProperties} table holds opaque data fields used by the |
RoboErik | 260598d | 2011-06-13 17:12:12 -0700 | [diff] [blame] | 82 | * sync adapter. The provider takes no action with items in this table except to |
| 83 | * delete them when their related events are deleted.</li> |
| 84 | * </ul> |
| 85 | * <p> |
| 86 | * Other tables include: |
| 87 | * </p> |
| 88 | * <ul> |
| 89 | * <li> |
| 90 | * {@link SyncState}, which contains free-form data maintained by the sync |
| 91 | * adapters</li> |
| 92 | * </ul> |
RoboErik | bec6c36 | 2011-06-14 11:06:01 -0700 | [diff] [blame] | 93 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | */ |
RoboErik | bec6c36 | 2011-06-14 11:06:01 -0700 | [diff] [blame] | 95 | public final class CalendarContract { |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 96 | private static final String TAG = "Calendar"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | |
| 98 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 99 | * Broadcast Action: This is the intent that gets fired when an alarm |
| 100 | * notification needs to be posted for a reminder. |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 101 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | */ |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 103 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 104 | public static final String ACTION_EVENT_REMINDER = "android.intent.action.EVENT_REMINDER"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 107 | * Activity Action: Display the event to the user in the custom app as |
| 108 | * specified in {@link EventsColumns#CUSTOM_APP_PACKAGE}. The custom app |
| 109 | * will be started via {@link Activity#startActivityForResult(Intent, int)} |
| 110 | * and it should call {@link Activity#setResult(int)} with |
| 111 | * {@link Activity#RESULT_OK} or {@link Activity#RESULT_CANCELED} to |
| 112 | * acknowledge whether the action was handled or not. |
Michael Chan | 9a9001f | 2012-05-14 18:27:27 -0700 | [diff] [blame] | 113 | * |
kmccormick | e4ce502 | 2013-04-03 14:00:19 -0700 | [diff] [blame] | 114 | * The custom app should have an intent filter like the following: |
Michael Chan | 9a9001f | 2012-05-14 18:27:27 -0700 | [diff] [blame] | 115 | * <pre> |
kmccormick | e4ce502 | 2013-04-03 14:00:19 -0700 | [diff] [blame] | 116 | * <intent-filter> |
| 117 | * <action android:name="android.provider.calendar.action.HANDLE_CUSTOM_EVENT" /> |
| 118 | * <category android:name="android.intent.category.DEFAULT" /> |
| 119 | * <data android:mimeType="vnd.android.cursor.item/event" /> |
| 120 | * </intent-filter></pre> |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 121 | * <p> |
| 122 | * Input: {@link Intent#getData} has the event URI. The extra |
| 123 | * {@link #EXTRA_EVENT_BEGIN_TIME} has the start time of the instance. The |
| 124 | * extra {@link #EXTRA_CUSTOM_APP_URI} will have the |
| 125 | * {@link EventsColumns#CUSTOM_APP_URI}. |
| 126 | * <p> |
| 127 | * Output: {@link Activity#RESULT_OK} if this was handled; otherwise |
kmccormick | e4ce502 | 2013-04-03 14:00:19 -0700 | [diff] [blame] | 128 | * {@link Activity#RESULT_CANCELED}. |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 129 | */ |
| 130 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 131 | public static final String ACTION_HANDLE_CUSTOM_EVENT = |
| 132 | "android.provider.calendar.action.HANDLE_CUSTOM_EVENT"; |
| 133 | |
| 134 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 135 | * Action used to help apps show calendar events in the managed profile. |
| 136 | */ |
| 137 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 138 | public static final String ACTION_VIEW_WORK_CALENDAR_EVENT = |
| 139 | "android.provider.calendar.action.VIEW_WORK_CALENDAR_EVENT"; |
| 140 | |
| 141 | /** |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 142 | * Intent Extras key: {@link EventsColumns#CUSTOM_APP_URI} for the event in |
| 143 | * the {@link #ACTION_HANDLE_CUSTOM_EVENT} intent |
| 144 | */ |
Michael Chan | f0c4c65 | 2012-04-19 16:27:46 -0700 | [diff] [blame] | 145 | public static final String EXTRA_CUSTOM_APP_URI = "customAppUri"; |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 148 | * Intent Extras key: The start time of an event or an instance of a |
| 149 | * recurring event. (milliseconds since epoch) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | */ |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 151 | public static final String EXTRA_EVENT_BEGIN_TIME = "beginTime"; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Intent Extras key: The end time of an event or an instance of a recurring |
| 155 | * event. (milliseconds since epoch) |
| 156 | */ |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 157 | public static final String EXTRA_EVENT_END_TIME = "endTime"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | |
Erik | e9b734d | 2011-02-14 13:32:19 -0800 | [diff] [blame] | 159 | /** |
Michael Chan | 7420f13 | 2011-08-25 00:54:25 -0700 | [diff] [blame] | 160 | * Intent Extras key: When creating an event, set this to true to create an |
| 161 | * all-day event by default |
| 162 | */ |
| 163 | public static final String EXTRA_EVENT_ALL_DAY = "allDay"; |
| 164 | |
| 165 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 166 | * Intent Extras key: The id of an event. |
| 167 | */ |
| 168 | public static final String EXTRA_EVENT_ID = "id"; |
| 169 | |
| 170 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 171 | * This authority is used for writing to or querying from the calendar |
| 172 | * provider. Note: This is set at first run and cannot be changed without |
| 173 | * breaking apps that access the provider. |
Erik | e9b734d | 2011-02-14 13:32:19 -0800 | [diff] [blame] | 174 | */ |
Ken Shirriff | 1790c13 | 2010-01-22 13:45:31 -0800 | [diff] [blame] | 175 | public static final String AUTHORITY = "com.android.calendar"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * The content:// style URL for the top-level calendar authority |
| 179 | */ |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 180 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | |
| 182 | /** |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 183 | * An optional insert, update or delete URI parameter that allows the caller |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 184 | * to specify that it is a sync adapter. The default value is false. If set |
| 185 | * to true, the modified row is not marked as "dirty" (needs to be synced) |
| 186 | * and when the provider calls |
| 187 | * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)} |
| 188 | * , the third parameter "syncToNetwork" is set to false. Furthermore, if |
| 189 | * set to true, the caller must also include |
Andy McFadden | 6f5b455 | 2011-06-09 15:43:59 -0700 | [diff] [blame] | 190 | * {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 191 | * query parameters. |
| 192 | * |
Andy McFadden | 6f5b455 | 2011-06-09 15:43:59 -0700 | [diff] [blame] | 193 | * @see Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String) |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 194 | */ |
| 195 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 196 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 197 | /** |
| 198 | * A special account type for calendars not associated with any account. |
| 199 | * Normally calendars that do not match an account on the device will be |
| 200 | * removed. Setting the account_type on a calendar to this will prevent it |
| 201 | * from being wiped if it does not match an existing account. |
| 202 | * |
| 203 | * @see SyncColumns#ACCOUNT_TYPE |
| 204 | */ |
| 205 | public static final String ACCOUNT_TYPE_LOCAL = "LOCAL"; |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 206 | |
| 207 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 208 | * This utility class cannot be instantiated |
| 209 | */ |
| 210 | private CalendarContract() {} |
| 211 | |
| 212 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 213 | * Starts an activity to view calendar events in the managed profile. |
| 214 | * |
| 215 | * When this API is called, the system will attempt to start an activity |
| 216 | * in the managed profile with an intent targeting the same caller package. |
| 217 | * The intent will have its action set to |
| 218 | * {@link CalendarContract#ACTION_VIEW_WORK_CALENDAR_EVENT} and contain extras |
| 219 | * corresponding to the API's arguments. A calendar app intending to support |
| 220 | * cross profile events viewing should handle this intent, parse the arguments |
| 221 | * and show the appropriate UI. |
| 222 | * |
| 223 | * @param context the context. |
| 224 | * @param eventId the id of the event to be viewed. Will be put into {@link #EXTRA_EVENT_ID} |
| 225 | * field of the intent. |
| 226 | * @param start the start time of the event. Will be put into {@link #EXTRA_EVENT_BEGIN_TIME} |
| 227 | * field of the intent. |
| 228 | * @param end the end time of the event. Will be put into {@link #EXTRA_EVENT_END_TIME} field |
| 229 | * of the intent. |
| 230 | * @param allDay if the event is an all-day event. Will be put into |
| 231 | * {@link #EXTRA_EVENT_ALL_DAY} field of the intent. |
| 232 | * @param flags flags to be set on the intent via {@link Intent#setFlags} |
| 233 | * @return {@code true} if the activity is started successfully. {@code false} otherwise. |
| 234 | * |
| 235 | * @see #EXTRA_EVENT_ID |
| 236 | * @see #EXTRA_EVENT_BEGIN_TIME |
| 237 | * @see #EXTRA_EVENT_END_TIME |
| 238 | * @see #EXTRA_EVENT_ALL_DAY |
| 239 | */ |
| 240 | public static boolean startViewCalendarEventInManagedProfile(@NonNull Context context, |
| 241 | long eventId, long start, long end, boolean allDay, int flags) { |
| 242 | Preconditions.checkNotNull(context, "Context is null"); |
| 243 | final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService( |
| 244 | Context.DEVICE_POLICY_SERVICE); |
| 245 | return dpm.startViewCalendarEventInManagedProfile(eventId, start, |
| 246 | end, allDay, flags); |
| 247 | } |
| 248 | |
| 249 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 250 | * Generic columns for use by sync adapters. The specific functions of these |
| 251 | * columns are private to the sync adapter. Other clients of the API should |
| 252 | * not attempt to either read or write this column. These columns are |
| 253 | * editable as part of the Calendars Uri, but can only be read if accessed |
| 254 | * through any other Uri. |
Fabrice Di Meglio | 36f7784 | 2010-06-29 19:33:45 -0700 | [diff] [blame] | 255 | */ |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 256 | protected interface CalendarSyncColumns { |
Fabrice Di Meglio | 36f7784 | 2010-06-29 19:33:45 -0700 | [diff] [blame] | 257 | |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * Generic column for use by sync adapters. Column name. |
| 261 | * <P>Type: TEXT</P> |
| 262 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 263 | public static final String CAL_SYNC1 = "cal_sync1"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 264 | |
| 265 | /** |
| 266 | * Generic column for use by sync adapters. Column name. |
| 267 | * <P>Type: TEXT</P> |
| 268 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 269 | public static final String CAL_SYNC2 = "cal_sync2"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 270 | |
| 271 | /** |
| 272 | * Generic column for use by sync adapters. Column name. |
| 273 | * <P>Type: TEXT</P> |
| 274 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 275 | public static final String CAL_SYNC3 = "cal_sync3"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 276 | |
| 277 | /** |
| 278 | * Generic column for use by sync adapters. Column name. |
| 279 | * <P>Type: TEXT</P> |
| 280 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 281 | public static final String CAL_SYNC4 = "cal_sync4"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 282 | |
| 283 | /** |
| 284 | * Generic column for use by sync adapters. Column name. |
| 285 | * <P>Type: TEXT</P> |
| 286 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 287 | public static final String CAL_SYNC5 = "cal_sync5"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 288 | |
| 289 | /** |
| 290 | * Generic column for use by sync adapters. Column name. |
| 291 | * <P>Type: TEXT</P> |
| 292 | */ |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 293 | public static final String CAL_SYNC6 = "cal_sync6"; |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | * Generic column for use by sync adapters. Column name. |
| 297 | * <P>Type: TEXT</P> |
| 298 | */ |
| 299 | public static final String CAL_SYNC7 = "cal_sync7"; |
| 300 | |
| 301 | /** |
| 302 | * Generic column for use by sync adapters. Column name. |
| 303 | * <P>Type: TEXT</P> |
| 304 | */ |
| 305 | public static final String CAL_SYNC8 = "cal_sync8"; |
| 306 | |
| 307 | /** |
| 308 | * Generic column for use by sync adapters. Column name. |
| 309 | * <P>Type: TEXT</P> |
| 310 | */ |
| 311 | public static final String CAL_SYNC9 = "cal_sync9"; |
| 312 | |
| 313 | /** |
| 314 | * Generic column for use by sync adapters. Column name. |
| 315 | * <P>Type: TEXT</P> |
| 316 | */ |
| 317 | public static final String CAL_SYNC10 = "cal_sync10"; |
Fabrice Di Meglio | 36f7784 | 2010-06-29 19:33:45 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 321 | * Columns for Sync information used by Calendars and Events tables. These |
| 322 | * have specific uses which are expected to be consistent by the app and |
| 323 | * sync adapter. |
| 324 | * |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 325 | */ |
RoboErik | 0025860 | 2011-06-13 13:47:59 -0700 | [diff] [blame] | 326 | protected interface SyncColumns extends CalendarSyncColumns { |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 327 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 328 | * The account that was used to sync the entry to the device. If the |
| 329 | * account_type is not {@link #ACCOUNT_TYPE_LOCAL} then the name and |
| 330 | * type must match an account on the device or the calendar will be |
| 331 | * deleted. |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 332 | * <P>Type: TEXT</P> |
| 333 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 334 | public static final String ACCOUNT_NAME = "account_name"; |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 335 | |
| 336 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 337 | * The type of the account that was used to sync the entry to the |
| 338 | * device. A type of {@link #ACCOUNT_TYPE_LOCAL} will keep this event |
| 339 | * form being deleted if there are no matching accounts on the device. |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 340 | * <P>Type: TEXT</P> |
| 341 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 342 | public static final String ACCOUNT_TYPE = "account_type"; |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 343 | |
| 344 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 345 | * The unique ID for a row assigned by the sync source. NULL if the row |
| 346 | * has never been synced. This is used as a reference id for exceptions |
| 347 | * along with {@link BaseColumns#_ID}. |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 348 | * <P>Type: TEXT</P> |
| 349 | */ |
| 350 | public static final String _SYNC_ID = "_sync_id"; |
| 351 | |
| 352 | /** |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 353 | * Used to indicate that local, unsynced, changes are present. |
| 354 | * <P>Type: INTEGER (long)</P> |
| 355 | */ |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 356 | |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 357 | public static final String DIRTY = "dirty"; |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 358 | |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 359 | /** |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 360 | * Used in conjunction with {@link #DIRTY} to indicate what packages wrote local changes. |
| 361 | * <P>Type: TEXT</P> |
| 362 | */ |
| 363 | public static final String MUTATORS = "mutators"; |
| 364 | |
| 365 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 366 | * Whether the row has been deleted but not synced to the server. A |
| 367 | * deleted row should be ignored. |
| 368 | * <P> |
| 369 | * Type: INTEGER (boolean) |
| 370 | * </P> |
| 371 | */ |
| 372 | public static final String DELETED = "deleted"; |
| 373 | |
| 374 | /** |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 375 | * If set to 1 this causes events on this calendar to be duplicated with |
RoboErik | 0025860 | 2011-06-13 13:47:59 -0700 | [diff] [blame] | 376 | * {@link Events#LAST_SYNCED} set to 1 whenever the event |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 377 | * transitions from non-dirty to dirty. The duplicated event will not be |
| 378 | * expanded in the instances table and will only show up in sync adapter |
| 379 | * queries of the events table. It will also be deleted when the |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 380 | * originating event has its dirty flag cleared by the sync adapter. |
| 381 | * <P>Type: INTEGER (boolean)</P> |
| 382 | */ |
| 383 | public static final String CAN_PARTIALLY_UPDATE = "canPartiallyUpdate"; |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 387 | * Columns specific to the Calendars Uri that other Uris can query. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 388 | */ |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 389 | protected interface CalendarColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | /** |
RoboErik | 4f52061 | 2011-09-19 17:47:53 -0700 | [diff] [blame] | 391 | * The color of the calendar. This should only be updated by the sync |
| 392 | * adapter, not other apps, as changing a calendar's color can adversely |
| 393 | * affect its display. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | * <P>Type: INTEGER (color value)</P> |
| 395 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 396 | public static final String CALENDAR_COLOR = "calendar_color"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | |
| 398 | /** |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 399 | * A key for looking up a color from the {@link Colors} table. NULL or |
| 400 | * an empty string are reserved for indicating that the calendar does |
| 401 | * not use a key for looking up the color. The provider will update |
| 402 | * {@link #CALENDAR_COLOR} automatically when a valid key is written to |
| 403 | * this column. The key must reference an existing row of the |
RoboErik | 8a8eebc | 2011-10-20 16:57:18 -0700 | [diff] [blame] | 404 | * {@link Colors} table. @see Colors |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 405 | * <P> |
| 406 | * Type: TEXT |
| 407 | * </P> |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 408 | */ |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 409 | public static final String CALENDAR_COLOR_KEY = "calendar_color_index"; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 410 | |
| 411 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 412 | * The display name of the calendar. Column name. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 413 | * <P> |
| 414 | * Type: TEXT |
| 415 | * </P> |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 416 | */ |
| 417 | public static final String CALENDAR_DISPLAY_NAME = "calendar_displayName"; |
| 418 | |
| 419 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | * The level of access that the user has for the calendar |
| 421 | * <P>Type: INTEGER (one of the values below)</P> |
| 422 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 423 | public static final String CALENDAR_ACCESS_LEVEL = "calendar_access_level"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 424 | |
| 425 | /** Cannot access the calendar */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 426 | public static final int CAL_ACCESS_NONE = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 427 | /** Can only see free/busy information about the calendar */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 428 | public static final int CAL_ACCESS_FREEBUSY = 100; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | /** Can read all event details */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 430 | public static final int CAL_ACCESS_READ = 200; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 431 | /** Can reply yes/no/maybe to an event */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 432 | public static final int CAL_ACCESS_RESPOND = 300; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 433 | /** not used */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 434 | public static final int CAL_ACCESS_OVERRIDE = 400; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 435 | /** Full access to modify the calendar, but not the access control |
| 436 | * settings |
| 437 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 438 | public static final int CAL_ACCESS_CONTRIBUTOR = 500; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 439 | /** Full access to modify the calendar, but not the access control |
| 440 | * settings |
| 441 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 442 | public static final int CAL_ACCESS_EDITOR = 600; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | /** Full access to the calendar */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 444 | public static final int CAL_ACCESS_OWNER = 700; |
Debajit Ghosh | 2dcaafd | 2009-09-18 18:29:37 -0700 | [diff] [blame] | 445 | /** Domain admin */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 446 | public static final int CAL_ACCESS_ROOT = 800; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | |
| 448 | /** |
| 449 | * Is the calendar selected to be displayed? |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 450 | * 0 - do not show events associated with this calendar. |
| 451 | * 1 - show events associated with this calendar |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | * <P>Type: INTEGER (boolean)</P> |
| 453 | */ |
Andy McFadden | df2e2c8 | 2011-04-19 15:08:37 -0700 | [diff] [blame] | 454 | public static final String VISIBLE = "visible"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | |
| 456 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 457 | * The time zone the calendar is associated with. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | * <P>Type: TEXT</P> |
| 459 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 460 | public static final String CALENDAR_TIME_ZONE = "calendar_timezone"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 461 | |
| 462 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 463 | * Is this calendar synced and are its events stored on the device? |
| 464 | * 0 - Do not sync this calendar or store events for this calendar. |
| 465 | * 1 - Sync down events for this calendar. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | * <p>Type: INTEGER (boolean)</p> |
| 467 | */ |
| 468 | public static final String SYNC_EVENTS = "sync_events"; |
Ken Shirriff | 1d6442f | 2009-07-09 13:50:17 -0700 | [diff] [blame] | 469 | |
| 470 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 471 | * The owner account for this calendar, based on the calendar feed. |
| 472 | * This will be different from the _SYNC_ACCOUNT for delegated calendars. |
| 473 | * Column name. |
| 474 | * <P>Type: String</P> |
Ken Shirriff | 1d6442f | 2009-07-09 13:50:17 -0700 | [diff] [blame] | 475 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 476 | public static final String OWNER_ACCOUNT = "ownerAccount"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 477 | |
| 478 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 479 | * Can the organizer respond to the event? If no, the status of the |
| 480 | * organizer should not be shown by the UI. Defaults to 1. Column name. |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 481 | * <P>Type: INTEGER (boolean)</P> |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 482 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 483 | public static final String CAN_ORGANIZER_RESPOND = "canOrganizerRespond"; |
| 484 | |
| 485 | /** |
| 486 | * Can the organizer modify the time zone of the event? Column name. |
| 487 | * <P>Type: INTEGER (boolean)</P> |
| 488 | */ |
| 489 | public static final String CAN_MODIFY_TIME_ZONE = "canModifyTimeZone"; |
| 490 | |
| 491 | /** |
| 492 | * The maximum number of reminders allowed for an event. Column name. |
| 493 | * <P>Type: INTEGER</P> |
| 494 | */ |
| 495 | public static final String MAX_REMINDERS = "maxReminders"; |
| 496 | |
| 497 | /** |
| 498 | * A comma separated list of reminder methods supported for this |
| 499 | * calendar in the format "#,#,#". Valid types are |
| 500 | * {@link Reminders#METHOD_DEFAULT}, {@link Reminders#METHOD_ALERT}, |
Alon Albert | bd25161 | 2012-02-23 10:30:51 -0800 | [diff] [blame] | 501 | * {@link Reminders#METHOD_EMAIL}, {@link Reminders#METHOD_SMS}, |
| 502 | * {@link Reminders#METHOD_ALARM}. Column name. |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 503 | * <P>Type: TEXT</P> |
| 504 | */ |
| 505 | public static final String ALLOWED_REMINDERS = "allowedReminders"; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 506 | |
| 507 | /** |
| 508 | * A comma separated list of availability types supported for this |
| 509 | * calendar in the format "#,#,#". Valid types are |
| 510 | * {@link Events#AVAILABILITY_BUSY}, {@link Events#AVAILABILITY_FREE}, |
| 511 | * {@link Events#AVAILABILITY_TENTATIVE}. Setting this field to only |
| 512 | * {@link Events#AVAILABILITY_BUSY} should be used to indicate that |
| 513 | * changing the availability is not supported. |
| 514 | * |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 515 | */ |
| 516 | public static final String ALLOWED_AVAILABILITY = "allowedAvailability"; |
| 517 | |
| 518 | /** |
| 519 | * A comma separated list of attendee types supported for this calendar |
| 520 | * in the format "#,#,#". Valid types are {@link Attendees#TYPE_NONE}, |
| 521 | * {@link Attendees#TYPE_OPTIONAL}, {@link Attendees#TYPE_REQUIRED}, |
| 522 | * {@link Attendees#TYPE_RESOURCE}. Setting this field to only |
| 523 | * {@link Attendees#TYPE_NONE} should be used to indicate that changing |
| 524 | * the attendee type is not supported. |
| 525 | * |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 526 | */ |
| 527 | public static final String ALLOWED_ATTENDEE_TYPES = "allowedAttendeeTypes"; |
Alon Albert | 0a9a219 | 2012-09-18 11:10:49 -0700 | [diff] [blame] | 528 | |
| 529 | /** |
| 530 | * Is this the primary calendar for this account. If this column is not explicitly set, the |
| 531 | * provider will return 1 if {@link Calendars#ACCOUNT_NAME} is equal to |
| 532 | * {@link Calendars#OWNER_ACCOUNT}. |
| 533 | */ |
| 534 | public static final String IS_PRIMARY = "isPrimary"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /** |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 538 | * Class that represents a Calendar Entity. There is one entry per calendar. |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 539 | * This is a helper class to make batch operations easier. |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 540 | */ |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 541 | public static final class CalendarEntity implements BaseColumns, SyncColumns, CalendarColumns { |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 542 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 543 | /** |
| 544 | * The default Uri used when creating a new calendar EntityIterator. |
| 545 | */ |
| 546 | @SuppressWarnings("hiding") |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 547 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + |
| 548 | "/calendar_entities"); |
| 549 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 550 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 551 | * This utility class cannot be instantiated |
| 552 | */ |
| 553 | private CalendarEntity() {} |
| 554 | |
| 555 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 556 | * Creates an entity iterator for the given cursor. It assumes the |
| 557 | * cursor contains a calendars query. |
| 558 | * |
| 559 | * @param cursor query on {@link #CONTENT_URI} |
| 560 | * @return an EntityIterator of calendars |
| 561 | */ |
| 562 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 563 | return new EntityIteratorImpl(cursor); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | private static class EntityIteratorImpl extends CursorEntityIterator { |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 567 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 568 | public EntityIteratorImpl(Cursor cursor) { |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 569 | super(cursor); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | @Override |
| 573 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 574 | // we expect the cursor is already at the row we need to read from |
| 575 | final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID)); |
| 576 | |
| 577 | // Create the content value |
| 578 | ContentValues cv = new ContentValues(); |
| 579 | cv.put(_ID, calendarId); |
| 580 | |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 581 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 582 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 583 | |
| 584 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID); |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 585 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 586 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 587 | |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 588 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1); |
| 589 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2); |
| 590 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3); |
| 591 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4); |
| 592 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5); |
| 593 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6); |
| 594 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7); |
| 595 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8); |
| 596 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9); |
| 597 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 598 | |
| 599 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME); |
| 600 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 601 | Calendars.CALENDAR_DISPLAY_NAME); |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 602 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
| 603 | Calendars.CALENDAR_COLOR); |
Alon Albert | 0114112 | 2013-02-07 11:50:27 -0800 | [diff] [blame] | 604 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 605 | Calendars.CALENDAR_COLOR_KEY); |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 606 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL); |
Andy McFadden | df2e2c8 | 2011-04-19 15:08:37 -0700 | [diff] [blame] | 607 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 608 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS); |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 609 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 610 | Calendars.CALENDAR_LOCATION); |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 611 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 612 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 613 | Calendars.OWNER_ACCOUNT); |
| 614 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
Andy McFadden | df2e2c8 | 2011-04-19 15:08:37 -0700 | [diff] [blame] | 615 | Calendars.CAN_ORGANIZER_RESPOND); |
| 616 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
| 617 | Calendars.CAN_MODIFY_TIME_ZONE); |
| 618 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
| 619 | Calendars.MAX_REMINDERS); |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 620 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
| 621 | Calendars.CAN_PARTIALLY_UPDATE); |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 622 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 623 | Calendars.ALLOWED_REMINDERS); |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 624 | |
| 625 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); |
| 626 | |
| 627 | // Create the Entity from the ContentValue |
| 628 | Entity entity = new Entity(cv); |
| 629 | |
| 630 | // Set cursor to next row |
| 631 | cursor.moveToNext(); |
| 632 | |
| 633 | // Return the created Entity |
| 634 | return entity; |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | /** |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 640 | * Constants and helpers for the Calendars table, which contains details for |
| 641 | * individual calendars. <h3>Operations</h3> All operations can be done |
| 642 | * either as an app or as a sync adapter. To perform an operation as a sync |
| 643 | * adapter {@link #CALLER_IS_SYNCADAPTER} should be set to true and |
| 644 | * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri |
| 645 | * parameters. See |
| 646 | * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)} |
| 647 | * for details on adding parameters. Sync adapters have write access to more |
| 648 | * columns but are restricted to a single account at a time. Calendars are |
| 649 | * designed to be primarily managed by a sync adapter and inserting new |
| 650 | * calendars should be done as a sync adapter. For the most part, apps |
| 651 | * should only update calendars (such as changing the color or display |
| 652 | * name). If a local calendar is required an app can do so by inserting as a |
| 653 | * sync adapter and using an {@link #ACCOUNT_TYPE} of |
| 654 | * {@link #ACCOUNT_TYPE_LOCAL} . |
| 655 | * <dl> |
| 656 | * <dt><b>Insert</b></dt> |
| 657 | * <dd>When inserting a new calendar the following fields must be included: |
| 658 | * <ul> |
| 659 | * <li>{@link #ACCOUNT_NAME}</li> |
| 660 | * <li>{@link #ACCOUNT_TYPE}</li> |
| 661 | * <li>{@link #NAME}</li> |
| 662 | * <li>{@link #CALENDAR_DISPLAY_NAME}</li> |
| 663 | * <li>{@link #CALENDAR_COLOR}</li> |
| 664 | * <li>{@link #CALENDAR_ACCESS_LEVEL}</li> |
| 665 | * <li>{@link #OWNER_ACCOUNT}</li> |
| 666 | * </ul> |
| 667 | * The following fields are not required when inserting a Calendar but are |
| 668 | * generally a good idea to include: |
| 669 | * <ul> |
| 670 | * <li>{@link #SYNC_EVENTS} set to 1</li> |
RoboErik | f92ccfb | 2011-06-17 15:24:02 -0700 | [diff] [blame] | 671 | * <li>{@link #CALENDAR_TIME_ZONE}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 672 | * <li>{@link #ALLOWED_REMINDERS}</li> |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 673 | * <li>{@link #ALLOWED_AVAILABILITY}</li> |
| 674 | * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 675 | * </ul> |
| 676 | * <dt><b>Update</b></dt> |
| 677 | * <dd>To perform an update on a calendar the {@link #_ID} of the calendar |
| 678 | * should be provided either as an appended id to the Uri ( |
| 679 | * {@link ContentUris#withAppendedId}) or as the first selection item--the |
| 680 | * selection should start with "_id=?" and the first selectionArg should be |
| 681 | * the _id of the calendar. Calendars may also be updated using a selection |
| 682 | * without the id. In general, the {@link #ACCOUNT_NAME} and |
| 683 | * {@link #ACCOUNT_TYPE} should not be changed after a calendar is created |
| 684 | * as this can cause issues for sync adapters. |
| 685 | * <dt><b>Delete</b></dt> |
| 686 | * <dd>Calendars can be deleted either by the {@link #_ID} as an appended id |
| 687 | * on the Uri or using any standard selection. Deleting a calendar should |
| 688 | * generally be handled by a sync adapter as it will remove the calendar |
| 689 | * from the database and all associated data (aka events).</dd> |
| 690 | * <dt><b>Query</b></dt> |
| 691 | * <dd>Querying the Calendars table will get you all information about a set |
| 692 | * of calendars. There will be one row returned for each calendar that |
| 693 | * matches the query selection, or at most a single row if the {@link #_ID} |
| 694 | * is appended to the Uri.</dd> |
| 695 | * </dl> |
| 696 | * <h3>Calendar Columns</h3> The following Calendar columns are writable by |
| 697 | * both an app and a sync adapter. |
| 698 | * <ul> |
| 699 | * <li>{@link #NAME}</li> |
| 700 | * <li>{@link #CALENDAR_DISPLAY_NAME}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 701 | * <li>{@link #VISIBLE}</li> |
| 702 | * <li>{@link #SYNC_EVENTS}</li> |
| 703 | * </ul> |
| 704 | * The following Calendars columns are writable only by a sync adapter |
| 705 | * <ul> |
| 706 | * <li>{@link #ACCOUNT_NAME}</li> |
| 707 | * <li>{@link #ACCOUNT_TYPE}</li> |
RoboErik | 4f52061 | 2011-09-19 17:47:53 -0700 | [diff] [blame] | 708 | * <li>{@link #CALENDAR_COLOR}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 709 | * <li>{@link #_SYNC_ID}</li> |
| 710 | * <li>{@link #DIRTY}</li> |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 711 | * <li>{@link #MUTATORS}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 712 | * <li>{@link #OWNER_ACCOUNT}</li> |
| 713 | * <li>{@link #MAX_REMINDERS}</li> |
| 714 | * <li>{@link #ALLOWED_REMINDERS}</li> |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 715 | * <li>{@link #ALLOWED_AVAILABILITY}</li> |
| 716 | * <li>{@link #ALLOWED_ATTENDEE_TYPES}</li> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 717 | * <li>{@link #CAN_MODIFY_TIME_ZONE}</li> |
| 718 | * <li>{@link #CAN_ORGANIZER_RESPOND}</li> |
| 719 | * <li>{@link #CAN_PARTIALLY_UPDATE}</li> |
| 720 | * <li>{@link #CALENDAR_LOCATION}</li> |
| 721 | * <li>{@link #CALENDAR_TIME_ZONE}</li> |
| 722 | * <li>{@link #CALENDAR_ACCESS_LEVEL}</li> |
| 723 | * <li>{@link #DELETED}</li> |
| 724 | * <li>{@link #CAL_SYNC1}</li> |
| 725 | * <li>{@link #CAL_SYNC2}</li> |
| 726 | * <li>{@link #CAL_SYNC3}</li> |
| 727 | * <li>{@link #CAL_SYNC4}</li> |
| 728 | * <li>{@link #CAL_SYNC5}</li> |
| 729 | * <li>{@link #CAL_SYNC6}</li> |
| 730 | * <li>{@link #CAL_SYNC7}</li> |
| 731 | * <li>{@link #CAL_SYNC8}</li> |
| 732 | * <li>{@link #CAL_SYNC9}</li> |
| 733 | * <li>{@link #CAL_SYNC10}</li> |
| 734 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 735 | */ |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 736 | public static final class Calendars implements BaseColumns, SyncColumns, CalendarColumns { |
| 737 | |
| 738 | /** |
| 739 | * This utility class cannot be instantiated |
| 740 | */ |
| 741 | private Calendars() {} |
| 742 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 743 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 744 | * The content:// style URL for accessing Calendars |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | */ |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 746 | @SuppressWarnings("hiding") |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 747 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/calendars"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 748 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 749 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 750 | * The content:// style URL for querying Calendars table in the managed profile. Appending a |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 751 | * calendar id using {@link ContentUris#withAppendedId(Uri, long)} will |
| 752 | * specify a single calendar. |
| 753 | * |
| 754 | * <p>The following columns are allowed to be queried via this uri: |
| 755 | * <ul> |
| 756 | * <li>{@link #_ID}</li> |
| 757 | * <li>{@link #NAME}</li> |
| 758 | * <li>{@link #CALENDAR_DISPLAY_NAME}</li> |
| 759 | * <li>{@link #CALENDAR_COLOR}</li> |
| 760 | * <li>{@link #VISIBLE}</li> |
| 761 | * <li>{@link #CALENDAR_LOCATION}</li> |
| 762 | * <li>{@link #CALENDAR_TIME_ZONE}</li> |
| 763 | * <li>{@link #IS_PRIMARY}</li> |
| 764 | * </ul> |
| 765 | * |
| 766 | * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the |
| 767 | * projection of the query to this uri that are not contained in the above list. |
| 768 | * |
| 769 | * <p>This uri will return an empty cursor if the calling user is not a parent profile |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 770 | * of a managed profile, or cross profile calendar is disabled in Settings, or this uri is |
| 771 | * queried from a package that is not whitelisted by profile owner of the managed profile |
| 772 | * via {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}. |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 773 | * |
| 774 | * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName) |
| 775 | * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED |
| 776 | */ |
| 777 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 778 | Uri.parse("content://" + AUTHORITY + "/enterprise/calendars"); |
| 779 | |
| 780 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 781 | * The default sort order for this table |
| 782 | */ |
Michael Chan | e5e0250 | 2011-09-01 10:46:14 -0700 | [diff] [blame] | 783 | public static final String DEFAULT_SORT_ORDER = CALENDAR_DISPLAY_NAME; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | |
| 785 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 786 | * The name of the calendar. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 787 | * <P>Type: TEXT</P> |
| 788 | */ |
| 789 | public static final String NAME = "name"; |
| 790 | |
| 791 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 792 | * The default location for the calendar. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 793 | * <P>Type: TEXT</P> |
| 794 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 795 | public static final String CALENDAR_LOCATION = "calendar_location"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 796 | |
| 797 | /** |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 798 | * These fields are only writable by a sync adapter. To modify them the |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 799 | * caller must include {@link #CALLER_IS_SYNCADAPTER}, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 800 | * {@link #ACCOUNT_NAME}, and {@link #ACCOUNT_TYPE} in the Uri's query |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 801 | * parameters. TODO move to provider |
| 802 | * |
| 803 | * @hide |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 804 | */ |
| 805 | public static final String[] SYNC_WRITABLE_COLUMNS = new String[] { |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 806 | ACCOUNT_NAME, |
| 807 | ACCOUNT_TYPE, |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 808 | _SYNC_ID, |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 809 | DIRTY, |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 810 | MUTATORS, |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 811 | OWNER_ACCOUNT, |
| 812 | MAX_REMINDERS, |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 813 | ALLOWED_REMINDERS, |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 814 | CAN_MODIFY_TIME_ZONE, |
| 815 | CAN_ORGANIZER_RESPOND, |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 816 | CAN_PARTIALLY_UPDATE, |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 817 | CALENDAR_LOCATION, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 818 | CALENDAR_TIME_ZONE, |
| 819 | CALENDAR_ACCESS_LEVEL, |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 820 | DELETED, |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 821 | CAL_SYNC1, |
| 822 | CAL_SYNC2, |
| 823 | CAL_SYNC3, |
| 824 | CAL_SYNC4, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 825 | CAL_SYNC5, |
| 826 | CAL_SYNC6, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 827 | CAL_SYNC7, |
| 828 | CAL_SYNC8, |
| 829 | CAL_SYNC9, |
| 830 | CAL_SYNC10, |
RoboErik | 6efb30f | 2011-05-05 10:11:47 -0700 | [diff] [blame] | 831 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 832 | } |
| 833 | |
Fabrice Di Meglio | c3cc133 | 2010-05-21 20:01:52 -0700 | [diff] [blame] | 834 | /** |
| 835 | * Columns from the Attendees table that other tables join into themselves. |
| 836 | */ |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 837 | protected interface AttendeesColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 838 | |
| 839 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 840 | * The id of the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 841 | * <P>Type: INTEGER</P> |
| 842 | */ |
| 843 | public static final String EVENT_ID = "event_id"; |
| 844 | |
| 845 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 846 | * The name of the attendee. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 847 | * <P>Type: STRING</P> |
| 848 | */ |
| 849 | public static final String ATTENDEE_NAME = "attendeeName"; |
| 850 | |
| 851 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 852 | * The email address of the attendee. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 853 | * <P>Type: STRING</P> |
| 854 | */ |
| 855 | public static final String ATTENDEE_EMAIL = "attendeeEmail"; |
| 856 | |
| 857 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 858 | * The relationship of the attendee to the user. Column name. |
| 859 | * <P>Type: INTEGER (one of {@link #RELATIONSHIP_ATTENDEE}, ...}.</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 860 | */ |
| 861 | public static final String ATTENDEE_RELATIONSHIP = "attendeeRelationship"; |
| 862 | |
| 863 | public static final int RELATIONSHIP_NONE = 0; |
| 864 | public static final int RELATIONSHIP_ATTENDEE = 1; |
| 865 | public static final int RELATIONSHIP_ORGANIZER = 2; |
| 866 | public static final int RELATIONSHIP_PERFORMER = 3; |
| 867 | public static final int RELATIONSHIP_SPEAKER = 4; |
| 868 | |
| 869 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 870 | * The type of attendee. Column name. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 871 | * <P> |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 872 | * Type: Integer (one of {@link #TYPE_NONE}, {@link #TYPE_REQUIRED}, |
| 873 | * {@link #TYPE_OPTIONAL}, {@link #TYPE_RESOURCE}) |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 874 | * </P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 875 | */ |
| 876 | public static final String ATTENDEE_TYPE = "attendeeType"; |
| 877 | |
| 878 | public static final int TYPE_NONE = 0; |
| 879 | public static final int TYPE_REQUIRED = 1; |
| 880 | public static final int TYPE_OPTIONAL = 2; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 881 | /** |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 882 | * This specifies that an attendee is a resource, like a room, a |
| 883 | * cabbage, or something and not an actual person. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 884 | */ |
| 885 | public static final int TYPE_RESOURCE = 3; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | |
| 887 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 888 | * The attendance status of the attendee. Column name. |
| 889 | * <P>Type: Integer (one of {@link #ATTENDEE_STATUS_ACCEPTED}, ...).</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 890 | */ |
| 891 | public static final String ATTENDEE_STATUS = "attendeeStatus"; |
| 892 | |
| 893 | public static final int ATTENDEE_STATUS_NONE = 0; |
| 894 | public static final int ATTENDEE_STATUS_ACCEPTED = 1; |
| 895 | public static final int ATTENDEE_STATUS_DECLINED = 2; |
| 896 | public static final int ATTENDEE_STATUS_INVITED = 3; |
| 897 | public static final int ATTENDEE_STATUS_TENTATIVE = 4; |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 898 | |
| 899 | /** |
| 900 | * The identity of the attendee as referenced in |
| 901 | * {@link ContactsContract.CommonDataKinds.Identity#IDENTITY}. |
Michael Chan | 37f1d29 | 2012-04-17 18:40:51 -0700 | [diff] [blame] | 902 | * This is required only if {@link #ATTENDEE_ID_NAMESPACE} is present. Column name. |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 903 | * <P>Type: STRING</P> |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 904 | */ |
| 905 | public static final String ATTENDEE_IDENTITY = "attendeeIdentity"; |
| 906 | |
| 907 | /** |
| 908 | * The identity name space of the attendee as referenced in |
| 909 | * {@link ContactsContract.CommonDataKinds.Identity#NAMESPACE}. |
Michael Chan | 37f1d29 | 2012-04-17 18:40:51 -0700 | [diff] [blame] | 910 | * This is required only if {@link #ATTENDEE_IDENTITY} is present. Column name. |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 911 | * <P>Type: STRING</P> |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 912 | */ |
| 913 | public static final String ATTENDEE_ID_NAMESPACE = "attendeeIdNamespace"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 914 | } |
| 915 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 916 | /** |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 917 | * Fields and helpers for interacting with Attendees. Each row of this table |
| 918 | * represents a single attendee or guest of an event. Calling |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 919 | * {@link #query(ContentResolver, long, String[])} will return a list of attendees for |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 920 | * the event with the given eventId. Both apps and sync adapters may write |
| 921 | * to this table. There are six writable fields and all of them except |
| 922 | * {@link #ATTENDEE_NAME} must be included when inserting a new attendee. |
| 923 | * They are: |
| 924 | * <ul> |
| 925 | * <li>{@link #EVENT_ID}</li> |
| 926 | * <li>{@link #ATTENDEE_NAME}</li> |
| 927 | * <li>{@link #ATTENDEE_EMAIL}</li> |
| 928 | * <li>{@link #ATTENDEE_RELATIONSHIP}</li> |
| 929 | * <li>{@link #ATTENDEE_TYPE}</li> |
| 930 | * <li>{@link #ATTENDEE_STATUS}</li> |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 931 | * <li>{@link #ATTENDEE_IDENTITY}</li> |
| 932 | * <li>{@link #ATTENDEE_ID_NAMESPACE}</li> |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 933 | * </ul> |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 934 | */ |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 935 | public static final class Attendees implements BaseColumns, AttendeesColumns, EventsColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 936 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 937 | /** |
| 938 | * The content:// style URL for accessing Attendees data |
| 939 | */ |
| 940 | @SuppressWarnings("hiding") |
| 941 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 942 | private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?"; |
| 943 | |
| 944 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 945 | * This utility class cannot be instantiated |
| 946 | */ |
| 947 | private Attendees() {} |
| 948 | |
| 949 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 950 | * Queries all attendees associated with the given event. This is a |
| 951 | * blocking call and should not be done on the UI thread. |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 952 | * |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 953 | * @param cr The content resolver to use for the query |
| 954 | * @param eventId The id of the event to retrieve attendees for |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 955 | * @param projection the columns to return in the cursor |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 956 | * @return A Cursor containing all attendees for the event |
| 957 | */ |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 958 | public static final Cursor query(ContentResolver cr, long eventId, String[] projection) { |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 959 | String[] attArgs = {Long.toString(eventId)}; |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 960 | return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 961 | null /* sort order */); |
| 962 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Columns from the Events table that other tables join into themselves. |
| 967 | */ |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 968 | protected interface EventsColumns { |
Andy McFadden | df2e2c8 | 2011-04-19 15:08:37 -0700 | [diff] [blame] | 969 | |
| 970 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 971 | * The {@link Calendars#_ID} of the calendar the event belongs to. |
| 972 | * Column name. |
| 973 | * <P>Type: INTEGER</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 974 | */ |
| 975 | public static final String CALENDAR_ID = "calendar_id"; |
| 976 | |
| 977 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 978 | * The title of the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 979 | * <P>Type: TEXT</P> |
| 980 | */ |
| 981 | public static final String TITLE = "title"; |
| 982 | |
| 983 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 984 | * The description of the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 985 | * <P>Type: TEXT</P> |
| 986 | */ |
| 987 | public static final String DESCRIPTION = "description"; |
| 988 | |
| 989 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 990 | * Where the event takes place. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 991 | * <P>Type: TEXT</P> |
| 992 | */ |
| 993 | public static final String EVENT_LOCATION = "eventLocation"; |
| 994 | |
| 995 | /** |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 996 | * A secondary color for the individual event. This should only be |
| 997 | * updated by the sync adapter for a given account. |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 998 | * <P>Type: INTEGER</P> |
| 999 | */ |
| 1000 | public static final String EVENT_COLOR = "eventColor"; |
| 1001 | |
| 1002 | /** |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 1003 | * A secondary color key for the individual event. NULL or an empty |
| 1004 | * string are reserved for indicating that the event does not use a key |
| 1005 | * for looking up the color. The provider will update |
| 1006 | * {@link #EVENT_COLOR} automatically when a valid key is written to |
| 1007 | * this column. The key must reference an existing row of the |
RoboErik | 8a8eebc | 2011-10-20 16:57:18 -0700 | [diff] [blame] | 1008 | * {@link Colors} table. @see Colors |
| 1009 | * <P> |
| 1010 | * Type: TEXT |
| 1011 | * </P> |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 1012 | */ |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 1013 | public static final String EVENT_COLOR_KEY = "eventColor_index"; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 1014 | |
| 1015 | /** |
Alon Albert | dc92730 | 2012-03-01 16:05:55 -0800 | [diff] [blame] | 1016 | * This will be {@link #EVENT_COLOR} if it is not null; otherwise, this will be |
| 1017 | * {@link Calendars#CALENDAR_COLOR}. |
| 1018 | * Read-only value. To modify, write to {@link #EVENT_COLOR} or |
| 1019 | * {@link Calendars#CALENDAR_COLOR} directly. |
| 1020 | *<P> |
| 1021 | * Type: INTEGER |
| 1022 | *</P> |
| 1023 | */ |
| 1024 | public static final String DISPLAY_COLOR = "displayColor"; |
| 1025 | |
| 1026 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1027 | * The event status. Column name. |
| 1028 | * <P>Type: INTEGER (one of {@link #STATUS_TENTATIVE}...)</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1029 | */ |
| 1030 | public static final String STATUS = "eventStatus"; |
| 1031 | |
| 1032 | public static final int STATUS_TENTATIVE = 0; |
| 1033 | public static final int STATUS_CONFIRMED = 1; |
| 1034 | public static final int STATUS_CANCELED = 2; |
| 1035 | |
| 1036 | /** |
| 1037 | * This is a copy of the attendee status for the owner of this event. |
| 1038 | * This field is copied here so that we can efficiently filter out |
| 1039 | * events that are declined without having to look in the Attendees |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1040 | * table. Column name. |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 1041 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1042 | * <P>Type: INTEGER (int)</P> |
| 1043 | */ |
| 1044 | public static final String SELF_ATTENDEE_STATUS = "selfAttendeeStatus"; |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 1045 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1046 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1047 | * This column is available for use by sync adapters. Column name. |
Marc Blank | 64a556d | 2010-02-25 12:53:16 -0800 | [diff] [blame] | 1048 | * <P>Type: TEXT</P> |
| 1049 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1050 | public static final String SYNC_DATA1 = "sync_data1"; |
Marc Blank | 64a556d | 2010-02-25 12:53:16 -0800 | [diff] [blame] | 1051 | |
| 1052 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1053 | * This column is available for use by sync adapters. Column name. |
| 1054 | * <P>Type: TEXT</P> |
| 1055 | */ |
| 1056 | public static final String SYNC_DATA2 = "sync_data2"; |
| 1057 | |
| 1058 | /** |
| 1059 | * This column is available for use by sync adapters. Column name. |
| 1060 | * <P>Type: TEXT</P> |
| 1061 | */ |
| 1062 | public static final String SYNC_DATA3 = "sync_data3"; |
| 1063 | |
| 1064 | /** |
| 1065 | * This column is available for use by sync adapters. Column name. |
| 1066 | * <P>Type: TEXT</P> |
| 1067 | */ |
| 1068 | public static final String SYNC_DATA4 = "sync_data4"; |
| 1069 | |
| 1070 | /** |
| 1071 | * This column is available for use by sync adapters. Column name. |
| 1072 | * <P>Type: TEXT</P> |
| 1073 | */ |
| 1074 | public static final String SYNC_DATA5 = "sync_data5"; |
| 1075 | |
| 1076 | /** |
| 1077 | * This column is available for use by sync adapters. Column name. |
| 1078 | * <P>Type: TEXT</P> |
| 1079 | */ |
| 1080 | public static final String SYNC_DATA6 = "sync_data6"; |
| 1081 | |
| 1082 | /** |
| 1083 | * This column is available for use by sync adapters. Column name. |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 1084 | * <P>Type: TEXT</P> |
| 1085 | */ |
| 1086 | public static final String SYNC_DATA7 = "sync_data7"; |
| 1087 | |
| 1088 | /** |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1089 | * This column is available for use by sync adapters. Column name. |
| 1090 | * <P>Type: TEXT</P> |
| 1091 | */ |
| 1092 | public static final String SYNC_DATA8 = "sync_data8"; |
| 1093 | |
| 1094 | /** |
| 1095 | * This column is available for use by sync adapters. Column name. |
| 1096 | * <P>Type: TEXT</P> |
| 1097 | */ |
| 1098 | public static final String SYNC_DATA9 = "sync_data9"; |
| 1099 | |
| 1100 | /** |
| 1101 | * This column is available for use by sync adapters. Column name. |
| 1102 | * <P>Type: TEXT</P> |
| 1103 | */ |
| 1104 | public static final String SYNC_DATA10 = "sync_data10"; |
| 1105 | |
| 1106 | /** |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 1107 | * Used to indicate that a row is not a real event but an original copy of a locally |
| 1108 | * modified event. A copy is made when an event changes from non-dirty to dirty and the |
| 1109 | * event is on a calendar with {@link Calendars#CAN_PARTIALLY_UPDATE} set to 1. This copy |
| 1110 | * does not get expanded in the instances table and is only visible in queries made by a |
| 1111 | * sync adapter. The copy gets removed when the event is changed back to non-dirty by a |
| 1112 | * sync adapter. |
| 1113 | * <P>Type: INTEGER (boolean)</P> |
| 1114 | */ |
| 1115 | public static final String LAST_SYNCED = "lastSynced"; |
| 1116 | |
| 1117 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1118 | * The time the event starts in UTC millis since epoch. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1119 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 1120 | */ |
| 1121 | public static final String DTSTART = "dtstart"; |
| 1122 | |
| 1123 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1124 | * The time the event ends in UTC millis since epoch. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1125 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 1126 | */ |
| 1127 | public static final String DTEND = "dtend"; |
| 1128 | |
| 1129 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1130 | * The duration of the event in RFC2445 format. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1131 | * <P>Type: TEXT (duration in RFC2445 format)</P> |
| 1132 | */ |
| 1133 | public static final String DURATION = "duration"; |
| 1134 | |
| 1135 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1136 | * The timezone for the event. Column name. |
| 1137 | * <P>Type: TEXT</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1138 | */ |
| 1139 | public static final String EVENT_TIMEZONE = "eventTimezone"; |
| 1140 | |
| 1141 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1142 | * The timezone for the end time of the event. Column name. |
| 1143 | * <P>Type: TEXT</P> |
Erik | c07b06f | 2010-05-03 11:37:31 -0700 | [diff] [blame] | 1144 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1145 | public static final String EVENT_END_TIMEZONE = "eventEndTimezone"; |
Erik | c07b06f | 2010-05-03 11:37:31 -0700 | [diff] [blame] | 1146 | |
| 1147 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1148 | * Is the event all day (time zone independent). Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1149 | * <P>Type: INTEGER (boolean)</P> |
| 1150 | */ |
| 1151 | public static final String ALL_DAY = "allDay"; |
| 1152 | |
| 1153 | /** |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1154 | * Defines how the event shows up for others when the calendar is |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1155 | * shared. Column name. |
| 1156 | * <P>Type: INTEGER (One of {@link #ACCESS_DEFAULT}, ...)</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1157 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1158 | public static final String ACCESS_LEVEL = "accessLevel"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1159 | |
| 1160 | /** |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1161 | * Default access is controlled by the server and will be treated as |
| 1162 | * public on the device. |
| 1163 | */ |
| 1164 | public static final int ACCESS_DEFAULT = 0; |
| 1165 | /** |
| 1166 | * Confidential is not used by the app. |
| 1167 | */ |
| 1168 | public static final int ACCESS_CONFIDENTIAL = 1; |
| 1169 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1170 | * Private shares the event as a free/busy slot with no details. |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1171 | */ |
| 1172 | public static final int ACCESS_PRIVATE = 2; |
| 1173 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1174 | * Public makes the contents visible to anyone with access to the |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1175 | * calendar. |
| 1176 | */ |
| 1177 | public static final int ACCESS_PUBLIC = 3; |
| 1178 | |
| 1179 | /** |
| 1180 | * If this event counts as busy time or is still free time that can be |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1181 | * scheduled over. Column name. |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 1182 | * <P> |
| 1183 | * Type: INTEGER (One of {@link #AVAILABILITY_BUSY}, |
| 1184 | * {@link #AVAILABILITY_FREE}, {@link #AVAILABILITY_TENTATIVE}) |
| 1185 | * </P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1186 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1187 | public static final String AVAILABILITY = "availability"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1188 | |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1189 | /** |
| 1190 | * Indicates that this event takes up time and will conflict with other |
| 1191 | * events. |
| 1192 | */ |
| 1193 | public static final int AVAILABILITY_BUSY = 0; |
| 1194 | /** |
| 1195 | * Indicates that this event is free time and will not conflict with |
| 1196 | * other events. |
| 1197 | */ |
| 1198 | public static final int AVAILABILITY_FREE = 1; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 1199 | /** |
| 1200 | * Indicates that the owner's availability may change, but should be |
| 1201 | * considered busy time that will conflict. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 1202 | */ |
| 1203 | public static final int AVAILABILITY_TENTATIVE = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1204 | |
| 1205 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1206 | * Whether the event has an alarm or not. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1207 | * <P>Type: INTEGER (boolean)</P> |
| 1208 | */ |
| 1209 | public static final String HAS_ALARM = "hasAlarm"; |
| 1210 | |
| 1211 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1212 | * Whether the event has extended properties or not. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1213 | * <P>Type: INTEGER (boolean)</P> |
| 1214 | */ |
| 1215 | public static final String HAS_EXTENDED_PROPERTIES = "hasExtendedProperties"; |
| 1216 | |
| 1217 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1218 | * The recurrence rule for the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1219 | * <P>Type: TEXT</P> |
| 1220 | */ |
| 1221 | public static final String RRULE = "rrule"; |
| 1222 | |
| 1223 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1224 | * The recurrence dates for the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1225 | * <P>Type: TEXT</P> |
| 1226 | */ |
| 1227 | public static final String RDATE = "rdate"; |
| 1228 | |
| 1229 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1230 | * The recurrence exception rule for the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1231 | * <P>Type: TEXT</P> |
| 1232 | */ |
| 1233 | public static final String EXRULE = "exrule"; |
| 1234 | |
| 1235 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1236 | * The recurrence exception dates for the event. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1237 | * <P>Type: TEXT</P> |
| 1238 | */ |
| 1239 | public static final String EXDATE = "exdate"; |
| 1240 | |
| 1241 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1242 | * The {@link Events#_ID} of the original recurring event for which this |
| 1243 | * event is an exception. Column name. |
RoboErik | c0bd9bc | 2011-05-13 17:54:24 -0700 | [diff] [blame] | 1244 | * <P>Type: TEXT</P> |
| 1245 | */ |
| 1246 | public static final String ORIGINAL_ID = "original_id"; |
| 1247 | |
| 1248 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1249 | * The _sync_id of the original recurring event for which this event is |
RoboErik | c0bd9bc | 2011-05-13 17:54:24 -0700 | [diff] [blame] | 1250 | * an exception. The provider should keep the original_id in sync when |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1251 | * this is updated. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1252 | * <P>Type: TEXT</P> |
| 1253 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1254 | public static final String ORIGINAL_SYNC_ID = "original_sync_id"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1255 | |
| 1256 | /** |
| 1257 | * The original instance time of the recurring event for which this |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1258 | * event is an exception. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1259 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 1260 | */ |
| 1261 | public static final String ORIGINAL_INSTANCE_TIME = "originalInstanceTime"; |
| 1262 | |
| 1263 | /** |
| 1264 | * The allDay status (true or false) of the original recurring event |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1265 | * for which this event is an exception. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1266 | * <P>Type: INTEGER (boolean)</P> |
| 1267 | */ |
| 1268 | public static final String ORIGINAL_ALL_DAY = "originalAllDay"; |
| 1269 | |
| 1270 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1271 | * The last date this event repeats on, or NULL if it never ends. Column |
| 1272 | * name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1273 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 1274 | */ |
| 1275 | public static final String LAST_DATE = "lastDate"; |
Ken Shirriff | 79f0c56 | 2009-08-05 13:29:42 -0700 | [diff] [blame] | 1276 | |
| 1277 | /** |
| 1278 | * Whether the event has attendee information. True if the event |
| 1279 | * has full attendee data, false if the event has information about |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1280 | * self only. Column name. |
Ken Shirriff | 79f0c56 | 2009-08-05 13:29:42 -0700 | [diff] [blame] | 1281 | * <P>Type: INTEGER (boolean)</P> |
| 1282 | */ |
| 1283 | public static final String HAS_ATTENDEE_DATA = "hasAttendeeData"; |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1284 | |
| 1285 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1286 | * Whether guests can modify the event. Column name. |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1287 | * <P>Type: INTEGER (boolean)</P> |
| 1288 | */ |
| 1289 | public static final String GUESTS_CAN_MODIFY = "guestsCanModify"; |
| 1290 | |
| 1291 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1292 | * Whether guests can invite other guests. Column name. |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1293 | * <P>Type: INTEGER (boolean)</P> |
| 1294 | */ |
| 1295 | public static final String GUESTS_CAN_INVITE_OTHERS = "guestsCanInviteOthers"; |
| 1296 | |
| 1297 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1298 | * Whether guests can see the list of attendees. Column name. |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1299 | * <P>Type: INTEGER (boolean)</P> |
| 1300 | */ |
| 1301 | public static final String GUESTS_CAN_SEE_GUESTS = "guestsCanSeeGuests"; |
| 1302 | |
| 1303 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1304 | * Email of the organizer (owner) of the event. Column name. |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1305 | * <P>Type: STRING</P> |
| 1306 | */ |
| 1307 | public static final String ORGANIZER = "organizer"; |
| 1308 | |
| 1309 | /** |
Alon Albert | 0a9a219 | 2012-09-18 11:10:49 -0700 | [diff] [blame] | 1310 | * Are we the organizer of this event. If this column is not explicitly set, the provider |
| 1311 | * will return 1 if {@link #ORGANIZER} is equal to {@link Calendars#OWNER_ACCOUNT}. |
| 1312 | * Column name. |
| 1313 | * <P>Type: STRING</P> |
| 1314 | */ |
| 1315 | public static final String IS_ORGANIZER = "isOrganizer"; |
| 1316 | |
| 1317 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1318 | * Whether the user can invite others to the event. The |
| 1319 | * GUESTS_CAN_INVITE_OTHERS is a setting that applies to an arbitrary |
| 1320 | * guest, while CAN_INVITE_OTHERS indicates if the user can invite |
| 1321 | * others (either through GUESTS_CAN_INVITE_OTHERS or because the user |
| 1322 | * has modify access to the event). Column name. |
Ken Shirriff | 3d03707 | 2009-08-17 15:43:21 -0700 | [diff] [blame] | 1323 | * <P>Type: INTEGER (boolean, readonly)</P> |
| 1324 | */ |
| 1325 | public static final String CAN_INVITE_OTHERS = "canInviteOthers"; |
Michael Chan | 37960c7 | 2012-04-19 00:18:13 -0700 | [diff] [blame] | 1326 | |
| 1327 | /** |
| 1328 | * The package name of the custom app that can provide a richer |
| 1329 | * experience for the event. See the ACTION TYPE |
| 1330 | * {@link CalendarContract#ACTION_HANDLE_CUSTOM_EVENT} for details. |
| 1331 | * Column name. |
| 1332 | * <P> Type: TEXT </P> |
| 1333 | */ |
| 1334 | public static final String CUSTOM_APP_PACKAGE = "customAppPackage"; |
| 1335 | |
| 1336 | /** |
| 1337 | * The URI used by the custom app for the event. Column name. |
| 1338 | * <P>Type: TEXT</P> |
| 1339 | */ |
| 1340 | public static final String CUSTOM_APP_URI = "customAppUri"; |
| 1341 | |
Sara Ting | 4d6f90e | 2012-09-17 11:17:15 -0700 | [diff] [blame] | 1342 | /** |
| 1343 | * The UID for events added from the RFC 2445 iCalendar format. |
| 1344 | * Column name. |
| 1345 | * <P>Type: TEXT</P> |
| 1346 | */ |
| 1347 | public static final String UID_2445 = "uid2445"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1348 | } |
| 1349 | |
| 1350 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1351 | * Class that represents an Event Entity. There is one entry per event. |
| 1352 | * Recurring events show up as a single entry. This is a helper class to |
| 1353 | * make batch operations easier. A {@link ContentResolver} or |
| 1354 | * {@link ContentProviderClient} is required as the helper does additional |
| 1355 | * queries to add reminders and attendees to each entry. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1356 | */ |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1357 | public static final class EventsEntity implements BaseColumns, SyncColumns, EventsColumns { |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1358 | /** |
| 1359 | * The content:// style URL for this table |
| 1360 | */ |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 1361 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + |
| 1362 | "/event_entities"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1363 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1364 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 1365 | * This utility class cannot be instantiated |
| 1366 | */ |
| 1367 | private EventsEntity() {} |
| 1368 | |
| 1369 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1370 | * Creates a new iterator for events |
| 1371 | * |
| 1372 | * @param cursor An event query |
| 1373 | * @param resolver For performing additional queries |
| 1374 | * @return an EntityIterator containing one entity per event in the |
| 1375 | * cursor |
| 1376 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1377 | public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) { |
| 1378 | return new EntityIteratorImpl(cursor, resolver); |
| 1379 | } |
| 1380 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1381 | /** |
| 1382 | * Creates a new iterator for events |
| 1383 | * |
| 1384 | * @param cursor An event query |
| 1385 | * @param provider For performing additional queries |
| 1386 | * @return an EntityIterator containing one entity per event in the |
| 1387 | * cursor |
| 1388 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1389 | public static EntityIterator newEntityIterator(Cursor cursor, |
| 1390 | ContentProviderClient provider) { |
| 1391 | return new EntityIteratorImpl(cursor, provider); |
| 1392 | } |
| 1393 | |
| 1394 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 1395 | private final ContentResolver mResolver; |
| 1396 | private final ContentProviderClient mProvider; |
| 1397 | |
| 1398 | private static final String[] REMINDERS_PROJECTION = new String[] { |
| 1399 | Reminders.MINUTES, |
| 1400 | Reminders.METHOD, |
| 1401 | }; |
| 1402 | private static final int COLUMN_MINUTES = 0; |
| 1403 | private static final int COLUMN_METHOD = 1; |
| 1404 | |
| 1405 | private static final String[] ATTENDEES_PROJECTION = new String[] { |
| 1406 | Attendees.ATTENDEE_NAME, |
| 1407 | Attendees.ATTENDEE_EMAIL, |
| 1408 | Attendees.ATTENDEE_RELATIONSHIP, |
| 1409 | Attendees.ATTENDEE_TYPE, |
| 1410 | Attendees.ATTENDEE_STATUS, |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 1411 | Attendees.ATTENDEE_IDENTITY, |
| 1412 | Attendees.ATTENDEE_ID_NAMESPACE |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1413 | }; |
| 1414 | private static final int COLUMN_ATTENDEE_NAME = 0; |
| 1415 | private static final int COLUMN_ATTENDEE_EMAIL = 1; |
| 1416 | private static final int COLUMN_ATTENDEE_RELATIONSHIP = 2; |
| 1417 | private static final int COLUMN_ATTENDEE_TYPE = 3; |
| 1418 | private static final int COLUMN_ATTENDEE_STATUS = 4; |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 1419 | private static final int COLUMN_ATTENDEE_IDENTITY = 5; |
| 1420 | private static final int COLUMN_ATTENDEE_ID_NAMESPACE = 6; |
| 1421 | |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1422 | private static final String[] EXTENDED_PROJECTION = new String[] { |
Marc Blank | 8f643c1 | 2010-04-29 14:16:48 -0700 | [diff] [blame] | 1423 | ExtendedProperties._ID, |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1424 | ExtendedProperties.NAME, |
Marc Blank | 8f643c1 | 2010-04-29 14:16:48 -0700 | [diff] [blame] | 1425 | ExtendedProperties.VALUE |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1426 | }; |
Marc Blank | 8f643c1 | 2010-04-29 14:16:48 -0700 | [diff] [blame] | 1427 | private static final int COLUMN_ID = 0; |
| 1428 | private static final int COLUMN_NAME = 1; |
| 1429 | private static final int COLUMN_VALUE = 2; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1430 | |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1431 | private static final String WHERE_EVENT_ID = "event_id=?"; |
| 1432 | |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1433 | public EntityIteratorImpl(Cursor cursor, ContentResolver resolver) { |
| 1434 | super(cursor); |
| 1435 | mResolver = resolver; |
| 1436 | mProvider = null; |
| 1437 | } |
| 1438 | |
| 1439 | public EntityIteratorImpl(Cursor cursor, ContentProviderClient provider) { |
| 1440 | super(cursor); |
| 1441 | mResolver = null; |
| 1442 | mProvider = provider; |
| 1443 | } |
| 1444 | |
Marc Blank | 64a556d | 2010-02-25 12:53:16 -0800 | [diff] [blame] | 1445 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1446 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 1447 | // we expect the cursor is already at the row we need to read from |
| 1448 | final long eventId = cursor.getLong(cursor.getColumnIndexOrThrow(Events._ID)); |
| 1449 | ContentValues cv = new ContentValues(); |
| 1450 | cv.put(Events._ID, eventId); |
| 1451 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ID); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1452 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, TITLE); |
| 1453 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DESCRIPTION); |
| 1454 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_LOCATION); |
| 1455 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, STATUS); |
| 1456 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SELF_ATTENDEE_STATUS); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1457 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTSTART); |
| 1458 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DTEND); |
| 1459 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DURATION); |
| 1460 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_TIMEZONE); |
RoboErik | c0bd9bc | 2011-05-13 17:54:24 -0700 | [diff] [blame] | 1461 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_END_TIMEZONE); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1462 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ALL_DAY); |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1463 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL); |
| 1464 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, AVAILABILITY); |
Alon Albert | 971c28b | 2013-02-04 13:49:50 -0800 | [diff] [blame] | 1465 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, EVENT_COLOR); |
Alon Albert | 0a35dd5 | 2013-02-05 11:07:56 -0800 | [diff] [blame] | 1466 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EVENT_COLOR_KEY); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1467 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, HAS_ALARM); |
| 1468 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 1469 | HAS_EXTENDED_PROPERTIES); |
| 1470 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RRULE); |
| 1471 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, RDATE); |
| 1472 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXRULE); |
| 1473 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, EXDATE); |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1474 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_SYNC_ID); |
RoboErik | c0bd9bc | 2011-05-13 17:54:24 -0700 | [diff] [blame] | 1475 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORIGINAL_ID); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1476 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 1477 | ORIGINAL_INSTANCE_TIME); |
| 1478 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ORIGINAL_ALL_DAY); |
| 1479 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_DATE); |
| 1480 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, HAS_ATTENDEE_DATA); |
| 1481 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, |
| 1482 | GUESTS_CAN_INVITE_OTHERS); |
| 1483 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_MODIFY); |
| 1484 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_SEE_GUESTS); |
Michael Chan | bb9fd4a | 2012-04-24 17:32:03 -0700 | [diff] [blame] | 1485 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_PACKAGE); |
| 1486 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CUSTOM_APP_URI); |
Sara Ting | 4d6f90e | 2012-09-17 11:17:15 -0700 | [diff] [blame] | 1487 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, UID_2445); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1488 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORGANIZER); |
Alon Albert | 0a9a219 | 2012-09-18 11:10:49 -0700 | [diff] [blame] | 1489 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, IS_ORGANIZER); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1490 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID); |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1491 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 1492 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS); |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 1493 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1494 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1495 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA1); |
| 1496 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA2); |
| 1497 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA3); |
| 1498 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA4); |
| 1499 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA5); |
| 1500 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA6); |
| 1501 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA7); |
| 1502 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA8); |
| 1503 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA9); |
| 1504 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA10); |
RoboErik | be01039 | 2011-05-26 12:28:38 -0700 | [diff] [blame] | 1505 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1); |
| 1506 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2); |
| 1507 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3); |
| 1508 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4); |
| 1509 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5); |
| 1510 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6); |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1511 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7); |
| 1512 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8); |
| 1513 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9); |
| 1514 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1515 | |
| 1516 | Entity entity = new Entity(cv); |
| 1517 | Cursor subCursor; |
| 1518 | if (mResolver != null) { |
| 1519 | subCursor = mResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1520 | WHERE_EVENT_ID, |
| 1521 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1522 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1523 | } else { |
| 1524 | subCursor = mProvider.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1525 | WHERE_EVENT_ID, |
| 1526 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1527 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1528 | } |
| 1529 | try { |
| 1530 | while (subCursor.moveToNext()) { |
| 1531 | ContentValues reminderValues = new ContentValues(); |
| 1532 | reminderValues.put(Reminders.MINUTES, subCursor.getInt(COLUMN_MINUTES)); |
| 1533 | reminderValues.put(Reminders.METHOD, subCursor.getInt(COLUMN_METHOD)); |
| 1534 | entity.addSubValue(Reminders.CONTENT_URI, reminderValues); |
| 1535 | } |
| 1536 | } finally { |
| 1537 | subCursor.close(); |
| 1538 | } |
| 1539 | |
| 1540 | if (mResolver != null) { |
| 1541 | subCursor = mResolver.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1542 | WHERE_EVENT_ID, |
| 1543 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1544 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1545 | } else { |
| 1546 | subCursor = mProvider.query(Attendees.CONTENT_URI, ATTENDEES_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1547 | WHERE_EVENT_ID, |
| 1548 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1549 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1550 | } |
| 1551 | try { |
| 1552 | while (subCursor.moveToNext()) { |
| 1553 | ContentValues attendeeValues = new ContentValues(); |
| 1554 | attendeeValues.put(Attendees.ATTENDEE_NAME, |
| 1555 | subCursor.getString(COLUMN_ATTENDEE_NAME)); |
| 1556 | attendeeValues.put(Attendees.ATTENDEE_EMAIL, |
| 1557 | subCursor.getString(COLUMN_ATTENDEE_EMAIL)); |
| 1558 | attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP, |
| 1559 | subCursor.getInt(COLUMN_ATTENDEE_RELATIONSHIP)); |
| 1560 | attendeeValues.put(Attendees.ATTENDEE_TYPE, |
| 1561 | subCursor.getInt(COLUMN_ATTENDEE_TYPE)); |
| 1562 | attendeeValues.put(Attendees.ATTENDEE_STATUS, |
| 1563 | subCursor.getInt(COLUMN_ATTENDEE_STATUS)); |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 1564 | attendeeValues.put(Attendees.ATTENDEE_IDENTITY, |
Michael Chan | a07ea5d | 2012-07-13 14:10:40 -0700 | [diff] [blame] | 1565 | subCursor.getString(COLUMN_ATTENDEE_IDENTITY)); |
Michael Chan | 48ec622 | 2012-04-17 15:58:28 -0700 | [diff] [blame] | 1566 | attendeeValues.put(Attendees.ATTENDEE_ID_NAMESPACE, |
Michael Chan | a07ea5d | 2012-07-13 14:10:40 -0700 | [diff] [blame] | 1567 | subCursor.getString(COLUMN_ATTENDEE_ID_NAMESPACE)); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1568 | entity.addSubValue(Attendees.CONTENT_URI, attendeeValues); |
| 1569 | } |
| 1570 | } finally { |
| 1571 | subCursor.close(); |
| 1572 | } |
| 1573 | |
| 1574 | if (mResolver != null) { |
| 1575 | subCursor = mResolver.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1576 | WHERE_EVENT_ID, |
| 1577 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1578 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1579 | } else { |
| 1580 | subCursor = mProvider.query(ExtendedProperties.CONTENT_URI, EXTENDED_PROJECTION, |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1581 | WHERE_EVENT_ID, |
| 1582 | new String[] { Long.toString(eventId) } /* selectionArgs */, |
| 1583 | null /* sortOrder */); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1584 | } |
| 1585 | try { |
| 1586 | while (subCursor.moveToNext()) { |
| 1587 | ContentValues extendedValues = new ContentValues(); |
Marc Blank | 8f643c1 | 2010-04-29 14:16:48 -0700 | [diff] [blame] | 1588 | extendedValues.put(ExtendedProperties._ID, |
| 1589 | subCursor.getString(COLUMN_ID)); |
Ken Shirriff | 3b16892 | 2010-01-27 12:27:28 -0800 | [diff] [blame] | 1590 | extendedValues.put(ExtendedProperties.NAME, |
| 1591 | subCursor.getString(COLUMN_NAME)); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1592 | extendedValues.put(ExtendedProperties.VALUE, |
Ken Shirriff | 3b16892 | 2010-01-27 12:27:28 -0800 | [diff] [blame] | 1593 | subCursor.getString(COLUMN_VALUE)); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1594 | entity.addSubValue(ExtendedProperties.CONTENT_URI, extendedValues); |
| 1595 | } |
| 1596 | } finally { |
| 1597 | subCursor.close(); |
| 1598 | } |
| 1599 | |
| 1600 | cursor.moveToNext(); |
| 1601 | return entity; |
| 1602 | } |
| 1603 | } |
| 1604 | } |
| 1605 | |
| 1606 | /** |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 1607 | * Constants and helpers for the Events table, which contains details for |
| 1608 | * individual events. <h3>Operations</h3> All operations can be done either |
| 1609 | * as an app or as a sync adapter. To perform an operation as a sync adapter |
| 1610 | * {@link #CALLER_IS_SYNCADAPTER} should be set to true and |
| 1611 | * {@link #ACCOUNT_NAME} and {@link #ACCOUNT_TYPE} must be set in the Uri |
| 1612 | * parameters. See |
| 1613 | * {@link Uri.Builder#appendQueryParameter(java.lang.String, java.lang.String)} |
| 1614 | * for details on adding parameters. Sync adapters have write access to more |
| 1615 | * columns but are restricted to a single account at a time. |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1616 | * <dl> |
| 1617 | * <dt><b>Insert</b></dt> |
| 1618 | * <dd>When inserting a new event the following fields must be included: |
| 1619 | * <ul> |
| 1620 | * <li>dtstart</li> |
Michael Chan | e6fbf65 | 2011-10-18 14:43:11 -0700 | [diff] [blame] | 1621 | * <li>dtend if the event is non-recurring</li> |
| 1622 | * <li>duration if the event is recurring</li> |
| 1623 | * <li>rrule or rdate if the event is recurring</li> |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 1624 | * <li>eventTimezone</li> |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1625 | * <li>a calendar_id</li> |
| 1626 | * </ul> |
| 1627 | * There are also further requirements when inserting or updating an event. |
| 1628 | * See the section on Writing to Events.</dd> |
| 1629 | * <dt><b>Update</b></dt> |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 1630 | * <dd>To perform an update of an Event the {@link Events#_ID} of the event |
| 1631 | * should be provided either as an appended id to the Uri ( |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1632 | * {@link ContentUris#withAppendedId}) or as the first selection item--the |
| 1633 | * selection should start with "_id=?" and the first selectionArg should be |
RoboErik | f4010c5 | 2011-06-17 11:04:26 -0700 | [diff] [blame] | 1634 | * the _id of the event. Updates may also be done using a selection and no |
| 1635 | * id. Updating an event must respect the same rules as inserting and is |
| 1636 | * further restricted in the fields that can be written. See the section on |
| 1637 | * Writing to Events.</dd> |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1638 | * <dt><b>Delete</b></dt> |
| 1639 | * <dd>Events can be deleted either by the {@link Events#_ID} as an appended |
| 1640 | * id on the Uri or using any standard selection. If an appended id is used |
| 1641 | * a selection is not allowed. There are two versions of delete: as an app |
| 1642 | * and as a sync adapter. An app delete will set the deleted column on an |
| 1643 | * event and remove all instances of that event. A sync adapter delete will |
| 1644 | * remove the event from the database and all associated data.</dd> |
| 1645 | * <dt><b>Query</b></dt> |
| 1646 | * <dd>Querying the Events table will get you all information about a set of |
| 1647 | * events except their reminders, attendees, and extended properties. There |
| 1648 | * will be one row returned for each event that matches the query selection, |
| 1649 | * or at most a single row if the {@link Events#_ID} is appended to the Uri. |
| 1650 | * Recurring events will only return a single row regardless of the number |
| 1651 | * of times that event repeats.</dd> |
| 1652 | * </dl> |
| 1653 | * <h3>Writing to Events</h3> There are further restrictions on all Updates |
| 1654 | * and Inserts in the Events table: |
| 1655 | * <ul> |
| 1656 | * <li>If allDay is set to 1 eventTimezone must be {@link Time#TIMEZONE_UTC} |
| 1657 | * and the time must correspond to a midnight boundary.</li> |
| 1658 | * <li>Exceptions are not allowed to recur. If rrule or rdate is not empty, |
| 1659 | * original_id and original_sync_id must be empty.</li> |
| 1660 | * <li>In general a calendar_id should not be modified after insertion. This |
| 1661 | * is not explicitly forbidden but many sync adapters will not behave in an |
| 1662 | * expected way if the calendar_id is modified.</li> |
| 1663 | * </ul> |
| 1664 | * The following Events columns are writable by both an app and a sync |
| 1665 | * adapter. |
| 1666 | * <ul> |
| 1667 | * <li>{@link #CALENDAR_ID}</li> |
| 1668 | * <li>{@link #ORGANIZER}</li> |
| 1669 | * <li>{@link #TITLE}</li> |
| 1670 | * <li>{@link #EVENT_LOCATION}</li> |
| 1671 | * <li>{@link #DESCRIPTION}</li> |
| 1672 | * <li>{@link #EVENT_COLOR}</li> |
| 1673 | * <li>{@link #DTSTART}</li> |
| 1674 | * <li>{@link #DTEND}</li> |
| 1675 | * <li>{@link #EVENT_TIMEZONE}</li> |
| 1676 | * <li>{@link #EVENT_END_TIMEZONE}</li> |
| 1677 | * <li>{@link #DURATION}</li> |
| 1678 | * <li>{@link #ALL_DAY}</li> |
| 1679 | * <li>{@link #RRULE}</li> |
| 1680 | * <li>{@link #RDATE}</li> |
| 1681 | * <li>{@link #EXRULE}</li> |
| 1682 | * <li>{@link #EXDATE}</li> |
| 1683 | * <li>{@link #ORIGINAL_ID}</li> |
| 1684 | * <li>{@link #ORIGINAL_SYNC_ID}</li> |
| 1685 | * <li>{@link #ORIGINAL_INSTANCE_TIME}</li> |
| 1686 | * <li>{@link #ORIGINAL_ALL_DAY}</li> |
| 1687 | * <li>{@link #ACCESS_LEVEL}</li> |
| 1688 | * <li>{@link #AVAILABILITY}</li> |
| 1689 | * <li>{@link #GUESTS_CAN_MODIFY}</li> |
| 1690 | * <li>{@link #GUESTS_CAN_INVITE_OTHERS}</li> |
| 1691 | * <li>{@link #GUESTS_CAN_SEE_GUESTS}</li> |
Michael Chan | bb9fd4a | 2012-04-24 17:32:03 -0700 | [diff] [blame] | 1692 | * <li>{@link #CUSTOM_APP_PACKAGE}</li> |
| 1693 | * <li>{@link #CUSTOM_APP_URI}</li> |
Sara Ting | 4d6f90e | 2012-09-17 11:17:15 -0700 | [diff] [blame] | 1694 | * <li>{@link #UID_2445}</li> |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1695 | * </ul> |
| 1696 | * The following Events columns are writable only by a sync adapter |
| 1697 | * <ul> |
| 1698 | * <li>{@link #DIRTY}</li> |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 1699 | * <li>{@link #MUTATORS}</li> |
RoboErik | fe37b49 | 2011-06-16 12:31:56 -0700 | [diff] [blame] | 1700 | * <li>{@link #_SYNC_ID}</li> |
| 1701 | * <li>{@link #SYNC_DATA1}</li> |
| 1702 | * <li>{@link #SYNC_DATA2}</li> |
| 1703 | * <li>{@link #SYNC_DATA3}</li> |
| 1704 | * <li>{@link #SYNC_DATA4}</li> |
| 1705 | * <li>{@link #SYNC_DATA5}</li> |
| 1706 | * <li>{@link #SYNC_DATA6}</li> |
| 1707 | * <li>{@link #SYNC_DATA7}</li> |
| 1708 | * <li>{@link #SYNC_DATA8}</li> |
| 1709 | * <li>{@link #SYNC_DATA9}</li> |
| 1710 | * <li>{@link #SYNC_DATA10}</li> |
| 1711 | * </ul> |
| 1712 | * The remaining columns are either updated by the provider only or are |
| 1713 | * views into other tables and cannot be changed through the Events table. |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1714 | */ |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1715 | public static final class Events implements BaseColumns, SyncColumns, EventsColumns, |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 1716 | CalendarColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1717 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1718 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1719 | * The content:// style URL for interacting with events. Appending an |
| 1720 | * event id using {@link ContentUris#withAppendedId(Uri, long)} will |
| 1721 | * specify a single event. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1722 | */ |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1723 | @SuppressWarnings("hiding") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1724 | public static final Uri CONTENT_URI = |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 1725 | Uri.parse("content://" + AUTHORITY + "/events"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1726 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1727 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1728 | * The content:// style URL for querying Events table in the managed profile. Appending an |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1729 | * event id using {@link ContentUris#withAppendedId(Uri, long)} will |
| 1730 | * specify a single event. |
| 1731 | * |
| 1732 | * <p>The following columns are allowed to be queried via this uri: |
| 1733 | * <ul> |
| 1734 | * <li>{@link #_ID}</li> |
| 1735 | * <li>{@link #CALENDAR_ID}</li> |
| 1736 | * <li>{@link #TITLE}</li> |
| 1737 | * <li>{@link #EVENT_LOCATION}</li> |
| 1738 | * <li>{@link #EVENT_COLOR}</li> |
| 1739 | * <li>{@link #STATUS}</li> |
| 1740 | * <li>{@link #DTSTART}</li> |
| 1741 | * <li>{@link #DTEND}</li> |
| 1742 | * <li>{@link #EVENT_TIMEZONE}</li> |
| 1743 | * <li>{@link #EVENT_END_TIMEZONE}</li> |
| 1744 | * <li>{@link #DURATION}</li> |
| 1745 | * <li>{@link #ALL_DAY}</li> |
| 1746 | * <li>{@link #AVAILABILITY}</li> |
| 1747 | * <li>{@link #RRULE}</li> |
| 1748 | * <li>{@link #RDATE}</li> |
| 1749 | * <li>{@link #EXRULE}</li> |
| 1750 | * <li>{@link #EXDATE}</li> |
| 1751 | * <li>{@link #CALENDAR_DISPLAY_NAME}</li> |
| 1752 | * <li>{@link #CALENDAR_COLOR}</li> |
| 1753 | * <li>{@link #VISIBLE}</li> |
| 1754 | * <li>{@link #CALENDAR_TIME_ZONE}</li> |
| 1755 | * </ul> |
| 1756 | * |
| 1757 | * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the |
| 1758 | * projection of the query to this uri that are not contained in the above list. |
| 1759 | * |
| 1760 | * <p>This uri will return an empty cursor if the calling user is not a parent profile |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1761 | * of a managed profile, or cross profile calendar is disabled in Settings, or this uri is |
| 1762 | * queried from a package that is not whitelisted by profile owner of the managed profile |
| 1763 | * via {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}. |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1764 | * |
| 1765 | * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName) |
| 1766 | * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED |
| 1767 | */ |
| 1768 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 1769 | Uri.parse("content://" + AUTHORITY + "/enterprise/events"); |
| 1770 | |
| 1771 | /** |
Andy McFadden | 4a8c478 | 2011-05-24 13:00:29 -0700 | [diff] [blame] | 1772 | * The content:// style URI for recurring event exceptions. Insertions require an |
| 1773 | * appended event ID. Deletion of exceptions requires both the original event ID and |
| 1774 | * the exception event ID (see {@link Uri.Builder#appendPath}). |
| 1775 | */ |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 1776 | public static final Uri CONTENT_EXCEPTION_URI = |
Andy McFadden | 4a8c478 | 2011-05-24 13:00:29 -0700 | [diff] [blame] | 1777 | Uri.parse("content://" + AUTHORITY + "/exception"); |
| 1778 | |
| 1779 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 1780 | * This utility class cannot be instantiated |
| 1781 | */ |
| 1782 | private Events() {} |
| 1783 | |
| 1784 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1785 | * The default sort order for this table |
| 1786 | */ |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1787 | private static final String DEFAULT_SORT_ORDER = ""; |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1788 | |
| 1789 | /** |
| 1790 | * These are columns that should only ever be updated by the provider, |
| 1791 | * either because they are views mapped to another table or because they |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 1792 | * are used for provider only functionality. TODO move to provider |
| 1793 | * |
| 1794 | * @hide |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1795 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 1796 | @UnsupportedAppUsage |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1797 | public static String[] PROVIDER_WRITABLE_COLUMNS = new String[] { |
| 1798 | ACCOUNT_NAME, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1799 | ACCOUNT_TYPE, |
| 1800 | CAL_SYNC1, |
| 1801 | CAL_SYNC2, |
| 1802 | CAL_SYNC3, |
| 1803 | CAL_SYNC4, |
| 1804 | CAL_SYNC5, |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 1805 | CAL_SYNC6, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1806 | CAL_SYNC7, |
| 1807 | CAL_SYNC8, |
| 1808 | CAL_SYNC9, |
| 1809 | CAL_SYNC10, |
| 1810 | ALLOWED_REMINDERS, |
RoboErik | c7ef939 | 2011-10-27 14:11:44 -0700 | [diff] [blame] | 1811 | ALLOWED_ATTENDEE_TYPES, |
| 1812 | ALLOWED_AVAILABILITY, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1813 | CALENDAR_ACCESS_LEVEL, |
| 1814 | CALENDAR_COLOR, |
| 1815 | CALENDAR_TIME_ZONE, |
| 1816 | CAN_MODIFY_TIME_ZONE, |
| 1817 | CAN_ORGANIZER_RESPOND, |
| 1818 | CALENDAR_DISPLAY_NAME, |
Alon Albert | 866f40a | 2011-06-06 14:04:00 -0700 | [diff] [blame] | 1819 | CAN_PARTIALLY_UPDATE, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1820 | SYNC_EVENTS, |
| 1821 | VISIBLE, |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1822 | }; |
| 1823 | |
| 1824 | /** |
| 1825 | * These fields are only writable by a sync adapter. To modify them the |
| 1826 | * caller must include CALLER_IS_SYNCADAPTER, _SYNC_ACCOUNT, and |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 1827 | * _SYNC_ACCOUNT_TYPE in the query parameters. TODO move to provider. |
| 1828 | * |
| 1829 | * @hide |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1830 | */ |
| 1831 | public static final String[] SYNC_WRITABLE_COLUMNS = new String[] { |
| 1832 | _SYNC_ID, |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1833 | DIRTY, |
Alon Albert | 8ac6a63 | 2012-12-17 17:21:18 -0800 | [diff] [blame] | 1834 | MUTATORS, |
RoboErik | 9734df5 | 2011-06-09 14:11:25 -0700 | [diff] [blame] | 1835 | SYNC_DATA1, |
| 1836 | SYNC_DATA2, |
| 1837 | SYNC_DATA3, |
| 1838 | SYNC_DATA4, |
| 1839 | SYNC_DATA5, |
| 1840 | SYNC_DATA6, |
| 1841 | SYNC_DATA7, |
| 1842 | SYNC_DATA8, |
| 1843 | SYNC_DATA9, |
| 1844 | SYNC_DATA10, |
RoboErik | 651c02e | 2011-05-05 15:14:31 -0700 | [diff] [blame] | 1845 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1846 | } |
| 1847 | |
| 1848 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1849 | * Fields and helpers for interacting with Instances. An instance is a |
| 1850 | * single occurrence of an event including time zone specific start and end |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 1851 | * days and minutes. The instances table is not writable and only provides a |
| 1852 | * way to query event occurrences. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1853 | */ |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 1854 | public static final class Instances implements BaseColumns, EventsColumns, CalendarColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1855 | |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 1856 | private static final String WHERE_CALENDARS_SELECTED = Calendars.VISIBLE + "=?"; |
| 1857 | private static final String[] WHERE_CALENDARS_ARGS = { |
| 1858 | "1" |
| 1859 | }; |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1860 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1861 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 1862 | * This utility class cannot be instantiated |
| 1863 | */ |
| 1864 | private Instances() {} |
| 1865 | |
| 1866 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1867 | * Performs a query to return all visible instances in the given range. |
| 1868 | * This is a blocking function and should not be done on the UI thread. |
| 1869 | * This will cause an expansion of recurring events to fill this time |
| 1870 | * range if they are not already expanded and will slow down for larger |
| 1871 | * time ranges with many recurring events. |
| 1872 | * |
| 1873 | * @param cr The ContentResolver to use for the query |
| 1874 | * @param projection The columns to return |
| 1875 | * @param begin The start of the time range to query in UTC millis since |
| 1876 | * epoch |
| 1877 | * @param end The end of the time range to query in UTC millis since |
| 1878 | * epoch |
| 1879 | * @return A Cursor containing all instances in the given range |
| 1880 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1881 | public static final Cursor query(ContentResolver cr, String[] projection, |
| 1882 | long begin, long end) { |
| 1883 | Uri.Builder builder = CONTENT_URI.buildUpon(); |
| 1884 | ContentUris.appendId(builder, begin); |
| 1885 | ContentUris.appendId(builder, end); |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 1886 | return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED, |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 1887 | WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1888 | } |
| 1889 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1890 | /** |
| 1891 | * Performs a query to return all visible instances in the given range |
| 1892 | * that match the given query. This is a blocking function and should |
| 1893 | * not be done on the UI thread. This will cause an expansion of |
| 1894 | * recurring events to fill this time range if they are not already |
| 1895 | * expanded and will slow down for larger time ranges with many |
| 1896 | * recurring events. |
| 1897 | * |
| 1898 | * @param cr The ContentResolver to use for the query |
| 1899 | * @param projection The columns to return |
| 1900 | * @param begin The start of the time range to query in UTC millis since |
| 1901 | * epoch |
| 1902 | * @param end The end of the time range to query in UTC millis since |
| 1903 | * epoch |
| 1904 | * @param searchQuery A string of space separated search terms. Segments |
| 1905 | * enclosed by double quotes will be treated as a single |
| 1906 | * term. |
| 1907 | * @return A Cursor of instances matching the search terms in the given |
| 1908 | * time range |
| 1909 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1910 | public static final Cursor query(ContentResolver cr, String[] projection, |
Mason Tang | 19f8458 | 2010-07-08 18:01:41 -0700 | [diff] [blame] | 1911 | long begin, long end, String searchQuery) { |
| 1912 | Uri.Builder builder = CONTENT_SEARCH_URI.buildUpon(); |
| 1913 | ContentUris.appendId(builder, begin); |
| 1914 | ContentUris.appendId(builder, end); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1915 | builder = builder.appendPath(searchQuery); |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 1916 | return cr.query(builder.build(), projection, WHERE_CALENDARS_SELECTED, |
| 1917 | WHERE_CALENDARS_ARGS, DEFAULT_SORT_ORDER); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | /** |
| 1921 | * The content:// style URL for querying an instance range. The begin |
| 1922 | * and end of the range to query should be added as path segments if |
| 1923 | * this is used directly. |
| 1924 | */ |
| 1925 | @SuppressWarnings("hiding") |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 1926 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + |
| 1927 | "/instances/when"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1928 | /** |
| 1929 | * The content:// style URL for querying an instance range by Julian |
| 1930 | * Day. The start and end day should be added as path segments if this |
| 1931 | * is used directly. |
| 1932 | */ |
Michael Chan | 2cfb0d1 | 2009-06-30 18:11:23 -0700 | [diff] [blame] | 1933 | public static final Uri CONTENT_BY_DAY_URI = |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 1934 | Uri.parse("content://" + AUTHORITY + "/instances/whenbyday"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1935 | /** |
| 1936 | * The content:// style URL for querying an instance range with a search |
| 1937 | * term. The begin, end, and search string should be appended as path |
| 1938 | * segments if this is used directly. |
| 1939 | */ |
Mason Tang | 19f8458 | 2010-07-08 18:01:41 -0700 | [diff] [blame] | 1940 | public static final Uri CONTENT_SEARCH_URI = Uri.parse("content://" + AUTHORITY + |
| 1941 | "/instances/search"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 1942 | /** |
| 1943 | * The content:// style URL for querying an instance range with a search |
| 1944 | * term. The start day, end day, and search string should be appended as |
| 1945 | * path segments if this is used directly. |
| 1946 | */ |
Mason Tang | 19f8458 | 2010-07-08 18:01:41 -0700 | [diff] [blame] | 1947 | public static final Uri CONTENT_SEARCH_BY_DAY_URI = |
| 1948 | Uri.parse("content://" + AUTHORITY + "/instances/searchbyday"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1949 | |
| 1950 | /** |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1951 | * The content:// style URL for querying an instance range in the managed profile. |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1952 | * It supports similar semantics as {@link #CONTENT_URI}. |
| 1953 | * |
| 1954 | * <p>The following columns plus the columns that are whitelisted by |
| 1955 | * {@link Events#ENTERPRISE_CONTENT_URI} are allowed to be queried via this uri: |
| 1956 | * <ul> |
| 1957 | * <li>{@link #_ID}</li> |
| 1958 | * <li>{@link #EVENT_ID}</li> |
| 1959 | * <li>{@link #BEGIN}</li> |
| 1960 | * <li>{@link #END}</li> |
| 1961 | * <li>{@link #START_DAY}</li> |
| 1962 | * <li>{@link #END_DAY}</li> |
| 1963 | * <li>{@link #START_MINUTE}</li> |
| 1964 | * <li>{@link #END_MINUTE}</li> |
| 1965 | * </ul> |
| 1966 | * |
| 1967 | * <p>{@link IllegalArgumentException} will be thrown if there exist columns in the |
| 1968 | * projection of the query to this uri that are not contained in the above list. |
| 1969 | * |
| 1970 | * <p>This uri will return an empty cursor if the calling user is not a parent profile |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1971 | * of a managed profile, or cross profile calendar for the managed profile is disabled in |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1972 | * Settings, or this uri is queried from a package that is not whitelisted by |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1973 | * profile owner of the managed profile via |
Tor Norbye | 3332cd5 | 2018-12-09 09:28:46 -0800 | [diff] [blame] | 1974 | * {@link DevicePolicyManager#addCrossProfileCalendarPackage(ComponentName, String)}. |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1975 | * |
| 1976 | * @see DevicePolicyManager#getCrossProfileCalendarPackages(ComponentName) |
| 1977 | * @see Settings.Secure#CROSS_PROFILE_CALENDAR_ENABLED |
| 1978 | */ |
| 1979 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 1980 | Uri.parse("content://" + AUTHORITY + "/enterprise/instances/when"); |
| 1981 | |
| 1982 | /** |
| 1983 | * The content:// style URL for querying an instance range by Julian |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1984 | * Day in the managed profile. It supports similar semantics as {@link #CONTENT_BY_DAY_URI} |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1985 | * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}. |
| 1986 | */ |
| 1987 | public static final Uri ENTERPRISE_CONTENT_BY_DAY_URI = |
| 1988 | Uri.parse("content://" + AUTHORITY + "/enterprise/instances/whenbyday"); |
| 1989 | |
| 1990 | /** |
| 1991 | * The content:// style URL for querying an instance range with a search |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 1992 | * term in the managed profile. It supports similar semantics as {@link #CONTENT_SEARCH_URI} |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 1993 | * and performs similar checks as {@link #ENTERPRISE_CONTENT_URI}. |
| 1994 | */ |
| 1995 | public static final Uri ENTERPRISE_CONTENT_SEARCH_URI = |
| 1996 | Uri.parse("content://" + AUTHORITY + "/enterprise/instances/search"); |
| 1997 | |
| 1998 | /** |
| 1999 | * The content:// style URL for querying an instance range with a search |
yuemingw | 369f96d | 2018-12-05 22:07:04 +0000 | [diff] [blame] | 2000 | * term in the managed profile. It supports similar semantics as |
yuemingw | b714ba0 | 2018-10-26 18:54:44 +0100 | [diff] [blame] | 2001 | * {@link #CONTENT_SEARCH_BY_DAY_URI} and performs similar checks as |
| 2002 | * {@link #ENTERPRISE_CONTENT_URI}. |
| 2003 | */ |
| 2004 | public static final Uri ENTERPRISE_CONTENT_SEARCH_BY_DAY_URI = |
| 2005 | Uri.parse("content://" + AUTHORITY + "/enterprise/instances/searchbyday"); |
| 2006 | |
| 2007 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2008 | * The default sort order for this table. |
| 2009 | */ |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2010 | private static final String DEFAULT_SORT_ORDER = "begin ASC"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2011 | |
| 2012 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2013 | * The beginning time of the instance, in UTC milliseconds. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2014 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2015 | */ |
| 2016 | public static final String BEGIN = "begin"; |
| 2017 | |
| 2018 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2019 | * The ending time of the instance, in UTC milliseconds. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2020 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2021 | */ |
| 2022 | public static final String END = "end"; |
| 2023 | |
| 2024 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2025 | * The _id of the event for this instance. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2026 | * <P>Type: INTEGER (long, foreign key to the Events table)</P> |
| 2027 | */ |
| 2028 | public static final String EVENT_ID = "event_id"; |
| 2029 | |
| 2030 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2031 | * The Julian start day of the instance, relative to the local time |
| 2032 | * zone. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2033 | * <P>Type: INTEGER (int)</P> |
| 2034 | */ |
| 2035 | public static final String START_DAY = "startDay"; |
| 2036 | |
| 2037 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2038 | * The Julian end day of the instance, relative to the local time |
| 2039 | * zone. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2040 | * <P>Type: INTEGER (int)</P> |
| 2041 | */ |
| 2042 | public static final String END_DAY = "endDay"; |
| 2043 | |
| 2044 | /** |
| 2045 | * The start minute of the instance measured from midnight in the |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2046 | * local time zone. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2047 | * <P>Type: INTEGER (int)</P> |
| 2048 | */ |
| 2049 | public static final String START_MINUTE = "startMinute"; |
| 2050 | |
| 2051 | /** |
| 2052 | * The end minute of the instance measured from midnight in the |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2053 | * local time zone. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2054 | * <P>Type: INTEGER (int)</P> |
| 2055 | */ |
| 2056 | public static final String END_MINUTE = "endMinute"; |
| 2057 | } |
| 2058 | |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2059 | protected interface CalendarCacheColumns { |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2060 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2061 | * The key for the setting. Keys are defined in {@link CalendarCache}. |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2062 | */ |
| 2063 | public static final String KEY = "key"; |
| 2064 | |
| 2065 | /** |
| 2066 | * The value of the given setting. |
| 2067 | */ |
| 2068 | public static final String VALUE = "value"; |
| 2069 | } |
| 2070 | |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2071 | /** |
| 2072 | * CalendarCache stores some settings for calendar including the current |
| 2073 | * time zone for the instances. These settings are stored using a key/value |
| 2074 | * scheme. A {@link #KEY} must be specified when updating these values. |
| 2075 | */ |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2076 | public static final class CalendarCache implements CalendarCacheColumns { |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2077 | /** |
| 2078 | * The URI to use for retrieving the properties from the Calendar db. |
| 2079 | */ |
| 2080 | public static final Uri URI = |
| 2081 | Uri.parse("content://" + AUTHORITY + "/properties"); |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2082 | |
| 2083 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2084 | * This utility class cannot be instantiated |
| 2085 | */ |
| 2086 | private CalendarCache() {} |
| 2087 | |
| 2088 | /** |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2089 | * They key for updating the use of auto/home time zones in Calendar. |
| 2090 | * Valid values are {@link #TIMEZONE_TYPE_AUTO} or |
| 2091 | * {@link #TIMEZONE_TYPE_HOME}. |
| 2092 | */ |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2093 | public static final String KEY_TIMEZONE_TYPE = "timezoneType"; |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2094 | |
| 2095 | /** |
| 2096 | * The key for updating the time zone used by the provider when it |
| 2097 | * generates the instances table. This should only be written if the |
| 2098 | * type is set to {@link #TIMEZONE_TYPE_HOME}. A valid time zone id |
| 2099 | * should be written to this field. |
| 2100 | */ |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2101 | public static final String KEY_TIMEZONE_INSTANCES = "timezoneInstances"; |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2102 | |
| 2103 | /** |
| 2104 | * The key for reading the last time zone set by the user. This should |
| 2105 | * only be read by apps and it will be automatically updated whenever |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2106 | * {@link #KEY_TIMEZONE_INSTANCES} is updated with |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2107 | * {@link #TIMEZONE_TYPE_HOME} set. |
| 2108 | */ |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2109 | public static final String KEY_TIMEZONE_INSTANCES_PREVIOUS = "timezoneInstancesPrevious"; |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2110 | |
| 2111 | /** |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2112 | * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2113 | * should stay in sync with the device's time zone. |
| 2114 | */ |
| 2115 | public static final String TIMEZONE_TYPE_AUTO = "auto"; |
| 2116 | |
| 2117 | /** |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2118 | * The value to write to {@link #KEY_TIMEZONE_TYPE} if the provider |
Erik | 71ad58c | 2010-09-13 16:41:35 -0700 | [diff] [blame] | 2119 | * should use a fixed time zone set by the user. |
| 2120 | */ |
| 2121 | public static final String TIMEZONE_TYPE_HOME = "home"; |
| 2122 | } |
| 2123 | |
| 2124 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2125 | * A few Calendar globals are needed in the CalendarProvider for expanding |
RoboErik | 59dab49 | 2011-06-17 11:09:36 -0700 | [diff] [blame] | 2126 | * the Instances table and these are all stored in the first (and only) row |
| 2127 | * of the CalendarMetaData table. |
| 2128 | * |
| 2129 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2130 | */ |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2131 | protected interface CalendarMetaDataColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2132 | /** |
| 2133 | * The local timezone that was used for precomputing the fields |
| 2134 | * in the Instances table. |
| 2135 | */ |
| 2136 | public static final String LOCAL_TIMEZONE = "localTimezone"; |
| 2137 | |
| 2138 | /** |
| 2139 | * The minimum time used in expanding the Instances table, |
| 2140 | * in UTC milliseconds. |
| 2141 | * <P>Type: INTEGER</P> |
| 2142 | */ |
| 2143 | public static final String MIN_INSTANCE = "minInstance"; |
| 2144 | |
| 2145 | /** |
| 2146 | * The maximum time used in expanding the Instances table, |
| 2147 | * in UTC milliseconds. |
| 2148 | * <P>Type: INTEGER</P> |
| 2149 | */ |
| 2150 | public static final String MAX_INSTANCE = "maxInstance"; |
| 2151 | |
| 2152 | /** |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2153 | * The minimum Julian day in the EventDays table. |
| 2154 | * <P>Type: INTEGER</P> |
| 2155 | */ |
| 2156 | public static final String MIN_EVENTDAYS = "minEventDays"; |
| 2157 | |
| 2158 | /** |
| 2159 | * The maximum Julian day in the EventDays table. |
| 2160 | * <P>Type: INTEGER</P> |
| 2161 | */ |
| 2162 | public static final String MAX_EVENTDAYS = "maxEventDays"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2163 | } |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2164 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2165 | /** |
| 2166 | * @hide |
| 2167 | */ |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2168 | public static final class CalendarMetaData implements CalendarMetaDataColumns, BaseColumns { |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2169 | |
| 2170 | /** |
| 2171 | * This utility class cannot be instantiated |
| 2172 | */ |
| 2173 | private CalendarMetaData() {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2174 | } |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2175 | |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2176 | protected interface EventDaysColumns { |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2177 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2178 | * The Julian starting day number. Column name. |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2179 | * <P>Type: INTEGER (int)</P> |
| 2180 | */ |
| 2181 | public static final String STARTDAY = "startDay"; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2182 | /** |
| 2183 | * The Julian ending day number. Column name. |
| 2184 | * <P>Type: INTEGER (int)</P> |
| 2185 | */ |
Erik | bd8e2e2 | 2010-01-07 11:56:46 -0800 | [diff] [blame] | 2186 | public static final String ENDDAY = "endDay"; |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2187 | |
| 2188 | } |
| 2189 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2190 | /** |
| 2191 | * Fields and helpers for querying for a list of days that contain events. |
| 2192 | */ |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2193 | public static final class EventDays implements EventDaysColumns { |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2194 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2195 | + "/instances/groupbyday"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2196 | private static final String SELECTION = "selected=1"; |
| 2197 | |
| 2198 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2199 | * This utility class cannot be instantiated |
| 2200 | */ |
| 2201 | private EventDays() {} |
| 2202 | |
| 2203 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2204 | * Retrieves the days with events for the Julian days starting at |
| 2205 | * "startDay" for "numDays". It returns a cursor containing startday and |
| 2206 | * endday representing the max range of days for all events beginning on |
| 2207 | * each startday.This is a blocking function and should not be done on |
| 2208 | * the UI thread. |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2209 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2210 | * @param cr the ContentResolver |
| 2211 | * @param startDay the first Julian day in the range |
| 2212 | * @param numDays the number of days to load (must be at least 1) |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2213 | * @param projection the columns to return in the cursor |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2214 | * @return a database cursor containing a list of start and end days for |
| 2215 | * events |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2216 | */ |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2217 | public static final Cursor query(ContentResolver cr, int startDay, int numDays, |
| 2218 | String[] projection) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2219 | if (numDays < 1) { |
| 2220 | return null; |
| 2221 | } |
| 2222 | int endDay = startDay + numDays - 1; |
| 2223 | Uri.Builder builder = CONTENT_URI.buildUpon(); |
| 2224 | ContentUris.appendId(builder, startDay); |
| 2225 | ContentUris.appendId(builder, endDay); |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2226 | return cr.query(builder.build(), projection, SELECTION, |
Erik | 3763464 | 2009-12-23 15:24:14 -0800 | [diff] [blame] | 2227 | null /* selection args */, STARTDAY); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2228 | } |
| 2229 | } |
| 2230 | |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2231 | protected interface RemindersColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2232 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2233 | * The event the reminder belongs to. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2234 | * <P>Type: INTEGER (foreign key to the Events table)</P> |
| 2235 | */ |
| 2236 | public static final String EVENT_ID = "event_id"; |
| 2237 | |
| 2238 | /** |
| 2239 | * The minutes prior to the event that the alarm should ring. -1 |
| 2240 | * specifies that we should use the default value for the system. |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2241 | * Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2242 | * <P>Type: INTEGER</P> |
| 2243 | */ |
| 2244 | public static final String MINUTES = "minutes"; |
| 2245 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2246 | /** |
| 2247 | * Passing this as a minutes value will use the default reminder |
| 2248 | * minutes. |
| 2249 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2250 | public static final int MINUTES_DEFAULT = -1; |
| 2251 | |
| 2252 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2253 | * The alarm method, as set on the server. {@link #METHOD_DEFAULT}, |
Alon Albert | bd25161 | 2012-02-23 10:30:51 -0800 | [diff] [blame] | 2254 | * {@link #METHOD_ALERT}, {@link #METHOD_EMAIL}, {@link #METHOD_SMS} and |
| 2255 | * {@link #METHOD_ALARM} are possible values; the device will only |
| 2256 | * process {@link #METHOD_DEFAULT} and {@link #METHOD_ALERT} reminders |
| 2257 | * (the other types are simply stored so we can send the same reminder |
| 2258 | * info back to the server when we make changes). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2259 | */ |
| 2260 | public static final String METHOD = "method"; |
| 2261 | |
| 2262 | public static final int METHOD_DEFAULT = 0; |
| 2263 | public static final int METHOD_ALERT = 1; |
| 2264 | public static final int METHOD_EMAIL = 2; |
| 2265 | public static final int METHOD_SMS = 3; |
Alon Albert | bd25161 | 2012-02-23 10:30:51 -0800 | [diff] [blame] | 2266 | public static final int METHOD_ALARM = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2267 | } |
| 2268 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2269 | /** |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2270 | * Fields and helpers for accessing reminders for an event. Each row of this |
| 2271 | * table represents a single reminder for an event. Calling |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2272 | * {@link #query(ContentResolver, long, String[])} will return a list of reminders for |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2273 | * the event with the given eventId. Both apps and sync adapters may write |
| 2274 | * to this table. There are three writable fields and all of them must be |
| 2275 | * included when inserting a new reminder. They are: |
| 2276 | * <ul> |
| 2277 | * <li>{@link #EVENT_ID}</li> |
| 2278 | * <li>{@link #MINUTES}</li> |
| 2279 | * <li>{@link #METHOD}</li> |
| 2280 | * </ul> |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2281 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2282 | public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns { |
RoboErik | bec6c36 | 2011-06-14 11:06:01 -0700 | [diff] [blame] | 2283 | private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?"; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2284 | @SuppressWarnings("hiding") |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 2285 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders"); |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2286 | |
| 2287 | /** |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2288 | * This utility class cannot be instantiated |
| 2289 | */ |
| 2290 | private Reminders() {} |
| 2291 | |
| 2292 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2293 | * Queries all reminders associated with the given event. This is a |
| 2294 | * blocking call and should not be done on the UI thread. |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2295 | * |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2296 | * @param cr The content resolver to use for the query |
| 2297 | * @param eventId The id of the event to retrieve reminders for |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2298 | * @param projection the columns to return in the cursor |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2299 | * @return A Cursor containing all reminders for the event |
| 2300 | */ |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2301 | public static final Cursor query(ContentResolver cr, long eventId, String[] projection) { |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2302 | String[] remArgs = {Long.toString(eventId)}; |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2303 | return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2304 | null /* sort order */); |
| 2305 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2306 | } |
| 2307 | |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2308 | protected interface CalendarAlertsColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2309 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2310 | * The event that the alert belongs to. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2311 | * <P>Type: INTEGER (foreign key to the Events table)</P> |
| 2312 | */ |
| 2313 | public static final String EVENT_ID = "event_id"; |
| 2314 | |
| 2315 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2316 | * The start time of the event, in UTC. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2317 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2318 | */ |
| 2319 | public static final String BEGIN = "begin"; |
| 2320 | |
| 2321 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2322 | * The end time of the event, in UTC. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2323 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2324 | */ |
| 2325 | public static final String END = "end"; |
| 2326 | |
| 2327 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2328 | * The alarm time of the event, in UTC. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2329 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2330 | */ |
| 2331 | public static final String ALARM_TIME = "alarmTime"; |
| 2332 | |
| 2333 | /** |
| 2334 | * The creation time of this database entry, in UTC. |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2335 | * Useful for debugging missed reminders. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2336 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2337 | */ |
| 2338 | public static final String CREATION_TIME = "creationTime"; |
| 2339 | |
| 2340 | /** |
| 2341 | * The time that the alarm broadcast was received by the Calendar app, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2342 | * in UTC. Useful for debugging missed reminders. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2343 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2344 | */ |
| 2345 | public static final String RECEIVED_TIME = "receivedTime"; |
| 2346 | |
| 2347 | /** |
| 2348 | * The time that the notification was created by the Calendar app, |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2349 | * in UTC. Useful for debugging missed reminders. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2350 | * <P>Type: INTEGER (long; millis since epoch)</P> |
| 2351 | */ |
| 2352 | public static final String NOTIFY_TIME = "notifyTime"; |
| 2353 | |
| 2354 | /** |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2355 | * The state of this alert. It starts out as {@link #STATE_SCHEDULED}, then |
| 2356 | * when the alarm goes off, it changes to {@link #STATE_FIRED}, and then when |
| 2357 | * the user dismisses the alarm it changes to {@link #STATE_DISMISSED}. Column |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2358 | * name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2359 | * <P>Type: INTEGER</P> |
| 2360 | */ |
| 2361 | public static final String STATE = "state"; |
| 2362 | |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2363 | /** |
| 2364 | * An alert begins in this state when it is first created. |
| 2365 | */ |
| 2366 | public static final int STATE_SCHEDULED = 0; |
| 2367 | /** |
| 2368 | * After a notification for an alert has been created it should be |
| 2369 | * updated to fired. |
| 2370 | */ |
| 2371 | public static final int STATE_FIRED = 1; |
| 2372 | /** |
| 2373 | * Once the user has dismissed the notification the alert's state should |
| 2374 | * be set to dismissed so it is not fired again. |
| 2375 | */ |
| 2376 | public static final int STATE_DISMISSED = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2377 | |
| 2378 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2379 | * The number of minutes that this alarm precedes the start time. Column |
| 2380 | * name. |
| 2381 | * <P>Type: INTEGER</P> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2382 | */ |
| 2383 | public static final String MINUTES = "minutes"; |
| 2384 | |
| 2385 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2386 | * The default sort order for this alerts queries |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2387 | */ |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2388 | public static final String DEFAULT_SORT_ORDER = "begin ASC,title ASC"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2389 | } |
| 2390 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2391 | /** |
| 2392 | * Fields and helpers for accessing calendar alerts information. These |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2393 | * fields are for tracking which alerts have been fired. Scheduled alarms |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 2394 | * will generate an intent using {@link #ACTION_EVENT_REMINDER}. Apps that |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2395 | * receive this action may update the {@link #STATE} for the reminder when |
| 2396 | * they have finished handling it. Apps that have their notifications |
| 2397 | * disabled should not modify the table to ensure that they do not conflict |
| 2398 | * with another app that is generating a notification. In general, apps |
| 2399 | * should not need to write to this table directly except to update the |
| 2400 | * state of a reminder. |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2401 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2402 | public static final class CalendarAlerts implements BaseColumns, |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 2403 | CalendarAlertsColumns, EventsColumns, CalendarColumns { |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2404 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2405 | /** |
| 2406 | * @hide |
| 2407 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2408 | public static final String TABLE_NAME = "CalendarAlerts"; |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2409 | /** |
| 2410 | * The Uri for querying calendar alert information |
| 2411 | */ |
| 2412 | @SuppressWarnings("hiding") |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 2413 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + |
| 2414 | "/calendar_alerts"); |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2415 | |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2416 | /** |
| 2417 | * This utility class cannot be instantiated |
| 2418 | */ |
| 2419 | private CalendarAlerts() {} |
| 2420 | |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2421 | private static final String WHERE_ALARM_EXISTS = EVENT_ID + "=?" |
| 2422 | + " AND " + BEGIN + "=?" |
| 2423 | + " AND " + ALARM_TIME + "=?"; |
| 2424 | |
| 2425 | private static final String WHERE_FINDNEXTALARMTIME = ALARM_TIME + ">=?"; |
| 2426 | private static final String SORT_ORDER_ALARMTIME_ASC = ALARM_TIME + " ASC"; |
| 2427 | |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2428 | private static final String WHERE_RESCHEDULE_MISSED_ALARMS = STATE + "=" + STATE_SCHEDULED |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2429 | + " AND " + ALARM_TIME + "<?" |
| 2430 | + " AND " + ALARM_TIME + ">?" |
| 2431 | + " AND " + END + ">=?"; |
| 2432 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2433 | /** |
| 2434 | * This URI is for grouping the query results by event_id and begin |
| 2435 | * time. This will return one result per instance of an event. So |
| 2436 | * events with multiple alarms will appear just once, but multiple |
| 2437 | * instances of a repeating event will show up multiple times. |
| 2438 | */ |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2439 | public static final Uri CONTENT_URI_BY_INSTANCE = |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 2440 | Uri.parse("content://" + AUTHORITY + "/calendar_alerts/by_instance"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2441 | |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2442 | private static final boolean DEBUG = false; |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2443 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2444 | /** |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2445 | * Helper for inserting an alarm time associated with an event TODO move |
| 2446 | * to Provider |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2447 | * |
| 2448 | * @hide |
| 2449 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2450 | public static final Uri insert(ContentResolver cr, long eventId, |
| 2451 | long begin, long end, long alarmTime, int minutes) { |
| 2452 | ContentValues values = new ContentValues(); |
| 2453 | values.put(CalendarAlerts.EVENT_ID, eventId); |
| 2454 | values.put(CalendarAlerts.BEGIN, begin); |
| 2455 | values.put(CalendarAlerts.END, end); |
| 2456 | values.put(CalendarAlerts.ALARM_TIME, alarmTime); |
| 2457 | long currentTime = System.currentTimeMillis(); |
| 2458 | values.put(CalendarAlerts.CREATION_TIME, currentTime); |
| 2459 | values.put(CalendarAlerts.RECEIVED_TIME, 0); |
| 2460 | values.put(CalendarAlerts.NOTIFY_TIME, 0); |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2461 | values.put(CalendarAlerts.STATE, STATE_SCHEDULED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2462 | values.put(CalendarAlerts.MINUTES, minutes); |
| 2463 | return cr.insert(CONTENT_URI, values); |
| 2464 | } |
| 2465 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2466 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2467 | * Finds the next alarm after (or equal to) the given time and returns |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2468 | * the time of that alarm or -1 if no such alarm exists. This is a |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2469 | * blocking call and should not be done on the UI thread. TODO move to |
| 2470 | * provider |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2471 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2472 | * @param cr the ContentResolver |
| 2473 | * @param millis the time in UTC milliseconds |
| 2474 | * @return the next alarm time greater than or equal to "millis", or -1 |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2475 | * if no such alarm exists. |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2476 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2477 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 2478 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2479 | public static final long findNextAlarmTime(ContentResolver cr, long millis) { |
| 2480 | String selection = ALARM_TIME + ">=" + millis; |
| 2481 | // TODO: construct an explicit SQL query so that we can add |
| 2482 | // "LIMIT 1" to the end and get just one result. |
| 2483 | String[] projection = new String[] { ALARM_TIME }; |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2484 | Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_FINDNEXTALARMTIME, |
| 2485 | (new String[] { |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2486 | Long.toString(millis) |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2487 | }), SORT_ORDER_ALARMTIME_ASC); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2488 | long alarmTime = -1; |
| 2489 | try { |
| 2490 | if (cursor != null && cursor.moveToFirst()) { |
| 2491 | alarmTime = cursor.getLong(0); |
| 2492 | } |
| 2493 | } finally { |
| 2494 | if (cursor != null) { |
| 2495 | cursor.close(); |
| 2496 | } |
| 2497 | } |
| 2498 | return alarmTime; |
| 2499 | } |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2500 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2501 | /** |
| 2502 | * Searches the CalendarAlerts table for alarms that should have fired |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2503 | * but have not and then reschedules them. This method can be called at |
| 2504 | * boot time to restore alarms that may have been lost due to a phone |
| 2505 | * reboot. TODO move to provider |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2506 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2507 | * @param cr the ContentResolver |
| 2508 | * @param context the Context |
| 2509 | * @param manager the AlarmManager |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2510 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2511 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 2512 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2513 | public static final void rescheduleMissedAlarms(ContentResolver cr, |
| 2514 | Context context, AlarmManager manager) { |
| 2515 | // Get all the alerts that have been scheduled but have not fired |
| 2516 | // and should have fired by now and are not too old. |
| 2517 | long now = System.currentTimeMillis(); |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2518 | long ancient = now - DateUtils.DAY_IN_MILLIS; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2519 | String[] projection = new String[] { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2520 | ALARM_TIME, |
| 2521 | }; |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2522 | |
| 2523 | // TODO: construct an explicit SQL query so that we can add |
| 2524 | // "GROUPBY" instead of doing a sort and de-dup |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2525 | Cursor cursor = cr.query(CalendarAlerts.CONTENT_URI, projection, |
| 2526 | WHERE_RESCHEDULE_MISSED_ALARMS, (new String[] { |
| 2527 | Long.toString(now), Long.toString(ancient), Long.toString(now) |
| 2528 | }), SORT_ORDER_ALARMTIME_ASC); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2529 | if (cursor == null) { |
| 2530 | return; |
| 2531 | } |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2532 | |
| 2533 | if (DEBUG) { |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2534 | Log.d(TAG, "missed alarms found: " + cursor.getCount()); |
| 2535 | } |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2536 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2537 | try { |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2538 | long alarmTime = -1; |
| 2539 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2540 | while (cursor.moveToNext()) { |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2541 | long newAlarmTime = cursor.getLong(0); |
| 2542 | if (alarmTime != newAlarmTime) { |
| 2543 | if (DEBUG) { |
| 2544 | Log.w(TAG, "rescheduling missed alarm. alarmTime: " + newAlarmTime); |
| 2545 | } |
| 2546 | scheduleAlarm(context, manager, newAlarmTime); |
| 2547 | alarmTime = newAlarmTime; |
| 2548 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2549 | } |
| 2550 | } finally { |
| 2551 | cursor.close(); |
| 2552 | } |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2553 | } |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2554 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2555 | /** |
| 2556 | * Schedules an alarm intent with the system AlarmManager that will |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2557 | * notify listeners when a reminder should be fired. The provider will |
| 2558 | * keep scheduled reminders up to date but apps may use this to |
| 2559 | * implement snooze functionality without modifying the reminders table. |
| 2560 | * Scheduled alarms will generate an intent using |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2561 | * {@link #ACTION_EVENT_REMINDER}. TODO Move to provider |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2562 | * |
| 2563 | * @param context A context for referencing system resources |
| 2564 | * @param manager The AlarmManager to use or null |
| 2565 | * @param alarmTime The time to fire the intent in UTC millis since |
| 2566 | * epoch |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2567 | * @hide |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2568 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 2569 | @UnsupportedAppUsage |
Michael Chan | cdaeafd | 2009-10-29 00:11:58 -0700 | [diff] [blame] | 2570 | public static void scheduleAlarm(Context context, AlarmManager manager, long alarmTime) { |
| 2571 | if (DEBUG) { |
| 2572 | Time time = new Time(); |
| 2573 | time.set(alarmTime); |
| 2574 | String schedTime = time.format(" %a, %b %d, %Y %I:%M%P"); |
| 2575 | Log.d(TAG, "Schedule alarm at " + alarmTime + " " + schedTime); |
| 2576 | } |
| 2577 | |
| 2578 | if (manager == null) { |
| 2579 | manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); |
| 2580 | } |
| 2581 | |
RoboErik | e00d589 | 2011-06-23 15:16:55 -0700 | [diff] [blame] | 2582 | Intent intent = new Intent(ACTION_EVENT_REMINDER); |
RoboErik | bec6c36 | 2011-06-14 11:06:01 -0700 | [diff] [blame] | 2583 | intent.setData(ContentUris.withAppendedId(CalendarContract.CONTENT_URI, alarmTime)); |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2584 | intent.putExtra(ALARM_TIME, alarmTime); |
Makoto Onuki | b63830a | 2017-02-09 17:06:28 -0800 | [diff] [blame] | 2585 | intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
Erik | 42f1957 | 2010-03-17 16:17:22 -0700 | [diff] [blame] | 2586 | PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); |
Tony Mak | faf96ebc | 2015-07-02 17:05:35 +0100 | [diff] [blame] | 2587 | manager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, pi); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2588 | } |
Ken Shirriff | 5b387e1 | 2009-10-23 09:50:41 -0700 | [diff] [blame] | 2589 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2590 | /** |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2591 | * Searches for an entry in the CalendarAlerts table that matches the |
| 2592 | * given event id, begin time and alarm time. If one is found then this |
| 2593 | * alarm already exists and this method returns true. TODO Move to |
| 2594 | * provider |
RoboErik | 5864402 | 2011-07-08 13:39:05 -0700 | [diff] [blame] | 2595 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2596 | * @param cr the ContentResolver |
| 2597 | * @param eventId the event id to match |
| 2598 | * @param begin the start time of the event in UTC millis |
| 2599 | * @param alarmTime the alarm time of the event in UTC millis |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2600 | * @return true if there is already an alarm for the given event with |
| 2601 | * the same start time and alarm time. |
| 2602 | * @hide |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2603 | */ |
| 2604 | public static final boolean alarmExists(ContentResolver cr, long eventId, |
| 2605 | long begin, long alarmTime) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2606 | // TODO: construct an explicit SQL query so that we can add |
| 2607 | // "LIMIT 1" to the end and get just one result. |
Fabrice Di Meglio | 1dfc8a2 | 2010-03-10 17:49:46 -0800 | [diff] [blame] | 2608 | String[] projection = new String[] { ALARM_TIME }; |
RoboErik | 083cd2d | 2011-06-30 11:53:05 -0700 | [diff] [blame] | 2609 | Cursor cursor = cr.query(CONTENT_URI, projection, WHERE_ALARM_EXISTS, |
| 2610 | (new String[] { |
| 2611 | Long.toString(eventId), Long.toString(begin), Long.toString(alarmTime) |
| 2612 | }), null); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2613 | boolean found = false; |
| 2614 | try { |
| 2615 | if (cursor != null && cursor.getCount() > 0) { |
| 2616 | found = true; |
| 2617 | } |
| 2618 | } finally { |
| 2619 | if (cursor != null) { |
| 2620 | cursor.close(); |
| 2621 | } |
| 2622 | } |
| 2623 | return found; |
| 2624 | } |
| 2625 | } |
| 2626 | |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2627 | protected interface ColorsColumns extends SyncStateContract.Columns { |
| 2628 | |
| 2629 | /** |
| 2630 | * The type of color, which describes how it should be used. Valid types |
| 2631 | * are {@link #TYPE_CALENDAR} and {@link #TYPE_EVENT}. Column name. |
| 2632 | * <P> |
| 2633 | * Type: INTEGER (NOT NULL) |
| 2634 | * </P> |
| 2635 | */ |
| 2636 | public static final String COLOR_TYPE = "color_type"; |
| 2637 | |
| 2638 | /** |
| 2639 | * This indicateds a color that can be used for calendars. |
| 2640 | */ |
| 2641 | public static final int TYPE_CALENDAR = 0; |
| 2642 | /** |
| 2643 | * This indicates a color that can be used for events. |
| 2644 | */ |
| 2645 | public static final int TYPE_EVENT = 1; |
| 2646 | |
| 2647 | /** |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 2648 | * The key used to reference this color. This can be any non-empty |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2649 | * string, but must be unique for a given {@link #ACCOUNT_TYPE} and |
RoboErik | 8a8eebc | 2011-10-20 16:57:18 -0700 | [diff] [blame] | 2650 | * {@link #ACCOUNT_NAME}. Column name. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2651 | * <P> |
| 2652 | * Type: TEXT |
| 2653 | * </P> |
| 2654 | */ |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 2655 | public static final String COLOR_KEY = "color_index"; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2656 | |
| 2657 | /** |
RoboErik | 05b36e5 | 2011-10-14 15:31:15 -0700 | [diff] [blame] | 2658 | * The color as an 8-bit ARGB integer value. Colors should specify alpha |
| 2659 | * as fully opaque (eg 0xFF993322) as the alpha may be ignored or |
| 2660 | * modified for display. It is reccomended that colors be usable with |
| 2661 | * light (near white) text. Apps should not depend on that assumption, |
| 2662 | * however. Column name. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2663 | * <P> |
| 2664 | * Type: INTEGER (NOT NULL) |
| 2665 | * </P> |
| 2666 | */ |
RoboErik | 05b36e5 | 2011-10-14 15:31:15 -0700 | [diff] [blame] | 2667 | public static final String COLOR = "color"; |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2668 | |
| 2669 | } |
| 2670 | |
| 2671 | /** |
| 2672 | * Fields for accessing colors available for a given account. Colors are |
RoboErik | 4172d95 | 2011-10-25 13:59:13 -0700 | [diff] [blame] | 2673 | * referenced by {@link #COLOR_KEY} which must be unique for a given |
RoboErik | 0c559c6 | 2011-10-21 11:20:51 -0700 | [diff] [blame] | 2674 | * account name/type. These values can only be updated by the sync |
RoboErik | 8a8eebc | 2011-10-20 16:57:18 -0700 | [diff] [blame] | 2675 | * adapter. Only {@link #COLOR} may be updated after the initial insert. In |
| 2676 | * addition, a row can only be deleted once all references to that color |
| 2677 | * have been removed from the {@link Calendars} or {@link Events} tables. |
RoboErik | f8143c5 | 2011-09-28 15:16:00 -0700 | [diff] [blame] | 2678 | */ |
| 2679 | public static final class Colors implements ColorsColumns { |
| 2680 | /** |
| 2681 | * @hide |
| 2682 | */ |
| 2683 | public static final String TABLE_NAME = "Colors"; |
| 2684 | /** |
| 2685 | * The Uri for querying color information |
| 2686 | */ |
| 2687 | @SuppressWarnings("hiding") |
| 2688 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/colors"); |
| 2689 | |
| 2690 | /** |
| 2691 | * This utility class cannot be instantiated |
| 2692 | */ |
| 2693 | private Colors() { |
| 2694 | } |
| 2695 | } |
| 2696 | |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2697 | protected interface ExtendedPropertiesColumns { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2698 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2699 | * The event the extended property belongs to. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2700 | * <P>Type: INTEGER (foreign key to the Events table)</P> |
| 2701 | */ |
| 2702 | public static final String EVENT_ID = "event_id"; |
| 2703 | |
| 2704 | /** |
| 2705 | * The name of the extended property. This is a uri of the form |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2706 | * {scheme}#{local-name} convention. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2707 | * <P>Type: TEXT</P> |
| 2708 | */ |
| 2709 | public static final String NAME = "name"; |
| 2710 | |
| 2711 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2712 | * The value of the extended property. Column name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2713 | * <P>Type: TEXT</P> |
| 2714 | */ |
| 2715 | public static final String VALUE = "value"; |
| 2716 | } |
| 2717 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2718 | /** |
| 2719 | * Fields for accessing the Extended Properties. This is a generic set of |
Michael Chan | 73bddfc | 2011-10-19 18:21:49 -0700 | [diff] [blame] | 2720 | * name/value pairs for use by sync adapters to add extra |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2721 | * information to events. There are three writable columns and all three |
| 2722 | * must be present when inserting a new value. They are: |
| 2723 | * <ul> |
| 2724 | * <li>{@link #EVENT_ID}</li> |
| 2725 | * <li>{@link #NAME}</li> |
| 2726 | * <li>{@link #VALUE}</li> |
| 2727 | * </ul> |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2728 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2729 | public static final class ExtendedProperties implements BaseColumns, |
| 2730 | ExtendedPropertiesColumns, EventsColumns { |
| 2731 | public static final Uri CONTENT_URI = |
Ken Shirriff | a69a23b | 2010-01-21 17:32:39 -0800 | [diff] [blame] | 2732 | Uri.parse("content://" + AUTHORITY + "/extendedproperties"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2733 | |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2734 | /** |
| 2735 | * This utility class cannot be instantiated |
| 2736 | */ |
| 2737 | private ExtendedProperties() {} |
| 2738 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2739 | // TODO: fill out this class when we actually start utilizing extendedproperties |
| 2740 | // in the calendar application. |
| 2741 | } |
Ken Shirriff | ead4f9c | 2010-01-22 12:26:02 -0800 | [diff] [blame] | 2742 | |
| 2743 | /** |
| 2744 | * A table provided for sync adapters to use for storing private sync state data. |
| 2745 | * |
| 2746 | * @see SyncStateContract |
| 2747 | */ |
| 2748 | public static final class SyncState implements SyncStateContract.Columns { |
| 2749 | /** |
| 2750 | * This utility class cannot be instantiated |
| 2751 | */ |
| 2752 | private SyncState() {} |
| 2753 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2754 | private static final String CONTENT_DIRECTORY = |
Ken Shirriff | ead4f9c | 2010-01-22 12:26:02 -0800 | [diff] [blame] | 2755 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 2756 | |
| 2757 | /** |
| 2758 | * The content:// style URI for this table |
| 2759 | */ |
| 2760 | public static final Uri CONTENT_URI = |
RoboErik | bec6c36 | 2011-06-14 11:06:01 -0700 | [diff] [blame] | 2761 | Uri.withAppendedPath(CalendarContract.CONTENT_URI, CONTENT_DIRECTORY); |
Ken Shirriff | ead4f9c | 2010-01-22 12:26:02 -0800 | [diff] [blame] | 2762 | } |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2763 | |
| 2764 | /** |
| 2765 | * Columns from the EventsRawTimes table |
RoboErik | 3771fcb | 2011-06-16 15:41:31 -0700 | [diff] [blame] | 2766 | * |
| 2767 | * @hide |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2768 | */ |
RoboErik | b2c7560 | 2011-06-13 12:53:48 -0700 | [diff] [blame] | 2769 | protected interface EventsRawTimesColumns { |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2770 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2771 | * The corresponding event id. Column name. |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2772 | * <P>Type: INTEGER (long)</P> |
| 2773 | */ |
| 2774 | public static final String EVENT_ID = "event_id"; |
| 2775 | |
| 2776 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2777 | * The RFC2445 compliant time the event starts. Column name. |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2778 | * <P>Type: TEXT</P> |
| 2779 | */ |
| 2780 | public static final String DTSTART_2445 = "dtstart2445"; |
| 2781 | |
| 2782 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2783 | * The RFC2445 compliant time the event ends. Column name. |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2784 | * <P>Type: TEXT</P> |
| 2785 | */ |
| 2786 | public static final String DTEND_2445 = "dtend2445"; |
| 2787 | |
| 2788 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2789 | * The RFC2445 compliant original instance time of the recurring event |
| 2790 | * for which this event is an exception. Column name. |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2791 | * <P>Type: TEXT</P> |
| 2792 | */ |
| 2793 | public static final String ORIGINAL_INSTANCE_TIME_2445 = "originalInstanceTime2445"; |
| 2794 | |
| 2795 | /** |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2796 | * The RFC2445 compliant last date this event repeats on, or NULL if it |
| 2797 | * never ends. Column name. |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2798 | * <P>Type: TEXT</P> |
| 2799 | */ |
| 2800 | public static final String LAST_DATE_2445 = "lastDate2445"; |
| 2801 | } |
| 2802 | |
RoboErik | c2d5330 | 2011-06-03 09:37:58 -0700 | [diff] [blame] | 2803 | /** |
| 2804 | * @hide |
| 2805 | */ |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2806 | public static final class EventsRawTimes implements BaseColumns, EventsRawTimesColumns { |
RoboErik | 3672696 | 2011-06-14 14:01:15 -0700 | [diff] [blame] | 2807 | |
| 2808 | /** |
| 2809 | * This utility class cannot be instantiated |
| 2810 | */ |
| 2811 | private EventsRawTimes() {} |
Fabrice Di Meglio | 5056355 | 2010-06-15 16:35:20 -0700 | [diff] [blame] | 2812 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2813 | } |