blob: 3e916262f9616ec6e5d84f366626af7c1641c41d [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
29 /** Kernel event log tag. Also listed in data/etc/event-log-tags. */
30 public static final int LOG_SYNC_DETAILS = 2743;
31
32 class Transport extends ISyncAdapter.Stub {
Fred Quintanad9d2f112009-04-23 13:36:27 -070033 public void startSync(ISyncContext syncContext, Account account,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034 Bundle extras) throws RemoteException {
35 SyncAdapter.this.startSync(new SyncContext(syncContext), account, extras);
36 }
37
38 public void cancelSync() throws RemoteException {
39 SyncAdapter.this.cancelSync();
40 }
41 }
42
43 Transport mTransport = new Transport();
44
45 /**
46 * Get the Transport object. (note this is package private).
47 */
48 final ISyncAdapter getISyncAdapter()
49 {
50 return mTransport;
51 }
52
53 /**
54 * Initiate a sync for this account. SyncAdapter-specific parameters may
55 * be specified in extras, which is guaranteed to not be null. IPC invocations
56 * of this method and cancelSync() are guaranteed to be serialized.
57 *
58 * @param syncContext the ISyncContext used to indicate the progress of the sync. When
59 * the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
60 * @param account the account that should be synced
61 * @param extras SyncAdapter-specific parameters
62 */
Fred Quintanad9d2f112009-04-23 13:36:27 -070063 public abstract void startSync(SyncContext syncContext, Account account, Bundle extras);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064
65 /**
66 * Cancel the most recently initiated sync. Due to race conditions, this may arrive
67 * after the ISyncContext.onFinished() for that sync was called. IPC invocations
68 * of this method and startSync() are guaranteed to be serialized.
69 */
70 public abstract void cancelSync();
71}