Build 1.0_r1(from source)

android.content
Class TempProviderSyncAdapter

java.lang.Object
  extended by android.content.SyncAdapter
      extended by android.content.TempProviderSyncAdapter

public abstract class TempProviderSyncAdapter
extends SyncAdapter


Nested Class Summary
static class TempProviderSyncAdapter.SyncData
          Used by getServerDiffs() to track the sync progress for a given sync adapter.
 
Nested classes/interfaces inherited from class android.content.SyncAdapter
SyncAdapter.Transport
 
Field Summary
 
Fields inherited from class android.content.SyncAdapter
LOG_SYNC_DETAILS, mTransport
 
Constructor Summary
TempProviderSyncAdapter(SyncableContentProvider provider)
           
 
Method Summary
 void cancelSync()
          Cancel the most recently initiated sync.
protected  Object createSyncInfo()
           
 Context getContext()
          Retrieve the Context this adapter is running in.
abstract  void getServerDiffs(SyncContext context, TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider tempProvider, Bundle extras, Object syncInfo, SyncResult syncResult)
          Get diffs from the server since the last completed sync and put them into a temporary provider.
protected  boolean hasTooManyDeletions(SyncStats stats)
           
protected  void initTempProvider(SyncableContentProvider cp)
          Initializes the temporary content providers used during sendClientDiffs(android.content.SyncContext, android.content.SyncableContentProvider, android.content.SyncableContentProvider, android.content.SyncResult, boolean).
abstract  boolean isReadOnly()
          Implement this to return true if the data in your content provider is read only.
protected  void logSyncDetails(long bytesSent, long bytesReceived, SyncResult result)
          Logs details on the sync.
 TempProviderSyncAdapter.SyncData newSyncData()
          Create and return a new, empty SyncData object
abstract  void onAccountsChanged(String[] accounts)
          Called when the accounts list possibly changed, to give the SyncAdapter a chance to do any necessary bookkeeping, e.g.
abstract  void onSyncCanceled()
          Indicate to the SyncAdapter that the last sync that was started has been cancelled.
abstract  void onSyncEnding(SyncContext context, boolean success)
          Called right after a sync is completed
abstract  void onSyncStarting(SyncContext context, String account, boolean forced, SyncResult result)
          Called right before a sync is started.
 TempProviderSyncAdapter.SyncData readSyncData(SyncableContentProvider contentProvider)
          Reads the sync data from the ContentProvider
abstract  void sendClientDiffs(SyncContext context, SyncableContentProvider clientDiffs, SyncableContentProvider serverDiffs, SyncResult syncResult, boolean dontActuallySendDeletes)
          Send client diffs to the server, optionally receiving more diffs from the server
 void setContext(Context context)
           
 void startSync(SyncContext syncContext, String account, Bundle extras)
          Initiate a sync for this account.
 void writeSyncData(TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider contentProvider)
          Stores the sync data in the Sync Stats database, keying it by the account that was set in the last call to onSyncStarting()
 
Methods inherited from class android.content.SyncAdapter
getISyncAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempProviderSyncAdapter

public TempProviderSyncAdapter(SyncableContentProvider provider)
Method Detail

setContext

public final void setContext(Context context)

getContext

public final Context getContext()
Retrieve the Context this adapter is running in. Only available once onSyncStarting() is called (not available from constructor).


onSyncStarting

public abstract void onSyncStarting(SyncContext context,
                                    String account,
                                    boolean forced,
                                    SyncResult result)
Called right before a sync is started.

Parameters:
context - allows you to publish status and interact with the
account - the account to sync
forced - if true then the sync was forced
result - information to track what happened during this sync attempt

onSyncEnding

public abstract void onSyncEnding(SyncContext context,
                                  boolean success)
Called right after a sync is completed

Parameters:
context - allows you to publish status and interact with the user during interactive syncs.
success - true if the sync suceeded, false if an error occured

isReadOnly

public abstract boolean isReadOnly()
Implement this to return true if the data in your content provider is read only.


getServerDiffs

public abstract void getServerDiffs(SyncContext context,
                                    TempProviderSyncAdapter.SyncData syncData,
                                    SyncableContentProvider tempProvider,
                                    Bundle extras,
                                    Object syncInfo,
                                    SyncResult syncResult)
Get diffs from the server since the last completed sync and put them into a temporary provider.

Parameters:
context - allows you to publish status and interact with the user during interactive syncs.
syncData - used to track the progress this client has made in syncing data from the server
tempProvider - this is where the diffs should be stored
extras - any extra data describing the sync that is desired
syncInfo - sync adapter-specific data that is used during a single sync operation
syncResult - information to track what happened during this sync attempt

sendClientDiffs

public abstract void sendClientDiffs(SyncContext context,
                                     SyncableContentProvider clientDiffs,
                                     SyncableContentProvider serverDiffs,
                                     SyncResult syncResult,
                                     boolean dontActuallySendDeletes)
Send client diffs to the server, optionally receiving more diffs from the server

Parameters:
context - allows you to publish status and interact with the user during interactive syncs.
clientDiffs - the diffs from the client
serverDiffs - the SyncableContentProvider that should be populated with the entries that were returned in response to an insert/update/delete request to the server
syncResult - information to track what happened during this sync attempt
dontActuallySendDeletes -

readSyncData

public TempProviderSyncAdapter.SyncData readSyncData(SyncableContentProvider contentProvider)
Reads the sync data from the ContentProvider

Parameters:
contentProvider - the ContentProvider to read from
Returns:
the SyncData for the provider. This may be null.

newSyncData

public TempProviderSyncAdapter.SyncData newSyncData()
Create and return a new, empty SyncData object


writeSyncData

public void writeSyncData(TempProviderSyncAdapter.SyncData syncData,
                          SyncableContentProvider contentProvider)
Stores the sync data in the Sync Stats database, keying it by the account that was set in the last call to onSyncStarting()


onSyncCanceled

public abstract void onSyncCanceled()
Indicate to the SyncAdapter that the last sync that was started has been cancelled.


initTempProvider

protected void initTempProvider(SyncableContentProvider cp)
Initializes the temporary content providers used during sendClientDiffs(android.content.SyncContext, android.content.SyncableContentProvider, android.content.SyncableContentProvider, android.content.SyncResult, boolean). May copy relevant data from the underlying db into this provider so joins, etc., can work.

Parameters:
cp - The ContentProvider to initialize.

createSyncInfo

protected Object createSyncInfo()

onAccountsChanged

public abstract void onAccountsChanged(String[] accounts)
Called when the accounts list possibly changed, to give the SyncAdapter a chance to do any necessary bookkeeping, e.g. to make sure that any required SubscribedFeeds subscriptions exist.

Parameters:
accounts - the list of accounts

logSyncDetails

protected void logSyncDetails(long bytesSent,
                              long bytesReceived,
                              SyncResult result)
Logs details on the sync. Normally this will be overridden by a subclass that will provide provider-specific details.

Parameters:
bytesSent - number of bytes the sync sent over the network
bytesReceived - number of bytes the sync received over the network
result - The SyncResult object holding info on the sync

startSync

public void startSync(SyncContext syncContext,
                      String account,
                      Bundle extras)
Description copied from class: SyncAdapter
Initiate a sync for this account. SyncAdapter-specific parameters may be specified in extras, which is guaranteed to not be null. IPC invocations of this method and cancelSync() are guaranteed to be serialized.

Specified by:
startSync in class SyncAdapter
Parameters:
syncContext - the ISyncContext used to indicate the progress of the sync. When the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
account - the account that should be synced
extras - SyncAdapter-specific parameters

cancelSync

public void cancelSync()
Description copied from class: SyncAdapter
Cancel the most recently initiated sync. Due to race conditions, this may arrive after the ISyncContext.onFinished() for that sync was called. IPC invocations of this method and startSync() are guaranteed to be serialized.

Specified by:
cancelSync in class SyncAdapter

hasTooManyDeletions

protected boolean hasTooManyDeletions(SyncStats stats)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature