blob: 7826e5052ab7c7164bbf08835fa1691ca01d937f [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import android.os.Bundle;
20import android.os.RemoteException;
21
22/**
23 * @hide
24 */
25public abstract class SyncAdapter {
26 private static final String TAG = "SyncAdapter";
27
28 /** Kernel event log tag. Also listed in data/etc/event-log-tags. */
29 public static final int LOG_SYNC_DETAILS = 2743;
30
31 class Transport extends ISyncAdapter.Stub {
32 public void startSync(ISyncContext syncContext, String account,
33 Bundle extras) throws RemoteException {
34 SyncAdapter.this.startSync(new SyncContext(syncContext), account, extras);
35 }
36
37 public void cancelSync() throws RemoteException {
38 SyncAdapter.this.cancelSync();
39 }
40 }
41
42 Transport mTransport = new Transport();
43
44 /**
45 * Get the Transport object. (note this is package private).
46 */
47 final ISyncAdapter getISyncAdapter()
48 {
49 return mTransport;
50 }
51
52 /**
53 * Initiate a sync for this account. SyncAdapter-specific parameters may
54 * be specified in extras, which is guaranteed to not be null. IPC invocations
55 * of this method and cancelSync() are guaranteed to be serialized.
56 *
57 * @param syncContext the ISyncContext used to indicate the progress of the sync. When
58 * the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
59 * @param account the account that should be synced
60 * @param extras SyncAdapter-specific parameters
61 */
62 public abstract void startSync(SyncContext syncContext, String account, Bundle extras);
63
64 /**
65 * Cancel the most recently initiated sync. Due to race conditions, this may arrive
66 * after the ISyncContext.onFinished() for that sync was called. IPC invocations
67 * of this method and startSync() are guaranteed to be serialized.
68 */
69 public abstract void cancelSync();
70}