blob: a5afe87dc42f2c85706476af0d4723ec3d6fe160 [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;
Fred Quintanad9d2f112009-04-23 13:36:27 -070021import android.accounts.Account;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23/**
24 * @hide
25 */
26public abstract class SyncAdapter {
27 private static final String TAG = "SyncAdapter";
28
Doug Zongker45e6dbf2009-12-08 12:47:12 -080029 /** Kernel event log tag. */
30 public static final int LOG_SYNC_DETAILS = EventLogTags.SYNC_DETAILS;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031
32 class Transport extends ISyncAdapter.Stub {
Fred Quintana21bb0de2009-06-16 10:24:58 -070033 public void startSync(ISyncContext syncContext, String authority, Account account,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034 Bundle extras) throws RemoteException {
Fred Quintana4a6679b2009-08-17 13:05:39 -070035 SyncAdapter.this.startSync(new SyncContext(syncContext), account, authority, extras);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036 }
37
Fred Quintana21bb0de2009-06-16 10:24:58 -070038 public void cancelSync(ISyncContext syncContext) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 SyncAdapter.this.cancelSync();
40 }
Fred Quintanae7424ff2009-10-14 15:59:21 -070041
42 public void initialize(Account account, String authority) throws RemoteException {
43 Bundle extras = new Bundle();
44 extras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
45 startSync(null, authority, account, extras);
46 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047 }
48
49 Transport mTransport = new Transport();
50
51 /**
Fred Quintana718d8a22009-04-29 17:53:20 -070052 * Get the Transport object.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
Fred Quintana718d8a22009-04-29 17:53:20 -070054 public final ISyncAdapter getISyncAdapter()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 {
56 return mTransport;
57 }
58
59 /**
60 * Initiate a sync for this account. SyncAdapter-specific parameters may
61 * be specified in extras, which is guaranteed to not be null. IPC invocations
62 * of this method and cancelSync() are guaranteed to be serialized.
63 *
64 * @param syncContext the ISyncContext used to indicate the progress of the sync. When
65 * the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
66 * @param account the account that should be synced
Fred Quintana4a6679b2009-08-17 13:05:39 -070067 * @param authority the authority if the sync request
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 * @param extras SyncAdapter-specific parameters
69 */
Fred Quintana4a6679b2009-08-17 13:05:39 -070070 public abstract void startSync(SyncContext syncContext, Account account, String authority,
71 Bundle extras);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072
73 /**
74 * Cancel the most recently initiated sync. Due to race conditions, this may arrive
75 * after the ISyncContext.onFinished() for that sync was called. IPC invocations
76 * of this method and startSync() are guaranteed to be serialized.
77 */
78 public abstract void cancelSync();
79}