blob: 57dde669300199e3ffb2a56189b3d78b69279512 [file] [log] [blame]
Jeff Hamiltone5d0a832010-08-17 12:38:53 -05001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package android.provider;
18
19import android.accounts.Account;
Mathew Inwood6750f2e2018-08-10 09:29:25 +010020import android.annotation.UnsupportedAppUsage;
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050021import android.content.ContentProviderClient;
22import android.content.ContentProviderOperation;
23import android.content.ContentResolver;
24import android.content.ContentUris;
Jeff Hamiltona2f92662010-09-27 16:54:57 -050025import android.content.ContentValues;
26import android.content.Context;
27import android.database.Cursor;
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050028import android.graphics.BitmapFactory;
29import android.net.Uri;
30import android.os.RemoteException;
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050031import android.util.Pair;
32
33/**
Tao Baib5f15e72012-04-10 11:59:45 -070034 * <p>
35 * The contract between the browser provider and applications. Contains the definition
36 * for the supported URIS and columns.
37 * </p>
38 * <h3>Overview</h3>
39 * <p>
40 * BrowserContract defines an database of browser-related information which are bookmarks,
41 * history, images and the mapping between the image and URL.
42 * </p>
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050043 * @hide
44 */
45public class BrowserContract {
46 /** The authority for the browser provider */
47 public static final String AUTHORITY = "com.android.browser";
48
49 /** A content:// style uri to the authority for the browser provider */
Mathew Inwood6750f2e2018-08-10 09:29:25 +010050 @UnsupportedAppUsage
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050051 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
52
53 /**
54 * An optional insert, update or delete URI parameter that allows the caller
55 * to specify that it is a sync adapter. The default value is false. If true
56 * the dirty flag is not automatically set and the "syncToNetwork" parameter
57 * is set to false when calling
58 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
Tao Baib5f15e72012-04-10 11:59:45 -070059 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050060 */
61 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
62
63 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -050064 * A parameter for use when querying any table that allows specifying a limit on the number
65 * of rows returned.
Tao Baib5f15e72012-04-10 11:59:45 -070066 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -050067 */
68 public static final String PARAM_LIMIT = "limit";
69
70 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050071 * Generic columns for use by sync adapters. The specific functions of
72 * these columns are private to the sync adapter. Other clients of the API
73 * should not attempt to either read or write these columns.
Tao Baib5f15e72012-04-10 11:59:45 -070074 *
75 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -050076 */
77 interface BaseSyncColumns {
78 /** Generic column for use by sync adapters. */
79 public static final String SYNC1 = "sync1";
80 /** Generic column for use by sync adapters. */
81 public static final String SYNC2 = "sync2";
82 /** Generic column for use by sync adapters. */
83 public static final String SYNC3 = "sync3";
84 /** Generic column for use by sync adapters. */
85 public static final String SYNC4 = "sync4";
86 /** Generic column for use by sync adapters. */
87 public static final String SYNC5 = "sync5";
88 }
89
90 /**
Jeff Hamilton98bfcfb2010-08-17 13:51:17 -050091 * Convenience definitions for use in implementing chrome bookmarks sync in the Bookmarks table.
Tao Baib5f15e72012-04-10 11:59:45 -070092 * @hide
Jeff Hamilton98bfcfb2010-08-17 13:51:17 -050093 */
94 public static final class ChromeSyncColumns {
95 private ChromeSyncColumns() {}
96
97 /** The server unique ID for an item */
98 public static final String SERVER_UNIQUE = BaseSyncColumns.SYNC3;
99
100 public static final String FOLDER_NAME_ROOT = "google_chrome";
101 public static final String FOLDER_NAME_BOOKMARKS = "google_chrome_bookmarks";
102 public static final String FOLDER_NAME_BOOKMARKS_BAR = "bookmark_bar";
103 public static final String FOLDER_NAME_OTHER_BOOKMARKS = "other_bookmarks";
Cyrus Master78a99ce2010-09-01 09:26:15 -0700104
Jeff Hamilton98bfcfb2010-08-17 13:51:17 -0500105 /** The client unique ID for an item */
106 public static final String CLIENT_UNIQUE = BaseSyncColumns.SYNC4;
107 }
Cyrus Master78a99ce2010-09-01 09:26:15 -0700108
Jeff Hamilton98bfcfb2010-08-17 13:51:17 -0500109 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500110 * Columns that appear when each row of a table belongs to a specific
111 * account, including sync information that an account may need.
Tao Baib5f15e72012-04-10 11:59:45 -0700112 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500113 */
114 interface SyncColumns extends BaseSyncColumns {
115 /**
116 * The name of the account instance to which this row belongs, which when paired with
117 * {@link #ACCOUNT_TYPE} identifies a specific account.
118 * <P>Type: TEXT</P>
119 */
120 public static final String ACCOUNT_NAME = "account_name";
121
122 /**
123 * The type of account to which this row belongs, which when paired with
124 * {@link #ACCOUNT_NAME} identifies a specific account.
125 * <P>Type: TEXT</P>
126 */
127 public static final String ACCOUNT_TYPE = "account_type";
128
129 /**
130 * String that uniquely identifies this row to its source account.
131 * <P>Type: TEXT</P>
132 */
133 public static final String SOURCE_ID = "sourceid";
134
135 /**
136 * Version number that is updated whenever this row or its related data
137 * changes.
138 * <P>Type: INTEGER</P>
139 */
140 public static final String VERSION = "version";
141
142 /**
143 * Flag indicating that {@link #VERSION} has changed, and this row needs
144 * to be synchronized by its owning account.
145 * <P>Type: INTEGER (boolean)</P>
146 */
147 public static final String DIRTY = "dirty";
Cyrus Master78a99ce2010-09-01 09:26:15 -0700148
149 /**
Cyrus Master78a99ce2010-09-01 09:26:15 -0700150 * The time that this row was last modified by a client (msecs since the epoch).
151 * <P>Type: INTEGER</P>
152 */
153 public static final String DATE_MODIFIED = "modified";
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500154 }
155
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500156 interface CommonColumns {
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500157 /**
158 * The unique ID for a row.
159 * <P>Type: INTEGER (long)</P>
160 */
161 public static final String _ID = "_id";
162
163 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700164 * This column is valid when the row is a URL. The history table's URL
165 * can not be updated.
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500166 * <P>Type: TEXT (URL)</P>
167 */
168 public static final String URL = "url";
169
170 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700171 * The user visible title.
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500172 * <P>Type: TEXT</P>
173 */
174 public static final String TITLE = "title";
175
176 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500177 * The time that this row was created on its originating client (msecs
178 * since the epoch).
179 * <P>Type: INTEGER</P>
Tao Baib5f15e72012-04-10 11:59:45 -0700180 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500181 */
182 public static final String DATE_CREATED = "created";
183 }
184
Tao Baib5f15e72012-04-10 11:59:45 -0700185 /**
186 * @hide
187 */
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500188 interface ImageColumns {
189 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500190 * The favicon of the bookmark, may be NULL.
191 * Must decode via {@link BitmapFactory#decodeByteArray}.
192 * <p>Type: BLOB (image)</p>
193 */
194 public static final String FAVICON = "favicon";
195
196 /**
197 * A thumbnail of the page,may be NULL.
198 * Must decode via {@link BitmapFactory#decodeByteArray}.
199 * <p>Type: BLOB (image)</p>
200 */
201 public static final String THUMBNAIL = "thumbnail";
202
203 /**
204 * The touch icon for the web page, may be NULL.
205 * Must decode via {@link BitmapFactory#decodeByteArray}.
206 * <p>Type: BLOB (image)</p>
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500207 */
208 public static final String TOUCH_ICON = "touch_icon";
209 }
210
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500211 interface HistoryColumns {
212 /**
213 * The date the item was last visited, in milliseconds since the epoch.
214 * <p>Type: INTEGER (date in milliseconds since January 1, 1970)</p>
215 */
216 public static final String DATE_LAST_VISITED = "date";
217
218 /**
219 * The number of times the item has been visited.
220 * <p>Type: INTEGER</p>
221 */
222 public static final String VISITS = "visits";
223
Tao Baib5f15e72012-04-10 11:59:45 -0700224 /**
225 * @hide
226 */
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500227 public static final String USER_ENTERED = "user_entered";
228 }
229
Tao Baib5f15e72012-04-10 11:59:45 -0700230 interface ImageMappingColumns {
231 /**
232 * The ID of the image in Images. One image can map onto the multiple URLs.
233 * <P>Type: INTEGER (long)</P>
234 */
235 public static final String IMAGE_ID = "image_id";
236
237 /**
238 * The URL. The URL can map onto the different type of images.
239 * <P>Type: TEXT (URL)</P>
240 */
241 public static final String URL = "url";
242 }
243
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500244 /**
245 * The bookmarks table, which holds the user's browser bookmarks.
246 */
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500247 public static final class Bookmarks implements CommonColumns, ImageColumns, SyncColumns {
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500248 /**
249 * This utility class cannot be instantiated.
250 */
251 private Bookmarks() {}
252
253 /**
254 * The content:// style URI for this table
255 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100256 @UnsupportedAppUsage
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500257 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "bookmarks");
258
259 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700260 * Used in {@link Bookmarks#TYPE} column and indicats the row is a bookmark.
261 */
262 public static final int BOOKMARK_TYPE_BOOKMARK = 1;
263
264 /**
265 * Used in {@link Bookmarks#TYPE} column and indicats the row is a folder.
266 */
267 public static final int BOOKMARK_TYPE_FOLDER = 2;
268
269 /**
270 * Used in {@link Bookmarks#TYPE} column and indicats the row is the bookmark bar folder.
271 */
272 public static final int BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER = 3;
273
274 /**
275 * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder and
276 */
277 public static final int BOOKMARK_TYPE_OTHER_FOLDER = 4;
278
279 /**
280 * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder, .
281 */
282 public static final int BOOKMARK_TYPE_MOBILE_FOLDER = 5;
283
284 /**
285 * The type of the item.
286 * <P>Type: INTEGER</P>
287 * <p>Allowed values are:</p>
288 * <p>
289 * <ul>
290 * <li>{@link #BOOKMARK_TYPE_BOOKMARK}</li>
291 * <li>{@link #BOOKMARK_TYPE_FOLDER}</li>
292 * <li>{@link #BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER}</li>
293 * <li>{@link #BOOKMARK_TYPE_OTHER_FOLDER}</li>
294 * <li>{@link #BOOKMARK_TYPE_MOBILE_FOLDER}</li>
295 * </ul>
296 * </p>
297 * <p> The TYPE_BOOKMARK_BAR_FOLDER, TYPE_OTHER_FOLDER and TYPE_MOBILE_FOLDER
298 * can not be updated or deleted.</p>
299 */
300 public static final String TYPE = "type";
301
302 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500303 * The content:// style URI for the default folder
Tao Baib5f15e72012-04-10 11:59:45 -0700304 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500305 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100306 @UnsupportedAppUsage
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500307 public static final Uri CONTENT_URI_DEFAULT_FOLDER =
308 Uri.withAppendedPath(CONTENT_URI, "folder");
309
310 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500311 * Query parameter used to specify an account name
Tao Baib5f15e72012-04-10 11:59:45 -0700312 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500313 */
314 public static final String PARAM_ACCOUNT_NAME = "acct_name";
315
316 /**
317 * Query parameter used to specify an account type
Tao Baib5f15e72012-04-10 11:59:45 -0700318 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500319 */
320 public static final String PARAM_ACCOUNT_TYPE = "acct_type";
321
322 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500323 * Builds a URI that points to a specific folder.
324 * @param folderId the ID of the folder to point to
Tao Baib5f15e72012-04-10 11:59:45 -0700325 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500326 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100327 @UnsupportedAppUsage
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500328 public static final Uri buildFolderUri(long folderId) {
329 return ContentUris.withAppendedId(CONTENT_URI_DEFAULT_FOLDER, folderId);
330 }
331
332 /**
333 * The MIME type of {@link #CONTENT_URI} providing a directory of bookmarks.
334 */
335 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/bookmark";
336
337 /**
338 * The MIME type of a {@link #CONTENT_URI} of a single bookmark.
339 */
340 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/bookmark";
341
342 /**
343 * Query parameter to use if you want to see deleted bookmarks that are still
344 * around on the device and haven't been synced yet.
345 * @see #IS_DELETED
Tao Baib5f15e72012-04-10 11:59:45 -0700346 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500347 */
348 public static final String QUERY_PARAMETER_SHOW_DELETED = "show_deleted";
349
350 /**
351 * Flag indicating if an item is a folder or bookmark. Non-zero values indicate
352 * a folder and zero indicates a bookmark.
353 * <P>Type: INTEGER (boolean)</P>
Tao Baib5f15e72012-04-10 11:59:45 -0700354 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500355 */
356 public static final String IS_FOLDER = "folder";
357
358 /**
359 * The ID of the parent folder. ID 0 is the root folder.
360 * <P>Type: INTEGER (reference to item in the same table)</P>
361 */
362 public static final String PARENT = "parent";
363
364 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500365 * The source ID for an item's parent. Read-only.
366 * @see #PARENT
Tao Baib5f15e72012-04-10 11:59:45 -0700367 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500368 */
369 public static final String PARENT_SOURCE_ID = "parent_source";
370
371 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500372 * The position of the bookmark in relation to it's siblings that share the same
373 * {@link #PARENT}. May be negative.
374 * <P>Type: INTEGER</P>
Tao Baib5f15e72012-04-10 11:59:45 -0700375 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500376 */
377 public static final String POSITION = "position";
378
379 /**
380 * The item that the bookmark should be inserted after.
381 * May be negative.
382 * <P>Type: INTEGER</P>
Tao Baib5f15e72012-04-10 11:59:45 -0700383 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500384 */
385 public static final String INSERT_AFTER = "insert_after";
386
387 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500388 * The source ID for the item that the bookmark should be inserted after. Read-only.
389 * May be negative.
390 * <P>Type: INTEGER</P>
391 * @see #INSERT_AFTER
Tao Baib5f15e72012-04-10 11:59:45 -0700392 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500393 */
394 public static final String INSERT_AFTER_SOURCE_ID = "insert_after_source";
395
396 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500397 * A flag to indicate if an item has been deleted. Queries will not return deleted
398 * entries unless you add the {@link #QUERY_PARAMETER_SHOW_DELETED} query paramter
399 * to the URI when performing your query.
400 * <p>Type: INTEGER (non-zero if the item has been deleted, zero if it hasn't)
401 * @see #QUERY_PARAMETER_SHOW_DELETED
Tao Baib5f15e72012-04-10 11:59:45 -0700402 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500403 */
404 public static final String IS_DELETED = "deleted";
405 }
406
407 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500408 * Read-only table that lists all the accounts that are used to provide bookmarks.
Tao Baib5f15e72012-04-10 11:59:45 -0700409 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500410 */
411 public static final class Accounts {
412 /**
413 * Directory under {@link Bookmarks#CONTENT_URI}
414 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100415 @UnsupportedAppUsage
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500416 public static final Uri CONTENT_URI =
417 AUTHORITY_URI.buildUpon().appendPath("accounts").build();
418
419 /**
420 * The name of the account instance to which this row belongs, which when paired with
421 * {@link #ACCOUNT_TYPE} identifies a specific account.
422 * <P>Type: TEXT</P>
423 */
424 public static final String ACCOUNT_NAME = "account_name";
425
426 /**
427 * The type of account to which this row belongs, which when paired with
428 * {@link #ACCOUNT_NAME} identifies a specific account.
429 * <P>Type: TEXT</P>
430 */
431 public static final String ACCOUNT_TYPE = "account_type";
John Reck2b3fcfb2011-05-10 14:07:18 -0700432
433 /**
434 * The ID of the account's root folder. This will be the ID of the folder
435 * returned when querying {@link Bookmarks#CONTENT_URI_DEFAULT_FOLDER}.
436 * <P>Type: INTEGER</P>
437 */
438 public static final String ROOT_ID = "root_id";
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500439 }
440
441 /**
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500442 * The history table, which holds the browsing history.
443 */
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500444 public static final class History implements CommonColumns, HistoryColumns, ImageColumns {
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500445 /**
446 * This utility class cannot be instantiated.
447 */
448 private History() {}
449
450 /**
451 * The content:// style URI for this table
452 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100453 @UnsupportedAppUsage
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500454 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "history");
455
456 /**
457 * The MIME type of {@link #CONTENT_URI} providing a directory of browser history items.
458 */
459 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/browser-history";
460
461 /**
462 * The MIME type of a {@link #CONTENT_URI} of a single browser history item.
463 */
464 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/browser-history";
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500465 }
466
467 /**
468 * The search history table.
469 * @hide
470 */
471 public static final class Searches {
472 private Searches() {}
473
474 /**
475 * The content:// style URI for this table
476 */
477 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "searches");
478
479 /**
480 * The MIME type of {@link #CONTENT_URI} providing a directory of browser search items.
481 */
482 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/searches";
483
484 /**
485 * The MIME type of a {@link #CONTENT_URI} of a single browser search item.
486 */
487 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/searches";
488
489 /**
490 * The unique ID for a row.
491 * <P>Type: INTEGER (long)</P>
492 */
493 public static final String _ID = "_id";
494
495 /**
496 * The user entered search term.
497 */
498 public static final String SEARCH = "search";
499
500 /**
501 * The date the search was performed, in milliseconds since the epoch.
502 * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p>
503 */
504 public static final String DATE = "date";
505 }
506
507 /**
508 * A table provided for sync adapters to use for storing private sync state data.
509 *
510 * @see SyncStateContract
Tao Baib5f15e72012-04-10 11:59:45 -0700511 * @hide
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500512 */
513 public static final class SyncState implements SyncStateContract.Columns {
514 /**
515 * This utility class cannot be instantiated
516 */
517 private SyncState() {}
518
519 public static final String CONTENT_DIRECTORY =
520 SyncStateContract.Constants.CONTENT_DIRECTORY;
521
522 /**
523 * The content:// style URI for this table
524 */
525 public static final Uri CONTENT_URI =
526 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
527
528 /**
529 * @see android.provider.SyncStateContract.Helpers#get
530 */
531 public static byte[] get(ContentProviderClient provider, Account account)
532 throws RemoteException {
533 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
534 }
535
536 /**
537 * @see android.provider.SyncStateContract.Helpers#get
538 */
539 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
540 throws RemoteException {
541 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
542 }
543
544 /**
545 * @see android.provider.SyncStateContract.Helpers#set
546 */
547 public static void set(ContentProviderClient provider, Account account, byte[] data)
548 throws RemoteException {
549 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
550 }
551
552 /**
553 * @see android.provider.SyncStateContract.Helpers#newSetOperation
554 */
555 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
556 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
557 }
558 }
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500559
560 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700561 * <p>
562 * Stores images for URLs.
563 * </p>
564 * <p>
565 * The rows in this table can not be updated since there might have multiple URLs mapping onto
566 * the same image. If you want to update a URL's image, you need to add the new image in this
567 * table, then update the mapping onto the added image.
568 * </p>
569 * <p>
570 * Every image should be at least associated with one URL, otherwise it will be removed after a
571 * while.
572 * </p>
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500573 */
574 public static final class Images implements ImageColumns {
575 /**
576 * This utility class cannot be instantiated
577 */
578 private Images() {}
579
580 /**
581 * The content:// style URI for this table
582 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100583 @UnsupportedAppUsage
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500584 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "images");
585
586 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700587 * The MIME type of {@link #CONTENT_URI} providing a directory of images.
588 */
589 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/images";
590
591 /**
592 * The MIME type of a {@link #CONTENT_URI} of a single image.
593 */
594 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/images";
595
596 /**
597 * Used in {@link Images#TYPE} column and indicats the row is a favicon.
598 */
599 public static final int IMAGE_TYPE_FAVICON = 1;
600
601 /**
602 * Used in {@link Images#TYPE} column and indicats the row is a precomposed touch icon.
603 */
604 public static final int IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON = 2;
605
606 /**
607 * Used in {@link Images#TYPE} column and indicats the row is a touch icon.
608 */
609 public static final int IMAGE_TYPE_TOUCH_ICON = 4;
610
611 /**
612 * The type of item in the table.
613 * <P>Type: INTEGER</P>
614 * <p>Allowed values are:</p>
615 * <p>
616 * <ul>
617 * <li>{@link #IMAGE_TYPE_FAVICON}</li>
618 * <li>{@link #IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON}</li>
619 * <li>{@link #IMAGE_TYPE_TOUCH_ICON}</li>
620 * </ul>
621 * </p>
622 */
623 public static final String TYPE = "type";
624
625 /**
626 * The image data.
627 * <p>Type: BLOB (image)</p>
628 */
629 public static final String DATA = "data";
630
631 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500632 * The URL the images came from.
633 * <P>Type: TEXT (URL)</P>
Tao Baib5f15e72012-04-10 11:59:45 -0700634 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500635 */
636 public static final String URL = "url_key";
637 }
638
639 /**
Tao Baib5f15e72012-04-10 11:59:45 -0700640 * <p>
641 * A table that stores the mappings between the image and the URL.
642 * </p>
643 * <p>
644 * Deleting or Updating a mapping might also deletes the mapped image if there is no other URL
645 * maps onto it.
646 * </p>
647 */
648 public static final class ImageMappings implements ImageMappingColumns {
649 /**
650 * This utility class cannot be instantiated
651 */
652 private ImageMappings() {}
653
654 /**
655 * The content:// style URI for this table
656 */
657 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "image_mappings");
658
659 /**
660 * The MIME type of {@link #CONTENT_URI} providing a directory of image mappings.
661 */
662 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/image_mappings";
663
664 /**
665 * The MIME type of a {@link #CONTENT_URI} of a single image mapping.
666 */
667 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/image_mappings";
668 }
669
670 /**
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500671 * A combined view of bookmarks and history. All bookmarks in all folders are included and
672 * no folders are included.
Tao Baib5f15e72012-04-10 11:59:45 -0700673 * @hide
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500674 */
675 public static final class Combined implements CommonColumns, HistoryColumns, ImageColumns {
676 /**
677 * This utility class cannot be instantiated
678 */
679 private Combined() {}
680
681 /**
682 * The content:// style URI for this table
683 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +0100684 @UnsupportedAppUsage
Jeff Hamilton4d67ac22010-09-08 09:58:17 -0500685 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "combined");
686
687 /**
688 * Flag indicating that an item is a bookmark. A value of 1 indicates a bookmark, a value
689 * of 0 indicates a history item.
690 * <p>Type: INTEGER (boolean)</p>
691 */
692 public static final String IS_BOOKMARK = "bookmark";
693 }
Jeff Hamiltona2f92662010-09-27 16:54:57 -0500694
695 /**
696 * A table that stores settings specific to the browser. Only support query and insert.
Tao Baib5f15e72012-04-10 11:59:45 -0700697 * @hide
Jeff Hamiltona2f92662010-09-27 16:54:57 -0500698 */
699 public static final class Settings {
700 /**
701 * This utility class cannot be instantiated
702 */
703 private Settings() {}
704
705 /**
706 * The content:// style URI for this table
707 */
708 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "settings");
709
710 /**
711 * Key for a setting value.
712 */
713 public static final String KEY = "key";
714
715 /**
716 * Value for a setting.
717 */
718 public static final String VALUE = "value";
719
720 /**
721 * If set to non-0 the user has opted into bookmark sync.
722 */
723 public static final String KEY_SYNC_ENABLED = "sync_enabled";
724
725 /**
726 * Returns true if bookmark sync is enabled
727 */
728 static public boolean isSyncEnabled(Context context) {
729 Cursor cursor = null;
730 try {
731 cursor = context.getContentResolver().query(CONTENT_URI, new String[] { VALUE },
732 KEY + "=?", new String[] { KEY_SYNC_ENABLED }, null);
733 if (cursor == null || !cursor.moveToFirst()) {
734 return false;
735 }
736 return cursor.getInt(0) != 0;
737 } finally {
738 if (cursor != null) cursor.close();
739 }
740 }
741
742 /**
743 * Sets the bookmark sync enabled setting.
744 */
745 static public void setSyncEnabled(Context context, boolean enabled) {
746 ContentValues values = new ContentValues();
747 values.put(KEY, KEY_SYNC_ENABLED);
748 values.put(VALUE, enabled ? 1 : 0);
749 context.getContentResolver().insert(CONTENT_URI, values);
750 }
751 }
Jeff Hamiltone5d0a832010-08-17 12:38:53 -0500752}